1 /* Distribute list functions
2 * Copyright (C) 1998, 1999 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published
8 * by the Free Software Foundation; either version 2, or (at your
9 * option) any later version.
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
28 #include "distribute.h"
31 /* Hash of distribute list. */
32 struct hash *disthash;
35 void (*distribute_add_hook) (struct distribute *);
36 void (*distribute_delete_hook) (struct distribute *);
38 static struct distribute *
41 return XCALLOC (MTYPE_DISTRIBUTE, sizeof (struct distribute));
44 /* Free distribute object. */
46 distribute_free (struct distribute *dist)
50 XFREE (MTYPE_DISTRIBUTE_IFNAME, dist->ifname);
52 for (i=0; i < DISTRIBUTE_MAX; i++)
56 for (i=0; i < DISTRIBUTE_MAX; i++)
58 free(dist->prefix[i]);
60 XFREE (MTYPE_DISTRIBUTE, dist);
64 distribute_free_if_empty(struct distribute *dist)
67 for (i=0; i < DISTRIBUTE_MAX; i++)
68 if (dist->list[i] != NULL || dist->prefix[i] != NULL)
71 hash_release (disthash, dist);
72 distribute_free (dist);
75 /* Lookup interface's distribute list. */
77 distribute_lookup (const char *ifname)
79 struct distribute key;
80 struct distribute *dist;
82 /* temporary reference */
83 key.ifname = (char *)ifname;
85 dist = hash_lookup (disthash, &key);
91 distribute_list_add_hook (void (*func) (struct distribute *))
93 distribute_add_hook = func;
97 distribute_list_delete_hook (void (*func) (struct distribute *))
99 distribute_delete_hook = func;
103 distribute_hash_alloc (struct distribute *arg)
105 struct distribute *dist;
107 dist = distribute_new ();
109 dist->ifname = XSTRDUP (MTYPE_DISTRIBUTE_IFNAME, arg->ifname);
115 /* Make new distribute list and push into hash. */
116 static struct distribute *
117 distribute_get (const char *ifname)
119 struct distribute key;
121 /* temporary reference */
122 key.ifname = (char *)ifname;
124 return hash_get (disthash, &key, (void * (*) (void *))distribute_hash_alloc);
128 distribute_hash_make (void *arg)
130 const struct distribute *dist = arg;
132 return dist->ifname ? string_hash_make (dist->ifname) : 0;
135 /* If two distribute-list have same value then return 1 else return
136 0. This function is used by hash package. */
138 distribute_cmp (const struct distribute *dist1, const struct distribute *dist2)
140 if (dist1->ifname && dist2->ifname)
141 if (strcmp (dist1->ifname, dist2->ifname) == 0)
143 if (! dist1->ifname && ! dist2->ifname)
148 /* Set access-list name to the distribute list. */
149 static struct distribute *
150 distribute_list_set (const char *ifname, enum distribute_type type,
151 const char *alist_name)
153 struct distribute *dist;
155 dist = distribute_get (ifname);
157 if (dist->list[type])
158 free (dist->list[type]);
159 dist->list[type] = strdup (alist_name);
161 /* Apply this distribute-list to the interface. */
162 (*distribute_add_hook) (dist);
167 /* Unset distribute-list. If matched distribute-list exist then
170 distribute_list_unset (const char *ifname, enum distribute_type type,
171 const char *alist_name)
173 struct distribute *dist;
175 dist = distribute_lookup (ifname);
179 if (!dist->list[type])
181 if (strcmp (dist->list[type], alist_name) != 0)
184 free (dist->list[type]);
185 dist->list[type] = NULL;
187 /* Apply this distribute-list to the interface. */
188 (*distribute_delete_hook) (dist);
190 /* If all dist are NULL, then free distribute list. */
191 distribute_free_if_empty(dist);
195 /* Set access-list name to the distribute list. */
196 static struct distribute *
197 distribute_list_prefix_set (const char *ifname, enum distribute_type type,
198 const char *plist_name)
200 struct distribute *dist;
202 dist = distribute_get (ifname);
204 if (dist->prefix[type])
205 free (dist->prefix[type]);
206 dist->prefix[type] = strdup (plist_name);
208 /* Apply this distribute-list to the interface. */
209 (*distribute_add_hook) (dist);
214 /* Unset distribute-list. If matched distribute-list exist then
217 distribute_list_prefix_unset (const char *ifname, enum distribute_type type,
218 const char *plist_name)
220 struct distribute *dist;
222 dist = distribute_lookup (ifname);
226 if (!dist->prefix[type])
228 if (strcmp (dist->prefix[type], plist_name) != 0)
231 free (dist->prefix[type]);
232 dist->prefix[type] = NULL;
234 /* Apply this distribute-list to the interface. */
235 (*distribute_delete_hook) (dist);
237 /* If all dist are NULL, then free distribute list. */
238 distribute_free_if_empty(dist);
242 DEFUN (distribute_list_all,
243 distribute_list_all_cmd,
244 "distribute-list WORD (in|out)",
245 "Filter networks in routing updates\n"
247 "Filter incoming routing updates\n"
248 "Filter outgoing routing updates\n")
250 enum distribute_type type;
252 /* Check of distribute list type. */
253 if (strncmp (argv[1], "i", 1) == 0)
254 type = DISTRIBUTE_V4_IN;
255 else if (strncmp (argv[1], "o", 1) == 0)
256 type = DISTRIBUTE_V4_OUT;
259 vty_out (vty, "distribute list direction must be [in|out]%s",
264 /* Get interface name corresponding distribute list. */
265 distribute_list_set (NULL, type, argv[0]);
270 DEFUN (ipv6_distribute_list_all,
271 ipv6_distribute_list_all_cmd,
272 "ipv6 distribute-list WORD (in|out)",
273 "Filter networks in routing updates\n"
275 "Filter incoming routing updates\n"
276 "Filter outgoing routing updates\n")
278 enum distribute_type type;
280 /* Check of distribute list type. */
281 if (strncmp (argv[1], "i", 1) == 0)
282 type = DISTRIBUTE_V6_IN;
283 else if (strncmp (argv[1], "o", 1) == 0)
284 type = DISTRIBUTE_V6_OUT;
287 vty_out (vty, "distribute list direction must be [in|out]%s",
292 /* Get interface name corresponding distribute list. */
293 distribute_list_set (NULL, type, argv[0]);
298 ALIAS (ipv6_distribute_list_all,
299 ipv6_as_v4_distribute_list_all_cmd,
300 "distribute-list WORD (in|out)",
301 "Filter networks in routing updates\n"
303 "Filter incoming routing updates\n"
304 "Filter outgoing routing updates\n")
306 DEFUN (no_distribute_list_all,
307 no_distribute_list_all_cmd,
308 "no distribute-list WORD (in|out)",
310 "Filter networks in routing updates\n"
312 "Filter incoming routing updates\n"
313 "Filter outgoing routing updates\n")
316 enum distribute_type type;
318 /* Check of distribute list type. */
319 if (strncmp (argv[1], "i", 1) == 0)
320 type = DISTRIBUTE_V4_IN;
321 else if (strncmp (argv[1], "o", 1) == 0)
322 type = DISTRIBUTE_V4_OUT;
325 vty_out (vty, "distribute list direction must be [in|out]%s",
330 ret = distribute_list_unset (NULL, type, argv[0]);
333 vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE);
339 DEFUN (no_ipv6_distribute_list_all,
340 no_ipv6_distribute_list_all_cmd,
341 "no ipv6 distribute-list WORD (in|out)",
343 "Filter networks in routing updates\n"
345 "Filter incoming routing updates\n"
346 "Filter outgoing routing updates\n")
349 enum distribute_type type;
351 /* Check of distribute list type. */
352 if (strncmp (argv[1], "i", 1) == 0)
353 type = DISTRIBUTE_V6_IN;
354 else if (strncmp (argv[1], "o", 1) == 0)
355 type = DISTRIBUTE_V6_OUT;
358 vty_out (vty, "distribute list direction must be [in|out]%s",
363 ret = distribute_list_unset (NULL, type, argv[0]);
366 vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE);
372 ALIAS (no_ipv6_distribute_list_all,
373 no_ipv6_as_v4_distribute_list_all_cmd,
374 "no distribute-list WORD (in|out)",
376 "Filter networks in routing updates\n"
378 "Filter incoming routing updates\n"
379 "Filter outgoing routing updates\n")
381 DEFUN (distribute_list,
383 "distribute-list WORD (in|out) WORD",
384 "Filter networks in routing updates\n"
386 "Filter incoming routing updates\n"
387 "Filter outgoing routing updates\n"
390 enum distribute_type type;
392 /* Check of distribute list type. */
393 if (strncmp (argv[1], "i", 1) == 0)
394 type = DISTRIBUTE_V4_IN;
395 else if (strncmp (argv[1], "o", 1) == 0)
396 type = DISTRIBUTE_V4_OUT;
399 vty_out (vty, "distribute list direction must be [in|out]%s", VTY_NEWLINE);
403 /* Get interface name corresponding distribute list. */
404 distribute_list_set (argv[2], type, argv[0]);
409 DEFUN (ipv6_distribute_list,
410 ipv6_distribute_list_cmd,
411 "ipv6 distribute-list WORD (in|out) WORD",
412 "Filter networks in routing updates\n"
414 "Filter incoming routing updates\n"
415 "Filter outgoing routing updates\n"
418 enum distribute_type type;
420 /* Check of distribute list type. */
421 if (strncmp (argv[1], "i", 1) == 0)
422 type = DISTRIBUTE_V6_IN;
423 else if (strncmp (argv[1], "o", 1) == 0)
424 type = DISTRIBUTE_V6_OUT;
427 vty_out (vty, "distribute list direction must be [in|out]%s", VTY_NEWLINE);
431 /* Get interface name corresponding distribute list. */
432 distribute_list_set (argv[2], type, argv[0]);
437 ALIAS (ipv6_distribute_list,
438 ipv6_as_v4_distribute_list_cmd,
439 "distribute-list WORD (in|out) WORD",
440 "Filter networks in routing updates\n"
442 "Filter incoming routing updates\n"
443 "Filter outgoing routing updates\n"
446 DEFUN (no_distribute_list, no_distribute_list_cmd,
447 "no distribute-list WORD (in|out) WORD",
449 "Filter networks in routing updates\n"
451 "Filter incoming routing updates\n"
452 "Filter outgoing routing updates\n"
456 enum distribute_type type;
458 /* Check of distribute list type. */
459 if (strncmp (argv[1], "i", 1) == 0)
460 type = DISTRIBUTE_V4_IN;
461 else if (strncmp (argv[1], "o", 1) == 0)
462 type = DISTRIBUTE_V4_OUT;
465 vty_out (vty, "distribute list direction must be [in|out]%s", VTY_NEWLINE);
469 ret = distribute_list_unset (argv[2], type, argv[0]);
472 vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE);
478 DEFUN (no_ipv6_distribute_list,
479 no_ipv6_distribute_list_cmd,
480 "no ipv6 distribute-list WORD (in|out) WORD",
482 "Filter networks in routing updates\n"
484 "Filter incoming routing updates\n"
485 "Filter outgoing routing updates\n"
489 enum distribute_type type;
491 /* Check of distribute list type. */
492 if (strncmp (argv[1], "i", 1) == 0)
493 type = DISTRIBUTE_V6_IN;
494 else if (strncmp (argv[1], "o", 1) == 0)
495 type = DISTRIBUTE_V6_OUT;
498 vty_out (vty, "distribute list direction must be [in|out]%s", VTY_NEWLINE);
502 ret = distribute_list_unset (argv[2], type, argv[0]);
505 vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE);
511 ALIAS (no_ipv6_distribute_list,
512 no_ipv6_as_v4_distribute_list_cmd,
513 "no distribute-list WORD (in|out) WORD",
515 "Filter networks in routing updates\n"
517 "Filter incoming routing updates\n"
518 "Filter outgoing routing updates\n"
521 DEFUN (distribute_list_prefix_all,
522 distribute_list_prefix_all_cmd,
523 "distribute-list prefix WORD (in|out)",
524 "Filter networks in routing updates\n"
525 "Filter prefixes in routing updates\n"
526 "Name of an IP prefix-list\n"
527 "Filter incoming routing updates\n"
528 "Filter outgoing routing updates\n")
530 enum distribute_type type;
532 /* Check of distribute list type. */
533 if (strncmp (argv[1], "i", 1) == 0)
534 type = DISTRIBUTE_V4_IN;
535 else if (strncmp (argv[1], "o", 1) == 0)
536 type = DISTRIBUTE_V4_OUT;
539 vty_out (vty, "distribute list direction must be [in|out]%s",
544 /* Get interface name corresponding distribute list. */
545 distribute_list_prefix_set (NULL, type, argv[0]);
550 DEFUN (ipv6_distribute_list_prefix_all,
551 ipv6_distribute_list_prefix_all_cmd,
552 "ipv6 distribute-list prefix WORD (in|out)",
553 "Filter networks in routing updates\n"
554 "Filter prefixes in routing updates\n"
555 "Name of an IP prefix-list\n"
556 "Filter incoming routing updates\n"
557 "Filter outgoing routing updates\n")
559 enum distribute_type type;
561 /* Check of distribute list type. */
562 if (strncmp (argv[1], "i", 1) == 0)
563 type = DISTRIBUTE_V6_IN;
564 else if (strncmp (argv[1], "o", 1) == 0)
565 type = DISTRIBUTE_V6_OUT;
568 vty_out (vty, "distribute list direction must be [in|out]%s",
573 /* Get interface name corresponding distribute list. */
574 distribute_list_prefix_set (NULL, type, argv[0]);
579 ALIAS (ipv6_distribute_list_prefix_all,
580 ipv6_as_v4_distribute_list_prefix_all_cmd,
581 "distribute-list prefix WORD (in|out)",
582 "Filter networks in routing updates\n"
583 "Filter prefixes in routing updates\n"
584 "Name of an IP prefix-list\n"
585 "Filter incoming routing updates\n"
586 "Filter outgoing routing updates\n")
588 DEFUN (no_distribute_list_prefix_all,
589 no_distribute_list_prefix_all_cmd,
590 "no distribute-list prefix WORD (in|out)",
592 "Filter networks in routing updates\n"
593 "Filter prefixes in routing updates\n"
594 "Name of an IP prefix-list\n"
595 "Filter incoming routing updates\n"
596 "Filter outgoing routing updates\n")
599 enum distribute_type type;
601 /* Check of distribute list type. */
602 if (strncmp (argv[1], "i", 1) == 0)
603 type = DISTRIBUTE_V4_IN;
604 else if (strncmp (argv[1], "o", 1) == 0)
605 type = DISTRIBUTE_V4_OUT;
608 vty_out (vty, "distribute list direction must be [in|out]%s",
613 ret = distribute_list_prefix_unset (NULL, type, argv[0]);
616 vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE);
622 DEFUN (no_ipv6_distribute_list_prefix_all,
623 no_ipv6_distribute_list_prefix_all_cmd,
624 "no ipv6 distribute-list prefix WORD (in|out)",
626 "Filter networks in routing updates\n"
627 "Filter prefixes in routing updates\n"
628 "Name of an IP prefix-list\n"
629 "Filter incoming routing updates\n"
630 "Filter outgoing routing updates\n")
633 enum distribute_type type;
635 /* Check of distribute list type. */
636 if (strncmp (argv[1], "i", 1) == 0)
637 type = DISTRIBUTE_V6_IN;
638 else if (strncmp (argv[1], "o", 1) == 0)
639 type = DISTRIBUTE_V6_OUT;
642 vty_out (vty, "distribute list direction must be [in|out]%s",
647 ret = distribute_list_prefix_unset (NULL, type, argv[0]);
650 vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE);
656 ALIAS (no_ipv6_distribute_list_prefix_all,
657 no_ipv6_as_v4_distribute_list_prefix_all_cmd,
658 "no distribute-list prefix WORD (in|out)",
660 "Filter networks in routing updates\n"
661 "Filter prefixes in routing updates\n"
662 "Name of an IP prefix-list\n"
663 "Filter incoming routing updates\n"
664 "Filter outgoing routing updates\n")
666 DEFUN (distribute_list_prefix, distribute_list_prefix_cmd,
667 "distribute-list prefix WORD (in|out) WORD",
668 "Filter networks in routing updates\n"
669 "Filter prefixes in routing updates\n"
670 "Name of an IP prefix-list\n"
671 "Filter incoming routing updates\n"
672 "Filter outgoing routing updates\n"
675 enum distribute_type type;
677 /* Check of distribute list type. */
678 if (strncmp (argv[1], "i", 1) == 0)
679 type = DISTRIBUTE_V4_IN;
680 else if (strncmp (argv[1], "o", 1) == 0)
681 type = DISTRIBUTE_V4_OUT;
684 vty_out (vty, "distribute list direction must be [in|out]%s",
689 /* Get interface name corresponding distribute list. */
690 distribute_list_prefix_set (argv[2], type, argv[0]);
695 DEFUN (ipv6_distribute_list_prefix,
696 ipv6_distribute_list_prefix_cmd,
697 "ipv6 distribute-list prefix WORD (in|out) WORD",
698 "Filter networks in routing updates\n"
699 "Filter prefixes in routing updates\n"
700 "Name of an IP prefix-list\n"
701 "Filter incoming routing updates\n"
702 "Filter outgoing routing updates\n"
705 enum distribute_type type;
707 /* Check of distribute list type. */
708 if (strncmp (argv[1], "i", 1) == 0)
709 type = DISTRIBUTE_V6_IN;
710 else if (strncmp (argv[1], "o", 1) == 0)
711 type = DISTRIBUTE_V6_OUT;
714 vty_out (vty, "distribute list direction must be [in|out]%s",
719 /* Get interface name corresponding distribute list. */
720 distribute_list_prefix_set (argv[2], type, argv[0]);
725 ALIAS (ipv6_distribute_list_prefix,
726 ipv6_as_v4_distribute_list_prefix_cmd,
727 "distribute-list prefix WORD (in|out) WORD",
728 "Filter networks in routing updates\n"
729 "Filter prefixes in routing updates\n"
730 "Name of an IP prefix-list\n"
731 "Filter incoming routing updates\n"
732 "Filter outgoing routing updates\n"
735 DEFUN (no_distribute_list_prefix, no_distribute_list_prefix_cmd,
736 "no distribute-list prefix WORD (in|out) WORD",
738 "Filter networks in routing updates\n"
739 "Filter prefixes in routing updates\n"
740 "Name of an IP prefix-list\n"
741 "Filter incoming routing updates\n"
742 "Filter outgoing routing updates\n"
746 enum distribute_type type;
748 /* Check of distribute list type. */
749 if (strncmp (argv[1], "i", 1) == 0)
750 type = DISTRIBUTE_V4_IN;
751 else if (strncmp (argv[1], "o", 1) == 0)
752 type = DISTRIBUTE_V4_OUT;
755 vty_out (vty, "distribute list direction must be [in|out]%s",
760 ret = distribute_list_prefix_unset (argv[2], type, argv[0]);
763 vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE);
769 DEFUN (no_ipv6_distribute_list_prefix,
770 no_ipv6_distribute_list_prefix_cmd,
771 "no ipv6 distribute-list prefix WORD (in|out) WORD",
773 "Filter networks in routing updates\n"
774 "Filter prefixes in routing updates\n"
775 "Name of an IP prefix-list\n"
776 "Filter incoming routing updates\n"
777 "Filter outgoing routing updates\n"
781 enum distribute_type type;
783 /* Check of distribute list type. */
784 if (strncmp (argv[1], "i", 1) == 0)
785 type = DISTRIBUTE_V6_IN;
786 else if (strncmp (argv[1], "o", 1) == 0)
787 type = DISTRIBUTE_V6_OUT;
790 vty_out (vty, "distribute list direction must be [in|out]%s",
795 ret = distribute_list_prefix_unset (argv[2], type, argv[0]);
798 vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE);
804 ALIAS (no_ipv6_distribute_list_prefix,
805 no_ipv6_as_v4_distribute_list_prefix_cmd,
806 "no distribute-list prefix WORD (in|out) WORD",
808 "Filter networks in routing updates\n"
809 "Filter prefixes in routing updates\n"
810 "Name of an IP prefix-list\n"
811 "Filter incoming routing updates\n"
812 "Filter outgoing routing updates\n"
816 distribute_print (struct vty *vty, char *tab[], int is_prefix,
817 enum distribute_type type, int has_print)
820 vty_out (vty, "%s %s%s",
821 has_print ? "," : "",
822 is_prefix ? "(prefix-list) " : "",
830 config_show_distribute (struct vty *vty)
834 struct hash_backet *mp;
835 struct distribute *dist;
837 /* Output filter configuration. */
838 dist = distribute_lookup (NULL);
839 vty_out(vty, " Outgoing update filter list for all interface is");
843 has_print = distribute_print(vty, dist->list, 0,
844 DISTRIBUTE_V4_OUT, has_print);
845 has_print = distribute_print(vty, dist->prefix, 1,
846 DISTRIBUTE_V4_OUT, has_print);
847 has_print = distribute_print(vty, dist->list, 0,
848 DISTRIBUTE_V6_OUT, has_print);
849 has_print = distribute_print(vty, dist->prefix, 1,
850 DISTRIBUTE_V6_OUT, has_print);
853 vty_out (vty, "%s", VTY_NEWLINE);
855 vty_out (vty, " not set%s", VTY_NEWLINE);
857 for (i = 0; i < disthash->size; i++)
858 for (mp = disthash->index[i]; mp; mp = mp->next)
863 vty_out (vty, " %s filtered by", dist->ifname);
865 has_print = distribute_print(vty, dist->list, 0,
866 DISTRIBUTE_V4_OUT, has_print);
867 has_print = distribute_print(vty, dist->prefix, 1,
868 DISTRIBUTE_V4_OUT, has_print);
869 has_print = distribute_print(vty, dist->list, 0,
870 DISTRIBUTE_V6_OUT, has_print);
871 has_print = distribute_print(vty, dist->prefix, 1,
872 DISTRIBUTE_V6_OUT, has_print);
874 vty_out (vty, "%s", VTY_NEWLINE);
876 vty_out(vty, " nothing%s", VTY_NEWLINE);
881 /* Input filter configuration. */
882 dist = distribute_lookup (NULL);
883 vty_out(vty, " Incoming update filter list for all interface is");
887 has_print = distribute_print(vty, dist->list, 0,
888 DISTRIBUTE_V4_IN, has_print);
889 has_print = distribute_print(vty, dist->prefix, 1,
890 DISTRIBUTE_V4_IN, has_print);
891 has_print = distribute_print(vty, dist->list, 0,
892 DISTRIBUTE_V6_IN, has_print);
893 has_print = distribute_print(vty, dist->prefix, 1,
894 DISTRIBUTE_V6_IN, has_print);
897 vty_out (vty, "%s", VTY_NEWLINE);
899 vty_out (vty, " not set%s", VTY_NEWLINE);
901 for (i = 0; i < disthash->size; i++)
902 for (mp = disthash->index[i]; mp; mp = mp->next)
907 vty_out (vty, " %s filtered by", dist->ifname);
909 has_print = distribute_print(vty, dist->list, 0,
910 DISTRIBUTE_V4_IN, has_print);
911 has_print = distribute_print(vty, dist->prefix, 1,
912 DISTRIBUTE_V4_IN, has_print);
913 has_print = distribute_print(vty, dist->list, 0,
914 DISTRIBUTE_V6_IN, has_print);
915 has_print = distribute_print(vty, dist->prefix, 1,
916 DISTRIBUTE_V6_IN, has_print);
918 vty_out (vty, "%s", VTY_NEWLINE);
920 vty_out(vty, " nothing%s", VTY_NEWLINE);
926 /* Configuration write function. */
928 config_write_distribute (struct vty *vty)
933 struct hash_backet *mp;
936 for (i = 0; i < disthash->size; i++)
937 for (mp = disthash->index[i]; mp; mp = mp->next)
939 struct distribute *dist;
943 for (j=0; j < DISTRIBUTE_MAX; j++)
945 output = j == DISTRIBUTE_V4_OUT || j == DISTRIBUTE_V6_OUT;
946 v6 = j == DISTRIBUTE_V6_IN || j == DISTRIBUTE_V6_OUT;
947 vty_out (vty, " %sdistribute-list %s %s %s%s",
950 output ? "out" : "in",
951 dist->ifname ? dist->ifname : "",
956 for (j=0; j < DISTRIBUTE_MAX; j++)
957 if (dist->prefix[j]) {
958 output = j == DISTRIBUTE_V4_OUT || j == DISTRIBUTE_V6_OUT;
959 v6 = j == DISTRIBUTE_V6_IN || j == DISTRIBUTE_V6_OUT;
960 vty_out (vty, " %sdistribute-list prefix %s %s %s%s",
963 output ? "out" : "in",
964 dist->ifname ? dist->ifname : "",
972 /* Clear all distribute list. */
974 distribute_list_reset ()
976 hash_clean (disthash, (void (*) (void *)) distribute_free);
979 /* Initialize distribute list related hash. */
981 distribute_list_init (int node)
983 disthash = hash_create (distribute_hash_make,
984 (int (*) (const void *, const void *)) distribute_cmp);
986 if (node == RIP_NODE || node == BABEL_NODE) {
987 install_element (node, &distribute_list_all_cmd);
988 install_element (node, &no_distribute_list_all_cmd);
989 install_element (node, &distribute_list_cmd);
990 install_element (node, &no_distribute_list_cmd);
991 install_element (node, &distribute_list_prefix_all_cmd);
992 install_element (node, &no_distribute_list_prefix_all_cmd);
993 install_element (node, &distribute_list_prefix_cmd);
994 install_element (node, &no_distribute_list_prefix_cmd);
998 if (node == RIPNG_NODE || node == BABEL_NODE) {
999 install_element (node, &ipv6_distribute_list_all_cmd);
1000 install_element (node, &no_ipv6_distribute_list_all_cmd);
1001 install_element (node, &ipv6_distribute_list_cmd);
1002 install_element (node, &no_ipv6_distribute_list_cmd);
1003 install_element (node, &ipv6_distribute_list_prefix_all_cmd);
1004 install_element (node, &no_ipv6_distribute_list_prefix_all_cmd);
1005 install_element (node, &ipv6_distribute_list_prefix_cmd);
1006 install_element (node, &no_ipv6_distribute_list_prefix_cmd);
1009 /* install v4 syntax command for v6 only protocols. */
1010 if (node == RIPNG_NODE) {
1011 install_element (node, &ipv6_as_v4_distribute_list_all_cmd);
1012 install_element (node, &no_ipv6_as_v4_distribute_list_all_cmd);
1013 install_element (node, &ipv6_as_v4_distribute_list_cmd);
1014 install_element (node, &no_ipv6_as_v4_distribute_list_cmd);
1015 install_element (node, &ipv6_as_v4_distribute_list_prefix_all_cmd);
1016 install_element (node, &no_ipv6_as_v4_distribute_list_prefix_all_cmd);
1017 install_element (node, &ipv6_as_v4_distribute_list_prefix_cmd);
1018 install_element (node, &no_ipv6_as_v4_distribute_list_prefix_cmd);