routed.h (8858) | routed.h (16009) |
---|---|
1/*- 2 * Copyright (c) 1983, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 19 unchanged lines hidden (view full) --- 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)routed.h 8.1 (Berkeley) 6/2/93 34 */ 35 | 1/*- 2 * Copyright (c) 1983, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 19 unchanged lines hidden (view full) --- 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)routed.h 8.1 (Berkeley) 6/2/93 34 */ 35 |
36#ifndef _PROTOCOLS_ROUTED_H_ 37#define _PROTOCOLS_ROUTED_H_ | 36#ifndef _ROUTED_H_ 37#define _ROUTED_H_ 38#ifdef __cplusplus 39extern "C" { 40#endif 41#ident "$Revision: 1.7 $" |
38 39/* 40 * Routing Information Protocol 41 * 42 * Derived from Xerox NS Routing Information Protocol 43 * by changing 32-bit net numbers to sockaddr's and 44 * padding stuff to 32-bit boundaries. 45 */ | 42 43/* 44 * Routing Information Protocol 45 * 46 * Derived from Xerox NS Routing Information Protocol 47 * by changing 32-bit net numbers to sockaddr's and 48 * padding stuff to 32-bit boundaries. 49 */ |
46#define RIPVERSION 1 | |
47 | 50 |
51#define RIPv1 1 52#define RIPv2 2 53#ifndef RIPVERSION 54#define RIPVERSION RIPv1 55#endif 56 57#define RIP_PORT 520 58 59#if RIPVERSION == 1 60/* Note that this so called sockaddr has a 2-byte sa_family and no sa_len. 61 * It is not a UNIX sockaddr, but the shape of an address as defined 62 * in RIPv1. 63 */ |
|
48struct netinfo { 49 struct sockaddr rip_dst; /* destination net/host */ 50 int rip_metric; /* cost of route */ 51}; | 64struct netinfo { 65 struct sockaddr rip_dst; /* destination net/host */ 66 int rip_metric; /* cost of route */ 67}; |
68#else 69struct netinfo { 70 u_short n_family; 71#define RIP_AF_INET htons(AF_INET) 72#define RIP_AF_UNSPEC 0 73#define RIP_AF_AUTH 0xffff 74 u_short n_tag; /* optional in RIPv2 */ 75 u_int n_dst; /* destination net or host */ 76#define RIP_DEFAULT 0 77 u_int n_mask; /* netmask in RIPv2 */ 78 u_int n_nhop; /* optional next hop in RIPv2 */ 79 u_int n_metric; /* cost of route */ 80}; 81#endif |
|
52 | 82 |
83/* RIPv2 authentication */ 84struct netauth { 85 u_short a_type; 86#define RIP_AUTH_PW htons(2) /* password type */ 87 union { 88#define RIP_AUTH_PW_LEN 16 89 char au_pw[RIP_AUTH_PW_LEN]; 90 } au; 91}; 92 |
|
53struct rip { 54 u_char rip_cmd; /* request/response */ 55 u_char rip_vers; /* protocol version # */ | 93struct rip { 94 u_char rip_cmd; /* request/response */ 95 u_char rip_vers; /* protocol version # */ |
56 u_char rip_res1[2]; /* pad to 32-bit boundary */ 57 union { 58 struct netinfo ru_nets[1]; /* variable length... */ 59 char ru_tracefile[1]; /* ditto ... */ | 96 u_short rip_res1; /* pad to 32-bit boundary */ 97 union { /* variable length... */ 98 struct netinfo ru_nets[1]; 99 char ru_tracefile[1]; 100 struct netauth ru_auth[1]; |
60 } ripun; 61#define rip_nets ripun.ru_nets 62#define rip_tracefile ripun.ru_tracefile 63}; 64 | 101 } ripun; 102#define rip_nets ripun.ru_nets 103#define rip_tracefile ripun.ru_tracefile 104}; 105 |
65/* 66 * Packet types. | 106/* Packet types. |
67 */ 68#define RIPCMD_REQUEST 1 /* want info */ 69#define RIPCMD_RESPONSE 2 /* responding to request */ 70#define RIPCMD_TRACEON 3 /* turn tracing on */ 71#define RIPCMD_TRACEOFF 4 /* turn it off */ 72 | 107 */ 108#define RIPCMD_REQUEST 1 /* want info */ 109#define RIPCMD_RESPONSE 2 /* responding to request */ 110#define RIPCMD_TRACEON 3 /* turn tracing on */ 111#define RIPCMD_TRACEOFF 4 /* turn it off */ 112 |
73#define RIPCMD_MAX 5 | 113/* Gated extended RIP to include a "poll" command instead of using 114 * RIPCMD_REQUEST with (RIP_AF_UNSPEC, RIP_DEFAULT). RFC 1058 says 115 * command 5 is used by Sun Microsystems for its own purposes. 116 */ 117#define RIPCMD_POLL 5 118 119#define RIPCMD_MAX 6 120 |
74#ifdef RIPCMDS | 121#ifdef RIPCMDS |
75char *ripcmds[RIPCMD_MAX] = 76 { "#0", "REQUEST", "RESPONSE", "TRACEON", "TRACEOFF" }; | 122char *ripcmds[RIPCMD_MAX] = { 123 "#0", "REQUEST", "RESPONSE", "TRACEON", "TRACEOFF" 124}; |
77#endif 78 | 125#endif 126 |
79#define HOPCNT_INFINITY 16 /* per Xerox NS */ | 127#define HOPCNT_INFINITY 16 |
80#define MAXPACKETSIZE 512 /* max broadcast size */ | 128#define MAXPACKETSIZE 512 /* max broadcast size */ |
129#define NETS_LEN ((MAXPACKETSIZE-sizeof(struct rip)) \ 130 / sizeof(struct netinfo) +1) |
|
81 | 131 |
82/* 83 * Timer values used in managing the routing table. | 132#define INADDR_RIP_GROUP (u_long)0xe0000009 /* 224.0.0.9 */ 133 134 135/* Timer values used in managing the routing table. 136 * |
84 * Complete tables are broadcast every SUPPLY_INTERVAL seconds. 85 * If changes occur between updates, dynamic updates containing only changes 86 * may be sent. When these are sent, a timer is set for a random value 87 * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates 88 * are sent until the timer expires. 89 * 90 * Every update of a routing entry forces an entry's timer to be reset. 91 * After EXPIRE_TIME without updates, the entry is marked invalid, | 137 * Complete tables are broadcast every SUPPLY_INTERVAL seconds. 138 * If changes occur between updates, dynamic updates containing only changes 139 * may be sent. When these are sent, a timer is set for a random value 140 * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates 141 * are sent until the timer expires. 142 * 143 * Every update of a routing entry forces an entry's timer to be reset. 144 * After EXPIRE_TIME without updates, the entry is marked invalid, |
92 * but held onto until GARBAGE_TIME so that others may 93 * see it "be deleted". | 145 * but held onto until GARBAGE_TIME so that others may see it, to 146 * "poison" the bad route. |
94 */ | 147 */ |
95#define TIMER_RATE 30 /* alarm clocks every 30 seconds */ 96 | |
97#define SUPPLY_INTERVAL 30 /* time to supply tables */ | 148#define SUPPLY_INTERVAL 30 /* time to supply tables */ |
98#define MIN_WAITTIME 2 /* min. interval to broadcast changes */ 99#define MAX_WAITTIME 5 /* max. time to delay changes */ | 149#define MIN_WAITTIME 2 /* min sec until next flash updates */ 150#define MAX_WAITTIME 5 /* max sec until flash update */ |
100 | 151 |
152#define STALE_TIME 90 /* switch to a new gateway */ |
|
101#define EXPIRE_TIME 180 /* time to mark entry invalid */ 102#define GARBAGE_TIME 240 /* time to garbage collect */ 103 | 153#define EXPIRE_TIME 180 /* time to mark entry invalid */ 154#define GARBAGE_TIME 240 /* time to garbage collect */ 155 |
156/* It is good to continue advertising bad routes this long so other 157 * routers notice. This is fairly cheap, so it can be long. It 158 * should be long to combat bogus holddowns implemented by major 159 * router vendors. 160 */ 161#define POISON_TIME 120 162 163/* Do not switch to a new route for this long after a route has gone 164 * bad, to ensure that the new route is not a remanent of the old route. 165 */ 166#define HOLD_TIME (MAX_WAITTIME*2) 167 168#ifdef __cplusplus 169} 170#endif |
|
104#endif /* !_ROUTED_H_ */ | 171#endif /* !_ROUTED_H_ */ |