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 DEFINE_MTYPE_STATIC(LIB
, DISTRIBUTE
, "Distribute list")
32 DEFINE_MTYPE_STATIC(LIB
, DISTRIBUTE_IFNAME
, "Dist-list ifname")
33 DEFINE_MTYPE_STATIC(LIB
, DISTRIBUTE_NAME
, "Dist-list name")
35 /* Hash of distribute list. */
36 struct hash
*disthash
;
39 void (*distribute_add_hook
) (struct distribute
*);
40 void (*distribute_delete_hook
) (struct distribute
*);
42 static struct distribute
*
45 return XCALLOC (MTYPE_DISTRIBUTE
, sizeof (struct distribute
));
48 /* Free distribute object. */
50 distribute_free (struct distribute
*dist
)
55 XFREE (MTYPE_DISTRIBUTE_IFNAME
, dist
->ifname
);
57 for (i
= 0; i
< DISTRIBUTE_MAX
; i
++)
59 XFREE(MTYPE_DISTRIBUTE_NAME
, dist
->list
[i
]);
61 for (i
= 0; i
< DISTRIBUTE_MAX
; i
++)
63 XFREE(MTYPE_DISTRIBUTE_NAME
, dist
->prefix
[i
]);
65 XFREE (MTYPE_DISTRIBUTE
, dist
);
69 distribute_free_if_empty(struct distribute
*dist
)
73 for (i
= 0; i
< DISTRIBUTE_MAX
; i
++)
74 if (dist
->list
[i
] != NULL
|| dist
->prefix
[i
] != NULL
)
77 hash_release (disthash
, dist
);
78 distribute_free (dist
);
81 /* Lookup interface's distribute list. */
83 distribute_lookup (const char *ifname
)
85 struct distribute key
;
86 struct distribute
*dist
;
88 /* temporary reference */
89 key
.ifname
= (ifname
) ? XSTRDUP(MTYPE_DISTRIBUTE_IFNAME
, ifname
) : NULL
;
91 dist
= hash_lookup (disthash
, &key
);
94 XFREE(MTYPE_DISTRIBUTE_IFNAME
, key
.ifname
);
100 distribute_list_add_hook (void (*func
) (struct distribute
*))
102 distribute_add_hook
= func
;
106 distribute_list_delete_hook (void (*func
) (struct distribute
*))
108 distribute_delete_hook
= func
;
112 distribute_hash_alloc (struct distribute
*arg
)
114 struct distribute
*dist
;
116 dist
= distribute_new ();
118 dist
->ifname
= XSTRDUP (MTYPE_DISTRIBUTE_IFNAME
, arg
->ifname
);
124 /* Make new distribute list and push into hash. */
125 static struct distribute
*
126 distribute_get (const char *ifname
)
128 struct distribute key
;
129 struct distribute
*ret
;
131 /* temporary reference */
132 key
.ifname
= (ifname
) ? XSTRDUP(MTYPE_DISTRIBUTE_IFNAME
, ifname
) : NULL
;
134 ret
= hash_get (disthash
, &key
, (void * (*) (void *))distribute_hash_alloc
);
137 XFREE(MTYPE_DISTRIBUTE_IFNAME
, key
.ifname
);
143 distribute_hash_make (void *arg
)
145 const struct distribute
*dist
= arg
;
147 return dist
->ifname
? string_hash_make (dist
->ifname
) : 0;
150 /* If two distribute-list have same value then return 1 else return
151 0. This function is used by hash package. */
153 distribute_cmp (const struct distribute
*dist1
, const struct distribute
*dist2
)
155 if (dist1
->ifname
&& dist2
->ifname
)
156 if (strcmp (dist1
->ifname
, dist2
->ifname
) == 0)
158 if (! dist1
->ifname
&& ! dist2
->ifname
)
163 /* Set access-list name to the distribute list. */
164 static struct distribute
*
165 distribute_list_set (const char *ifname
, enum distribute_type type
,
166 const char *alist_name
)
168 struct distribute
*dist
;
170 dist
= distribute_get (ifname
);
172 if (dist
->list
[type
])
173 XFREE(MTYPE_DISTRIBUTE_NAME
, dist
->list
[type
]);
174 dist
->list
[type
] = XSTRDUP(MTYPE_DISTRIBUTE_NAME
, alist_name
);
176 /* Apply this distribute-list to the interface. */
177 (*distribute_add_hook
) (dist
);
182 /* Unset distribute-list. If matched distribute-list exist then
185 distribute_list_unset (const char *ifname
, enum distribute_type type
,
186 const char *alist_name
)
188 struct distribute
*dist
;
190 dist
= distribute_lookup (ifname
);
194 if (!dist
->list
[type
])
196 if (strcmp (dist
->list
[type
], alist_name
) != 0)
199 XFREE(MTYPE_DISTRIBUTE_NAME
, dist
->list
[type
]);
200 dist
->list
[type
] = NULL
;
202 /* Apply this distribute-list to the interface. */
203 (*distribute_delete_hook
) (dist
);
205 /* If all dist are NULL, then free distribute list. */
206 distribute_free_if_empty(dist
);
210 /* Set access-list name to the distribute list. */
211 static struct distribute
*
212 distribute_list_prefix_set (const char *ifname
, enum distribute_type type
,
213 const char *plist_name
)
215 struct distribute
*dist
;
217 dist
= distribute_get (ifname
);
219 if (dist
->prefix
[type
])
220 XFREE(MTYPE_DISTRIBUTE_NAME
, dist
->prefix
[type
]);
221 dist
->prefix
[type
] = XSTRDUP(MTYPE_DISTRIBUTE_NAME
, plist_name
);
223 /* Apply this distribute-list to the interface. */
224 (*distribute_add_hook
) (dist
);
229 /* Unset distribute-list. If matched distribute-list exist then
232 distribute_list_prefix_unset (const char *ifname
, enum distribute_type type
,
233 const char *plist_name
)
235 struct distribute
*dist
;
237 dist
= distribute_lookup (ifname
);
241 if (!dist
->prefix
[type
])
243 if (strcmp (dist
->prefix
[type
], plist_name
) != 0)
246 XFREE(MTYPE_DISTRIBUTE_NAME
, dist
->prefix
[type
]);
247 dist
->prefix
[type
] = NULL
;
249 /* Apply this distribute-list to the interface. */
250 (*distribute_delete_hook
) (dist
);
252 /* If all dist are NULL, then free distribute list. */
253 distribute_free_if_empty(dist
);
257 DEFUN (distribute_list_all
,
258 distribute_list_all_cmd
,
259 "distribute-list WORD (in|out)",
260 "Filter networks in routing updates\n"
262 "Filter incoming routing updates\n"
263 "Filter outgoing routing updates\n")
265 enum distribute_type type
;
267 /* Check of distribute list type. */
268 if (strncmp (argv
[1], "i", 1) == 0)
269 type
= DISTRIBUTE_V4_IN
;
270 else if (strncmp (argv
[1], "o", 1) == 0)
271 type
= DISTRIBUTE_V4_OUT
;
274 vty_out (vty
, "distribute list direction must be [in|out]%s",
279 /* Get interface name corresponding distribute list. */
280 distribute_list_set (NULL
, type
, argv
[0]);
285 DEFUN (ipv6_distribute_list_all
,
286 ipv6_distribute_list_all_cmd
,
287 "ipv6 distribute-list WORD (in|out)",
288 "Filter networks in routing updates\n"
290 "Filter incoming routing updates\n"
291 "Filter outgoing routing updates\n")
293 enum distribute_type type
;
295 /* Check of distribute list type. */
296 if (strncmp (argv
[1], "i", 1) == 0)
297 type
= DISTRIBUTE_V6_IN
;
298 else if (strncmp (argv
[1], "o", 1) == 0)
299 type
= DISTRIBUTE_V6_OUT
;
302 vty_out (vty
, "distribute list direction must be [in|out]%s",
307 /* Get interface name corresponding distribute list. */
308 distribute_list_set (NULL
, type
, argv
[0]);
313 ALIAS (ipv6_distribute_list_all
,
314 ipv6_as_v4_distribute_list_all_cmd
,
315 "distribute-list WORD (in|out)",
316 "Filter networks in routing updates\n"
318 "Filter incoming routing updates\n"
319 "Filter outgoing routing updates\n")
321 DEFUN (no_distribute_list_all
,
322 no_distribute_list_all_cmd
,
323 "no distribute-list WORD (in|out)",
325 "Filter networks in routing updates\n"
327 "Filter incoming routing updates\n"
328 "Filter outgoing routing updates\n")
331 enum distribute_type type
;
333 /* Check of distribute list type. */
334 if (strncmp (argv
[1], "i", 1) == 0)
335 type
= DISTRIBUTE_V4_IN
;
336 else if (strncmp (argv
[1], "o", 1) == 0)
337 type
= DISTRIBUTE_V4_OUT
;
340 vty_out (vty
, "distribute list direction must be [in|out]%s",
345 ret
= distribute_list_unset (NULL
, type
, argv
[0]);
348 vty_out (vty
, "distribute list doesn't exist%s", VTY_NEWLINE
);
354 DEFUN (no_ipv6_distribute_list_all
,
355 no_ipv6_distribute_list_all_cmd
,
356 "no ipv6 distribute-list WORD (in|out)",
358 "Filter networks in routing updates\n"
360 "Filter incoming routing updates\n"
361 "Filter outgoing routing updates\n")
364 enum distribute_type type
;
366 /* Check of distribute list type. */
367 if (strncmp (argv
[1], "i", 1) == 0)
368 type
= DISTRIBUTE_V6_IN
;
369 else if (strncmp (argv
[1], "o", 1) == 0)
370 type
= DISTRIBUTE_V6_OUT
;
373 vty_out (vty
, "distribute list direction must be [in|out]%s",
378 ret
= distribute_list_unset (NULL
, type
, argv
[0]);
381 vty_out (vty
, "distribute list doesn't exist%s", VTY_NEWLINE
);
387 ALIAS (no_ipv6_distribute_list_all
,
388 no_ipv6_as_v4_distribute_list_all_cmd
,
389 "no distribute-list WORD (in|out)",
391 "Filter networks in routing updates\n"
393 "Filter incoming routing updates\n"
394 "Filter outgoing routing updates\n")
396 DEFUN (distribute_list
,
398 "distribute-list WORD (in|out) WORD",
399 "Filter networks in routing updates\n"
401 "Filter incoming routing updates\n"
402 "Filter outgoing routing updates\n"
405 enum distribute_type type
;
407 /* Check of distribute list type. */
408 if (strncmp (argv
[1], "i", 1) == 0)
409 type
= DISTRIBUTE_V4_IN
;
410 else if (strncmp (argv
[1], "o", 1) == 0)
411 type
= DISTRIBUTE_V4_OUT
;
414 vty_out (vty
, "distribute list direction must be [in|out]%s", VTY_NEWLINE
);
418 /* Get interface name corresponding distribute list. */
419 distribute_list_set (argv
[2], type
, argv
[0]);
424 DEFUN (ipv6_distribute_list
,
425 ipv6_distribute_list_cmd
,
426 "ipv6 distribute-list WORD (in|out) WORD",
427 "Filter networks in routing updates\n"
429 "Filter incoming routing updates\n"
430 "Filter outgoing routing updates\n"
433 enum distribute_type type
;
435 /* Check of distribute list type. */
436 if (strncmp (argv
[1], "i", 1) == 0)
437 type
= DISTRIBUTE_V6_IN
;
438 else if (strncmp (argv
[1], "o", 1) == 0)
439 type
= DISTRIBUTE_V6_OUT
;
442 vty_out (vty
, "distribute list direction must be [in|out]%s", VTY_NEWLINE
);
446 /* Get interface name corresponding distribute list. */
447 distribute_list_set (argv
[2], type
, argv
[0]);
452 ALIAS (ipv6_distribute_list
,
453 ipv6_as_v4_distribute_list_cmd
,
454 "distribute-list WORD (in|out) WORD",
455 "Filter networks in routing updates\n"
457 "Filter incoming routing updates\n"
458 "Filter outgoing routing updates\n"
461 DEFUN (no_distribute_list
, no_distribute_list_cmd
,
462 "no distribute-list WORD (in|out) WORD",
464 "Filter networks in routing updates\n"
466 "Filter incoming routing updates\n"
467 "Filter outgoing routing updates\n"
471 enum distribute_type type
;
473 /* Check of distribute list type. */
474 if (strncmp (argv
[1], "i", 1) == 0)
475 type
= DISTRIBUTE_V4_IN
;
476 else if (strncmp (argv
[1], "o", 1) == 0)
477 type
= DISTRIBUTE_V4_OUT
;
480 vty_out (vty
, "distribute list direction must be [in|out]%s", VTY_NEWLINE
);
484 ret
= distribute_list_unset (argv
[2], type
, argv
[0]);
487 vty_out (vty
, "distribute list doesn't exist%s", VTY_NEWLINE
);
493 DEFUN (no_ipv6_distribute_list
,
494 no_ipv6_distribute_list_cmd
,
495 "no ipv6 distribute-list WORD (in|out) WORD",
497 "Filter networks in routing updates\n"
499 "Filter incoming routing updates\n"
500 "Filter outgoing routing updates\n"
504 enum distribute_type type
;
506 /* Check of distribute list type. */
507 if (strncmp (argv
[1], "i", 1) == 0)
508 type
= DISTRIBUTE_V6_IN
;
509 else if (strncmp (argv
[1], "o", 1) == 0)
510 type
= DISTRIBUTE_V6_OUT
;
513 vty_out (vty
, "distribute list direction must be [in|out]%s", VTY_NEWLINE
);
517 ret
= distribute_list_unset (argv
[2], type
, argv
[0]);
520 vty_out (vty
, "distribute list doesn't exist%s", VTY_NEWLINE
);
526 ALIAS (no_ipv6_distribute_list
,
527 no_ipv6_as_v4_distribute_list_cmd
,
528 "no distribute-list WORD (in|out) WORD",
530 "Filter networks in routing updates\n"
532 "Filter incoming routing updates\n"
533 "Filter outgoing routing updates\n"
536 DEFUN (distribute_list_prefix_all
,
537 distribute_list_prefix_all_cmd
,
538 "distribute-list prefix WORD (in|out)",
539 "Filter networks in routing updates\n"
540 "Filter prefixes in routing updates\n"
541 "Name of an IP prefix-list\n"
542 "Filter incoming routing updates\n"
543 "Filter outgoing routing updates\n")
545 enum distribute_type type
;
547 /* Check of distribute list type. */
548 if (strncmp (argv
[1], "i", 1) == 0)
549 type
= DISTRIBUTE_V4_IN
;
550 else if (strncmp (argv
[1], "o", 1) == 0)
551 type
= DISTRIBUTE_V4_OUT
;
554 vty_out (vty
, "distribute list direction must be [in|out]%s",
559 /* Get interface name corresponding distribute list. */
560 distribute_list_prefix_set (NULL
, type
, argv
[0]);
565 DEFUN (ipv6_distribute_list_prefix_all
,
566 ipv6_distribute_list_prefix_all_cmd
,
567 "ipv6 distribute-list prefix WORD (in|out)",
568 "Filter networks in routing updates\n"
569 "Filter prefixes in routing updates\n"
570 "Name of an IP prefix-list\n"
571 "Filter incoming routing updates\n"
572 "Filter outgoing routing updates\n")
574 enum distribute_type type
;
576 /* Check of distribute list type. */
577 if (strncmp (argv
[1], "i", 1) == 0)
578 type
= DISTRIBUTE_V6_IN
;
579 else if (strncmp (argv
[1], "o", 1) == 0)
580 type
= DISTRIBUTE_V6_OUT
;
583 vty_out (vty
, "distribute list direction must be [in|out]%s",
588 /* Get interface name corresponding distribute list. */
589 distribute_list_prefix_set (NULL
, type
, argv
[0]);
594 ALIAS (ipv6_distribute_list_prefix_all
,
595 ipv6_as_v4_distribute_list_prefix_all_cmd
,
596 "distribute-list prefix WORD (in|out)",
597 "Filter networks in routing updates\n"
598 "Filter prefixes in routing updates\n"
599 "Name of an IP prefix-list\n"
600 "Filter incoming routing updates\n"
601 "Filter outgoing routing updates\n")
603 DEFUN (no_distribute_list_prefix_all
,
604 no_distribute_list_prefix_all_cmd
,
605 "no distribute-list prefix WORD (in|out)",
607 "Filter networks in routing updates\n"
608 "Filter prefixes in routing updates\n"
609 "Name of an IP prefix-list\n"
610 "Filter incoming routing updates\n"
611 "Filter outgoing routing updates\n")
614 enum distribute_type type
;
616 /* Check of distribute list type. */
617 if (strncmp (argv
[1], "i", 1) == 0)
618 type
= DISTRIBUTE_V4_IN
;
619 else if (strncmp (argv
[1], "o", 1) == 0)
620 type
= DISTRIBUTE_V4_OUT
;
623 vty_out (vty
, "distribute list direction must be [in|out]%s",
628 ret
= distribute_list_prefix_unset (NULL
, type
, argv
[0]);
631 vty_out (vty
, "distribute list doesn't exist%s", VTY_NEWLINE
);
637 DEFUN (no_ipv6_distribute_list_prefix_all
,
638 no_ipv6_distribute_list_prefix_all_cmd
,
639 "no ipv6 distribute-list prefix WORD (in|out)",
641 "Filter networks in routing updates\n"
642 "Filter prefixes in routing updates\n"
643 "Name of an IP prefix-list\n"
644 "Filter incoming routing updates\n"
645 "Filter outgoing routing updates\n")
648 enum distribute_type type
;
650 /* Check of distribute list type. */
651 if (strncmp (argv
[1], "i", 1) == 0)
652 type
= DISTRIBUTE_V6_IN
;
653 else if (strncmp (argv
[1], "o", 1) == 0)
654 type
= DISTRIBUTE_V6_OUT
;
657 vty_out (vty
, "distribute list direction must be [in|out]%s",
662 ret
= distribute_list_prefix_unset (NULL
, type
, argv
[0]);
665 vty_out (vty
, "distribute list doesn't exist%s", VTY_NEWLINE
);
671 ALIAS (no_ipv6_distribute_list_prefix_all
,
672 no_ipv6_as_v4_distribute_list_prefix_all_cmd
,
673 "no distribute-list prefix WORD (in|out)",
675 "Filter networks in routing updates\n"
676 "Filter prefixes in routing updates\n"
677 "Name of an IP prefix-list\n"
678 "Filter incoming routing updates\n"
679 "Filter outgoing routing updates\n")
681 DEFUN (distribute_list_prefix
, distribute_list_prefix_cmd
,
682 "distribute-list prefix WORD (in|out) WORD",
683 "Filter networks in routing updates\n"
684 "Filter prefixes in routing updates\n"
685 "Name of an IP prefix-list\n"
686 "Filter incoming routing updates\n"
687 "Filter outgoing routing updates\n"
690 enum distribute_type type
;
692 /* Check of distribute list type. */
693 if (strncmp (argv
[1], "i", 1) == 0)
694 type
= DISTRIBUTE_V4_IN
;
695 else if (strncmp (argv
[1], "o", 1) == 0)
696 type
= DISTRIBUTE_V4_OUT
;
699 vty_out (vty
, "distribute list direction must be [in|out]%s",
704 /* Get interface name corresponding distribute list. */
705 distribute_list_prefix_set (argv
[2], type
, argv
[0]);
710 DEFUN (ipv6_distribute_list_prefix
,
711 ipv6_distribute_list_prefix_cmd
,
712 "ipv6 distribute-list prefix WORD (in|out) WORD",
713 "Filter networks in routing updates\n"
714 "Filter prefixes in routing updates\n"
715 "Name of an IP prefix-list\n"
716 "Filter incoming routing updates\n"
717 "Filter outgoing routing updates\n"
720 enum distribute_type type
;
722 /* Check of distribute list type. */
723 if (strncmp (argv
[1], "i", 1) == 0)
724 type
= DISTRIBUTE_V6_IN
;
725 else if (strncmp (argv
[1], "o", 1) == 0)
726 type
= DISTRIBUTE_V6_OUT
;
729 vty_out (vty
, "distribute list direction must be [in|out]%s",
734 /* Get interface name corresponding distribute list. */
735 distribute_list_prefix_set (argv
[2], type
, argv
[0]);
740 ALIAS (ipv6_distribute_list_prefix
,
741 ipv6_as_v4_distribute_list_prefix_cmd
,
742 "distribute-list prefix WORD (in|out) WORD",
743 "Filter networks in routing updates\n"
744 "Filter prefixes in routing updates\n"
745 "Name of an IP prefix-list\n"
746 "Filter incoming routing updates\n"
747 "Filter outgoing routing updates\n"
750 DEFUN (no_distribute_list_prefix
, no_distribute_list_prefix_cmd
,
751 "no distribute-list prefix WORD (in|out) WORD",
753 "Filter networks in routing updates\n"
754 "Filter prefixes in routing updates\n"
755 "Name of an IP prefix-list\n"
756 "Filter incoming routing updates\n"
757 "Filter outgoing routing updates\n"
761 enum distribute_type type
;
763 /* Check of distribute list type. */
764 if (strncmp (argv
[1], "i", 1) == 0)
765 type
= DISTRIBUTE_V4_IN
;
766 else if (strncmp (argv
[1], "o", 1) == 0)
767 type
= DISTRIBUTE_V4_OUT
;
770 vty_out (vty
, "distribute list direction must be [in|out]%s",
775 ret
= distribute_list_prefix_unset (argv
[2], type
, argv
[0]);
778 vty_out (vty
, "distribute list doesn't exist%s", VTY_NEWLINE
);
784 DEFUN (no_ipv6_distribute_list_prefix
,
785 no_ipv6_distribute_list_prefix_cmd
,
786 "no ipv6 distribute-list prefix WORD (in|out) WORD",
788 "Filter networks in routing updates\n"
789 "Filter prefixes in routing updates\n"
790 "Name of an IP prefix-list\n"
791 "Filter incoming routing updates\n"
792 "Filter outgoing routing updates\n"
796 enum distribute_type type
;
798 /* Check of distribute list type. */
799 if (strncmp (argv
[1], "i", 1) == 0)
800 type
= DISTRIBUTE_V6_IN
;
801 else if (strncmp (argv
[1], "o", 1) == 0)
802 type
= DISTRIBUTE_V6_OUT
;
805 vty_out (vty
, "distribute list direction must be [in|out]%s",
810 ret
= distribute_list_prefix_unset (argv
[2], type
, argv
[0]);
813 vty_out (vty
, "distribute list doesn't exist%s", VTY_NEWLINE
);
819 ALIAS (no_ipv6_distribute_list_prefix
,
820 no_ipv6_as_v4_distribute_list_prefix_cmd
,
821 "no distribute-list prefix WORD (in|out) WORD",
823 "Filter networks in routing updates\n"
824 "Filter prefixes in routing updates\n"
825 "Name of an IP prefix-list\n"
826 "Filter incoming routing updates\n"
827 "Filter outgoing routing updates\n"
831 distribute_print (struct vty
*vty
, char *tab
[], int is_prefix
,
832 enum distribute_type type
, int has_print
)
835 vty_out (vty
, "%s %s%s",
836 has_print
? "," : "",
837 is_prefix
? "(prefix-list) " : "",
845 config_show_distribute (struct vty
*vty
)
849 struct hash_backet
*mp
;
850 struct distribute
*dist
;
852 /* Output filter configuration. */
853 dist
= distribute_lookup (NULL
);
854 vty_out(vty
, " Outgoing update filter list for all interface is");
858 has_print
= distribute_print(vty
, dist
->list
, 0,
859 DISTRIBUTE_V4_OUT
, has_print
);
860 has_print
= distribute_print(vty
, dist
->prefix
, 1,
861 DISTRIBUTE_V4_OUT
, has_print
);
862 has_print
= distribute_print(vty
, dist
->list
, 0,
863 DISTRIBUTE_V6_OUT
, has_print
);
864 has_print
= distribute_print(vty
, dist
->prefix
, 1,
865 DISTRIBUTE_V6_OUT
, has_print
);
868 vty_out (vty
, "%s", VTY_NEWLINE
);
870 vty_out (vty
, " not set%s", VTY_NEWLINE
);
872 for (i
= 0; i
< disthash
->size
; i
++)
873 for (mp
= disthash
->index
[i
]; mp
; mp
= mp
->next
)
878 vty_out (vty
, " %s filtered by", dist
->ifname
);
880 has_print
= distribute_print(vty
, dist
->list
, 0,
881 DISTRIBUTE_V4_OUT
, has_print
);
882 has_print
= distribute_print(vty
, dist
->prefix
, 1,
883 DISTRIBUTE_V4_OUT
, has_print
);
884 has_print
= distribute_print(vty
, dist
->list
, 0,
885 DISTRIBUTE_V6_OUT
, has_print
);
886 has_print
= distribute_print(vty
, dist
->prefix
, 1,
887 DISTRIBUTE_V6_OUT
, has_print
);
889 vty_out (vty
, "%s", VTY_NEWLINE
);
891 vty_out(vty
, " nothing%s", VTY_NEWLINE
);
896 /* Input filter configuration. */
897 dist
= distribute_lookup (NULL
);
898 vty_out(vty
, " Incoming update filter list for all interface is");
902 has_print
= distribute_print(vty
, dist
->list
, 0,
903 DISTRIBUTE_V4_IN
, has_print
);
904 has_print
= distribute_print(vty
, dist
->prefix
, 1,
905 DISTRIBUTE_V4_IN
, has_print
);
906 has_print
= distribute_print(vty
, dist
->list
, 0,
907 DISTRIBUTE_V6_IN
, has_print
);
908 has_print
= distribute_print(vty
, dist
->prefix
, 1,
909 DISTRIBUTE_V6_IN
, has_print
);
912 vty_out (vty
, "%s", VTY_NEWLINE
);
914 vty_out (vty
, " not set%s", VTY_NEWLINE
);
916 for (i
= 0; i
< disthash
->size
; i
++)
917 for (mp
= disthash
->index
[i
]; mp
; mp
= mp
->next
)
922 vty_out (vty
, " %s filtered by", dist
->ifname
);
924 has_print
= distribute_print(vty
, dist
->list
, 0,
925 DISTRIBUTE_V4_IN
, has_print
);
926 has_print
= distribute_print(vty
, dist
->prefix
, 1,
927 DISTRIBUTE_V4_IN
, has_print
);
928 has_print
= distribute_print(vty
, dist
->list
, 0,
929 DISTRIBUTE_V6_IN
, has_print
);
930 has_print
= distribute_print(vty
, dist
->prefix
, 1,
931 DISTRIBUTE_V6_IN
, has_print
);
933 vty_out (vty
, "%s", VTY_NEWLINE
);
935 vty_out(vty
, " nothing%s", VTY_NEWLINE
);
941 /* Configuration write function. */
943 config_write_distribute (struct vty
*vty
)
948 struct hash_backet
*mp
;
951 for (i
= 0; i
< disthash
->size
; i
++)
952 for (mp
= disthash
->index
[i
]; mp
; mp
= mp
->next
)
954 struct distribute
*dist
;
958 for (j
= 0; j
< DISTRIBUTE_MAX
; j
++)
960 output
= j
== DISTRIBUTE_V4_OUT
|| j
== DISTRIBUTE_V6_OUT
;
961 v6
= j
== DISTRIBUTE_V6_IN
|| j
== DISTRIBUTE_V6_OUT
;
962 vty_out (vty
, " %sdistribute-list %s %s %s%s",
965 output
? "out" : "in",
966 dist
->ifname
? dist
->ifname
: "",
971 for (j
= 0; j
< DISTRIBUTE_MAX
; j
++)
972 if (dist
->prefix
[j
]) {
973 output
= j
== DISTRIBUTE_V4_OUT
|| j
== DISTRIBUTE_V6_OUT
;
974 v6
= j
== DISTRIBUTE_V6_IN
|| j
== DISTRIBUTE_V6_OUT
;
975 vty_out (vty
, " %sdistribute-list prefix %s %s %s%s",
978 output
? "out" : "in",
979 dist
->ifname
? dist
->ifname
: "",
987 /* Clear all distribute list. */
989 distribute_list_reset ()
991 hash_clean (disthash
, (void (*) (void *)) distribute_free
);
994 /* Initialize distribute list related hash. */
996 distribute_list_init (int node
)
998 disthash
= hash_create (distribute_hash_make
,
999 (int (*) (const void *, const void *)) distribute_cmp
);
1001 if (node
== RIP_NODE
) {
1002 install_element (node
, &distribute_list_all_cmd
);
1003 install_element (node
, &no_distribute_list_all_cmd
);
1004 install_element (node
, &distribute_list_cmd
);
1005 install_element (node
, &no_distribute_list_cmd
);
1006 install_element (node
, &distribute_list_prefix_all_cmd
);
1007 install_element (node
, &no_distribute_list_prefix_all_cmd
);
1008 install_element (node
, &distribute_list_prefix_cmd
);
1009 install_element (node
, &no_distribute_list_prefix_cmd
);
1013 if (node
== RIPNG_NODE
) {
1014 install_element (node
, &ipv6_distribute_list_all_cmd
);
1015 install_element (node
, &no_ipv6_distribute_list_all_cmd
);
1016 install_element (node
, &ipv6_distribute_list_cmd
);
1017 install_element (node
, &no_ipv6_distribute_list_cmd
);
1018 install_element (node
, &ipv6_distribute_list_prefix_all_cmd
);
1019 install_element (node
, &no_ipv6_distribute_list_prefix_all_cmd
);
1020 install_element (node
, &ipv6_distribute_list_prefix_cmd
);
1021 install_element (node
, &no_ipv6_distribute_list_prefix_cmd
);
1024 /* install v4 syntax command for v6 only protocols. */
1025 if (node
== RIPNG_NODE
) {
1026 install_element (node
, &ipv6_as_v4_distribute_list_all_cmd
);
1027 install_element (node
, &no_ipv6_as_v4_distribute_list_all_cmd
);
1028 install_element (node
, &ipv6_as_v4_distribute_list_cmd
);
1029 install_element (node
, &no_ipv6_as_v4_distribute_list_cmd
);
1030 install_element (node
, &ipv6_as_v4_distribute_list_prefix_all_cmd
);
1031 install_element (node
, &no_ipv6_as_v4_distribute_list_prefix_all_cmd
);
1032 install_element (node
, &ipv6_as_v4_distribute_list_prefix_cmd
);
1033 install_element (node
, &no_ipv6_as_v4_distribute_list_prefix_cmd
);