Annotation of embedaddon/quagga/ospfd/ospfd.h, revision 1.1.1.3
1.1 misho 1: /*
2: * OSPFd main header.
3: * Copyright (C) 1998, 99, 2000 Kunihiro Ishiguro, Toshiaki Takada
4: *
5: * This file is part of GNU Zebra.
6: *
7: * GNU Zebra is free software; you can redistribute it and/or modify it
8: * under the terms of the GNU General Public License as published by the
9: * Free Software Foundation; either version 2, or (at your option) any
10: * later version.
11: *
12: * GNU Zebra is distributed in the hope that it will be useful, but
13: * WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with GNU Zebra; see the file COPYING. If not, write to the Free
19: * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20: * 02111-1307, USA.
21: */
22:
23: #ifndef _ZEBRA_OSPFD_H
24: #define _ZEBRA_OSPFD_H
25:
26: #include <zebra.h>
1.1.1.3 ! misho 27: #include "libospf.h"
1.1 misho 28:
29: #include "filter.h"
30: #include "log.h"
31:
32: #define OSPF_VERSION 2
33:
34: /* VTY port number. */
35: #define OSPF_VTY_PORT 2604
36:
37: /* IP TTL for OSPF protocol. */
38: #define OSPF_IP_TTL 1
39: #define OSPF_VL_IP_TTL 100
40:
41: /* Default configuration file name for ospfd. */
42: #define OSPF_DEFAULT_CONFIG "ospfd.conf"
43:
44: #define OSPF_NSSA_TRANS_STABLE_DEFAULT 40
45:
46: #define OSPF_ALLSPFROUTERS 0xe0000005 /* 224.0.0.5 */
47: #define OSPF_ALLDROUTERS 0xe0000006 /* 224.0.0.6 */
48:
49:
50: /* OSPF Authentication Type. */
51: #define OSPF_AUTH_NULL 0
52: #define OSPF_AUTH_SIMPLE 1
53: #define OSPF_AUTH_CRYPTOGRAPHIC 2
54: /* For Interface authentication setting default */
55: #define OSPF_AUTH_NOTSET -1
56: /* For the consumption and sanity of the command handler */
57: /* DO NIOT REMOVE!!! Need to detect whether a value has
58: been given or not in VLink command handlers */
59: #define OSPF_AUTH_CMD_NOTSEEN -2
60:
61: /* OSPF options. */
62: #define OSPF_OPTION_T 0x01 /* TOS. */
63: #define OSPF_OPTION_E 0x02
64: #define OSPF_OPTION_MC 0x04
65: #define OSPF_OPTION_NP 0x08
66: #define OSPF_OPTION_EA 0x10
67: #define OSPF_OPTION_DC 0x20
68: #define OSPF_OPTION_O 0x40
69:
70: /* OSPF Database Description flags. */
71: #define OSPF_DD_FLAG_MS 0x01
72: #define OSPF_DD_FLAG_M 0x02
73: #define OSPF_DD_FLAG_I 0x04
74: #define OSPF_DD_FLAG_ALL 0x07
75:
76: #define OSPF_LS_REFRESH_SHIFT (60 * 15)
77: #define OSPF_LS_REFRESH_JITTER 60
78:
79: /* OSPF master for system wide configuration and variables. */
80: struct ospf_master
81: {
82: /* OSPF instance. */
83: struct list *ospf;
84:
85: /* OSPF thread master. */
86: struct thread_master *master;
87:
88: /* Zebra interface list. */
89: struct list *iflist;
90:
91: /* Redistributed external information. */
92: struct route_table *external_info[ZEBRA_ROUTE_MAX + 1];
93: #define EXTERNAL_INFO(T) om->external_info[T]
94:
95: /* OSPF start time. */
96: time_t start_time;
97:
98: /* Various OSPF global configuration. */
99: u_char options;
100: #define OSPF_MASTER_SHUTDOWN (1 << 0) /* deferred-shutdown */
101: };
102:
103: /* OSPF instance structure. */
104: struct ospf
105: {
106: /* OSPF Router ID. */
107: struct in_addr router_id; /* Configured automatically. */
108: struct in_addr router_id_static; /* Configured manually. */
109:
110: /* ABR/ASBR internal flags. */
111: u_char flags;
112: #define OSPF_FLAG_ABR 0x0001
113: #define OSPF_FLAG_ASBR 0x0002
114:
115: /* ABR type. */
116: u_char abr_type;
117: #define OSPF_ABR_UNKNOWN 0
118: #define OSPF_ABR_STAND 1
119: #define OSPF_ABR_IBM 2
120: #define OSPF_ABR_CISCO 3
121: #define OSPF_ABR_SHORTCUT 4
122: #define OSPF_ABR_DEFAULT OSPF_ABR_CISCO
123:
124: /* NSSA ABR */
125: u_char anyNSSA; /* Bump for every NSSA attached. */
126:
127: /* Configured variables. */
128: u_char config;
129: #define OSPF_RFC1583_COMPATIBLE (1 << 0)
130: #define OSPF_OPAQUE_CAPABLE (1 << 2)
131: #define OSPF_LOG_ADJACENCY_CHANGES (1 << 3)
132: #define OSPF_LOG_ADJACENCY_DETAIL (1 << 4)
133:
134: /* Opaque-LSA administrative flags. */
135: u_char opaque;
136: #define OPAQUE_OPERATION_READY_BIT (1 << 0)
137:
138: /* RFC3137 stub router. Configured time to stay stub / max-metric */
139: unsigned int stub_router_startup_time; /* seconds */
140: unsigned int stub_router_shutdown_time; /* seconds */
141: #define OSPF_STUB_ROUTER_UNCONFIGURED 0
1.1.1.2 misho 142: u_char stub_router_admin_set;
143: #define OSPF_STUB_ROUTER_ADMINISTRATIVE_SET 1
144: #define OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET 0
145:
146: #define OSPF_STUB_MAX_METRIC_SUMMARY_COST 0x00ff0000
1.1 misho 147:
1.1.1.3 ! misho 148: /* LSA timers */
! 149: unsigned int min_ls_interval; /* minimum delay between LSAs (in msec) */
! 150: unsigned int min_ls_arrival; /* minimum interarrival time between LSAs (in msec) */
! 151:
1.1 misho 152: /* SPF parameters */
153: unsigned int spf_delay; /* SPF delay time. */
154: unsigned int spf_holdtime; /* SPF hold time. */
155: unsigned int spf_max_holdtime; /* SPF maximum-holdtime */
156: unsigned int spf_hold_multiplier; /* Adaptive multiplier for hold time */
157:
158: int default_originate; /* Default information originate. */
159: #define DEFAULT_ORIGINATE_NONE 0
160: #define DEFAULT_ORIGINATE_ZEBRA 1
161: #define DEFAULT_ORIGINATE_ALWAYS 2
162: u_int32_t ref_bandwidth; /* Reference Bandwidth (Kbps). */
163: struct route_table *networks; /* OSPF config networks. */
164: struct list *vlinks; /* Configured Virtual-Links. */
165: struct list *areas; /* OSPF areas. */
166: struct route_table *nbr_nbma;
167: struct ospf_area *backbone; /* Pointer to the Backbone Area. */
168:
169: struct list *oiflist; /* ospf interfaces */
170: u_char passive_interface_default; /* passive-interface default */
171:
172: /* LSDB of AS-external-LSAs. */
173: struct ospf_lsdb *lsdb;
174:
175: /* Flags. */
176: int external_origin; /* AS-external-LSA origin flag. */
177: int ase_calc; /* ASE calculation flag. */
178:
179: struct list *opaque_lsa_self; /* Type-11 Opaque-LSAs */
180:
181: /* Routing tables. */
182: struct route_table *old_table; /* Old routing table. */
183: struct route_table *new_table; /* Current routing table. */
184:
185: struct route_table *old_rtrs; /* Old ABR/ASBR RT. */
186: struct route_table *new_rtrs; /* New ABR/ASBR RT. */
187:
188: struct route_table *new_external_route; /* New External Route. */
189: struct route_table *old_external_route; /* Old External Route. */
190:
191: struct route_table *external_lsas; /* Database of external LSAs,
192: prefix is LSA's adv. network*/
193:
1.1.1.3 ! misho 194: /* Time stamps */
1.1 misho 195: struct timeval ts_spf; /* SPF calculation time stamp. */
1.1.1.3 ! misho 196: struct timeval ts_spf_duration; /* Execution time of last SPF */
1.1 misho 197:
1.1.1.2 misho 198: struct route_table *maxage_lsa; /* List of MaxAge LSA for deletion. */
1.1 misho 199: int redistribute; /* Num of redistributed protocols. */
200:
201: /* Threads. */
202: struct thread *t_abr_task; /* ABR task timer. */
203: struct thread *t_asbr_check; /* ASBR check timer. */
204: struct thread *t_distribute_update; /* Distirbute list update timer. */
205: struct thread *t_spf_calc; /* SPF calculation timer. */
206: struct thread *t_ase_calc; /* ASE calculation timer. */
207: struct thread *t_external_lsa; /* AS-external-LSA origin timer. */
208: struct thread *t_opaque_lsa_self; /* Type-11 Opaque-LSAs origin event. */
209:
210: unsigned int maxage_delay; /* Delay on Maxage remover timer, sec */
211: struct thread *t_maxage; /* MaxAge LSA remover timer. */
212: struct thread *t_maxage_walker; /* MaxAge LSA checking timer. */
213:
214: struct thread *t_deferred_shutdown; /* deferred/stub-router shutdown timer*/
215:
216: struct thread *t_write;
217: struct thread *t_read;
218: int fd;
1.1.1.2 misho 219: unsigned int maxsndbuflen;
1.1 misho 220: struct stream *ibuf;
221: struct list *oi_write_q;
222:
223: /* Distribute lists out of other route sources. */
224: struct
225: {
226: char *name;
227: struct access_list *list;
228: } dlist[ZEBRA_ROUTE_MAX];
229: #define DISTRIBUTE_NAME(O,T) (O)->dlist[T].name
230: #define DISTRIBUTE_LIST(O,T) (O)->dlist[T].list
231:
232: /* Redistribute metric info. */
233: struct
234: {
235: int type; /* External metric type (E1 or E2). */
236: int value; /* Value for static metric (24-bit).
237: -1 means metric value is not set. */
238: } dmetric [ZEBRA_ROUTE_MAX + 1];
239:
240: /* For redistribute route map. */
241: struct
242: {
243: char *name;
244: struct route_map *map;
245: } route_map [ZEBRA_ROUTE_MAX + 1]; /* +1 is for default-information */
246: #define ROUTEMAP_NAME(O,T) (O)->route_map[T].name
247: #define ROUTEMAP(O,T) (O)->route_map[T].map
248:
249: int default_metric; /* Default metric for redistribute. */
250:
251: #define OSPF_LSA_REFRESHER_GRANULARITY 10
252: #define OSPF_LSA_REFRESHER_SLOTS ((OSPF_LS_REFRESH_TIME + \
253: OSPF_LS_REFRESH_SHIFT)/10 + 1)
254: struct
255: {
256: u_int16_t index;
257: struct list *qs[OSPF_LSA_REFRESHER_SLOTS];
258: } lsa_refresh_queue;
259:
260: struct thread *t_lsa_refresher;
261: time_t lsa_refresher_started;
262: #define OSPF_LSA_REFRESH_INTERVAL_DEFAULT 10
263: u_int16_t lsa_refresh_interval;
264:
265: /* Distance parameter. */
266: u_char distance_all;
267: u_char distance_intra;
268: u_char distance_inter;
269: u_char distance_external;
270:
271: /* Statistics for LSA origination. */
272: u_int32_t lsa_originate_count;
273:
274: /* Statistics for LSA used for new instantiation. */
275: u_int32_t rx_lsa_count;
276:
277: struct route_table *distance_table;
278: };
279:
280: /* OSPF area structure. */
281: struct ospf_area
282: {
283: /* OSPF instance. */
284: struct ospf *ospf;
285:
286: /* Zebra interface list belonging to the area. */
287: struct list *oiflist;
288:
289: /* Area ID. */
290: struct in_addr area_id;
291:
292: /* Area ID format. */
293: char format;
294: #define OSPF_AREA_ID_FORMAT_ADDRESS 1
295: #define OSPF_AREA_ID_FORMAT_DECIMAL 2
296:
297: /* Address range. */
298: struct list *address_range;
299:
300: /* Configured variables. */
301: int external_routing; /* ExternalRoutingCapability. */
302: #define OSPF_AREA_DEFAULT 0
303: #define OSPF_AREA_STUB 1
304: #define OSPF_AREA_NSSA 2
305: #define OSPF_AREA_TYPE_MAX 3
306: int no_summary; /* Don't inject summaries into stub.*/
307: int shortcut_configured; /* Area configured as shortcut. */
308: #define OSPF_SHORTCUT_DEFAULT 0
309: #define OSPF_SHORTCUT_ENABLE 1
310: #define OSPF_SHORTCUT_DISABLE 2
311: int shortcut_capability; /* Other ABRs agree on S-bit */
312: u_int32_t default_cost; /* StubDefaultCost. */
313: int auth_type; /* Authentication type. */
314:
315:
316: u_char NSSATranslatorRole; /* NSSA configured role */
317: #define OSPF_NSSA_ROLE_NEVER 0
318: #define OSPF_NSSA_ROLE_CANDIDATE 1
319: #define OSPF_NSSA_ROLE_ALWAYS 2
320: u_char NSSATranslatorState; /* NSSA operational role */
321: #define OSPF_NSSA_TRANSLATE_DISABLED 0
322: #define OSPF_NSSA_TRANSLATE_ENABLED 1
323: int NSSATranslatorStabilityInterval;
324:
325: u_char transit; /* TransitCapability. */
326: #define OSPF_TRANSIT_FALSE 0
327: #define OSPF_TRANSIT_TRUE 1
328: struct route_table *ranges; /* Configured Area Ranges. */
329:
330: /* RFC3137 stub router state flags for area */
331: u_char stub_router_state;
332: #define OSPF_AREA_ADMIN_STUB_ROUTED (1 << 0) /* admin stub-router set */
333: #define OSPF_AREA_IS_STUB_ROUTED (1 << 1) /* stub-router active */
334: #define OSPF_AREA_WAS_START_STUB_ROUTED (1 << 2) /* startup SR was done */
335:
336: /* Area related LSDBs[Type1-4]. */
337: struct ospf_lsdb *lsdb;
338:
339: /* Self-originated LSAs. */
340: struct ospf_lsa *router_lsa_self;
341: struct list *opaque_lsa_self; /* Type-10 Opaque-LSAs */
342:
343: /* Area announce list. */
344: struct
345: {
346: char *name;
347: struct access_list *list;
348: } _export;
349: #define EXPORT_NAME(A) (A)->_export.name
350: #define EXPORT_LIST(A) (A)->_export.list
351:
352: /* Area acceptance list. */
353: struct
354: {
355: char *name;
356: struct access_list *list;
357: } import;
358: #define IMPORT_NAME(A) (A)->import.name
359: #define IMPORT_LIST(A) (A)->import.list
360:
361: /* Type 3 LSA Area prefix-list. */
362: struct
363: {
364: char *name;
365: struct prefix_list *list;
366: } plist_in;
367: #define PREFIX_LIST_IN(A) (A)->plist_in.list
368: #define PREFIX_NAME_IN(A) (A)->plist_in.name
369:
370: struct
371: {
372: char *name;
373: struct prefix_list *list;
374: } plist_out;
375: #define PREFIX_LIST_OUT(A) (A)->plist_out.list
376: #define PREFIX_NAME_OUT(A) (A)->plist_out.name
377:
378: /* Shortest Path Tree. */
379: struct vertex *spf;
380:
381: /* Threads. */
382: struct thread *t_stub_router; /* Stub-router timer */
383: struct thread *t_opaque_lsa_self; /* Type-10 Opaque-LSAs origin. */
384:
385: /* Statistics field. */
386: u_int32_t spf_calculation; /* SPF Calculation Count. */
387:
1.1.1.3 ! misho 388: /* Time stamps. */
! 389: struct timeval ts_spf; /* SPF calculation time stamp. */
! 390:
1.1 misho 391: /* Router count. */
392: u_int32_t abr_count; /* ABR router in this area. */
393: u_int32_t asbr_count; /* ASBR router in this area. */
394:
395: /* Counters. */
396: u_int32_t act_ints; /* Active interfaces. */
397: u_int32_t full_nbrs; /* Fully adjacent neighbors. */
398: u_int32_t full_vls; /* Fully adjacent virtual neighbors. */
399: };
400:
401: /* OSPF config network structure. */
402: struct ospf_network
403: {
404: /* Area ID. */
405: struct in_addr area_id;
406: int format;
407: };
408:
409: /* OSPF NBMA neighbor structure. */
410: struct ospf_nbr_nbma
411: {
412: /* Neighbor IP address. */
413: struct in_addr addr;
414:
415: /* OSPF interface. */
416: struct ospf_interface *oi;
417:
418: /* OSPF neighbor structure. */
419: struct ospf_neighbor *nbr;
420:
421: /* Neighbor priority. */
422: u_char priority;
423:
424: /* Poll timer value. */
425: u_int32_t v_poll;
426:
427: /* Poll timer thread. */
428: struct thread *t_poll;
429:
430: /* State change. */
431: u_int32_t state_change;
432: };
433:
434: /* Macro. */
435: #define OSPF_AREA_SAME(X,Y) \
436: (memcmp ((X->area_id), (Y->area_id), IPV4_MAX_BYTELEN) == 0)
437:
438: #define IS_OSPF_ABR(O) ((O)->flags & OSPF_FLAG_ABR)
439: #define IS_OSPF_ASBR(O) ((O)->flags & OSPF_FLAG_ASBR)
440:
441: #define OSPF_IS_AREA_ID_BACKBONE(I) ((I).s_addr == OSPF_AREA_BACKBONE)
442: #define OSPF_IS_AREA_BACKBONE(A) OSPF_IS_AREA_ID_BACKBONE ((A)->area_id)
443:
444: #ifdef roundup
445: # define ROUNDUP(val, gran) roundup(val, gran)
446: #else /* roundup */
447: # define ROUNDUP(val, gran) (((val) - 1 | (gran) - 1) + 1)
448: #endif /* roundup */
449:
450: #define LSA_OPTIONS_GET(area) \
451: (((area)->external_routing == OSPF_AREA_DEFAULT) ? OSPF_OPTION_E : 0)
452: #define LSA_OPTIONS_NSSA_GET(area) \
453: (((area)->external_routing == OSPF_AREA_NSSA) ? OSPF_OPTION_NP : 0)
454:
455: #define OSPF_TIMER_ON(T,F,V) \
456: do { \
457: if (!(T)) \
458: (T) = thread_add_timer (master, (F), ospf, (V)); \
459: } while (0)
460:
461: #define OSPF_AREA_TIMER_ON(T,F,V) \
462: do { \
463: if (!(T)) \
464: (T) = thread_add_timer (master, (F), area, (V)); \
465: } while (0)
466:
467: #define OSPF_POLL_TIMER_ON(T,F,V) \
468: do { \
469: if (!(T)) \
470: (T) = thread_add_timer (master, (F), nbr_nbma, (V)); \
471: } while (0)
472:
473: #define OSPF_POLL_TIMER_OFF(X) OSPF_TIMER_OFF((X))
474:
475: #define OSPF_TIMER_OFF(X) \
476: do { \
477: if (X) \
478: { \
479: thread_cancel (X); \
480: (X) = NULL; \
481: } \
482: } while (0)
483:
484: /* Extern variables. */
485: extern struct ospf_master *om;
486: extern const struct message ospf_ism_state_msg[];
487: extern const struct message ospf_nsm_state_msg[];
488: extern const struct message ospf_lsa_type_msg[];
489: extern const struct message ospf_link_state_id_type_msg[];
490: extern const struct message ospf_network_type_msg[];
491: extern const int ospf_ism_state_msg_max;
492: extern const int ospf_nsm_state_msg_max;
493: extern const int ospf_lsa_type_msg_max;
494: extern const int ospf_link_state_id_type_msg_max;
495: extern const int ospf_redistributed_proto_max;
496: extern const int ospf_network_type_msg_max;
497: extern struct zclient *zclient;
498: extern struct thread_master *master;
499: extern int ospf_zlog;
500:
501: /* Prototypes. */
502: extern const char *ospf_redist_string(u_int route_type);
503: extern struct ospf *ospf_lookup (void);
504: extern struct ospf *ospf_get (void);
505: extern void ospf_finish (struct ospf *);
506: extern void ospf_router_id_update (struct ospf *ospf);
507: extern int ospf_network_set (struct ospf *, struct prefix_ipv4 *,
508: struct in_addr);
509: extern int ospf_network_unset (struct ospf *, struct prefix_ipv4 *,
510: struct in_addr);
511: extern int ospf_area_stub_set (struct ospf *, struct in_addr);
512: extern int ospf_area_stub_unset (struct ospf *, struct in_addr);
513: extern int ospf_area_no_summary_set (struct ospf *, struct in_addr);
514: extern int ospf_area_no_summary_unset (struct ospf *, struct in_addr);
515: extern int ospf_area_nssa_set (struct ospf *, struct in_addr);
516: extern int ospf_area_nssa_unset (struct ospf *, struct in_addr);
517: extern int ospf_area_nssa_translator_role_set (struct ospf *, struct in_addr,
518: int);
519: extern int ospf_area_export_list_set (struct ospf *, struct ospf_area *,
520: const char *);
521: extern int ospf_area_export_list_unset (struct ospf *, struct ospf_area *);
522: extern int ospf_area_import_list_set (struct ospf *, struct ospf_area *,
523: const char *);
524: extern int ospf_area_import_list_unset (struct ospf *, struct ospf_area *);
525: extern int ospf_area_shortcut_set (struct ospf *, struct ospf_area *, int);
526: extern int ospf_area_shortcut_unset (struct ospf *, struct ospf_area *);
527: extern int ospf_timers_refresh_set (struct ospf *, int);
528: extern int ospf_timers_refresh_unset (struct ospf *);
529: extern int ospf_nbr_nbma_set (struct ospf *, struct in_addr);
530: extern int ospf_nbr_nbma_unset (struct ospf *, struct in_addr);
531: extern int ospf_nbr_nbma_priority_set (struct ospf *, struct in_addr, u_char);
532: extern int ospf_nbr_nbma_priority_unset (struct ospf *, struct in_addr);
533: extern int ospf_nbr_nbma_poll_interval_set (struct ospf *, struct in_addr,
534: unsigned int);
535: extern int ospf_nbr_nbma_poll_interval_unset (struct ospf *, struct in_addr);
536: extern void ospf_prefix_list_update (struct prefix_list *);
537: extern void ospf_init (void);
538: extern void ospf_if_update (struct ospf *, struct interface *);
539: extern void ospf_ls_upd_queue_empty (struct ospf_interface *);
540: extern void ospf_terminate (void);
541: extern void ospf_nbr_nbma_if_update (struct ospf *, struct ospf_interface *);
542: extern struct ospf_nbr_nbma *ospf_nbr_nbma_lookup (struct ospf *,
543: struct in_addr);
544: extern struct ospf_nbr_nbma *ospf_nbr_nbma_lookup_next (struct ospf *,
545: struct in_addr *,
546: int);
547: extern int ospf_oi_count (struct interface *);
548:
549: extern struct ospf_area *ospf_area_get (struct ospf *, struct in_addr, int);
550: extern void ospf_area_check_free (struct ospf *, struct in_addr);
551: extern struct ospf_area *ospf_area_lookup_by_area_id (struct ospf *,
552: struct in_addr);
553: extern void ospf_area_add_if (struct ospf_area *, struct ospf_interface *);
554: extern void ospf_area_del_if (struct ospf_area *, struct ospf_interface *);
1.1.1.3 ! misho 555:
! 556: extern void ospf_interface_area_set (struct interface *);
! 557: extern void ospf_interface_area_unset (struct interface *);
1.1 misho 558:
559: extern void ospf_route_map_init (void);
560: extern void ospf_snmp_init (void);
561:
562: extern void ospf_master_init (void);
563:
564: #endif /* _ZEBRA_OSPFD_H */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>