]>
git.proxmox.com Git - mirror_frr.git/blob - babeld/babel_filter.c
1 // SPDX-License-Identifier: MIT
3 Copyright 2011 by Matthieu Boutier and Juliusz Chroboczek
10 #include "babel_filter.h"
15 #include "distribute.h"
19 babel_filter(int output
, const unsigned char *prefix
, unsigned short plen
,
22 struct interface
*ifp
= if_lookup_by_index(ifindex
, VRF_DEFAULT
);
23 babel_interface_nfo
*babel_ifp
= ifp
? babel_get_if_nfo(ifp
) : NULL
;
25 struct distribute
*dist
= NULL
;
26 struct access_list
*alist
;
27 struct prefix_list
*plist
;
32 p
.family
= v4mapped(prefix
) ? AF_INET
: AF_INET6
;
33 p
.prefixlen
= v4mapped(prefix
) ? plen
- 96 : plen
;
34 if (p
.family
== AF_INET
) {
35 uchar_to_inaddr(&p
.u
.prefix4
, prefix
);
36 distribute
= output
? DISTRIBUTE_V4_OUT
: DISTRIBUTE_V4_IN
;
39 uchar_to_in6addr(&p
.u
.prefix6
, prefix
);
40 distribute
= output
? DISTRIBUTE_V6_OUT
: DISTRIBUTE_V6_IN
;
44 if (babel_ifp
!= NULL
&& babel_ifp
->list
[distribute
]) {
45 if (access_list_apply (babel_ifp
->list
[distribute
], &p
)
47 debugf(BABEL_DEBUG_FILTER
,
48 "%pFX filtered by distribute %s",
49 &p
, output
? "out" : "in");
53 if (babel_ifp
!= NULL
&& babel_ifp
->prefix
[distribute
]) {
54 if (prefix_list_apply (babel_ifp
->prefix
[distribute
], &p
)
56 debugf(BABEL_DEBUG_FILTER
, "%pFX filtered by distribute %s",
57 &p
, output
? "out" : "in");
62 /* All interface filter check. */
63 babel
= babel_lookup();
65 dist
= distribute_lookup (babel
->distribute_ctx
, NULL
);
67 if (dist
->list
[distribute
]) {
68 alist
= access_list_lookup (family
, dist
->list
[distribute
]);
71 if (access_list_apply (alist
, &p
) == FILTER_DENY
) {
72 debugf(BABEL_DEBUG_FILTER
,"%pFX filtered by distribute %s",
73 &p
, output
? "out" : "in");
78 if (dist
->prefix
[distribute
]) {
79 plist
= prefix_list_lookup (family
, dist
->prefix
[distribute
]);
81 if (prefix_list_apply (plist
, &p
) == PREFIX_DENY
) {
82 debugf(BABEL_DEBUG_FILTER
,"%pFX filtered by distribute %s",
83 &p
, output
? "out" : "in");