Lines Matching refs:filter
25 #include "filter.h"
43 /* If this filter is "exact" match then this flag is set. */
51 struct filter
54 struct filter *next;
55 struct filter *prev;
126 /* Allocate new filter structure. */
127 struct filter *
130 return (struct filter *) XCALLOC (MTYPE_ACCESS_FILTER,
131 sizeof (struct filter));
135 filter_free (struct filter *filter)
137 XFREE (MTYPE_ACCESS_FILTER, filter);
142 filter_type_str (struct filter *filter)
144 switch (filter->type)
161 /* If filter match to the prefix then return 1. */
163 filter_match_cisco (struct filter *mfilter, struct prefix *p)
165 struct filter_cisco *filter;
170 filter = &mfilter->u.cfilter;
171 check_addr = p->u.prefix4.s_addr & ~filter->addr_mask.s_addr;
173 if (filter->extended)
176 check_mask = mask.s_addr & ~filter->mask_mask.s_addr;
178 if (memcmp (&check_addr, &filter->addr.s_addr, 4) == 0
179 && memcmp (&check_mask, &filter->mask.s_addr, 4) == 0)
182 else if (memcmp (&check_addr, &filter->addr.s_addr, 4) == 0)
188 /* If filter match to the prefix then return 1. */
190 filter_match_zebra (struct filter *mfilter, struct prefix *p)
192 struct filter_zebra *filter;
194 filter = &mfilter->u.zfilter;
196 if (filter->prefix.family == p->family)
198 if (filter->exact)
200 if (filter->prefix.prefixlen == p->prefixlen)
201 return prefix_match (&filter->prefix, p);
206 return prefix_match (&filter->prefix, p);
232 struct filter *filter;
233 struct filter *next;
237 for (filter = access->head; filter; filter = next)
239 next = filter->next;
240 filter_free (filter);
403 struct filter *filter;
411 for (filter = access->head; filter; filter = filter->next)
413 if (filter->cisco)
415 if (filter_match_cisco (filter, p))
416 return filter->type;
420 if (filter_match_zebra (filter, p))
421 return filter->type;
448 /* Add new filter to the end of specified access_list. */
450 access_list_filter_add (struct access_list *access, struct filter *filter)
452 filter->next = NULL;
453 filter->prev = access->tail;
456 access->tail->next = filter;
458 access->head = filter;
459 access->tail = filter;
466 /* If access_list has no filter then return 1. */
476 /* Delete filter from specified access_list. If there is hook
479 access_list_filter_delete (struct access_list *access, struct filter *filter)
485 if (filter->next)
486 filter->next->prev = filter->prev;
488 access->tail = filter->prev;
490 if (filter->prev)
491 filter->prev->next = filter->next;
493 access->head = filter->next;
495 filter_free (filter);
519 struct filter *
520 filter_lookup_cisco (struct access_list *access, struct filter *mnew)
522 struct filter *mfilter;
523 struct filter_cisco *filter;
530 filter = &mfilter->u.cfilter;
532 if (filter->extended)
535 && filter->addr.s_addr == new->addr.s_addr
536 && filter->addr_mask.s_addr == new->addr_mask.s_addr
537 && filter->mask.s_addr == new->mask.s_addr
538 && filter->mask_mask.s_addr == new->mask_mask.s_addr)
544 && filter->addr.s_addr == new->addr.s_addr
545 && filter->addr_mask.s_addr == new->addr_mask.s_addr)
554 struct filter *
555 filter_lookup_zebra (struct access_list *access, struct filter *mnew)
557 struct filter *mfilter;
558 struct filter_zebra *filter;
565 filter = &mfilter->u.zfilter;
567 if (filter->exact == new->exact
569 && prefix_same (&filter->prefix, &new->prefix))
609 struct filter *mfilter;
610 struct filter_cisco *filter;
617 /* Check of filter type. */
624 vty_out (vty, "%% filter type must be permit or deny%s", VTY_NEWLINE);
666 filter = &mfilter->u.cfilter;
667 filter->extended = extended;
668 filter->addr.s_addr = addr.s_addr & ~addr_mask.s_addr;
669 filter->addr_mask.s_addr = addr_mask.s_addr;
673 filter->mask.s_addr = mask.s_addr & ~mask_mask.s_addr;
674 filter->mask_mask.s_addr = mask_mask.s_addr;
677 /* Install new filter to the access_list. */
689 struct filter *delete_filter;
1167 struct filter *mfilter;
1168 struct filter_zebra *filter;
1172 /* Check of filter type. */
1179 vty_out (vty, "filter type must be [permit|deny]%s", VTY_NEWLINE);
1211 filter = &mfilter->u.zfilter;
1212 prefix_copy (&filter->prefix, &p);
1216 filter->exact = 1;
1218 /* Install new filter to the access_list. */
1230 struct filter *delete_filter;
1345 /* Delete all filter from access-list. */
1533 /* Delete all filter from access-list. */
1603 void config_write_access_zebra (struct vty *, struct filter *);
1604 void config_write_access_cisco (struct vty *, struct filter *);
1612 struct filter *mfilter;
1613 struct filter_cisco *filter;
1629 filter = &mfilter->u.cfilter;
1635 (filter->extended ? "Extended" : "Standard") : "Zebra",
1646 else if (filter->extended)
1650 if (filter->addr_mask.s_addr == 0xffffffff)
1654 vty_out (vty, " %s", inet_ntoa (filter->addr));
1655 if (filter->addr_mask.s_addr != 0)
1656 vty_out (vty, ", wildcard bits %s", inet_ntoa (filter->addr_mask));
1672 filter = &mfilter->u.cfilter;
1678 (filter->extended ? "Extended" : "Standard") : "Zebra",
1689 else if (filter->extended)
1693 if (filter->addr_mask.s_addr == 0xffffffff)
1697 vty_out (vty, " %s", inet_ntoa (filter->addr));
1698 if (filter->addr_mask.s_addr != 0)
1699 vty_out (vty, ", wildcard bits %s", inet_ntoa (filter->addr_mask));
1757 config_write_access_cisco (struct vty *vty, struct filter *mfilter)
1759 struct filter_cisco *filter;
1761 filter = &mfilter->u.cfilter;
1763 if (filter->extended)
1766 if (filter->addr_mask.s_addr == 0xffffffff)
1768 else if (filter->addr_mask.s_addr == 0)
1769 vty_out (vty, " host %s", inet_ntoa (filter->addr));
1772 vty_out (vty, " %s", inet_ntoa (filter->addr));
1773 vty_out (vty, " %s", inet_ntoa (filter->addr_mask));
1776 if (filter->mask_mask.s_addr == 0xffffffff)
1778 else if (filter->mask_mask.s_addr == 0)
1779 vty_out (vty, " host %s", inet_ntoa (filter->mask));
1782 vty_out (vty, " %s", inet_ntoa (filter->mask));
1783 vty_out (vty, " %s", inet_ntoa (filter->mask_mask));
1789 if (filter->addr_mask.s_addr == 0xffffffff)
1793 vty_out (vty, " %s", inet_ntoa (filter->addr));
1794 if (filter->addr_mask.s_addr != 0)
1795 vty_out (vty, " %s", inet_ntoa (filter->addr_mask));
1802 config_write_access_zebra (struct vty *vty, struct filter *mfilter)
1804 struct filter_zebra *filter;
1808 filter = &mfilter->u.zfilter;
1809 p = &filter->prefix;
1811 if (p->prefixlen == 0 && ! filter->exact)
1817 filter->exact ? " exact-match" : "");
1827 struct filter *mfilter;