]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
src: remove unused str2XXX helpers
authorZhongqiu Duan <dzq.aishenghu0@gmail.com>
Wed, 19 Mar 2025 14:20:53 +0000 (14:20 +0000)
committerFlorian Westphal <fw@strlen.de>
Wed, 19 Mar 2025 15:02:28 +0000 (16:02 +0100)
After commit 80077787f8f2 ("src: remove json support"), these internal
functions are no longer used:

nftnl_str2hooknum
nftnl_str2ntoh
nftnl_str2cmp
str2ctkey
str2ctdir
str2exthdr_op
str2exthdr_type
str2meta_key
nftnl_str2nat
nftnl_str2range
str2rt_key
nftnl_str2hooknum

Signed-off-by: Zhongqiu Duan <dzq.aishenghu0@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
src/chain.c
src/expr/byteorder.c
src/expr/cmp.c
src/expr/ct.c
src/expr/exthdr.c
src/expr/meta.c
src/expr/nat.c
src/expr/range.c
src/expr/rt.c
src/flowtable.c

index 7287dcd98e898680312ed0754656b3ec8d658540..895108cddad51843013fff592ff3786b904e73a6 100644 (file)
@@ -739,17 +739,6 @@ int nftnl_chain_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_chain *c)
        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)
 {
index 903c775bf19639b62c082ee8ae1bc51923870244..4171d0633728caa3e14a9ccaf31cf9d4b6dd0692 100644 (file)
@@ -179,18 +179,6 @@ static const char *bo2str(uint32_t type)
        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)
index f55a8c0299e131889ac5242e4a601fd89f1268ab..2908f56325b45a96cda781c17028ceaf5aa88fb2 100644 (file)
@@ -148,26 +148,6 @@ static const char *cmp2str(uint32_t op)
        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)
index 71dbaf932f93ca255de9b34318507e7cf3ccb595..8f8c2a6e73713545564121d24e3bfc83c3669409 100644 (file)
@@ -177,18 +177,6 @@ static const char *ctkey2str(uint32_t ctkey)
        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) {
@@ -201,21 +189,6 @@ static const char *ctdir2str(uint8_t 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)
index 339527dcd193c6465b6372131b49f3b27ba1bc0d..ddebe43eabf52dfcef0ee14de6c694852afb7d4d 100644 (file)
@@ -202,33 +202,6 @@ static const char *op2str(uint8_t op)
        }
 }
 
-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)
index 56d3ddaffa226635a0c237244b700023cb784644..d1ff6c4d2339b40c2ac43514047310186277078e 100644 (file)
@@ -173,19 +173,6 @@ static const char *meta_key2str(uint8_t key)
        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)
index 3ce1aafda55e40bf71d92fc2ad1c3c16ad9ae687..f7e24cb34d515820d1c9d6d820e7144b4da6685d 100644 (file)
@@ -202,18 +202,6 @@ static inline const char *nat2str(uint16_t nat)
        }
 }
 
-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)
index b05724fc5fa4f04d3af120b5119607a112ff5367..50a8ed092e38fe60bd58b39cacf60aaa49e120e4 100644 (file)
@@ -162,18 +162,6 @@ static const char *range2str(uint32_t op)
        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)
 {
index 633031e1427c3dd2082748712f8333b984bb58e6..4f2e96b53cad41474167a5b47d109b41ae322da1 100644 (file)
@@ -122,19 +122,6 @@ static const char *rt_key2str(uint8_t key)
        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)
index 2a8d374541b0b2de45192bca47b5ce8430880dd8..fbbe0a866368d697717ba4f72bcaf4514e8bbb9c 100644 (file)
@@ -488,17 +488,6 @@ static const char *nftnl_hooknum2str(int family, int hooknum)
        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)