11539Srgrimes/*- 21539Srgrimes * Copyright (c) 1983, 1989, 1993 31539Srgrimes * The Regents of the University of California. All rights reserved. 41539Srgrimes * 51539Srgrimes * Redistribution and use in source and binary forms, with or without 61539Srgrimes * modification, are permitted provided that the following conditions 71539Srgrimes * are met: 81539Srgrimes * 1. Redistributions of source code must retain the above copyright 91539Srgrimes * notice, this list of conditions and the following disclaimer. 101539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111539Srgrimes * notice, this list of conditions and the following disclaimer in the 121539Srgrimes * documentation and/or other materials provided with the distribution. 13203965Simp * 3. Neither the name of the University nor the names of its contributors 141539Srgrimes * may be used to endorse or promote products derived from this software 151539Srgrimes * without specific prior written permission. 161539Srgrimes * 171539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 181539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 191539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 201539Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 211539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 221539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 231539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 241539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 251539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 261539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 271539Srgrimes * SUCH DAMAGE. 281539Srgrimes * 291539Srgrimes * @(#)routed.h 8.1 (Berkeley) 6/2/93 3017844Swollman * 3150473Speter * $FreeBSD$ 32126250Sbms * $Revision: 2.26 $ 331539Srgrimes */ 341539Srgrimes 3516009Swollman#ifndef _ROUTED_H_ 3616009Swollman#define _ROUTED_H_ 3716009Swollman#ifdef __cplusplus 3816009Swollmanextern "C" { 3916009Swollman#endif 401539Srgrimes 411539Srgrimes/* 421539Srgrimes * Routing Information Protocol 431539Srgrimes * 441539Srgrimes * Derived from Xerox NS Routing Information Protocol 451539Srgrimes * by changing 32-bit net numbers to sockaddr's and 461539Srgrimes * padding stuff to 32-bit boundaries. 471539Srgrimes */ 481539Srgrimes 4916009Swollman#define RIPv1 1 5016009Swollman#define RIPv2 2 5116009Swollman#ifndef RIPVERSION 5216009Swollman#define RIPVERSION RIPv1 5316009Swollman#endif 5416009Swollman 5516009Swollman#define RIP_PORT 520 5617844Swollman 5716009Swollman#if RIPVERSION == 1 5816009Swollman/* Note that this so called sockaddr has a 2-byte sa_family and no sa_len. 5916009Swollman * It is not a UNIX sockaddr, but the shape of an address as defined 6017844Swollman * in RIPv1. It is still defined to allow old versions of programs 6117844Swollman * such as `gated` to use this file to define RIPv1. 6216009Swollman */ 631539Srgrimesstruct netinfo { 641539Srgrimes struct sockaddr rip_dst; /* destination net/host */ 6517844Swollman u_int32_t rip_metric; /* cost of route */ 661539Srgrimes}; 6716009Swollman#else 6816009Swollmanstruct netinfo { 6917844Swollman u_int16_t n_family; 7016009Swollman#define RIP_AF_INET htons(AF_INET) 7116009Swollman#define RIP_AF_UNSPEC 0 7216009Swollman#define RIP_AF_AUTH 0xffff 7317844Swollman u_int16_t n_tag; /* optional in RIPv2 */ 7417844Swollman u_int32_t n_dst; /* destination net or host */ 7516009Swollman#define RIP_DEFAULT 0 7617844Swollman u_int32_t n_mask; /* netmask in RIPv2 */ 7717844Swollman u_int32_t n_nhop; /* optional next hop in RIPv2 */ 7817844Swollman u_int32_t n_metric; /* cost of route */ 7916009Swollman}; 8016009Swollman#endif 811539Srgrimes 8216009Swollman/* RIPv2 authentication */ 8316009Swollmanstruct netauth { 8419886Swollman u_int16_t a_family; /* always RIP_AF_AUTH */ 8517844Swollman u_int16_t a_type; 8619886Swollman#define RIP_AUTH_NONE 0 8716009Swollman#define RIP_AUTH_PW htons(2) /* password type */ 8819886Swollman#define RIP_AUTH_MD5 htons(3) /* Keyed MD5 */ 8916009Swollman union { 9016009Swollman#define RIP_AUTH_PW_LEN 16 9119886Swollman u_int8_t au_pw[RIP_AUTH_PW_LEN]; 9219886Swollman struct a_md5 { 9319886Swollman int16_t md5_pkt_len; /* RIP-II packet length */ 9419886Swollman int8_t md5_keyid; /* key ID and auth data len */ 9519886Swollman int8_t md5_auth_len; /* 16 */ 9619886Swollman u_int32_t md5_seqno; /* sequence number */ 9719886Swollman u_int32_t rsvd[2]; /* must be 0 */ 98126250Sbms#define RIP_AUTH_MD5_KEY_LEN RIP_AUTH_PW_LEN 99126250Sbms#define RIP_AUTH_MD5_HASH_XTRA (sizeof(struct netauth)-sizeof(struct a_md5)) 100126250Sbms#define RIP_AUTH_MD5_HASH_LEN (RIP_AUTH_MD5_KEY_LEN+RIP_AUTH_MD5_HASH_XTRA) 10119886Swollman } a_md5; 10216009Swollman } au; 10316009Swollman}; 10416009Swollman 1051539Srgrimesstruct rip { 10617844Swollman u_int8_t rip_cmd; /* request/response */ 10717844Swollman u_int8_t rip_vers; /* protocol version # */ 10817844Swollman u_int16_t rip_res1; /* pad to 32-bit boundary */ 10916009Swollman union { /* variable length... */ 11016009Swollman struct netinfo ru_nets[1]; 11117844Swollman int8_t ru_tracefile[1]; 11216009Swollman struct netauth ru_auth[1]; 1131539Srgrimes } ripun; 1141539Srgrimes#define rip_nets ripun.ru_nets 11519886Swollman#define rip_auths ripun.ru_auth 1161539Srgrimes#define rip_tracefile ripun.ru_tracefile 1171539Srgrimes}; 1188858Srgrimes 11916009Swollman/* Packet types. 1201539Srgrimes */ 1211539Srgrimes#define RIPCMD_REQUEST 1 /* want info */ 1221539Srgrimes#define RIPCMD_RESPONSE 2 /* responding to request */ 1231539Srgrimes#define RIPCMD_TRACEON 3 /* turn tracing on */ 1241539Srgrimes#define RIPCMD_TRACEOFF 4 /* turn it off */ 1251539Srgrimes 12616009Swollman/* Gated extended RIP to include a "poll" command instead of using 12716009Swollman * RIPCMD_REQUEST with (RIP_AF_UNSPEC, RIP_DEFAULT). RFC 1058 says 12816009Swollman * command 5 is used by Sun Microsystems for its own purposes. 12916009Swollman */ 13016009Swollman#define RIPCMD_POLL 5 13116009Swollman 13216009Swollman#define RIPCMD_MAX 6 13316009Swollman 1341539Srgrimes#ifdef RIPCMDS 13546305Smarkmconst char *ripcmds[RIPCMD_MAX] = { 13616009Swollman "#0", "REQUEST", "RESPONSE", "TRACEON", "TRACEOFF" 13716009Swollman}; 1381539Srgrimes#endif 1391539Srgrimes 14016009Swollman#define HOPCNT_INFINITY 16 1411539Srgrimes#define MAXPACKETSIZE 512 /* max broadcast size */ 14216009Swollman#define NETS_LEN ((MAXPACKETSIZE-sizeof(struct rip)) \ 14316009Swollman / sizeof(struct netinfo) +1) 1441539Srgrimes 14517844Swollman#define INADDR_RIP_GROUP (u_int32_t)0xe0000009 /* 224.0.0.9 */ 14616009Swollman 14716009Swollman 14816009Swollman/* Timer values used in managing the routing table. 14916009Swollman * 1501539Srgrimes * Complete tables are broadcast every SUPPLY_INTERVAL seconds. 1511539Srgrimes * If changes occur between updates, dynamic updates containing only changes 1521539Srgrimes * may be sent. When these are sent, a timer is set for a random value 1531539Srgrimes * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates 1541539Srgrimes * are sent until the timer expires. 1551539Srgrimes * 1561539Srgrimes * Every update of a routing entry forces an entry's timer to be reset. 1571539Srgrimes * After EXPIRE_TIME without updates, the entry is marked invalid, 15816009Swollman * but held onto until GARBAGE_TIME so that others may see it, to 15916009Swollman * "poison" the bad route. 1601539Srgrimes */ 1611539Srgrimes#define SUPPLY_INTERVAL 30 /* time to supply tables */ 16216009Swollman#define MIN_WAITTIME 2 /* min sec until next flash updates */ 16316009Swollman#define MAX_WAITTIME 5 /* max sec until flash update */ 1641539Srgrimes 16516009Swollman#define STALE_TIME 90 /* switch to a new gateway */ 1661539Srgrimes#define EXPIRE_TIME 180 /* time to mark entry invalid */ 1671539Srgrimes#define GARBAGE_TIME 240 /* time to garbage collect */ 1681539Srgrimes 16916009Swollman#ifdef __cplusplus 17016009Swollman} 17116009Swollman#endif 1721539Srgrimes#endif /* !_ROUTED_H_ */ 173