Annotation of embedaddon/bird/proto/radv/radv.h, revision 1.1.1.2

1.1       misho       1: /*
                      2:  *     BIRD -- Router Advertisement
                      3:  *
                      4:  *
                      5:  *     Can be freely distributed and used under the terms of the GNU GPL.
                      6:  */
                      7: 
                      8: #ifndef _BIRD_RADV_H_
                      9: #define _BIRD_RADV_H_
                     10: 
                     11: #include "nest/bird.h"
                     12: 
                     13: #include "lib/ip.h"
                     14: #include "lib/lists.h"
                     15: #include "lib/socket.h"
                     16: #include "lib/timer.h"
                     17: #include "lib/resource.h"
                     18: #include "nest/protocol.h"
                     19: #include "nest/iface.h"
                     20: #include "nest/route.h"
                     21: #include "nest/cli.h"
                     22: #include "nest/locks.h"
                     23: #include "conf/conf.h"
                     24: #include "lib/string.h"
                     25: 
                     26: 
                     27: #define ICMPV6_PROTO 58
                     28: 
                     29: #define ICMPV6_RS 133
                     30: #define ICMPV6_RA 134
                     31: 
                     32: #define MAX_INITIAL_RTR_ADVERTISEMENTS 3
                     33: #define MAX_INITIAL_RTR_ADVERT_INTERVAL 16
                     34: 
                     35: #define DEFAULT_MAX_RA_INT 600
                     36: #define DEFAULT_MIN_DELAY 3
                     37: #define DEFAULT_CURRENT_HOP_LIMIT 64
                     38: 
                     39: #define DEFAULT_VALID_LIFETIME 86400
                     40: #define DEFAULT_PREFERRED_LIFETIME 14400
                     41: 
                     42: #define DEFAULT_DNS_LIFETIME_MULT 3
                     43: 
                     44: 
                     45: struct radv_config
                     46: {
                     47:   struct proto_config c;
                     48:   list patt_list;              /* List of iface configs (struct radv_iface_config) */
                     49:   list pref_list;              /* Global list of prefix configs (struct radv_prefix_config) */
                     50:   list rdnss_list;             /* Global list of RDNSS configs (struct radv_rdnss_config) */
                     51:   list dnssl_list;             /* Global list of DNSSL configs (struct radv_dnssl_config) */
                     52: 
                     53:   ip_addr trigger_prefix;      /* Prefix of a trigger route, if defined */
                     54:   u8 trigger_pxlen;            /* Pxlen of a trigger route, if defined */
                     55:   u8 trigger_valid;            /* Whether a trigger route is defined */
1.1.1.2 ! misho      56:   u8 propagate_routes;         /* Do we propagate more specific routes (RFC 4191)? */
        !            57:   u32 max_linger_time;         /* Maximum of interface route_linger_time */
1.1       misho      58: };
                     59: 
                     60: struct radv_iface_config
                     61: {
                     62:   struct iface_patt i;
                     63:   list pref_list;              /* Local list of prefix configs (struct radv_prefix_config) */
                     64:   list rdnss_list;             /* Local list of RDNSS configs (struct radv_rdnss_config) */
                     65:   list dnssl_list;             /* Local list of DNSSL configs (struct radv_dnssl_config) */
                     66: 
1.1.1.2 ! misho      67:   u32 min_ra_int;              /* Standard options from RFC 4861 */
1.1       misho      68:   u32 max_ra_int;
                     69:   u32 min_delay;
                     70: 
1.1.1.2 ! misho      71:   u32 prefix_linger_time;      /* How long we advertise dead prefixes with lifetime 0 */
        !            72:   u32 route_linger_time;       /* How long we advertise dead routes with lifetime 0 */
        !            73: 
1.1       misho      74:   u8 rdnss_local;              /* Global list is not used for RDNSS */
                     75:   u8 dnssl_local;              /* Global list is not used for DNSSL */
                     76: 
1.1.1.2 ! misho      77:   u8 managed;                  /* Standard options from RFC 4861 */
1.1       misho      78:   u8 other_config;
                     79:   u32 link_mtu;
                     80:   u32 reachable_time;
                     81:   u32 retrans_timer;
                     82:   u32 current_hop_limit;
                     83:   u32 default_lifetime;
1.1.1.2 ! misho      84:   u32 route_lifetime;          /* Lifetime for the RFC 4191 routes */
1.1       misho      85:   u8 default_lifetime_sensitive; /* Whether default_lifetime depends on trigger */
1.1.1.2 ! misho      86:   u8 route_lifetime_sensitive; /* Whether route_lifetime depends on trigger */
1.1       misho      87:   u8 default_preference;       /* Default Router Preference (RFC 4191) */
1.1.1.2 ! misho      88:   u8 route_preference;         /* Specific Route Preference (RFC 4191) */
1.1       misho      89: };
                     90: 
                     91: struct radv_prefix_config
                     92: {
                     93:   node n;
                     94:   ip_addr prefix;
                     95:   uint pxlen;
                     96: 
                     97:   u8 skip;                     /* Do not include this prefix to RA */
1.1.1.2 ! misho      98:   u8 onlink;                   /* Standard options from RFC 4861 */
1.1       misho      99:   u8 autonomous;
                    100:   u32 valid_lifetime;
                    101:   u32 preferred_lifetime;
                    102:   u8 valid_lifetime_sensitive;  /* Whether valid_lifetime depends on trigger */
                    103:   u8 preferred_lifetime_sensitive; /* Whether preferred_lifetime depends on trigger */
                    104: };
                    105: 
                    106: struct radv_rdnss_config
                    107: {
                    108:   node n;
                    109:   u32 lifetime;                        /* Valid if lifetime_mult is 0 */
                    110:   u16 lifetime_mult;           /* Lifetime specified as multiple of max_ra_int */
                    111:   ip_addr server;              /* IP address of recursive DNS server */
                    112: };
                    113: 
                    114: struct radv_dnssl_config
                    115: {
                    116:   node n;
                    117:   u32 lifetime;                        /* Valid if lifetime_mult is 0 */
                    118:   u16 lifetime_mult;           /* Lifetime specified as multiple of max_ra_int */
                    119:   u8 dlen_first;               /* Length of first label in domain */
                    120:   u8 dlen_all;                 /* Both dlen_ filled in radv_process_domain() */
                    121:   char *domain;                        /* Domain for DNS search list, in processed form */
                    122: };
                    123: 
1.1.1.2 ! misho     124: /*
        !           125:  * One more specific route as per RFC 4191.
        !           126:  *
        !           127:  * Note that it does *not* contain the next hop field. The next hop is always
        !           128:  * the router sending the advertisment and the more specific route only allows
        !           129:  * overriding the preference of the route.
        !           130:  */
        !           131: struct radv_route
        !           132: {
        !           133:   struct fib_node n;
        !           134:   u32 lifetime;                        /* Lifetime from an attribute */
        !           135:   u8 lifetime_set;             /* Whether lifetime is defined */
        !           136:   u8 preference;               /* Preference of the route, RA_PREF_* */
        !           137:   u8 preference_set;           /* Whether preference is defined */
        !           138:   u8 valid;                    /* Whethe route is valid or withdrawn */
        !           139:   bird_clock_t changed;                /* Last time when the route changed */
        !           140: };
1.1       misho     141: 
1.1.1.2 ! misho     142: struct radv_proto
1.1       misho     143: {
                    144:   struct proto p;
                    145:   list iface_list;             /* List of active ifaces */
1.1.1.2 ! misho     146:   u8 valid;                    /* Router is valid for forwarding, used for shutdown */
1.1       misho     147:   u8 active;                   /* Whether radv is active w.r.t. triggers */
1.1.1.2 ! misho     148:   u8 fib_up;                   /* FIB table (routes) is initialized */
        !           149:   struct fib routes;           /* FIB table of specific routes (struct radv_route) */
        !           150:   bird_clock_t prune_time;     /* Next time of route table pruning */
        !           151: };
        !           152: 
        !           153: struct radv_prefix             /* One prefix we advertise */
        !           154: {
        !           155:   node n;
        !           156:   ip_addr prefix;
        !           157:   u8 len;
        !           158:   u8 valid;                    /* Is the prefix valid? If not, we advertise it
        !           159:                                   with 0 lifetime, so clients stop using it */
        !           160:   u8 mark;                     /* A temporary mark for processing */
        !           161:   bird_clock_t changed;                /* Last time when the prefix changed */
        !           162:   struct radv_prefix_config *cf; /* The config tied to this prefix */
1.1       misho     163: };
                    164: 
                    165: struct radv_iface
                    166: {
                    167:   node n;
1.1.1.2 ! misho     168:   struct radv_proto *ra;
1.1       misho     169:   struct radv_iface_config *cf;        /* Related config, must be updated in reconfigure */
                    170:   struct iface *iface;
                    171:   struct ifa *addr;            /* Link-local address of iface */
1.1.1.2 ! misho     172:   struct pool *pool;           /* A pool for interface-specific things */
        !           173:   list prefixes;               /* The prefixes we advertise (struct radv_prefix) */
        !           174:   bird_clock_t prune_time;     /* Next time of prefix list pruning */
        !           175:   bird_clock_t valid_time;     /* Cached packet is valid until first linger timeout */
1.1       misho     176: 
                    177:   timer *timer;
                    178:   struct object_lock *lock;
                    179:   sock *sk;
                    180: 
                    181:   bird_clock_t last;           /* Time of last sending of RA */
                    182:   u16 plen;                    /* Length of prepared RA in tbuf, or 0 if not valid */
1.1.1.2 ! misho     183:   byte initial;                        /* How many RAs are still to be sent as initial */
1.1       misho     184: };
                    185: 
                    186: #define RA_EV_INIT 1           /* Switch to initial mode */
                    187: #define RA_EV_CHANGE 2         /* Change of options or prefixes */
                    188: #define RA_EV_RS 3             /* Received RS */
                    189: 
                    190: /* Default Router Preferences (RFC 4191) */
                    191: #define RA_PREF_LOW    0x18
                    192: #define RA_PREF_MEDIUM 0x00
                    193: #define RA_PREF_HIGH   0x08
                    194: #define RA_PREF_MASK   0x18
                    195: 
1.1.1.2 ! misho     196: /* Attributes */
        !           197: #define EA_RA_PREFERENCE       EA_CODE(EAP_RADV, 0)
        !           198: #define EA_RA_LIFETIME         EA_CODE(EAP_RADV, 1)
1.1       misho     199: 
                    200: #ifdef LOCAL_DEBUG
                    201: #define RADV_FORCE_DEBUG 1
                    202: #else
                    203: #define RADV_FORCE_DEBUG 0
                    204: #endif
1.1.1.2 ! misho     205: #define RADV_TRACE(flags, msg, args...) do { if ((p->p.debug & flags) || RADV_FORCE_DEBUG) \
        !           206:        log(L_TRACE "%s: " msg, p->p.name , ## args ); } while(0)
1.1       misho     207: 
                    208: 
                    209: /* radv.c */
                    210: void radv_iface_notify(struct radv_iface *ifa, int event);
                    211: 
                    212: /* packets.c */
                    213: int radv_process_domain(struct radv_dnssl_config *cf);
1.1.1.2 ! misho     214: void radv_send_ra(struct radv_iface *ifa);
1.1       misho     215: int radv_sk_open(struct radv_iface *ifa);
                    216: 
                    217: 
                    218: 
                    219: #endif /* _BIRD_RADV_H_ */

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