]> git.ipfire.org Git - thirdparty/bird.git/blob - nest/rt-dev.c
Renamed attr->attrs to attr->eattrs.
[thirdparty/bird.git] / nest / rt-dev.c
1 /*
2 * BIRD -- Direct Device Routes
3 *
4 * (c) 1998--1999 Martin Mares <mj@ucw.cz>
5 *
6 * Can be freely distributed and used under the terms of the GNU GPL.
7 */
8
9 #define LOCAL_DEBUG
10
11 #include <string.h>
12
13 #include "nest/bird.h"
14 #include "nest/iface.h"
15 #include "nest/protocol.h"
16 #include "nest/route.h"
17 #include "nest/rt-dev.h"
18 #include "conf/conf.h"
19 #include "lib/resource.h"
20
21 static void
22 dev_ifa_notify(struct proto *p, unsigned c, struct ifa *ad)
23 {
24 struct rt_dev_config *P = (void *) p->cf;
25
26 if (!EMPTY_LIST(P->iface_list) &&
27 !iface_patt_match(&P->iface_list, ad->iface))
28 /* Empty list is automagically treated as "*" */
29 return;
30 if (c & IF_CHANGE_DOWN)
31 {
32 net *n;
33
34 DBG("dev_if_notify: %s:%I going down\n", ad->iface->name, ad->ip);
35 n = net_find(p->table, ad->prefix, ad->pxlen);
36 if (!n)
37 {
38 debug("dev_if_notify: device shutdown: prefix not found\n");
39 return;
40 }
41 rte_update(p->table, n, p, NULL);
42 }
43 else if (c & IF_CHANGE_UP)
44 {
45 rta *a, A;
46 net *n;
47 rte *e;
48
49 debug("dev_if_notify: %s:%I going up\n", ad->iface->name, ad->ip);
50 bzero(&A, sizeof(A));
51 A.proto = p;
52 A.source = RTS_DEVICE;
53 A.scope = ad->scope;
54 A.cast = RTC_UNICAST;
55 A.dest = RTD_DEVICE;
56 A.iface = ad->iface;
57 A.eattrs = NULL;
58 a = rta_lookup(&A);
59 if (ad->flags & IF_UNNUMBERED)
60 n = net_get(p->table, ad->opposite, ad->pxlen);
61 else
62 n = net_get(p->table, ad->prefix, ad->pxlen);
63 e = rte_get_temp(a);
64 e->net = n;
65 e->pflags = 0;
66 rte_update(p->table, n, p, e);
67 }
68 }
69
70 static struct proto *
71 dev_init(struct proto_config *c)
72 {
73 struct proto *p = proto_new(c, sizeof(struct proto));
74
75 p->ifa_notify = dev_ifa_notify;
76 return p;
77 }
78
79 struct protocol proto_device = {
80 name: "Direct",
81 priority: 90,
82 init: dev_init,
83 };