]> git.ipfire.org Git - thirdparty/bird.git/blob - nest/protocol.h
59db428716f688aa4b100900fd75a095289cb7f0
[thirdparty/bird.git] / nest / protocol.h
1 /*
2 * BIRD Internet Routing Daemon -- Protocols
3 *
4 * (c) 1998 Martin Mares <mj@ucw.cz>
5 *
6 * Can be freely distributed and used under the terms of the GNU GPL.
7 */
8
9 #ifndef _BIRD_PROTOCOL_H_
10 #define _BIRD_PROTOCOL_H_
11
12 #include "lib/lists.h"
13 #include "lib/resource.h"
14
15 struct iface;
16 struct rte;
17 struct neighbor;
18 struct rtattr;
19 struct network;
20
21 /*
22 * Routing Protocol
23 */
24
25 struct protocol {
26 node n;
27 char *name;
28 unsigned debug; /* Default debugging flags */
29
30 void (*init)(struct protocol *); /* Boot time */
31 void (*preconfig)(struct protocol *); /* Just before configuring */
32 void (*postconfig)(struct protocol *); /* After configuring */
33 };
34
35 void protos_build(void);
36 void protos_init(void);
37 void protos_preconfig(void);
38 void protos_postconfig(void);
39 void protos_start(void);
40 void protos_dump_all(void);
41
42 extern list protocol_list;
43
44 /*
45 * Known protocols
46 */
47
48 extern struct protocol proto_device;
49 extern struct protocol proto_rip;
50
51 /*
52 * Routing Protocol Instance
53 */
54
55 struct proto {
56 node n;
57 struct protocol *proto; /* Protocol */
58 char *name; /* Name of this instance */
59 unsigned debug; /* Debugging flags */
60 pool *pool; /* Local objects */
61 unsigned preference; /* Default route preference */
62 unsigned state; /* PRS_... */
63 unsigned disabled; /* Manually disabled */
64
65 void (*if_notify)(struct proto *, unsigned flags, struct iface *new, struct iface *old);
66 void (*rt_notify)(struct proto *, struct network *net, struct rte *new, struct rte *old);
67 void (*neigh_notify)(struct neighbor *neigh);
68 void (*dump)(struct proto *); /* Debugging dump */
69 void (*start)(struct proto *); /* Start the instance */
70 void (*shutdown)(struct proto *, int time); /* Stop the instance */
71
72 int (*rta_same)(struct rtattr *, struct rtattr *);
73 int (*rte_better)(struct rte *, struct rte *);
74 void (*rte_insert)(struct network *, struct rte *);
75 void (*rte_remove)(struct network *, struct rte *);
76
77 /* Reconfigure function? */
78 /* Input/output filters */
79 /* Connection to routing tables? */
80
81 /* Hic sunt protocol-specific data */
82 };
83
84 #define PRS_DOWN 0 /* Inactive */
85 #define PRS_STARTING 1
86 #define PRS_UP 2
87
88 void *proto_new(struct protocol *, unsigned size);
89
90 extern list proto_list, inactive_proto_list;
91
92 /*
93 * Known unique protocol instances as referenced by config routines
94 */
95
96 extern struct proto *cf_dev_proto;
97
98 #endif