1 /* $OpenBSD: defs.h,v 1.8 2003/06/02 20:06:17 millert Exp $ */ 2 3 /* 4 * Copyright (c) 1983, 1988, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. Neither the name of the University nor the names of its contributors 16 * may be used to endorse or promote products derived from this software 17 * without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * 31 * @(#)defs.h 8.1 (Berkeley) 6/5/93 32 * 33 */ 34 35 /* Definitions for RIPv2 routing process. 36 * 37 * This code is based on the 4.4BSD `routed` daemon, with extensions to 38 * support: 39 * RIPv2, including variable length subnet masks. 40 * Router Discovery 41 * aggregate routes in the kernel tables. 42 * aggregate advertised routes. 43 * maintain spare routes for faster selection of another gateway 44 * when the current gateway dies. 45 * timers on routes with second granularity so that selection 46 * of a new route does not wait 30-60 seconds. 47 * tolerance of static routes. 48 * tell the kernel hop counts 49 * do not advertise if ipforwarding=0 50 * 51 * The vestigual support for other protocols has been removed. There 52 * is no likelihood that IETF RIPv1 or RIPv2 will ever be used with 53 * other protocols. The result is far smaller, faster, cleaner, and 54 * perhaps understandable. 55 * 56 * The accumulation of special flags and kludges added over the many 57 * years have been simplified and integrated. 58 */ 59 60 #include <stdio.h> 61 #include <netdb.h> 62 #include <stdlib.h> 63 #include <unistd.h> 64 #include <errno.h> 65 #include <string.h> 66 #include <stdarg.h> 67 #include <syslog.h> 68 #include <time.h> 69 #include <sys/types.h> 70 #include <sys/param.h> 71 #include <sys/ioctl.h> 72 #include <sys/sysctl.h> 73 #include <sys/socket.h> 74 #include <net/radix.h> 75 #include <net/if.h> 76 #include <net/route.h> 77 #include <net/if_dl.h> 78 #include <netinet/in.h> 79 #include <arpa/inet.h> 80 #define RIPVERSION RIPv2 81 #include <protocols/routed.h> 82 83 84 /* Type of an IP address. 85 * Some systems do not like to pass structures, so do not use in_addr. 86 * Some systems think a long has 64 bits, which would be a gross waste. 87 * So define it here so it can be changed for the target system. 88 * It should be defined somewhere netinet/in.h, but it is not. 89 */ 90 #define naddr u_int32_t 91 #define _HAVE_SA_LEN 92 #define _HAVE_SIN_LEN 93 94 /* Turn on if IP_DROP_MEMBERSHIP and IP_ADD_MEMBERSHIP do not look at 95 * the dstaddr of point-to-point interfaces. 96 */ 97 /* #define MCAST_PPP_BUG */ 98 99 #define NEVER (24*60*60) /* a long time */ 100 #define EPOCH NEVER /* bias time by this to avoid <0 */ 101 102 /* Scan the kernel regularly to see if any interfaces have appeared or been 103 * turned off. These must be less than STALE_TIME. 104 */ 105 #define CHECK_BAD_INTERVAL 5 /* when an interface is known bad */ 106 #define CHECK_ACT_INTERVAL 30 /* when advertising */ 107 #define CHECK_QUIET_INTERVAL 300 /* when not */ 108 109 #define LIM_SEC(s,l) ((s).tv_sec = MIN((s).tv_sec, (l))) 110 111 112 /* Router Discovery parameters */ 113 #ifndef sgi 114 #ifndef INADDR_ALLROUTERS_GROUP 115 #define INADDR_ALLROUTERS_GROUP 0xe0000002 /* 224.0.0.2 */ 116 #endif 117 #endif 118 #define MaxMaxAdvertiseInterval 1800 119 #define MinMaxAdvertiseInterval 4 120 #define DefMaxAdvertiseInterval 600 121 #define DEF_PreferenceLevel 0 122 #define MIN_PreferenceLevel 0x80000000 123 124 #define MAX_INITIAL_ADVERT_INTERVAL 16 125 #define MAX_INITIAL_ADVERTS 3 126 #define MAX_RESPONSE_DELAY 2 127 128 #define MAX_SOLICITATION_DELAY 1 129 #define SOLICITATION_INTERVAL 3 130 #define MAX_SOLICITATIONS 3 131 132 133 /* typical packet buffers */ 134 union pkt_buf { 135 char packet[MAXPACKETSIZE+1]; 136 struct rip rip; 137 }; 138 139 140 /* no more routes than this, to protect ourself in case something goes 141 * whacko and starts broadcast zillions of bogus routes. 142 */ 143 #define MAX_ROUTES (128*1024) 144 extern int total_routes; 145 146 /* Main, daemon routing table structure 147 */ 148 struct rt_entry { 149 struct radix_node rt_nodes[2]; /* radix tree glue */ 150 u_int rt_state; 151 # define RS_IF 0x001 /* for network interface */ 152 # define RS_NET_INT 0x002 /* authority route */ 153 # define RS_NET_SYN 0x004 /* fake net route for subnet */ 154 # define RS_NO_NET_SYN (RS_LOCAL | RS_LOCAL | RS_IF) 155 # define RS_SUBNET 0x008 /* subnet route from any source */ 156 # define RS_LOCAL 0x010 /* loopback for pt-to-pt */ 157 # define RS_MHOME 0x020 /* from -m */ 158 # define RS_STATIC 0x040 /* from the kernel */ 159 # define RS_RDISC 0x080 /* from router discovery */ 160 struct sockaddr_in rt_dst_sock; 161 naddr rt_mask; 162 struct rt_spare { 163 struct interface *rts_ifp; 164 naddr rts_gate; /* forward packets here */ 165 naddr rts_router; /* on the authority of this router */ 166 char rts_metric; 167 u_short rts_tag; 168 time_t rts_time; /* timer to junk stale routes */ 169 #define NUM_SPARES 4 170 } rt_spares[NUM_SPARES]; 171 u_int rt_seqno; /* when last changed */ 172 char rt_poison_metric; /* to notice maximum recently */ 173 time_t rt_poison_time; /* advertised metric */ 174 }; 175 #define rt_dst rt_dst_sock.sin_addr.s_addr 176 #define rt_ifp rt_spares[0].rts_ifp 177 #define rt_gate rt_spares[0].rts_gate 178 #define rt_router rt_spares[0].rts_router 179 #define rt_metric rt_spares[0].rts_metric 180 #define rt_tag rt_spares[0].rts_tag 181 #define rt_time rt_spares[0].rts_time 182 183 #define HOST_MASK 0xffffffff 184 #define RT_ISHOST(rt) ((rt)->rt_mask == HOST_MASK) 185 186 /* age all routes that 187 * are not from -g, -m, or static routes from the kernel 188 * not unbroken interface routes 189 * but not broken interfaces 190 * nor non-passive, remote interfaces that are not aliases 191 * (i.e. remote & metric=0) 192 */ 193 #define AGE_RT(rt_state,ifp) (0 == ((rt_state) & (RS_MHOME | RS_STATIC \ 194 | RS_NET_SYN | RS_RDISC)) \ 195 && (!((rt_state) & RS_IF) \ 196 || (ifp) == 0 \ 197 || (((ifp)->int_state & IS_REMOTE) \ 198 && !((ifp)->int_state & IS_PASSIVE)))) 199 200 /* true if A is better than B 201 * Better if 202 * - A is not a poisoned route 203 * - and A is not stale 204 * - and A has a shorter path 205 * - or is the router speaking for itself 206 * - or the current route is equal but stale 207 * - or it is a host route advertised by a system for itself 208 */ 209 #define BETTER_LINK(rt,A,B) ((A)->rts_metric < HOPCNT_INFINITY \ 210 && now_stale <= (A)->rts_time \ 211 && ((A)->rts_metric < (B)->rts_metric \ 212 || ((A)->rts_gate == (A)->rts_router \ 213 && (B)->rts_gate != (B)->rts_router) \ 214 || ((A)->rts_metric == (B)->rts_metric \ 215 && now_stale > (B)->rts_time) \ 216 || (RT_ISHOST(rt) \ 217 && (rt)->rt_dst == (A)->rts_router \ 218 && (A)->rts_metric == (B)->rts_metric))) 219 220 221 /* An "interface" is similar to a kernel ifnet structure, except it also 222 * handles "logical" or "IS_REMOTE" interfaces (remote gateways). 223 */ 224 struct interface { 225 struct interface *int_next, *int_prev; 226 char int_name[IFNAMSIZ+15+1]; /* big enough for IS_REMOTE */ 227 u_short int_index; 228 naddr int_addr; /* address on this host (net order) */ 229 naddr int_brdaddr; /* broadcast address (n) */ 230 naddr int_dstaddr; /* other end of pt-to-pt link (n) */ 231 naddr int_net; /* working network # (host order)*/ 232 naddr int_mask; /* working net mask (host order) */ 233 naddr int_ripv1_mask; /* for inferring a mask (n) */ 234 naddr int_std_addr; /* class A/B/C address (n) */ 235 naddr int_std_net; /* class A/B/C network (h) */ 236 naddr int_std_mask; /* class A/B/C netmask (h) */ 237 int int_rip_sock; /* for queries */ 238 int int_if_flags; /* some bits copied from kernel */ 239 u_int int_state; 240 time_t int_act_time; /* last thought healthy */ 241 u_short int_transitions; /* times gone up-down */ 242 char int_metric; 243 char int_d_metric; /* for faked default route */ 244 struct int_data { 245 u_int ipackets; /* previous network stats */ 246 u_int ierrors; 247 u_int opackets; 248 u_int oerrors; 249 #ifdef sgi 250 u_int odrops; 251 #endif 252 time_t ts; /* timestamp on network stats */ 253 } int_data; 254 char int_passwd[RIP_AUTH_PW_LEN]; /* RIPv2 password */ 255 int int_rdisc_pref; /* advertised rdisc preference */ 256 int int_rdisc_int; /* MaxAdvertiseInterval */ 257 int int_rdisc_cnt; 258 struct timeval int_rdisc_timer; 259 }; 260 261 /* bits in int_state */ 262 #define IS_ALIAS 0x0000001 /* interface alias */ 263 #define IS_SUBNET 0x0000002 /* interface on subnetted network */ 264 #define IS_REMOTE 0x0000004 /* interface is not on this machine */ 265 #define IS_PASSIVE 0x0000008 /* remote and does not do RIP */ 266 #define IS_EXTERNAL 0x0000010 /* handled by EGP or something */ 267 #define IS_CHECKED 0x0000020 /* still exists */ 268 #define IS_ALL_HOSTS 0x0000040 /* in INADDR_ALLHOSTS_GROUP */ 269 #define IS_ALL_ROUTERS 0x0000080 /* in INADDR_ALLROUTERS_GROUP */ 270 #define IS_RIP_QUERIED 0x0000100 /* query broadcast */ 271 #define IS_BROKE 0x0000200 /* seems to be broken */ 272 #define IS_SICK 0x0000400 /* seems to be broken */ 273 #define IS_DUP 0x0000800 /* has a duplicate address */ 274 #define IS_ACTIVE 0x0001000 /* heard from it at least once */ 275 #define IS_NEED_NET_SYN 0x0002000 /* need RS_NET_SYN route */ 276 #define IS_NO_AG 0x0004000 /* do not aggregate subnets */ 277 #define IS_NO_SUPER_AG 0x0008000 /* do not aggregate networks */ 278 #define IS_NO_RIPV1_IN 0x0010000 /* no RIPv1 input at all */ 279 #define IS_NO_RIPV2_IN 0x0020000 /* no RIPv2 input at all */ 280 #define IS_NO_RIP_IN (IS_NO_RIPV1_IN | IS_NO_RIPV2_IN) 281 #define IS_RIP_IN_OFF(s) (((s) & IS_NO_RIP_IN) == IS_NO_RIP_IN) 282 #define IS_NO_RIPV1_OUT 0x0040000 /* no RIPv1 output at all */ 283 #define IS_NO_RIPV2_OUT 0x0080000 /* no RIPv2 output at all */ 284 #define IS_NO_RIP_OUT (IS_NO_RIPV1_OUT | IS_NO_RIPV2_OUT) 285 #define IS_NO_RIP (IS_NO_RIP_OUT | IS_NO_RIP_IN) 286 #define IS_RIP_OUT_OFF(s) (((s) & IS_NO_RIP_OUT) == IS_NO_RIP_OUT) 287 #define IS_RIP_OFF(s) (((s) & IS_NO_RIP) == IS_NO_RIP) 288 #define IS_NO_ADV_IN 0x0100000 289 #define IS_NO_SOL_OUT 0x0200000 /* no solicitations */ 290 #define IS_SOL_OUT 0x0400000 /* send solicitations */ 291 #define GROUP_IS_SOL (IS_NO_ADV_IN|IS_NO_SOL_OUT) 292 #define IS_NO_ADV_OUT 0x0800000 /* do not advertise rdisc */ 293 #define IS_ADV_OUT 0x1000000 /* advertise rdisc */ 294 #define GROUP_IS_ADV (IS_NO_ADV_OUT|IS_ADV_OUT) 295 #define IS_BCAST_RDISC 0x2000000 /* broadcast instead of multicast */ 296 #define IS_NO_RDISC (IS_NO_ADV_IN | IS_NO_SOL_OUT | IS_NO_ADV_OUT) 297 #define IS_PM_RDISC 0x4000000 /* poor-man's router discovery */ 298 299 #ifdef sgi 300 #define IFF_UP_RUNNING (IFF_RUNNING|IFF_UP) 301 #else 302 #define IFF_UP_RUNNING IFF_UP 303 #endif 304 #define iff_alive(f) (((f) & IFF_UP_RUNNING) == IFF_UP_RUNNING) 305 306 307 /* Information for aggregating routes */ 308 #define NUM_AG_SLOTS 32 309 struct ag_info { 310 struct ag_info *ag_fine; /* slot with finer netmask */ 311 struct ag_info *ag_cors; /* more coarse netmask */ 312 naddr ag_dst_h; /* destination in host byte order */ 313 naddr ag_mask; 314 naddr ag_gate; 315 naddr ag_nhop; 316 char ag_metric; /* metric to be advertised */ 317 char ag_pref; /* aggregate based on this */ 318 u_int ag_seqno; 319 u_short ag_tag; 320 u_short ag_state; 321 #define AGS_SUPPRESS 0x001 /* combine with coaser mask */ 322 #define AGS_PROMOTE 0x002 /* synthesize combined routes */ 323 #define AGS_REDUN0 0x004 /* redundant, finer routes output */ 324 #define AGS_REDUN1 0x008 325 #define AG_IS_REDUN(state) (((state) & (AGS_REDUN0 | AGS_REDUN1)) \ 326 == (AGS_REDUN0 | AGS_REDUN1)) 327 #define AGS_GATEWAY 0x010 /* tell kernel RTF_GATEWAY */ 328 #define AGS_IF 0x020 /* for an interface */ 329 #define AGS_RIPV2 0x040 /* send only as RIPv2 */ 330 #define AGS_FINE_GATE 0x080 /* ignore differing ag_gate when this 331 * has the finer netmask */ 332 #define AGS_CORS_GATE 0x100 /* ignore differing gate when this 333 * has the coarser netmaks */ 334 #define AGS_SPLIT_HZ 0x200 /* suppress for split horizon */ 335 336 /* some bits are set if they are set on either route */ 337 #define AGS_PROMOTE_EITHER (AGS_RIPV2 | AGS_GATEWAY | \ 338 AGS_SUPPRESS | AGS_CORS_GATE) 339 }; 340 341 342 /* parameters for interfaces */ 343 extern struct parm { 344 struct parm *parm_next; 345 char parm_name[IFNAMSIZ+1]; 346 naddr parm_addr_h; 347 naddr parm_mask; 348 349 char parm_d_metric; 350 u_int parm_int_state; 351 int parm_rdisc_pref; 352 int parm_rdisc_int; 353 char parm_passwd[RIP_AUTH_PW_LEN+1]; 354 } *parms; 355 356 /* authority for internal networks */ 357 extern struct intnet { 358 struct intnet *intnet_next; 359 naddr intnet_addr; 360 naddr intnet_mask; 361 char intnet_metric; 362 } *intnets; 363 364 365 366 extern pid_t mypid; 367 extern naddr myaddr; /* main address of this system */ 368 369 extern int stopint; /* !=0 to stop */ 370 371 extern int sock_max; 372 extern int rip_sock; /* RIP socket */ 373 extern struct interface *rip_sock_mcast; /* current multicast interface */ 374 extern int rt_sock; /* routing socket */ 375 extern int rt_sock_seqno; 376 extern int rdisc_sock; /* router-discovery raw socket */ 377 378 extern int seqno; /* sequence number for messages */ 379 extern int supplier; /* process should supply updates */ 380 extern int lookforinterfaces; /* 1=probe for new up interfaces */ 381 extern int supplier_set; /* -s or -q requested */ 382 extern int ridhosts; /* 1=reduce host routes */ 383 extern int mhome; /* 1=want multi-homed host route */ 384 extern int advertise_mhome; /* 1=must continue adverising it */ 385 extern int auth_ok; /* 1=ignore auth if we do not care */ 386 387 extern struct timeval epoch; /* when started */ 388 extern struct timeval now; /* current idea of time */ 389 extern time_t now_stale; 390 extern time_t now_expire; 391 extern time_t now_garbage; 392 393 extern struct timeval next_bcast; /* next general broadcast */ 394 extern struct timeval age_timer; /* next check of old routes */ 395 extern struct timeval no_flash; /* inhibit flash update until then */ 396 extern struct timeval rdisc_timer; /* next advert. or solicitation */ 397 extern int rdisc_ok; /* using solicited route */ 398 399 extern struct timeval ifinit_timer; /* time to check interfaces */ 400 401 extern naddr loopaddr; /* our address on loopback */ 402 extern int tot_interfaces; /* # of remote and local interfaces */ 403 extern int rip_interfaces; /* # of interfaces doing RIP */ 404 extern struct interface *ifnet; /* all interfaces */ 405 extern int have_ripv1_out; /* have a RIPv1 interface */ 406 extern int have_ripv1_in; 407 extern int need_flash; /* flash update needed */ 408 extern struct timeval need_kern; /* need to update kernel table */ 409 extern int update_seqno; /* a route has changed */ 410 411 extern u_int tracelevel, new_tracelevel; 412 #define MAX_TRACELEVEL 4 413 #define TRACEKERNEL (tracelevel >= 4) /* log kernel changes */ 414 #define TRACECONTENTS (tracelevel >= 3) /* display packet contents */ 415 #define TRACEPACKETS (tracelevel >= 2) /* note packets */ 416 #define TRACEACTIONS (tracelevel != 0) 417 extern FILE *ftrace; /* output trace file */ 418 419 extern struct radix_node_head *rhead; 420 421 422 #ifdef sgi 423 /* Fix conflicts */ 424 #define dup2(x,y) BSDdup2(x,y) 425 #endif /* sgi */ 426 427 extern void fix_sock(int, char *); 428 extern void fix_select(void); 429 extern void rip_off(void); 430 extern void rip_on(struct interface *); 431 432 enum output_type {OUT_QUERY, OUT_UNICAST, OUT_BROADCAST, OUT_MULTICAST, 433 NO_OUT_MULTICAST, NO_OUT_RIPV2}; 434 extern int output(enum output_type, struct sockaddr_in *, 435 struct interface *, struct rip *, int); 436 extern void rip_query(void); 437 extern void rip_bcast(int); 438 extern void supply(struct sockaddr_in *, struct interface *, 439 enum output_type, int, int); 440 441 extern void msglog(char *, ...); 442 #define LOGERR(msg) msglog(msg ": %s", strerror(errno)) 443 extern void logbad(int, char *, ...); 444 #define BADERR(dump,msg) logbad(dump,msg ": %s", strerror(errno)) 445 #ifdef DEBUG 446 #define DBGERR(dump,msg) BADERR(dump,msg) 447 #else 448 #define DBGERR(dump,msg) LOGERR(msg) 449 #endif 450 extern char *naddr_ntoa(naddr); 451 extern char *saddr_ntoa(struct sockaddr *); 452 453 extern void *rtmalloc(size_t, char *); 454 extern void timevaladd(struct timeval *, struct timeval *); 455 extern void intvl_random(struct timeval *, u_long, u_long); 456 extern int getnet(char *, naddr *, naddr *); 457 extern int gethost(char *, naddr *); 458 extern void gwkludge(void); 459 extern char *parse_parms(char *); 460 extern char *check_parms(struct parm *); 461 extern void get_parms(struct interface *); 462 463 extern void lastlog(void); 464 extern void trace_on(char *, int); 465 extern void trace_off(char*, ...); 466 extern void trace_flush(void); 467 extern void set_tracelevel(void); 468 extern void trace_kernel(char *, ...); 469 extern void trace_act(char *, ...); 470 extern void trace_pkt(char *, ...); 471 extern void trace_add_del(char *, struct rt_entry *); 472 extern void trace_change(struct rt_entry *, u_int, naddr, naddr, int, 473 u_short, struct interface *, time_t, char *); 474 extern void trace_if(char *, struct interface *); 475 extern void trace_upslot(struct rt_entry *, struct rt_spare *, 476 naddr, naddr, 477 struct interface *, int, u_short, time_t); 478 extern void trace_rip(char*, char*, struct sockaddr_in *, 479 struct interface *, struct rip *, int); 480 extern char *addrname(naddr, naddr, int); 481 482 extern void rdisc_age(naddr); 483 extern void set_rdisc_mg(struct interface *, int); 484 extern void set_supplier(void); 485 extern void if_bad_rdisc(struct interface *); 486 extern void if_ok_rdisc(struct interface *); 487 extern void read_rip(int, struct interface *); 488 extern void read_rt(void); 489 extern void read_d(void); 490 extern void rdisc_adv(void); 491 extern void rdisc_sol(void); 492 493 extern void sigalrm(int); 494 extern void sigterm(int); 495 496 extern void sigtrace_on(int); 497 extern void sigtrace_off(int); 498 499 extern void flush_kern(void); 500 extern void age(naddr); 501 502 extern void ag_flush(naddr, naddr, void (*)(struct ag_info *)); 503 extern void ag_check(naddr, naddr, naddr, naddr, char, char, u_int, 504 u_short, u_short, void (*)(struct ag_info *)); 505 extern void del_static(naddr, naddr, int); 506 extern void del_redirects(naddr, time_t); 507 extern struct rt_entry *rtget(naddr, naddr); 508 extern struct rt_entry *rtfind(naddr); 509 extern void rtinit(void); 510 extern void rtadd(naddr, naddr, naddr, naddr, 511 int, u_short, u_int, struct interface *); 512 extern void rtchange(struct rt_entry *, u_int, naddr,naddr, int, u_short, 513 struct interface *ifp, time_t, char *); 514 extern void rtdelete(struct rt_entry *); 515 extern void rtbad_sub(struct rt_entry *); 516 extern void rtswitch(struct rt_entry *, struct rt_spare *); 517 extern void rtbad(struct rt_entry *); 518 519 520 #define S_ADDR(x) (((struct sockaddr_in *)(x))->sin_addr.s_addr) 521 #define INFO_DST(I) ((I)->rti_info[RTAX_DST]) 522 #define INFO_GATE(I) ((I)->rti_info[RTAX_GATEWAY]) 523 #define INFO_MASK(I) ((I)->rti_info[RTAX_NETMASK]) 524 #define INFO_IFA(I) ((I)->rti_info[RTAX_IFA]) 525 #define INFO_IFP(I) ((I)->rti_info[RTAX_IFP]) 526 #define INFO_AUTHOR(I) ((I)->rti_info[RTAX_AUTHOR]) 527 #define INFO_BRD(I) ((I)->rti_info[RTAX_BRD]) 528 void rt_xaddrs(struct rt_addrinfo *, struct sockaddr *, struct sockaddr *, 529 int); 530 531 extern naddr std_mask(naddr); 532 extern naddr ripv1_mask_net(naddr, struct interface *); 533 extern naddr ripv1_mask_host(naddr,struct interface *); 534 #define on_net(a,net,mask) (((ntohl(a) ^ (net)) & (mask)) == 0) 535 extern int check_dst(naddr); 536 extern void addrouteforif(register struct interface *); 537 extern void ifinit(void); 538 extern int walk_bad(struct radix_node *, void *); 539 extern int if_ok(struct interface *, char *); 540 extern void if_sick(struct interface *); 541 extern void if_bad(struct interface *); 542 extern struct interface *ifwithaddr(naddr, int, int); 543 extern struct interface *ifwithname(char *, naddr); 544 extern struct interface *ifwithindex(u_short); 545 extern struct interface *iflookup(naddr); 546