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 189/* timer.c */ 190void set_timer(struct timer_lst *tm, double); 191void clear_timer(struct timer_lst *tm); 192void init_timer(struct timer_lst *, void (*)(void *), void *); 193 194/* log.c */ 195int log_open(int, char *, char*, int); 196void flog(int, char *, ...); 197void dlog(int, int, char *, ...); 198int log_close(void); 199int log_reopen(void); 200void set_debuglevel(int); 201int get_debuglevel(void); 202 203/* device.c */ 204int setup_deviceinfo(int, struct Interface *); 205int check_device(int, struct Interface *); 206int setup_linklocal_addr(int, struct Interface *); 207int setup_allrouters_membership(int, struct Interface *); 208int check_allrouters_membership(int, struct Interface *); 209int get_v4addr(const char *, unsigned int *); 210int set_interface_var(const char *, const char *, const char *, uint32_t); 211int set_interface_linkmtu(const char *, uint32_t); 212int set_interface_curhlim(const char *, uint8_t); 213int set_interface_reachtime(const char *, uint32_t); 214int set_interface_retranstimer(const char *, uint32_t); 215 216/* interface.c */ 217void iface_init_defaults(struct Interface *); 218void prefix_init_defaults(struct AdvPrefix *); 219void route_init_defaults(struct AdvRoute *, struct Interface *); 220void rdnss_init_defaults(struct AdvRDNSS *, struct Interface *); 221int check_iface(struct Interface *); 222 223/* socket.c */ 224int open_icmpv6_socket(void); 225 226/* send.c */ 227void send_ra(int, struct Interface *iface, struct in6_addr *dest); 228void send_ra_forall(int, struct Interface *iface, struct in6_addr *dest); 229 230/* process.c */ 231void process(int sock, struct Interface *, unsigned char *, int, 232 struct sockaddr_in6 *, struct in6_pktinfo *, int); 233 234/* recv.c */ 235int recv_rs_ra(int, unsigned char *, struct sockaddr_in6 *, struct in6_pktinfo **, int *); 236 237/* util.c */ 238void mdelay(double); 239double rand_between(double, double); 240void print_addr(struct in6_addr *, char *); 241int check_rdnss_presence(struct AdvRDNSS *, struct in6_addr *); 242ssize_t readn(int fd, void *buf, size_t count); 243ssize_t writen(int fd, const void *buf, size_t count); 244 245/* privsep.c */ 246int privsep_init(void); 247int privsep_enabled(void); 248int privsep_interface_linkmtu(const char *iface, uint32_t mtu); 249int privsep_interface_curhlim(const char *iface, uint32_t hlim); 250int privsep_interface_reachtime(const char *iface, uint32_t rtime); 251int privsep_interface_retranstimer(const char *iface, uint32_t rettimer); 252 253/* 254 * compat hacks in case libc and kernel get out of sync: 255 * 256 * glibc 2.4 and uClibc 0.9.29 introduce IPV6_RECVPKTINFO etc. and change IPV6_PKTINFO 257 * This is only supported in Linux kernel >= 2.6.14 258 * 259 * This is only an approximation because the kernel version that libc was compiled against 260 * could be older or newer than the one being run. But this should not be a problem -- 261 * we just keep using the old kernel interface. 262 * 263 * these are placed here because they're needed in all of socket.c, recv.c and send.c 264 */ 265 266#if 0 267 268#define IPV6_ADDRFORM 1 269#define IPV6_2292PKTINFO 2 270#define IPV6_2292HOPOPTS 3 271#define IPV6_2292DSTOPTS 4 272#define IPV6_2292RTHDR 5 273#define IPV6_2292PKTOPTIONS 6 274#define IPV6_CHECKSUM 7 275#define IPV6_2292HOPLIMIT 8 276#define IPV6_NEXTHOP 9 277 278#define IPV6_RECVPKTINFO 49 279#define IPV6_PKTINFO 50 280#define IPV6_RECVHOPLIMIT 51 281#define IPV6_HOPLIMIT 52 282#define IPV6_RECVHOPOPTS 53 283#define IPV6_HOPOPTS 54 284#define IPV6_RTHDRDSTOPTS 55 285#define IPV6_RECVRTHDR 56 286#define IPV6_RTHDR 57 287#define IPV6_RECVDSTOPTS 58 288#define IPV6_DSTOPTS 59 289 290#endif 291 292//#if 0 293 294#ifdef __linux__ 295# if defined IPV6_RECVHOPLIMIT || defined IPV6_RECVPKTINFO 296# include <linux/version.h> 297# if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) 298# if defined IPV6_RECVHOPLIMIT && defined IPV6_2292HOPLIMIT 299# undef IPV6_RECVHOPLIMIT 300# define IPV6_RECVHOPLIMIT IPV6_2292HOPLIMIT 301# endif 302# if defined IPV6_RECVPKTINFO && defined IPV6_2292PKTINFO 303# undef IPV6_RECVPKTINFO 304# undef IPV6_PKTINFO 305# define IPV6_RECVPKTINFO IPV6_2292PKTINFO 306# define IPV6_PKTINFO IPV6_2292PKTINFO 307# endif 308# endif 309# endif 310#endif 311 312//#endif //#if 0 313 314#endif 315