extern void ipset_data_flags_set(struct ipset_data *data, uint64_t flags);
extern void ipset_data_flags_unset(struct ipset_data *data, uint64_t flags);
extern bool ipset_data_ignored(struct ipset_data *data, enum ipset_opt opt);
-extern bool ipset_data_test_ignored(struct ipset_data *data, enum ipset_opt opt);
+extern bool ipset_data_test_ignored(struct ipset_data *data,
+ enum ipset_opt opt);
extern int ipset_data_set(struct ipset_data *data, enum ipset_opt opt,
const void *value);
* returns negative error code,
* zero for no match/success to add/delete
* positive for matching element */
- int (*kadt)(struct ip_set *set, const struct sk_buff * skb,
+ int (*kadt)(struct ip_set *set, const struct sk_buff *skb,
const struct xt_action_param *par,
enum ipset_adt adt, const struct ip_set_adt_opt *opt);
return ret;
}
-static inline int nla_put_ipaddr6(struct sk_buff *skb, int type, const struct in6_addr *ipaddrptr)
+static inline int nla_put_ipaddr6(struct sk_buff *skb, int type,
+ const struct in6_addr *ipaddrptr)
{
struct nlattr *__nested = ipset_nest_start(skb, type);
int ret;
}
static int
-type_pf_kadt(struct ip_set *set, const struct sk_buff * skb,
+type_pf_kadt(struct ip_set *set, const struct sk_buff *skb,
const struct xt_action_param *par,
enum ipset_adt adt, const struct ip_set_adt_opt *opt);
static int
(elem->match == MAC_FILLED &&
nla_put(skb, IPSET_ATTR_ETHER, ETH_ALEN,
elem->ether)))
- goto nla_put_failure;
+ goto nla_put_failure;
timeout = elem->match == MAC_UNSET ? elem->timeout
: ip_set_timeout_get(elem->timeout);
if (nla_put_net32(skb, IPSET_ATTR_TIMEOUT, htonl(timeout)))
- goto nla_put_failure;
+ goto nla_put_failure;
ipset_nest_end(skb, nested);
}
ipset_nest_end(skb, atd);
list_for_each_entry_rcu(type, &ip_set_type_list, list)
if (STREQ(type->name, name) &&
- (type->family == family || type->family == NFPROTO_UNSPEC) &&
+ (type->family == family ||
+ type->family == NFPROTO_UNSPEC) &&
revision >= type->revision_min &&
revision <= type->revision_max)
return type;
rcu_read_lock();
list_for_each_entry_rcu(type, &ip_set_type_list, list)
if (STREQ(type->name, name) &&
- (type->family == family || type->family == NFPROTO_UNSPEC)) {
+ (type->family == family ||
+ type->family == NFPROTO_UNSPEC)) {
found = true;
if (type->revision_min < *min)
*min = type->revision_min;
* by the nfnl mutex. Find the first free index in ip_set_list
* and check clashing.
*/
- if ((ret = find_free_id(set->name, &index, &clash)) != 0) {
+ ret = find_free_id(set->name, &index, &clash);
+ if (ret != 0) {
/* If this is the same set and requested, ignore error */
if (ret == -EEXIST &&
(flags & IPSET_FLAG_EXIST) &&
/* Get Layer-4 data from the packets */
#include <linux/version.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
#include <linux/export.h>
#endif
#include <linux/ip.h>
{
int protoff;
u8 nexthdr;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)
__be16 frag_off;
#endif
nexthdr = ipv6_hdr(skb)->nexthdr;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)
protoff = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &nexthdr,
&frag_off);
#else
#include <linux/version.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
#include <linux/export.h>
#endif
#include <linux/netfilter/ipset/pfxlen.h>
break;
/* CADT options */
case IPSET_OPT_IP:
- if (!(data->family == NFPROTO_IPV4 || data->family == NFPROTO_IPV6))
+ if (!(data->family == NFPROTO_IPV4 ||
+ data->family == NFPROTO_IPV6))
return -1;
copy_addr(data->family, &data->ip, value);
break;
case IPSET_OPT_IP_TO:
- if (!(data->family == NFPROTO_IPV4 || data->family == NFPROTO_IPV6))
+ if (!(data->family == NFPROTO_IPV4 ||
+ data->family == NFPROTO_IPV6))
return -1;
copy_addr(data->family, &data->ip_to, value);
break;
ipset_strlcpy(data->adt.nameref, value, IPSET_MAXNAMELEN);
break;
case IPSET_OPT_IP2:
- if (!(data->family == NFPROTO_IPV4 || data->family == NFPROTO_IPV6))
+ if (!(data->family == NFPROTO_IPV4 ||
+ data->family == NFPROTO_IPV6))
return -1;
copy_addr(data->family, &data->adt.ip2, value);
break;
case IPSET_OPT_IP2_TO:
- if (!(data->family == NFPROTO_IPV4 || data->family == NFPROTO_IPV6))
+ if (!(data->family == NFPROTO_IPV4 ||
+ data->family == NFPROTO_IPV6))
return -1;
copy_addr(data->family, &data->adt.ip2_to, value);
break;
case IPSET_OPT_CADT_FLAGS:
data->cadt_flags = *(const uint32_t *)value;
if (data->cadt_flags & IPSET_FLAG_BEFORE)
- ipset_data_flags_set(data, IPSET_FLAG(IPSET_OPT_BEFORE));
+ ipset_data_flags_set(data,
+ IPSET_FLAG(IPSET_OPT_BEFORE));
if (data->cadt_flags & IPSET_FLAG_PHYSDEV)
- ipset_data_flags_set(data, IPSET_FLAG(IPSET_OPT_PHYSDEV));
+ ipset_data_flags_set(data,
+ IPSET_FLAG(IPSET_OPT_PHYSDEV));
if (data->cadt_flags & IPSET_FLAG_NOMATCH)
- ipset_data_flags_set(data, IPSET_FLAG(IPSET_OPT_NOMATCH));
+ ipset_data_flags_set(data,
+ IPSET_FLAG(IPSET_OPT_NOMATCH));
break;
default:
return -1;
d = mnl_attr_get_payload(
ipattr[IPSET_ATTR_IPADDR_IPV4]);
- inet_ntop(NFPROTO_IPV4, d, addr, INET6_ADDRSTRLEN);
+ inet_ntop(NFPROTO_IPV4, d, addr,
+ INET6_ADDRSTRLEN);
fprintf(stderr, "\t\t%s: %s\n",
attr2name[i].name, addr);
} else if (ipattr[IPSET_ATTR_IPADDR_IPV6]) {
d = mnl_attr_get_payload(
ipattr[IPSET_ATTR_IPADDR_IPV6]);
- inet_ntop(NFPROTO_IPV6, d, addr, INET6_ADDRSTRLEN);
+ inet_ntop(NFPROTO_IPV6, d, addr,
+ INET6_ADDRSTRLEN);
fprintf(stderr, "\t\t%s: %s\n",
attr2name[i].name, addr);
}
ipset_match_option;
ipset_match_envopt;
ipset_shift_argv;
-
+
local: *;
};
escape_range_separator(const char *str)
{
const char *tmp = NULL;
-
+
if (STRNEQ(str, IPSET_ESCAPE_START, 1)) {
tmp = strstr(str, IPSET_ESCAPE_END);
if (tmp == NULL)
return NULL;
}
-
+
return range_separator(tmp == NULL ? str : tmp);
}
}
static char *
-strip_escape(struct ipset_session *session, char * str)
+strip_escape(struct ipset_session *session, char *str)
{
if (STRNEQ(str, IPSET_ESCAPE_START, 1)) {
if (!STREQ(str + strlen(str) - 1, IPSET_ESCAPE_END)) {
if (tmp == NULL)
goto error;
- service = getservbyname(tmp, proto);
+ service = getservbyname(tmp, proto);
if (service != NULL) {
*port = ntohs((uint16_t) service->s_port);
free(saved);
if (found == 0)
return syntax_err("cannot parse %s: "
"%s address could not be resolved",
- str, family == NFPROTO_IPV4 ? "IPv4" : "IPv6");
+ str,
+ family == NFPROTO_IPV4 ? "IPv4" : "IPv6");
return err;
}
if (ipset_data_flags_test(data, IPSET_FLAG(arg->opt))
&& !(arg->opt == IPSET_OPT_FAMILY
- && ipset_data_test_ignored(data, IPSET_OPT_FAMILY)))
+ && ipset_data_test_ignored(data, IPSET_OPT_FAMILY)))
return syntax_err("%s already specified", arg->name[0]);
return arg->parse(session, arg->opt, str);
memmove(buf + 1, buf, strlen(buf) + 1);
buf[0] = escape[0];
strcat(buf, IPSET_ESCAPE_END);
- }
+ }
return (err == 0 ? (int)strlen(buf) :
(err == EAI_OVERFLOW || err == EAI_SYSTEM) ? (int)len : -1);
}
memmove(buf + 1, buf, strlen(buf) + 1);
buf[0] = escape[0];
strcat(buf, IPSET_ESCAPE_END);
- }
+ }
return (err == 0 ? (int)strlen(buf) :
(err == EAI_OVERFLOW || err == EAI_SYSTEM) ? (int)len : -1);
}
data2attr(session, nlh, data, type, family, attrs)
#define ADDATTR_SETNAME(session, nlh, data) \
- data2attr(session, nlh, data, IPSET_ATTR_SETNAME, NFPROTO_IPV4, cmd_attrs)
+ data2attr(session, nlh, data, IPSET_ATTR_SETNAME, NFPROTO_IPV4, \
+ cmd_attrs)
#define ADDATTR_IF(session, nlh, data, type, family, attrs) \
ipset_data_test(data, attrs[type].opt) ? \
ADDATTR_SETNAME(session, nlh, data);
if (flags && session->mode != IPSET_LIST_SAVE) {
ipset_data_set(data, IPSET_OPT_FLAGS, &flags);
- ADDATTR(session, nlh, data, IPSET_ATTR_FLAGS, NFPROTO_IPV4,
- cmd_attrs);
+ ADDATTR(session, nlh, data, IPSET_ATTR_FLAGS,
+ NFPROTO_IPV4, cmd_attrs);
}
break;
}
}
#define set_family_and_type(data, match, family) do { \
- if (family == NFPROTO_UNSPEC && match->family != NFPROTO_UNSPEC) \
+ if (family == NFPROTO_UNSPEC && match->family != NFPROTO_UNSPEC) \
family = match->family == NFPROTO_IPSET_IPV46 ? \
NFPROTO_IPV4 : match->family;\
ipset_data_set(data, IPSET_OPT_FAMILY, &family); \
*
* Load in (register) all known set types for the system
*/
- void
- ipset_load_types(void)
- {
+void
+ipset_load_types(void)
+{
#ifdef ENABLE_SETTYPE_MODULES
const char *dir = IPSET_MODSDIR;
const char *next = NULL;
int len;
#endif
- if (typelist != NULL)
- return;
+ if (typelist != NULL)
+ return;
/* Initialize static types */
ipset_types_init();
next = dir + strlen(dir);
len = snprintf(path, sizeof(path), "%.*s",
- (unsigned int)(next - dir), dir);
+ (unsigned int)(next - dir), dir);
if (len >= sizeof(path) || len < 0)
continue;
if (strstr(list[n]->d_name, ".so") == NULL)
goto nextf;
- len = snprintf(file, sizeof(file), "%s/%s", path, list[n]->d_name);
+ len = snprintf(file, sizeof(file), "%s/%s",
+ path, list[n]->d_name);
if (len >= sizeof(file) || len < 0)
goto nextf;
- if (dlopen(file, RTLD_NOW) == NULL) {
+ if (dlopen(file, RTLD_NOW) == NULL)
fprintf(stderr, "%s: %s\n", file, dlerror());
- }
nextf:
free(list[n]);
dir = next + 1;
} while (*next != '\0');
-#endif // ENABLE_SETTYPE_MODULES
+#endif /* ENABLE_SETTYPE_MODULES */
}
return exit_error(PARAMETER_PROBLEM,
"-file option can be specified once");
filename = str;
-
+
return 0;
}
-static
+static
int __attribute__ ((format (printf, 1, 2)))
ipset_print_file(const char *fmt, ...)
{
assert(fd != NULL);
va_start(args, fmt);
len = vfprintf(fd, fmt, args);
- va_end(args);
+ va_end(args);
return len;
}