1*53ee8cc1Swenshuai.xi /*- 2*53ee8cc1Swenshuai.xi * Copyright (c) 1983, 1989, 1993 3*53ee8cc1Swenshuai.xi * The Regents of the University of California. All rights reserved. 4*53ee8cc1Swenshuai.xi * 5*53ee8cc1Swenshuai.xi * Redistribution and use in source and binary forms, with or without 6*53ee8cc1Swenshuai.xi * modification, are permitted provided that the following conditions 7*53ee8cc1Swenshuai.xi * are met: 8*53ee8cc1Swenshuai.xi * 1. Redistributions of source code must retain the above copyright 9*53ee8cc1Swenshuai.xi * notice, this list of conditions and the following disclaimer. 10*53ee8cc1Swenshuai.xi * 2. Redistributions in binary form must reproduce the above copyright 11*53ee8cc1Swenshuai.xi * notice, this list of conditions and the following disclaimer in the 12*53ee8cc1Swenshuai.xi * documentation and/or other materials provided with the distribution. 13*53ee8cc1Swenshuai.xi * 4. Neither the name of the University nor the names of its contributors 14*53ee8cc1Swenshuai.xi * may be used to endorse or promote products derived from this software 15*53ee8cc1Swenshuai.xi * without specific prior written permission. 16*53ee8cc1Swenshuai.xi * 17*53ee8cc1Swenshuai.xi * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18*53ee8cc1Swenshuai.xi * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19*53ee8cc1Swenshuai.xi * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20*53ee8cc1Swenshuai.xi * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21*53ee8cc1Swenshuai.xi * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22*53ee8cc1Swenshuai.xi * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23*53ee8cc1Swenshuai.xi * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24*53ee8cc1Swenshuai.xi * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25*53ee8cc1Swenshuai.xi * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26*53ee8cc1Swenshuai.xi * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27*53ee8cc1Swenshuai.xi * SUCH DAMAGE. 28*53ee8cc1Swenshuai.xi * 29*53ee8cc1Swenshuai.xi * @(#)routed.h 8.1 (Berkeley) 6/2/93 30*53ee8cc1Swenshuai.xi */ 31*53ee8cc1Swenshuai.xi 32*53ee8cc1Swenshuai.xi #ifndef _PROTOCOLS_ROUTED_H 33*53ee8cc1Swenshuai.xi #define _PROTOCOLS_ROUTED_H 1 34*53ee8cc1Swenshuai.xi 35*53ee8cc1Swenshuai.xi #include <sys/socket.h> 36*53ee8cc1Swenshuai.xi /* 37*53ee8cc1Swenshuai.xi * Routing Information Protocol 38*53ee8cc1Swenshuai.xi * 39*53ee8cc1Swenshuai.xi * Derived from Xerox NS Routing Information Protocol 40*53ee8cc1Swenshuai.xi * by changing 32-bit net numbers to sockaddr's and 41*53ee8cc1Swenshuai.xi * padding stuff to 32-bit boundaries. 42*53ee8cc1Swenshuai.xi */ 43*53ee8cc1Swenshuai.xi #define RIPVERSION 1 44*53ee8cc1Swenshuai.xi 45*53ee8cc1Swenshuai.xi struct netinfo { 46*53ee8cc1Swenshuai.xi struct sockaddr rip_dst; /* destination net/host */ 47*53ee8cc1Swenshuai.xi int rip_metric; /* cost of route */ 48*53ee8cc1Swenshuai.xi }; 49*53ee8cc1Swenshuai.xi 50*53ee8cc1Swenshuai.xi struct rip { 51*53ee8cc1Swenshuai.xi u_char rip_cmd; /* request/response */ 52*53ee8cc1Swenshuai.xi u_char rip_vers; /* protocol version # */ 53*53ee8cc1Swenshuai.xi u_char rip_res1[2]; /* pad to 32-bit boundary */ 54*53ee8cc1Swenshuai.xi union { 55*53ee8cc1Swenshuai.xi struct netinfo ru_nets[1]; /* variable length... */ 56*53ee8cc1Swenshuai.xi char ru_tracefile[1]; /* ditto ... */ 57*53ee8cc1Swenshuai.xi } ripun; 58*53ee8cc1Swenshuai.xi #define rip_nets ripun.ru_nets 59*53ee8cc1Swenshuai.xi #define rip_tracefile ripun.ru_tracefile 60*53ee8cc1Swenshuai.xi }; 61*53ee8cc1Swenshuai.xi 62*53ee8cc1Swenshuai.xi /* 63*53ee8cc1Swenshuai.xi * Packet types. 64*53ee8cc1Swenshuai.xi */ 65*53ee8cc1Swenshuai.xi #define RIPCMD_REQUEST 1 /* want info */ 66*53ee8cc1Swenshuai.xi #define RIPCMD_RESPONSE 2 /* responding to request */ 67*53ee8cc1Swenshuai.xi #define RIPCMD_TRACEON 3 /* turn tracing on */ 68*53ee8cc1Swenshuai.xi #define RIPCMD_TRACEOFF 4 /* turn it off */ 69*53ee8cc1Swenshuai.xi 70*53ee8cc1Swenshuai.xi #define RIPCMD_MAX 5 71*53ee8cc1Swenshuai.xi #ifdef RIPCMDS 72*53ee8cc1Swenshuai.xi char *ripcmds[RIPCMD_MAX] = 73*53ee8cc1Swenshuai.xi { "#0", "REQUEST", "RESPONSE", "TRACEON", "TRACEOFF" }; 74*53ee8cc1Swenshuai.xi #endif 75*53ee8cc1Swenshuai.xi 76*53ee8cc1Swenshuai.xi #define HOPCNT_INFINITY 16 /* per Xerox NS */ 77*53ee8cc1Swenshuai.xi #define MAXPACKETSIZE 512 /* max broadcast size */ 78*53ee8cc1Swenshuai.xi 79*53ee8cc1Swenshuai.xi /* 80*53ee8cc1Swenshuai.xi * Timer values used in managing the routing table. 81*53ee8cc1Swenshuai.xi * Complete tables are broadcast every SUPPLY_INTERVAL seconds. 82*53ee8cc1Swenshuai.xi * If changes occur between updates, dynamic updates containing only changes 83*53ee8cc1Swenshuai.xi * may be sent. When these are sent, a timer is set for a random value 84*53ee8cc1Swenshuai.xi * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates 85*53ee8cc1Swenshuai.xi * are sent until the timer expires. 86*53ee8cc1Swenshuai.xi * 87*53ee8cc1Swenshuai.xi * Every update of a routing entry forces an entry's timer to be reset. 88*53ee8cc1Swenshuai.xi * After EXPIRE_TIME without updates, the entry is marked invalid, 89*53ee8cc1Swenshuai.xi * but held onto until GARBAGE_TIME so that others may 90*53ee8cc1Swenshuai.xi * see it "be deleted". 91*53ee8cc1Swenshuai.xi */ 92*53ee8cc1Swenshuai.xi #define TIMER_RATE 30 /* alarm clocks every 30 seconds */ 93*53ee8cc1Swenshuai.xi 94*53ee8cc1Swenshuai.xi #define SUPPLY_INTERVAL 30 /* time to supply tables */ 95*53ee8cc1Swenshuai.xi #define MIN_WAITTIME 2 /* min. interval to broadcast changes */ 96*53ee8cc1Swenshuai.xi #define MAX_WAITTIME 5 /* max. time to delay changes */ 97*53ee8cc1Swenshuai.xi 98*53ee8cc1Swenshuai.xi #define EXPIRE_TIME 180 /* time to mark entry invalid */ 99*53ee8cc1Swenshuai.xi #define GARBAGE_TIME 240 /* time to garbage collect */ 100*53ee8cc1Swenshuai.xi 101*53ee8cc1Swenshuai.xi #endif /* protocols/routed.h */ 102