Return to radv.h CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / bird / proto / radv |
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 */ ! 56: }; ! 57: ! 58: struct radv_iface_config ! 59: { ! 60: struct iface_patt i; ! 61: list pref_list; /* Local list of prefix configs (struct radv_prefix_config) */ ! 62: list rdnss_list; /* Local list of RDNSS configs (struct radv_rdnss_config) */ ! 63: list dnssl_list; /* Local list of DNSSL configs (struct radv_dnssl_config) */ ! 64: ! 65: u32 min_ra_int; /* Standard options from RFC 4261 */ ! 66: u32 max_ra_int; ! 67: u32 min_delay; ! 68: ! 69: u8 rdnss_local; /* Global list is not used for RDNSS */ ! 70: u8 dnssl_local; /* Global list is not used for DNSSL */ ! 71: ! 72: u8 managed; /* Standard options from RFC 4261 */ ! 73: u8 other_config; ! 74: u32 link_mtu; ! 75: u32 reachable_time; ! 76: u32 retrans_timer; ! 77: u32 current_hop_limit; ! 78: u32 default_lifetime; ! 79: u8 default_lifetime_sensitive; /* Whether default_lifetime depends on trigger */ ! 80: u8 default_preference; /* Default Router Preference (RFC 4191) */ ! 81: }; ! 82: ! 83: struct radv_prefix_config ! 84: { ! 85: node n; ! 86: ip_addr prefix; ! 87: uint pxlen; ! 88: ! 89: u8 skip; /* Do not include this prefix to RA */ ! 90: u8 onlink; /* Standard options from RFC 4261 */ ! 91: u8 autonomous; ! 92: u32 valid_lifetime; ! 93: u32 preferred_lifetime; ! 94: u8 valid_lifetime_sensitive; /* Whether valid_lifetime depends on trigger */ ! 95: u8 preferred_lifetime_sensitive; /* Whether preferred_lifetime depends on trigger */ ! 96: }; ! 97: ! 98: struct radv_rdnss_config ! 99: { ! 100: node n; ! 101: u32 lifetime; /* Valid if lifetime_mult is 0 */ ! 102: u16 lifetime_mult; /* Lifetime specified as multiple of max_ra_int */ ! 103: ip_addr server; /* IP address of recursive DNS server */ ! 104: }; ! 105: ! 106: struct radv_dnssl_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: u8 dlen_first; /* Length of first label in domain */ ! 112: u8 dlen_all; /* Both dlen_ filled in radv_process_domain() */ ! 113: char *domain; /* Domain for DNS search list, in processed form */ ! 114: }; ! 115: ! 116: ! 117: struct proto_radv ! 118: { ! 119: struct proto p; ! 120: list iface_list; /* List of active ifaces */ ! 121: u8 active; /* Whether radv is active w.r.t. triggers */ ! 122: }; ! 123: ! 124: struct radv_iface ! 125: { ! 126: node n; ! 127: struct proto_radv *ra; ! 128: struct radv_iface_config *cf; /* Related config, must be updated in reconfigure */ ! 129: struct iface *iface; ! 130: struct ifa *addr; /* Link-local address of iface */ ! 131: ! 132: timer *timer; ! 133: struct object_lock *lock; ! 134: sock *sk; ! 135: ! 136: bird_clock_t last; /* Time of last sending of RA */ ! 137: u16 plen; /* Length of prepared RA in tbuf, or 0 if not valid */ ! 138: byte initial; /* List of active ifaces */ ! 139: }; ! 140: ! 141: #define RA_EV_INIT 1 /* Switch to initial mode */ ! 142: #define RA_EV_CHANGE 2 /* Change of options or prefixes */ ! 143: #define RA_EV_RS 3 /* Received RS */ ! 144: ! 145: /* Default Router Preferences (RFC 4191) */ ! 146: #define RA_PREF_LOW 0x18 ! 147: #define RA_PREF_MEDIUM 0x00 ! 148: #define RA_PREF_HIGH 0x08 ! 149: #define RA_PREF_MASK 0x18 ! 150: ! 151: ! 152: #ifdef LOCAL_DEBUG ! 153: #define RADV_FORCE_DEBUG 1 ! 154: #else ! 155: #define RADV_FORCE_DEBUG 0 ! 156: #endif ! 157: #define RADV_TRACE(flags, msg, args...) do { if ((ra->p.debug & flags) || RADV_FORCE_DEBUG) \ ! 158: log(L_TRACE "%s: " msg, ra->p.name , ## args ); } while(0) ! 159: ! 160: ! 161: /* radv.c */ ! 162: void radv_iface_notify(struct radv_iface *ifa, int event); ! 163: ! 164: /* packets.c */ ! 165: int radv_process_domain(struct radv_dnssl_config *cf); ! 166: void radv_send_ra(struct radv_iface *ifa, int shutdown); ! 167: int radv_sk_open(struct radv_iface *ifa); ! 168: ! 169: ! 170: ! 171: #endif /* _BIRD_RADV_H_ */