]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/filter.c
*: clean up cmd_node initializers
[mirror_frr.git] / lib / filter.c
index 8c210bd7adf0ed5a55c40ff13ade0a3184bd94a2..381f9829bb735454cfa79819f8ed9459d923611f 100644 (file)
@@ -145,16 +145,12 @@ static const char *filter_type_str(struct filter *filter)
        switch (filter->type) {
        case FILTER_PERMIT:
                return "permit";
-               break;
        case FILTER_DENY:
                return "deny";
-               break;
        case FILTER_DYNAMIC:
                return "dynamic";
-               break;
        default:
                return "";
-               break;
        }
 }
 
@@ -416,7 +412,7 @@ static int64_t filter_new_seq_get(struct access_list *access)
        int64_t newseq;
        struct filter *filter;
 
-       maxseq = newseq = 0;
+       maxseq = 0;
 
        for (filter = access->head; filter; filter = filter->next) {
                if (maxseq < filter->seq)
@@ -608,10 +604,7 @@ static int vty_access_list_remark_unset(struct vty *vty, afi_t afi,
                return CMD_WARNING_CONFIG_FAILED;
        }
 
-       if (access->remark) {
-               XFREE(MTYPE_TMP, access->remark);
-               access->remark = NULL;
-       }
+       XFREE(MTYPE_TMP, access->remark);
 
        if (access->head == NULL && access->tail == NULL)
                access_list_delete(access);
@@ -2147,7 +2140,7 @@ DEFUN (no_access_list_any,
        "Specify packets to forward\n"
        "Prefix to match. e.g. 10.0.0.0/8\n")
 {
-       int idx_word = 1;
+       int idx_word = 2;
        int idx = 0;
        char *seq = NULL;
        char *permit_deny = NULL;
@@ -2352,7 +2345,7 @@ DEFUN (no_ipv6_access_list_exact,
 {
        int idx = 0;
        int exact = 0;
-       int idx_word = 2;
+       int idx_word = 3;
        char *seq = NULL;
        char *permit_deny = NULL;
        char *prefix = NULL;
@@ -2394,7 +2387,7 @@ DEFUN (no_ipv6_access_list_any,
        "Specify packets to forward\n"
        "Any prefixi to match\n")
 {
-       int idx_word = 2;
+       int idx_word = 3;
        int idx = 0;
        char *seq = NULL;
        char *permit_deny = NULL;
@@ -2498,8 +2491,8 @@ DEFUN (no_ipv6_access_list_remark_comment,
        return no_ipv6_access_list_remark(self, vty, argc, argv);
 }
 
-void config_write_access_zebra(struct vty *, struct filter *);
-void config_write_access_cisco(struct vty *, struct filter *);
+static void config_write_access_zebra(struct vty *, struct filter *);
+static void config_write_access_cisco(struct vty *, struct filter *);
 
 /* show access-list command. */
 static int filter_show(struct vty *vty, const char *name, afi_t afi)
@@ -2554,7 +2547,8 @@ static int filter_show(struct vty *vty, const char *name, afi_t afi)
                                else {
                                        vty_out(vty, " %s",
                                                inet_ntoa(filter->addr));
-                                       if (filter->addr_mask.s_addr != 0)
+                                       if (filter->addr_mask.s_addr
+                                           != INADDR_ANY)
                                                vty_out(vty,
                                                        ", wildcard bits %s",
                                                        inet_ntoa(
@@ -2602,7 +2596,8 @@ static int filter_show(struct vty *vty, const char *name, afi_t afi)
                                else {
                                        vty_out(vty, " %s",
                                                inet_ntoa(filter->addr));
-                                       if (filter->addr_mask.s_addr != 0)
+                                       if (filter->addr_mask.s_addr
+                                           != INADDR_ANY)
                                                vty_out(vty,
                                                        ", wildcard bits %s",
                                                        inet_ntoa(
@@ -2685,7 +2680,7 @@ DEFUN (show_ipv6_access_list_name,
        return filter_show(vty, argv[idx_word]->arg, AFI_IP6);
 }
 
-void config_write_access_cisco(struct vty *vty, struct filter *mfilter)
+static void config_write_access_cisco(struct vty *vty, struct filter *mfilter)
 {
        struct filter_cisco *filter;
 
@@ -2695,7 +2690,7 @@ void config_write_access_cisco(struct vty *vty, struct filter *mfilter)
                vty_out(vty, " ip");
                if (filter->addr_mask.s_addr == 0xffffffff)
                        vty_out(vty, " any");
-               else if (filter->addr_mask.s_addr == 0)
+               else if (filter->addr_mask.s_addr == INADDR_ANY)
                        vty_out(vty, " host %s", inet_ntoa(filter->addr));
                else {
                        vty_out(vty, " %s", inet_ntoa(filter->addr));
@@ -2704,7 +2699,7 @@ void config_write_access_cisco(struct vty *vty, struct filter *mfilter)
 
                if (filter->mask_mask.s_addr == 0xffffffff)
                        vty_out(vty, " any");
-               else if (filter->mask_mask.s_addr == 0)
+               else if (filter->mask_mask.s_addr == INADDR_ANY)
                        vty_out(vty, " host %s", inet_ntoa(filter->mask));
                else {
                        vty_out(vty, " %s", inet_ntoa(filter->mask));
@@ -2716,7 +2711,7 @@ void config_write_access_cisco(struct vty *vty, struct filter *mfilter)
                        vty_out(vty, " any\n");
                else {
                        vty_out(vty, " %s", inet_ntoa(filter->addr));
-                       if (filter->addr_mask.s_addr != 0)
+                       if (filter->addr_mask.s_addr != INADDR_ANY)
                                vty_out(vty, " %s",
                                        inet_ntoa(filter->addr_mask));
                        vty_out(vty, "\n");
@@ -2724,7 +2719,7 @@ void config_write_access_cisco(struct vty *vty, struct filter *mfilter)
        }
 }
 
-void config_write_access_zebra(struct vty *vty, struct filter *mfilter)
+static void config_write_access_zebra(struct vty *vty, struct filter *mfilter)
 {
        struct filter_zebra *filter;
        struct prefix *p;
@@ -2818,8 +2813,10 @@ static int config_write_access(struct vty *vty, afi_t afi)
 }
 
 static struct cmd_node access_mac_node = {
-       ACCESS_MAC_NODE, "", /* Access list has no interface. */
-       1};
+       .node = ACCESS_MAC_NODE,
+       .prompt = "",
+       .vtysh = 1,
+};
 
 static int config_write_access_mac(struct vty *vty)
 {
@@ -2868,9 +2865,11 @@ static void access_list_init_mac(void)
 }
 
 /* Access-list node. */
-static struct cmd_node access_node = {ACCESS_NODE,
-                                     "", /* Access list has no interface. */
-                                     1};
+static struct cmd_node access_node = {
+       .node = ACCESS_NODE,
+       .prompt = "",
+       .vtysh = 1,
+};
 
 static int config_write_access_ipv4(struct vty *vty)
 {
@@ -2953,7 +2952,11 @@ static void access_list_init_ipv4(void)
        install_element(CONFIG_NODE, &no_access_list_remark_comment_cmd);
 }
 
-static struct cmd_node access_ipv6_node = {ACCESS_IPV6_NODE, "", 1};
+static struct cmd_node access_ipv6_node = {
+       .node = ACCESS_IPV6_NODE,
+       .prompt = "",
+       .vtysh = 1,
+};
 
 static int config_write_access_ipv6(struct vty *vty)
 {