From 989b793a3bf689757b2b8f08a1c264743d75fa0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Neira=20Ayuso?= Date: Mon, 11 Nov 2013 21:09:35 +0100 Subject: src: unify parse and output types Unify parse and output types that are redundant to all existing nftables objects. Thus, all NFT_*_O_[XML|JSON|DEFAULT] are merged into NFT_OUTPUT_[JSON|XML] and NFT_PARSE_[JSON|XML]. Signed-off-by: Alvaro Neira Ayuso Signed-off-by: Pablo Neira Ayuso --- examples/nft-chain-get.c | 6 +++--- examples/nft-chain-json-add.c | 4 ++-- examples/nft-chain-xml-add.c | 4 ++-- examples/nft-events.c | 6 +++--- examples/nft-rule-get.c | 6 +++--- examples/nft-rule-json-add.c | 4 ++-- examples/nft-rule-xml-add.c | 4 ++-- examples/nft-set-elem-get.c | 6 +++--- examples/nft-set-get.c | 6 +++--- examples/nft-set-json-add.c | 4 ++-- examples/nft-table-get.c | 6 +++--- examples/nft-table-json-add.c | 4 ++-- examples/nft-table-xml-add.c | 4 ++-- 13 files changed, 32 insertions(+), 32 deletions(-) (limited to 'examples') diff --git a/examples/nft-chain-get.c b/examples/nft-chain-get.c index e466e8b..7e162f6 100644 --- a/examples/nft-chain-get.c +++ b/examples/nft-chain-get.c @@ -51,7 +51,7 @@ int main(int argc, char *argv[]) struct mnl_socket *nl; char buf[MNL_SOCKET_BUFFER_SIZE]; struct nlmsghdr *nlh; - uint32_t portid, seq, type = NFT_CHAIN_O_DEFAULT; + uint32_t portid, seq, type = NFT_OUTPUT_DEFAULT; struct nft_chain *t = NULL; int ret, family; @@ -96,9 +96,9 @@ int main(int argc, char *argv[]) } if (strcmp(argv[argc-1], "xml") == 0){ - type = NFT_CHAIN_O_XML; + type = NFT_OUTPUT_XML; }else if (strcmp(argv[argc-1], "json") == 0){ - type = NFT_CHAIN_O_JSON; + type = NFT_OUTPUT_JSON; } nl = mnl_socket_open(NETLINK_NETFILTER); diff --git a/examples/nft-chain-json-add.c b/examples/nft-chain-json-add.c index 42e2d82..50cb29f 100644 --- a/examples/nft-chain-json-add.c +++ b/examples/nft-chain-json-add.c @@ -65,12 +65,12 @@ int main(int argc, char *argv[]) close(fd); - if (nft_chain_parse(c, NFT_CHAIN_PARSE_JSON, json) < 0) { + if (nft_chain_parse(c, NFT_PARSE_JSON, json) < 0) { printf("E: Unable to parse JSON file: %s\n", strerror(errno)); exit(EXIT_FAILURE); } - nft_chain_snprintf(reprint, sizeof(reprint), c, NFT_CHAIN_O_JSON, 0); + nft_chain_snprintf(reprint, sizeof(reprint), c, NFT_OUTPUT_JSON, 0); printf("Parsed:\n%s\n", reprint); nft_chain_attr_unset(c, NFT_CHAIN_ATTR_HANDLE); diff --git a/examples/nft-chain-xml-add.c b/examples/nft-chain-xml-add.c index 2e2fe11..03a2950 100644 --- a/examples/nft-chain-xml-add.c +++ b/examples/nft-chain-xml-add.c @@ -63,12 +63,12 @@ int main(int argc, char *argv[]) close(fd); - if (nft_chain_parse(c, NFT_CHAIN_PARSE_XML, xml) < 0) { + if (nft_chain_parse(c, NFT_PARSE_XML, xml) < 0) { printf("E: Unable to parse XML file: %s\n", strerror(errno)); exit(EXIT_FAILURE); } - nft_chain_snprintf(reprint, sizeof(reprint), c, NFT_CHAIN_O_XML, 0); + nft_chain_snprintf(reprint, sizeof(reprint), c, NFT_OUTPUT_XML, 0); printf("Parsed:\n%s\n", reprint); nft_chain_attr_unset(c, NFT_CHAIN_ATTR_HANDLE); diff --git a/examples/nft-events.c b/examples/nft-events.c index 5550c70..29cb659 100644 --- a/examples/nft-events.c +++ b/examples/nft-events.c @@ -38,7 +38,7 @@ static int table_cb(const struct nlmsghdr *nlh, int type) goto err_free; } - nft_table_snprintf(buf, sizeof(buf), t, NFT_TABLE_O_DEFAULT, 0); + nft_table_snprintf(buf, sizeof(buf), t, NFT_OUTPUT_DEFAULT, 0); printf("[%s]\t%s\n", type == NFT_MSG_NEWTABLE ? "NEW" : "DEL", buf); err_free: @@ -63,7 +63,7 @@ static int rule_cb(const struct nlmsghdr *nlh, int type) goto err_free; } - nft_rule_snprintf(buf, sizeof(buf), t, NFT_RULE_O_DEFAULT, 0); + nft_rule_snprintf(buf, sizeof(buf), t, NFT_OUTPUT_DEFAULT, 0); printf("[%s]\t%s\n", type == NFT_MSG_NEWRULE ? "NEW" : "DEL", buf); err_free: @@ -88,7 +88,7 @@ static int chain_cb(const struct nlmsghdr *nlh, int type) goto err_free; } - nft_chain_snprintf(buf, sizeof(buf), t, NFT_CHAIN_O_DEFAULT, 0); + nft_chain_snprintf(buf, sizeof(buf), t, NFT_OUTPUT_DEFAULT, 0); printf("[%s]\t%s\n", type == NFT_MSG_NEWCHAIN ? "NEW" : "DEL", buf); err_free: diff --git a/examples/nft-rule-get.c b/examples/nft-rule-get.c index cd0f8dc..f17630b 100644 --- a/examples/nft-rule-get.c +++ b/examples/nft-rule-get.c @@ -51,7 +51,7 @@ int main(int argc, char *argv[]) struct mnl_socket *nl; char buf[MNL_SOCKET_BUFFER_SIZE]; struct nlmsghdr *nlh; - uint32_t portid, seq, type = NFT_RULE_O_DEFAULT; + uint32_t portid, seq, type = NFT_OUTPUT_DEFAULT; struct nft_rule *t = NULL; int ret, family; @@ -78,9 +78,9 @@ int main(int argc, char *argv[]) if (argc == 3) { if (strcmp(argv[2], "xml") == 0) - type = NFT_RULE_O_XML; + type = NFT_OUTPUT_XML; else if (strcmp(argv[2], "json") == 0) - type = NFT_RULE_O_JSON; + type = NFT_OUTPUT_JSON; } /* XXX requires table, chain and handle attributes for selective get */ diff --git a/examples/nft-rule-json-add.c b/examples/nft-rule-json-add.c index 83dec3e..8659081 100644 --- a/examples/nft-rule-json-add.c +++ b/examples/nft-rule-json-add.c @@ -63,12 +63,12 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - if (nft_rule_parse(r, NFT_RULE_PARSE_JSON, json) < 0) { + if (nft_rule_parse(r, NFT_PARSE_JSON, json) < 0) { printf("E: Unable to parse JSON file: %s\n", strerror(errno)); exit(EXIT_FAILURE); } - nft_rule_snprintf(reprint, sizeof(reprint), r, NFT_RULE_O_JSON, 0); + nft_rule_snprintf(reprint, sizeof(reprint), r, NFT_OUTPUT_JSON, 0); printf("Parsed:\n%s\n", reprint); nft_rule_attr_unset(r, NFT_RULE_ATTR_HANDLE); diff --git a/examples/nft-rule-xml-add.c b/examples/nft-rule-xml-add.c index 4de7a69..ce33fe7 100644 --- a/examples/nft-rule-xml-add.c +++ b/examples/nft-rule-xml-add.c @@ -63,12 +63,12 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - if (nft_rule_parse(r, NFT_RULE_PARSE_XML, xml) < 0) { + if (nft_rule_parse(r, NFT_PARSE_XML, xml) < 0) { printf("E: Unable to parse XML file: %s\n", strerror(errno)); exit(EXIT_FAILURE); } - nft_rule_snprintf(reprint, sizeof(reprint), r, NFT_RULE_O_XML, 0); + nft_rule_snprintf(reprint, sizeof(reprint), r, NFT_OUTPUT_XML, 0); printf("Parsed:\n%s\n", reprint); nft_rule_attr_unset(r, NFT_RULE_ATTR_HANDLE); diff --git a/examples/nft-set-elem-get.c b/examples/nft-set-elem-get.c index aeba400..0b46f36 100644 --- a/examples/nft-set-elem-get.c +++ b/examples/nft-set-elem-get.c @@ -52,7 +52,7 @@ int main(int argc, char *argv[]) char buf[MNL_SOCKET_BUFFER_SIZE]; struct nlmsghdr *nlh; uint32_t portid, seq, family; - uint32_t type = NFT_SET_O_DEFAULT; + uint32_t type = NFT_OUTPUT_DEFAULT; struct nft_set *t = NULL; int ret; @@ -81,9 +81,9 @@ int main(int argc, char *argv[]) } if (argc == 5 && strcmp(argv[4], "json") == 0 ) - type = NFT_SET_O_JSON; + type = NFT_OUTPUT_JSON; else if (argc == 5 && strcmp(argv[4], "xml") == 0) - type = NFT_SET_O_XML; + type = NFT_OUTPUT_XML; nlh = nft_set_nlmsg_build_hdr(buf, NFT_MSG_GETSETELEM, family, NLM_F_DUMP|NLM_F_ACK, seq); diff --git a/examples/nft-set-get.c b/examples/nft-set-get.c index 4bc585c..6762032 100644 --- a/examples/nft-set-get.c +++ b/examples/nft-set-get.c @@ -52,7 +52,7 @@ int main(int argc, char *argv[]) char buf[MNL_SOCKET_BUFFER_SIZE]; struct nlmsghdr *nlh; uint32_t portid, seq, family; - uint32_t type = NFT_SET_O_DEFAULT; + uint32_t type = NFT_OUTPUT_DEFAULT; struct nft_set *t = NULL; int ret; @@ -80,9 +80,9 @@ int main(int argc, char *argv[]) } if (argc == 3 && strcmp(argv[2], "json") == 0) - type = NFT_SET_O_JSON; + type = NFT_OUTPUT_JSON; else if (argc == 3 && strcmp(argv[2], "xml") == 0) - type = NFT_SET_O_XML; + type = NFT_OUTPUT_XML; nlh = nft_set_nlmsg_build_hdr(buf, NFT_MSG_GETSET, family, NLM_F_DUMP|NLM_F_ACK, seq); diff --git a/examples/nft-set-json-add.c b/examples/nft-set-json-add.c index 33c3acd..9a4aa48 100644 --- a/examples/nft-set-json-add.c +++ b/examples/nft-set-json-add.c @@ -64,12 +64,12 @@ int main(int argc, char *argv[]) close(fd); - if (nft_set_parse(s, NFT_SET_PARSE_JSON, json) < 0) { + if (nft_set_parse(s, NFT_PARSE_JSON, json) < 0) { printf("E: Unable to parse JSON file: %s\n", strerror(errno)); exit(EXIT_FAILURE); } - nft_set_snprintf(reprint, sizeof(reprint), s, NFT_SET_O_JSON, 0); + nft_set_snprintf(reprint, sizeof(reprint), s, NFT_OUTPUT_JSON, 0); printf("Parsed:\n%s\n", reprint); family = nft_set_attr_get_u32(s, NFT_SET_ATTR_FAMILY); diff --git a/examples/nft-table-get.c b/examples/nft-table-get.c index f57423b..c5bc89d 100644 --- a/examples/nft-table-get.c +++ b/examples/nft-table-get.c @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) uint32_t portid, seq, family; struct nft_table *t = NULL; int ret; - uint32_t type = NFT_TABLE_O_DEFAULT; + uint32_t type = NFT_OUTPUT_DEFAULT; if (argc < 2 || argc > 4) { fprintf(stderr, "%s [] []\n", @@ -78,11 +78,11 @@ int main(int argc, char *argv[]) } if (strcmp(argv[argc-1], "xml") == 0) { - type = NFT_TABLE_O_XML; + type = NFT_OUTPUT_XML; argv[argc-1] = NULL; argc--; }else if (strcmp(argv[argc-1], "json") == 0) { - type = NFT_TABLE_O_JSON; + type = NFT_OUTPUT_JSON; argv[argc-1] = NULL; argc--; } else if (strcmp(argv[argc - 1], "default") == 0) { diff --git a/examples/nft-table-json-add.c b/examples/nft-table-json-add.c index 5526c91..6b16c7f 100644 --- a/examples/nft-table-json-add.c +++ b/examples/nft-table-json-add.c @@ -64,12 +64,12 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - if (nft_table_parse(t, NFT_TABLE_PARSE_JSON, json) < 0) { + if (nft_table_parse(t, NFT_PARSE_JSON, json) < 0) { printf("E: Unable to parse JSON file: %s\n", strerror(errno)); exit(EXIT_FAILURE); } - nft_table_snprintf(reprint, sizeof(reprint), t, NFT_TABLE_O_JSON, 0); + nft_table_snprintf(reprint, sizeof(reprint), t, NFT_OUTPUT_JSON, 0); printf("Parsed:\n%s\n", reprint); family = nft_table_attr_get_u32(t, NFT_TABLE_ATTR_FAMILY); diff --git a/examples/nft-table-xml-add.c b/examples/nft-table-xml-add.c index 6de0855..6a9163b 100644 --- a/examples/nft-table-xml-add.c +++ b/examples/nft-table-xml-add.c @@ -60,12 +60,12 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - if (nft_table_parse(t, NFT_TABLE_PARSE_XML, xml) < 0) { + if (nft_table_parse(t, NFT_PARSE_XML, xml) < 0) { printf("E: Unable to parse XML file: %s\n", strerror(errno)); exit(EXIT_FAILURE); } - nft_table_snprintf(reprint, sizeof(reprint), t, NFT_TABLE_O_XML, 0); + nft_table_snprintf(reprint, sizeof(reprint), t, NFT_OUTPUT_XML, 0); printf("Parsed:\n%s\n", reprint); family = nft_table_attr_get_u32(t, NFT_TABLE_ATTR_FAMILY); -- cgit v1.2.3