]>
Commit | Line | Data |
---|---|---|
c1f8dc91 OF |
1 | /* |
2 | * BIRD -- OSPF | |
3 | * | |
4 | * (c) 1999 Ondrej Filip <feela@network.cz> | |
5 | * | |
6 | * Can be freely distributed and used under the terms of the GNU GPL. | |
7 | */ | |
8 | ||
9 | #ifndef _BIRD_OSPF_H_ | |
10 | #define _BIRD_OSPF_H_ | |
11 | ||
4364b47e OF |
12 | #define LOCAL_DEBUG |
13 | ||
14 | #define IAMMASTER(x) ((x) & DBDES_MS) | |
15 | #define INISET(x) ((x) & DBDES_I) | |
16 | ||
17 | #include <string.h> | |
18 | ||
19 | #include "nest/bird.h" | |
20 | ||
21 | #include "lib/checksum.h" | |
6ba36f06 MM |
22 | #include "lib/ip.h" |
23 | #include "lib/lists.h" | |
24 | #include "lib/socket.h" | |
25 | #include "lib/timer.h" | |
26 | #include "lib/resource.h" | |
27 | #include "nest/protocol.h" | |
28 | #include "nest/iface.h" | |
4364b47e OF |
29 | #include "nest/route.h" |
30 | #include "conf/conf.h" | |
6ba36f06 | 31 | |
5b1a92e6 | 32 | #define OSPF_PROTO 89 |
aec76c6e | 33 | #ifndef IPV6 |
296ecb56 | 34 | #define OSPF_VERSION 2 |
5b1a92e6 OF |
35 | #define AllSPFRouters ipa_from_u32(0xe0000005) /* 224.0.0.5 */ |
36 | #define AllDRouters ipa_from_u32(0xe0000006) /* 224.0.0.6 */ | |
aec76c6e | 37 | #else |
6376a961 | 38 | #error Multicast address not defined in IPv6 |
aec76c6e OF |
39 | #endif |
40 | ||
15087574 OF |
41 | |
42 | #define LSREFRESHTIME 1800 /* 30 minut */ | |
43 | #define MINLSINTERVAL 5 | |
44 | #define MINLSARRIVAL 1 | |
45 | #define MAXAGE 3600 /* 1 hour */ | |
46 | #define CHECKAGE 300 /* 5 min */ | |
47 | #define MAXAGEDIFF 900 /* 15 min */ | |
48 | #define LSINFINITY 0xffffff | |
49 | /*#define DEFAULTDES 0.0.0.0 FIXME: How to define it? */ | |
50 | #define INITSEQNUM 0x80000001 /* Initial Sequence Number */ | |
51 | #define MAXSEQNUM 0x7fffffff /* Maximal Sequence Number */ | |
52 | ||
c1f8dc91 OF |
53 | struct ospf_config { |
54 | struct proto_config c; | |
b11d8a4f | 55 | u32 area; /* FIXME: Area ID !!! This is wrong !!! |
aec76c6e | 56 | * Should respect interface */ |
c1f8dc91 OF |
57 | }; |
58 | ||
5b1a92e6 | 59 | struct ospf_iface { |
b11d8a4f | 60 | node n; |
f7103dfc | 61 | struct proto_ospf *proto; |
b11d8a4f | 62 | struct iface *iface; /* Nest's iface */ |
1af66415 OF |
63 | sock *hello_sk; /* Hello socket */ |
64 | sock *ip_sk; /* IP socket (for DD ...) */ | |
75b84c34 | 65 | list neigh_list; /* List of neigbours */ |
5b1a92e6 OF |
66 | u32 area; /* OSPF Area */ |
67 | u16 cost; /* Cost of iface */ | |
2c1d1cc7 OF |
68 | u16 rxmtint; /* number of seconds between LSA retransmissions */ |
69 | u16 iftransdelay; /* The estimated number of seconds it takes to | |
5b1a92e6 OF |
70 | transmit a Link State Update Packet over this |
71 | interface. LSAs contained in the update */ | |
72 | u8 priority; /* A router priority for DR election */ | |
73 | u16 helloint; /* number of seconds between hello sending */ | |
96f1b8ba | 74 | u16 waitint; /* number of sec before changing state from wait */ |
35ff423d | 75 | u32 deadc; /* after "deadint" missing hellos is router dead */ |
5b1a92e6 OF |
76 | u16 autype; |
77 | u8 aukey[8]; | |
78 | u8 options; | |
aec76c6e OF |
79 | ip_addr drip; /* Designated router */ |
80 | u32 drid; | |
81 | ip_addr bdrip; /* Backup DR */ | |
82 | u32 bdrid; | |
2c1d1cc7 | 83 | u8 type; /* OSPF view of type */ |
96f1b8ba | 84 | #define OSPF_IT_BCAST 0 |
4c630a6d OF |
85 | #define OSPF_IT_NBMA 1 |
86 | #define OSPF_IT_PTP 2 | |
96f1b8ba | 87 | #define OSPF_IT_VLINK 3 |
2c1d1cc7 | 88 | u8 state; /* Interface state machine */ |
96f1b8ba OF |
89 | #define OSPF_IS_DOWN 0 /* Not working */ |
90 | #define OSPF_IS_LOOP 1 /* Should never happen */ | |
91 | #define OSPF_IS_WAITING 2 /* Waiting for Wait timer */ | |
92 | #define OSPF_IS_PTP 3 /* PTP operational */ | |
93 | #define OSPF_IS_DROTHER 4 /* I'm on BCAST or NBMA and I'm not DR */ | |
94 | #define OSPF_IS_BACKUP 5 /* I'm BDR */ | |
95 | #define OSPF_IS_DR 6 /* I'm DR */ | |
65112dd2 OF |
96 | timer *wait_timer; /* WAIT timer */ |
97 | timer *hello_timer; /* HELLOINT timer */ | |
2c1d1cc7 | 98 | timer *rxmt_timer; /* RXMT timer */ |
5b1a92e6 OF |
99 | /* Default values for interface parameters */ |
100 | #define COST_D 10 | |
101 | #define RXMTINT_D 5 | |
102 | #define IFTRANSDELAY_D 1 | |
4c630a6d | 103 | #define PRIORITY_D 1 |
5b1a92e6 | 104 | #define HELLOINT_D 10 |
35ff423d | 105 | #define DEADC_D 4 |
96f1b8ba OF |
106 | #define WAIT_DMH 3 /* Value of Wait timer - not found it in RFC |
107 | * - using 3*HELLO | |
1af66415 | 108 | */ |
5b1a92e6 OF |
109 | }; |
110 | ||
296ecb56 OF |
111 | struct ospf_packet { |
112 | u8 version; | |
113 | u8 type; | |
114 | #define HELLO 1 /* Hello */ | |
115 | #define DBDES 2 /* Database description */ | |
116 | #define LSREQ 3 /* Link state request */ | |
117 | #define LSUPD 4 /* Link state update */ | |
118 | #define LSACK 5 /* Link state acknowledgement */ | |
119 | u16 length; | |
120 | u32 routerid; | |
121 | u32 areaid; | |
122 | u16 checksum; | |
123 | u16 autype; | |
124 | u8 authetication[8]; | |
125 | }; | |
126 | ||
127 | struct ospf_hello_packet { | |
67ff9130 OF |
128 | struct ospf_packet ospf_packet; |
129 | ip_addr netmask; | |
35ff423d | 130 | u16 helloint; |
296ecb56 OF |
131 | u8 options; |
132 | u8 priority; | |
133 | u32 deadint; | |
134 | u32 dr; | |
135 | u32 bdr; | |
136 | }; | |
137 | ||
2c1d1cc7 | 138 | struct ospf_dbdes_packet { |
1af66415 OF |
139 | struct ospf_packet ospf_packet; |
140 | u16 iface_mtu; | |
2c1d1cc7 OF |
141 | u8 options; |
142 | u8 imms; /* I, M, MS bits */ | |
143 | #define DBDES_MS 1 | |
144 | #define DBDES_M 2 | |
145 | #define DBDES_I 4 | |
146 | u32 ddseq; | |
1af66415 OF |
147 | }; |
148 | ||
2c1d1cc7 OF |
149 | struct ospf_lsaheader { |
150 | u16 lsage; /* LS Age */ | |
151 | u8 options; | |
152 | u8 lstype; | |
153 | u32 lsid; | |
154 | u32 advr; /* Advertising router */ | |
155 | u32 lssn; /* LS Sequence number */ | |
156 | u16 checksum; | |
157 | u16 length; | |
158 | }; | |
159 | ||
160 | ||
c76674f0 OF |
161 | struct ospf_neighbor |
162 | { | |
e83dc0d7 | 163 | node n; |
903a3f39 | 164 | struct ospf_iface *ifa; |
2c1d1cc7 | 165 | u8 state; |
c76674f0 | 166 | #define NEIGHBOR_DOWN 0 |
cd70d934 OF |
167 | #define NEIGHBOR_ATTEMPT 1 |
168 | #define NEIGHBOR_INIT 2 | |
169 | #define NEIGHBOR_2WAY 3 | |
c76674f0 | 170 | #define NEIGHBOR_EXSTART 4 |
903a3f39 OF |
171 | #define NEIGHBOR_EXCHANGE 5 |
172 | #define NEIGHBOR_LOADING 6 | |
173 | #define NEIGHBOR_FULL 7 | |
c76674f0 | 174 | timer *inactim; /* Inactivity timer */ |
986e3413 | 175 | u8 imms; /* I, M, Master/slave received */ |
c2250f91 OF |
176 | u32 dds; /* DD Sequence number being sent */ |
177 | u32 ddr; /* last Dat Des packet received */ | |
986e3413 | 178 | u8 myimms; /* I, M Master/slave */ |
c76674f0 | 179 | u32 rid; /* Router ID */ |
986e3413 | 180 | ip_addr ip; /* IP of it's interface */ |
2c1d1cc7 | 181 | u8 priority; /* Priority */ |
986e3413 | 182 | u8 options; /* Options received */ |
c76674f0 OF |
183 | u32 dr; /* Neigbour's idea of DR */ |
184 | u32 bdr; /* Neigbour's idea of BDR */ | |
e3121112 | 185 | u8 adj; /* built adjacency? */ |
c76674f0 OF |
186 | }; |
187 | ||
96f1b8ba OF |
188 | /* Definitions for interface state machine */ |
189 | #define ISM_UP 0 /* Interface Up */ | |
190 | #define ISM_WAITF 1 /* Wait timer fired */ | |
191 | #define ISM_BACKS 2 /* Backup seen */ | |
192 | #define ISM_NEICH 3 /* Neighbor change */ | |
193 | #define ISM_LOOP 4 /* Loop indicated */ | |
194 | #define ISM_UNLOOP 5 /* Unloop indicated */ | |
195 | #define ISM_DOWN 6 /* Interface down */ | |
196 | ||
197 | /* Definitions for neighbor state machine */ | |
198 | #define INM_HELLOREC 0 /* Hello Received */ | |
199 | #define INM_START 1 /* Neighbor start - for NBMA */ | |
200 | #define INM_2WAYREC 2 /* 2-Way received */ | |
201 | #define INM_NEGDONE 3 /* Negotiation done */ | |
202 | #define INM_EXDONE 4 /* Exchange done */ | |
203 | #define INM_BADLSREQ 5 /* Bad LS Request */ | |
204 | #define INM_LOADDONE 6 /* Load done */ | |
205 | #define INM_ADJOK 7 /* AdjOK? */ | |
206 | #define INM_SEQMIS 8 /* Sequence number mismatch */ | |
207 | #define INM_1WAYREC 9 /* 1-Way */ | |
6ba36f06 | 208 | #define INM_KILLNBR 10 /* Kill Neighbor */ |
96f1b8ba OF |
209 | #define INM_INACTTIM 11 /* Inactivity timer */ |
210 | #define INM_LLDOWN 12 /* Line down */ | |
211 | ||
15087574 OF |
212 | struct ospf_area { |
213 | struct ospf_area *next; | |
214 | u32 areaid; | |
215 | struct top_graph *gr; /* LSA graph */ | |
216 | }; | |
217 | ||
4364b47e OF |
218 | struct proto_ospf { |
219 | struct proto proto; | |
220 | list iface_list; /* Interfaces we really use */ | |
15087574 OF |
221 | int areano; /* Number of area I belong to */ |
222 | struct ospf_area *firstarea; | |
6ba36f06 MM |
223 | }; |
224 | ||
4364b47e OF |
225 | static int ospf_start(struct proto *p); |
226 | static void ospf_dump(struct proto *p); | |
227 | static struct proto *ospf_init(struct proto_config *c); | |
228 | static void ospf_preconfig(struct protocol *p, struct config *c); | |
229 | static void ospf_postconfig(struct proto_config *c); | |
230 | ||
231 | #include "proto/ospf/hello.h" | |
232 | #include "proto/ospf/packet.h" | |
233 | #include "proto/ospf/iface.h" | |
234 | #include "proto/ospf/neighbor.h" | |
235 | #include "proto/ospf/topology.h" | |
236 | #include "proto/ospf/dbdes.h" | |
6ba36f06 | 237 | |
c1f8dc91 | 238 | #endif /* _BIRD_OSPF_H_ */ |