1/* 2 * $Id: radvd.h,v 1.29 2009/06/19 07:34:07 psavola Exp $ 3 * 4 * Authors: 5 * Pedro Roque <roque@di.fc.ul.pt> 6 * Lars Fenneberg <lf@elemental.net> 7 * 8 * This software is Copyright 1996,1997 by the above mentioned author(s), 9 * All Rights Reserved. 10 * 11 * The license which is distributed with this software in the file COPYRIGHT 12 * applies to this software. If your distribution is missing this file, you 13 * may request it from <pekkas@netcore.fi>. 14 * 15 */ 16 17#ifndef RADV_H 18#define RADV_H 19 20#include <config.h> 21#include <includes.h> 22#include <defaults.h> 23 24#define CONTACT_EMAIL "Pekka Savola <pekkas@netcore.fi>" 25 26/* for log.c */ 27#define L_NONE 0 28#define L_SYSLOG 1 29#define L_STDERR 2 30#define L_STDERR_SYSLOG 3 31#define L_LOGFILE 4 32 33#define LOG_TIME_FORMAT "%b %d %H:%M:%S" 34 35struct timer_lst { 36 struct timeval expires; 37 void (*handler)(void *); 38 void * data; 39 struct timer_lst *next; 40 struct timer_lst *prev; 41}; 42 43#define min(a,b) (((a) < (b)) ? (a) : (b)) 44 45struct AdvPrefix; 46struct Clients; 47 48#define HWADDR_MAX 16 49#define USER_HZ 100 50 51struct Interface { 52 char Name[IFNAMSIZ]; /* interface name */ 53 54 struct in6_addr if_addr; 55 unsigned int if_index; 56 57 uint8_t init_racount; /* Initial RAs */ 58 59 uint8_t if_hwaddr[HWADDR_MAX]; 60 int if_hwaddr_len; 61 int if_prefix_len; 62 int if_maxmtu; 63 64 int IgnoreIfMissing; 65 int AdvSendAdvert; 66 double MaxRtrAdvInterval; 67 double MinRtrAdvInterval; 68 double MinDelayBetweenRAs; 69 int AdvManagedFlag; 70 int AdvOtherConfigFlag; 71 uint32_t AdvLinkMTU; 72 uint32_t AdvReachableTime; 73 uint32_t AdvRetransTimer; 74 uint8_t AdvCurHopLimit; 75 int32_t AdvDefaultLifetime; /* XXX: really uint16_t but we need to use -1 */ 76 int AdvDefaultPreference; 77 int AdvSourceLLAddress; 78 int UnicastOnly; 79 80 /* Mobile IPv6 extensions */ 81 int AdvIntervalOpt; 82 int AdvHomeAgentInfo; 83 int AdvHomeAgentFlag; 84 uint16_t HomeAgentPreference; 85 int32_t HomeAgentLifetime; /* XXX: really uint16_t but we need to use -1 */ 86 87 /* NEMO extensions */ 88 int AdvMobRtrSupportFlag; 89 90 struct AdvPrefix *AdvPrefixList; 91 struct AdvRoute *AdvRouteList; 92 struct AdvRDNSS *AdvRDNSSList; 93 struct Clients *ClientList; 94 struct timer_lst tm; 95 time_t last_multicast_sec; 96 suseconds_t last_multicast_usec; 97 98 /* Info whether this interface has failed in the past (and may need to be reinitialized) */ 99 int HasFailed; 100 101 struct Interface *next; 102}; 103 104struct Clients { 105 struct in6_addr Address; 106 struct Clients *next; 107}; 108 109struct AdvPrefix { 110 struct in6_addr Prefix; 111 uint8_t PrefixLen; 112 113 int AdvOnLinkFlag; 114 int AdvAutonomousFlag; 115 uint32_t AdvValidLifetime; 116 uint32_t AdvPreferredLifetime; 117 118 /* Mobile IPv6 extensions */ 119 int AdvRouterAddr; 120 121 /* 6to4 etc. extensions */ 122 char if6to4[IFNAMSIZ]; 123 int enabled; 124 int AutoSelected; 125 126 struct AdvPrefix *next; 127}; 128 129/* More-Specific Routes extensions */ 130 131struct AdvRoute { 132 struct in6_addr Prefix; 133 uint8_t PrefixLen; 134 135 int AdvRoutePreference; 136 uint32_t AdvRouteLifetime; 137 138 struct AdvRoute *next; 139}; 140 141/* Option for DNS configuration */ 142struct AdvRDNSS { 143 int AdvRDNSSNumber; 144 uint8_t AdvRDNSSPreference; 145 int AdvRDNSSOpenFlag; 146 uint32_t AdvRDNSSLifetime; 147 struct in6_addr AdvRDNSSAddr1; 148 struct in6_addr AdvRDNSSAddr2; 149 struct in6_addr AdvRDNSSAddr3; 150 151 struct AdvRDNSS *next; 152}; 153 154/* Mobile IPv6 extensions */ 155 156struct AdvInterval { 157 uint8_t type; 158 uint8_t length; 159 uint16_t reserved; 160 uint32_t adv_ival; 161}; 162 163struct HomeAgentInfo { 164 uint8_t type; 165 uint8_t length; 166 uint16_t flags_reserved; 167 uint16_t preference; 168 uint16_t lifetime; 169}; 170 171 172/* gram.y */ 173int yyparse(void); 174 175/* scanner.l */ 176int yylex(void); 177 178/* radvd.c */ 179int check_ip6_forwarding(void); 180void reload_config(void); 181 182/* Foxconn added start pling 12/22/2011 */ 183extern int use_dynamic_lifetime; 184extern unsigned long initial_advert_time; 185extern void set_initial_advert_time(void); 186extern unsigned long get_current_time(void); 187/* Foxconn added end pling 12/22/2011 */ 188/* timer.c */ 189void set_timer(struct timer_lst *tm, double); 190void clear_timer(struct timer_lst *tm); 191void init_timer(struct timer_lst *, void (*)(void *), void *); 192 193/* log.c */ 194int log_open(int, char *, char*, int); 195void flog(int, char *, ...); 196void dlog(int, int, char *, ...); 197int log_close(void); 198int log_reopen(void); 199void set_debuglevel(int); 200int get_debuglevel(void); 201 202/* device.c */ 203int setup_deviceinfo(int, struct Interface *); 204int check_device(int, struct Interface *); 205int setup_linklocal_addr(int, struct Interface *); 206int setup_allrouters_membership(int, struct Interface *); 207int check_allrouters_membership(int, struct Interface *); 208int get_v4addr(const char *, unsigned int *); 209int set_interface_var(const char *, const char *, const char *, uint32_t); 210int set_interface_linkmtu(const char *, uint32_t); 211int set_interface_curhlim(const char *, uint8_t); 212int set_interface_reachtime(const char *, uint32_t); 213int set_interface_retranstimer(const char *, uint32_t); 214 215/* interface.c */ 216void iface_init_defaults(struct Interface *); 217void prefix_init_defaults(struct AdvPrefix *); 218void route_init_defaults(struct AdvRoute *, struct Interface *); 219void rdnss_init_defaults(struct AdvRDNSS *, struct Interface *); 220int check_iface(struct Interface *); 221 222/* socket.c */ 223int open_icmpv6_socket(void); 224 225/* send.c */ 226void send_ra(int, struct Interface *iface, struct in6_addr *dest); 227void send_ra_forall(int, struct Interface *iface, struct in6_addr *dest); 228 229/* process.c */ 230void process(int sock, struct Interface *, unsigned char *, int, 231 struct sockaddr_in6 *, struct in6_pktinfo *, int); 232 233/* recv.c */ 234int recv_rs_ra(int, unsigned char *, struct sockaddr_in6 *, struct in6_pktinfo **, int *); 235 236/* util.c */ 237void mdelay(double); 238double rand_between(double, double); 239void print_addr(struct in6_addr *, char *); 240int check_rdnss_presence(struct AdvRDNSS *, struct in6_addr *); 241ssize_t readn(int fd, void *buf, size_t count); 242ssize_t writen(int fd, const void *buf, size_t count); 243 244/* privsep.c */ 245int privsep_init(void); 246int privsep_enabled(void); 247int privsep_interface_linkmtu(const char *iface, uint32_t mtu); 248int privsep_interface_curhlim(const char *iface, uint32_t hlim); 249int privsep_interface_reachtime(const char *iface, uint32_t rtime); 250int privsep_interface_retranstimer(const char *iface, uint32_t rettimer); 251 252/* 253 * compat hacks in case libc and kernel get out of sync: 254 * 255 * glibc 2.4 and uClibc 0.9.29 introduce IPV6_RECVPKTINFO etc. and change IPV6_PKTINFO 256 * This is only supported in Linux kernel >= 2.6.14 257 * 258 * This is only an approximation because the kernel version that libc was compiled against 259 * could be older or newer than the one being run. But this should not be a problem -- 260 * we just keep using the old kernel interface. 261 * 262 * these are placed here because they're needed in all of socket.c, recv.c and send.c 263 */ 264 265#if 0 266 267#define IPV6_ADDRFORM 1 268#define IPV6_2292PKTINFO 2 269#define IPV6_2292HOPOPTS 3 270#define IPV6_2292DSTOPTS 4 271#define IPV6_2292RTHDR 5 272#define IPV6_2292PKTOPTIONS 6 273#define IPV6_CHECKSUM 7 274#define IPV6_2292HOPLIMIT 8 275#define IPV6_NEXTHOP 9 276 277#define IPV6_RECVPKTINFO 49 278#define IPV6_PKTINFO 50 279#define IPV6_RECVHOPLIMIT 51 280#define IPV6_HOPLIMIT 52 281#define IPV6_RECVHOPOPTS 53 282#define IPV6_HOPOPTS 54 283#define IPV6_RTHDRDSTOPTS 55 284#define IPV6_RECVRTHDR 56 285#define IPV6_RTHDR 57 286#define IPV6_RECVDSTOPTS 58 287#define IPV6_DSTOPTS 59 288 289#endif 290 291//#if 0 292 293#ifdef __linux__ 294# if defined IPV6_RECVHOPLIMIT || defined IPV6_RECVPKTINFO 295# include <linux/version.h> 296# if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) 297# if defined IPV6_RECVHOPLIMIT && defined IPV6_2292HOPLIMIT 298# undef IPV6_RECVHOPLIMIT 299# define IPV6_RECVHOPLIMIT IPV6_2292HOPLIMIT 300# endif 301# if defined IPV6_RECVPKTINFO && defined IPV6_2292PKTINFO 302# undef IPV6_RECVPKTINFO 303# undef IPV6_PKTINFO 304# define IPV6_RECVPKTINFO IPV6_2292PKTINFO 305# define IPV6_PKTINFO IPV6_2292PKTINFO 306# endif 307# endif 308# endif 309#endif 310 311//#endif //#if 0 312 313#endif 314