Annotation of embedaddon/bird/sysdep/unix/krt.h, revision 1.1.1.1

1.1       misho       1: /*
                      2:  *     BIRD -- UNIX Kernel Route Syncer
                      3:  *
                      4:  *     (c) 1998--2000 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_KRT_H_
                     10: #define _BIRD_KRT_H_
                     11: 
                     12: struct config;
                     13: struct krt_config;
                     14: struct krt_proto;
                     15: struct kif_config;
                     16: struct kif_proto;
                     17: 
                     18: #include "lib/krt-sys.h"
                     19: 
                     20: /* Flags stored in net->n.flags, rest are in nest/route.h */
                     21: 
                     22: #define KRF_VERDICT_MASK 0x0f
                     23: #define KRF_CREATE 0                   /* Not seen in kernel table */
                     24: #define KRF_SEEN 1                     /* Seen in kernel table during last scan */
                     25: #define KRF_UPDATE 2                   /* Need to update this entry */
                     26: #define KRF_DELETE 3                   /* Should be deleted */
                     27: #define KRF_IGNORE 4                   /* To be ignored */
                     28: 
                     29: #define KRT_DEFAULT_ECMP_LIMIT 16
                     30: 
                     31: #define EA_KRT_SOURCE  EA_CODE(EAP_KRT, 0)
                     32: #define EA_KRT_METRIC  EA_CODE(EAP_KRT, 1)
                     33: 
                     34: /* Whenever we recognize our own routes, we allow learing of foreign routes */
                     35: 
                     36: #ifdef CONFIG_SELF_CONSCIOUS
                     37: #define KRT_ALLOW_LEARN
                     38: #endif
                     39: 
                     40: /* krt.c */
                     41: 
                     42: extern struct protocol proto_unix_kernel;
                     43: 
                     44: struct krt_config {
                     45:   struct proto_config c;
                     46:   struct krt_params sys;       /* Sysdep params */
                     47:   int persist;                 /* Keep routes when we exit */
                     48:   int scan_time;               /* How often we re-scan routes */
                     49:   int learn;                   /* Learn routes from other sources */
                     50:   int devroutes;               /* Allow export of device routes */
                     51:   int graceful_restart;                /* Regard graceful restart recovery */
                     52:   int merge_paths;             /* Exported routes are merged for ECMP */
                     53: };
                     54: 
                     55: struct krt_proto {
                     56:   struct proto p;
                     57:   struct krt_state sys;                /* Sysdep state */
                     58: 
                     59: #ifdef KRT_ALLOW_LEARN
                     60:   struct rtable krt_table;     /* Internal table of inherited routes */
                     61: #endif
                     62: 
                     63: #ifndef CONFIG_ALL_TABLES_AT_ONCE
                     64:   timer *scan_timer;
                     65: #endif
                     66: 
                     67:   node krt_node;               /* Node in krt_proto_list */
                     68:   byte ready;                  /* Initial feed has been finished */
                     69:   byte initialized;            /* First scan has been finished */
                     70:   byte reload;                 /* Next scan is doing reload */
                     71: };
                     72: 
                     73: extern pool *krt_pool;
                     74: 
                     75: #define KRT_CF ((struct krt_config *)p->p.cf)
                     76: 
                     77: #define KRT_TRACE(pr, fl, msg, args...) do {   \
                     78:   DBG("KRT: " msg "\n" , ## args);             \
                     79:   if (pr->p.debug & fl)                                \
                     80:     { log(L_TRACE "%s: " msg, pr->p.name , ## args); } } while(0)
                     81: 
                     82: struct proto_config * kif_init_config(int class);
                     83: void kif_request_scan(void);
                     84: void krt_got_route(struct krt_proto *p, struct rte *e);
                     85: void krt_got_route_async(struct krt_proto *p, struct rte *e, int new);
                     86: 
                     87: /* Values for rte->u.krt_sync.src */
                     88: #define KRT_SRC_UNKNOWN        -1      /* Nobody knows */
                     89: #define KRT_SRC_BIRD    0      /* Our route (not passed in async mode) */
                     90: #define KRT_SRC_REDIRECT 1     /* Redirect route, delete it */
                     91: #define KRT_SRC_ALIEN   2      /* Route installed by someone else */
                     92: #define KRT_SRC_KERNEL  3      /* Kernel routes, are ignored by krt syncer */
                     93: 
                     94: extern struct protocol proto_unix_iface;
                     95: 
                     96: struct kif_primary_item {
                     97:   node n;
                     98:   byte *pattern;
                     99:   ip_addr prefix;
                    100:   int pxlen;
                    101: };
                    102: 
                    103: struct kif_config {
                    104:   struct proto_config c;
                    105:   struct kif_params sys;       /* Sysdep params */
                    106:   int scan_time;               /* How often we re-scan interfaces */
                    107:   list primary;                        /* Preferences for primary addresses (struct kif_primary_item) */
                    108: };
                    109: 
                    110: struct kif_proto {
                    111:   struct proto p;
                    112:   struct kif_state sys;                /* Sysdep state */
                    113: };
                    114: 
                    115: struct kif_proto *kif_proto;
                    116: 
                    117: #define KIF_CF ((struct kif_config *)p->p.cf)
                    118: 
                    119: struct proto_config * krt_init_config(int class);
                    120: 
                    121: 
                    122: /* krt sysdep */
                    123: 
                    124: void krt_sys_io_init(void);
                    125: void krt_sys_init(struct krt_proto *);
                    126: int krt_sys_start(struct krt_proto *);
                    127: void krt_sys_shutdown(struct krt_proto *);
                    128: int krt_sys_reconfigure(struct krt_proto *p UNUSED, struct krt_config *n, struct krt_config *o);
                    129: 
                    130: void krt_sys_preconfig(struct config *);
                    131: void krt_sys_postconfig(struct krt_config *);
                    132: void krt_sys_init_config(struct krt_config *);
                    133: void krt_sys_copy_config(struct krt_config *, struct krt_config *);
                    134: 
                    135: int  krt_capable(rte *e);
                    136: void krt_do_scan(struct krt_proto *);
                    137: void krt_replace_rte(struct krt_proto *p, net *n, rte *new, rte *old, struct ea_list *eattrs);
                    138: int krt_sys_get_attr(eattr *a, byte *buf, int buflen);
                    139: 
                    140: 
                    141: /* kif sysdep */
                    142: 
                    143: void kif_sys_init(struct kif_proto *);
                    144: void kif_sys_start(struct kif_proto *);
                    145: void kif_sys_shutdown(struct kif_proto *);
                    146: int kif_sys_reconfigure(struct kif_proto *, struct kif_config *, struct kif_config *);
                    147: 
                    148: void kif_sys_init_config(struct kif_config *);
                    149: void kif_sys_copy_config(struct kif_config *, struct kif_config *);
                    150: 
                    151: void kif_do_scan(struct kif_proto *);
                    152: 
                    153: struct ifa *kif_get_primary_ip(struct iface *i);
                    154: 
                    155: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>