return ret;
}
-static inline int nftnl_str2hooknum(int family, const char *hook)
-{
- int hooknum;
-
- for (hooknum = 0; hooknum < NF_INET_NUMHOOKS; hooknum++) {
- if (strcmp(hook, nftnl_hooknum2str(family, hooknum)) == 0)
- return hooknum;
- }
- return -1;
-}
-
static int nftnl_chain_snprintf_default(char *buf, size_t remain,
const struct nftnl_chain *c)
{
return expr_byteorder_str[type];
}
-static inline int nftnl_str2ntoh(const char *op)
-{
- if (strcmp(op, "ntoh") == 0)
- return NFT_BYTEORDER_NTOH;
- else if (strcmp(op, "hton") == 0)
- return NFT_BYTEORDER_HTON;
- else {
- errno = EINVAL;
- return -1;
- }
-}
-
static int
nftnl_expr_byteorder_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
return expr_cmp_str[op];
}
-static inline int nftnl_str2cmp(const char *op)
-{
- if (strcmp(op, "eq") == 0)
- return NFT_CMP_EQ;
- else if (strcmp(op, "neq") == 0)
- return NFT_CMP_NEQ;
- else if (strcmp(op, "lt") == 0)
- return NFT_CMP_LT;
- else if (strcmp(op, "lte") == 0)
- return NFT_CMP_LTE;
- else if (strcmp(op, "gt") == 0)
- return NFT_CMP_GT;
- else if (strcmp(op, "gte") == 0)
- return NFT_CMP_GTE;
- else {
- errno = EINVAL;
- return -1;
- }
-}
-
static int
nftnl_expr_cmp_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
return ctkey2str_array[ctkey];
}
-static inline int str2ctkey(const char *ctkey)
-{
- int i;
-
- for (i = 0; i < NFT_CT_MAX; i++) {
- if (strcmp(ctkey2str_array[i], ctkey) == 0)
- return i;
- }
-
- return -1;
-}
-
static const char *ctdir2str(uint8_t ctdir)
{
switch (ctdir) {
}
}
-static inline int str2ctdir(const char *str, uint8_t *ctdir)
-{
- if (strcmp(str, "original") == 0) {
- *ctdir = IP_CT_DIR_ORIGINAL;
- return 0;
- }
-
- if (strcmp(str, "reply") == 0) {
- *ctdir = IP_CT_DIR_REPLY;
- return 0;
- }
-
- return -1;
-}
-
static int
nftnl_expr_ct_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
}
}
-static inline int str2exthdr_op(const char* str)
-{
- if (!strcmp(str, "tcpopt"))
- return NFT_EXTHDR_OP_TCPOPT;
- if (!strcmp(str, "ipv4"))
- return NFT_EXTHDR_OP_IPV4;
-
- /* if str == "ipv6" or anything else */
- return NFT_EXTHDR_OP_IPV6;
-}
-
-static inline int str2exthdr_type(const char *str)
-{
- if (strcmp(str, "hopopts") == 0)
- return IPPROTO_HOPOPTS;
- else if (strcmp(str, "routing") == 0)
- return IPPROTO_ROUTING;
- else if (strcmp(str, "fragment") == 0)
- return IPPROTO_FRAGMENT;
- else if (strcmp(str, "dstopts") == 0)
- return IPPROTO_DSTOPTS;
- else if (strcmp(str, "mh") == 0)
- return IPPROTO_MH;
-
- return -1;
-}
-
static int
nftnl_expr_exthdr_snprintf(char *buf, size_t len,
uint32_t flags, const struct nftnl_expr *e)
return "unknown";
}
-static inline int str2meta_key(const char *str)
-{
- int i;
-
- for (i = 0; i < NFT_META_MAX; i++) {
- if (strcmp(str, meta_key2str_array[i]) == 0)
- return i;
- }
-
- errno = EINVAL;
- return -1;
-}
-
static int
nftnl_expr_meta_snprintf(char *buf, size_t len,
uint32_t flags, const struct nftnl_expr *e)
}
}
-static inline int nftnl_str2nat(const char *nat)
-{
- if (strcmp(nat, "snat") == 0)
- return NFT_NAT_SNAT;
- else if (strcmp(nat, "dnat") == 0)
- return NFT_NAT_DNAT;
- else {
- errno = EINVAL;
- return -1;
- }
-}
-
static int
nftnl_expr_nat_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
return expr_range_str[op];
}
-static inline int nftnl_str2range(const char *op)
-{
- if (strcmp(op, "eq") == 0)
- return NFT_RANGE_EQ;
- else if (strcmp(op, "neq") == 0)
- return NFT_RANGE_NEQ;
- else {
- errno = EINVAL;
- return -1;
- }
-}
-
static int nftnl_expr_range_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
{
return "unknown";
}
-static inline int str2rt_key(const char *str)
-{
- int i;
-
- for (i = 0; i < NFT_RT_MAX; i++) {
- if (strcmp(str, rt_key2str_array[i]) == 0)
- return i;
- }
-
- errno = EINVAL;
- return -1;
-}
-
static int
nftnl_expr_rt_snprintf(char *buf, size_t len,
uint32_t flags, const struct nftnl_expr *e)
return "unknown";
}
-static inline int nftnl_str2hooknum(int family, const char *hook)
-{
- int hooknum;
-
- for (hooknum = 0; hooknum < NF_INET_NUMHOOKS; hooknum++) {
- if (strcmp(hook, nftnl_hooknum2str(family, hooknum)) == 0)
- return hooknum;
- }
- return -1;
-}
-
EXPORT_SYMBOL(nftnl_flowtable_parse);
int nftnl_flowtable_parse(struct nftnl_flowtable *c, enum nftnl_parse_type type,
const char *data, struct nftnl_parse_err *err)