]>
git.ipfire.org Git - thirdparty/bird.git/blob - nest/rt-dev.c
2 * BIRD -- Direct Device Routes
4 * (c) 1998--2000 Martin Mares <mj@ucw.cz>
6 * Can be freely distributed and used under the terms of the GNU GPL.
12 * The Direct protocol works by converting all ifa_notify() events it receives
13 * to rte_update() calls for the corresponding network.
18 #include "nest/bird.h"
19 #include "nest/iface.h"
20 #include "nest/protocol.h"
21 #include "nest/route.h"
22 #include "nest/rt-dev.h"
23 #include "conf/conf.h"
24 #include "lib/resource.h"
25 #include "lib/string.h"
28 dev_ifa_notify(struct proto
*p
, unsigned c
, struct ifa
*ad
)
30 struct rt_dev_config
*P
= (void *) p
->cf
;
32 if (!EMPTY_LIST(P
->iface_list
) &&
33 !iface_patt_find(&P
->iface_list
, ad
->iface
, ad
->iface
->addr
))
34 /* Empty list is automagically treated as "*" */
37 if (ad
->scope
<= SCOPE_LINK
)
40 if (c
& IF_CHANGE_DOWN
)
44 DBG("dev_if_notify: %s:%I going down\n", ad
->iface
->name
, ad
->ip
);
45 n
= net_find(p
->table
, ad
->prefix
, ad
->pxlen
);
48 DBG("dev_if_notify: device shutdown: prefix not found\n");
51 rte_update(p
->table
, n
, p
, p
, NULL
);
53 else if (c
& IF_CHANGE_UP
)
59 DBG("dev_if_notify: %s:%I going up\n", ad
->iface
->name
, ad
->ip
);
62 A
.source
= RTS_DEVICE
;
63 A
.scope
= SCOPE_UNIVERSE
;
69 n
= net_get(p
->table
, ad
->prefix
, ad
->pxlen
);
73 rte_update(p
->table
, n
, p
, p
, e
);
78 dev_init(struct proto_config
*c
)
80 struct proto
*p
= proto_new(c
, sizeof(struct proto
));
82 p
->ifa_notify
= dev_ifa_notify
;
87 dev_reconfigure(struct proto
*p
, struct proto_config
*new)
89 struct rt_dev_config
*o
= (struct rt_dev_config
*) p
->cf
;
90 struct rt_dev_config
*n
= (struct rt_dev_config
*) new;
92 return iface_patts_equal(&o
->iface_list
, &n
->iface_list
, NULL
);
95 struct protocol proto_device
= {
99 reconfigure
: dev_reconfigure