]>
git.ipfire.org Git - thirdparty/bird.git/blob - nest/rt-dev.c
2 * BIRD -- Direct Device Routes
4 * (c) 1998 Martin Mares <mj@ucw.cz>
6 * Can be freely distributed and used under the terms of the GNU GPL.
13 #include "nest/bird.h"
14 #include "nest/iface.h"
15 #include "nest/protocol.h"
16 #include "nest/route.h"
17 #include "lib/resource.h"
19 static struct proto
*dev_proto
;
22 dev_if_notify(struct proto
*p
, unsigned c
, struct iface
*old
, struct iface
*new)
24 if (c
& IF_CHANGE_DOWN
)
28 debug("dev_if_notify: %s going down\n", old
->name
);
29 n
= net_find(&master_table
, 0, old
->prefix
, old
->pxlen
);
32 debug("dev_if_notify: device shutdown: prefix not found\n");
35 rte_update(n
, dev_proto
, NULL
);
37 else if (c
& IF_CHANGE_UP
)
43 debug("dev_if_notify: %s going up\n", new->name
);
46 A
.source
= RTS_DEVICE
;
47 A
.scope
= (new->flags
& IF_LOOPBACK
) ? SCOPE_HOST
: SCOPE_UNIVERSE
;
53 n
= net_get(&master_table
, 0, new->prefix
, new->pxlen
);
56 rte_update(n
, dev_proto
, e
);
61 dev_start(struct proto
*p
)
66 dev_init(struct protocol
*p
)
71 dev_preconfig(struct protocol
*x
)
73 struct proto
*p
= proto_new(&proto_device
, sizeof(struct proto
));
76 p
->preference
= DEF_PREF_DIRECT
;
78 p
->if_notify
= dev_if_notify
;
82 dev_postconfig(struct protocol
*p
)
86 struct protocol proto_device
= {