10Sstevel@tonic-gate /* 21676Sjpk * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 30Sstevel@tonic-gate * Use is subject to license terms. 40Sstevel@tonic-gate */ 50Sstevel@tonic-gate 60Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 70Sstevel@tonic-gate /* All Rights Reserved */ 80Sstevel@tonic-gate 90Sstevel@tonic-gate /* 100Sstevel@tonic-gate * Copyright (c) 1983, 1989, 1993 110Sstevel@tonic-gate * The Regents of the University of California. All rights reserved. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without 140Sstevel@tonic-gate * modification, are permitted provided that the following conditions 150Sstevel@tonic-gate * are met: 160Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright 170Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer. 180Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright 190Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the 200Sstevel@tonic-gate * documentation and/or other materials provided with the distribution. 210Sstevel@tonic-gate * 3. All advertising materials mentioning features or use of this software 220Sstevel@tonic-gate * must display the following acknowledgment: 230Sstevel@tonic-gate * This product includes software developed by the University of 240Sstevel@tonic-gate * California, Berkeley and its contributors. 250Sstevel@tonic-gate * 4. Neither the name of the University nor the names of its contributors 260Sstevel@tonic-gate * may be used to endorse or promote products derived from this software 270Sstevel@tonic-gate * without specific prior written permission. 280Sstevel@tonic-gate * 290Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 300Sstevel@tonic-gate * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 310Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 320Sstevel@tonic-gate * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 330Sstevel@tonic-gate * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 340Sstevel@tonic-gate * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 350Sstevel@tonic-gate * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 360Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 370Sstevel@tonic-gate * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 380Sstevel@tonic-gate * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 390Sstevel@tonic-gate * SUCH DAMAGE. 400Sstevel@tonic-gate */ 410Sstevel@tonic-gate 420Sstevel@tonic-gate /* 430Sstevel@tonic-gate * Routing Information Protocol 440Sstevel@tonic-gate * 450Sstevel@tonic-gate * Derived from Xerox NS Routing Information Protocol 460Sstevel@tonic-gate * by changing 32-bit net numbers to sockaddr's and 470Sstevel@tonic-gate * padding stuff to 32-bit boundaries. 480Sstevel@tonic-gate */ 490Sstevel@tonic-gate 500Sstevel@tonic-gate #ifndef _PROTOCOLS_ROUTED_H 510Sstevel@tonic-gate #define _PROTOCOLS_ROUTED_H 520Sstevel@tonic-gate 530Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 540Sstevel@tonic-gate 550Sstevel@tonic-gate #ifdef __cplusplus 560Sstevel@tonic-gate extern "C" { 570Sstevel@tonic-gate #endif 580Sstevel@tonic-gate 590Sstevel@tonic-gate /* The RIPv2 protocol is described in RFC 2453 */ 600Sstevel@tonic-gate 610Sstevel@tonic-gate #define RIPv1 1 620Sstevel@tonic-gate #define RIPv2 2 630Sstevel@tonic-gate #ifndef RIPVERSION 640Sstevel@tonic-gate #define RIPVERSION RIPv1 650Sstevel@tonic-gate #endif 660Sstevel@tonic-gate 670Sstevel@tonic-gate #define RIP_PORT 520 680Sstevel@tonic-gate 690Sstevel@tonic-gate #if RIPVERSION == RIPv1 700Sstevel@tonic-gate struct netinfo { 710Sstevel@tonic-gate struct sockaddr rip_dst; /* destination net/host */ 720Sstevel@tonic-gate uint32_t rip_metric; /* cost of route */ 730Sstevel@tonic-gate }; 740Sstevel@tonic-gate #else 750Sstevel@tonic-gate struct netinfo { 760Sstevel@tonic-gate uint16_t n_family; 770Sstevel@tonic-gate #define RIP_AF_INET htons(AF_INET) 780Sstevel@tonic-gate #define RIP_AF_UNSPEC 0 790Sstevel@tonic-gate #define RIP_AF_AUTH 0xffff 800Sstevel@tonic-gate uint16_t n_tag; /* optional in RIPv2 */ 810Sstevel@tonic-gate uint32_t n_dst; /* destination net or host */ 820Sstevel@tonic-gate #define RIP_DEFAULT 0 830Sstevel@tonic-gate uint32_t n_mask; /* netmask in RIPv2 */ 840Sstevel@tonic-gate uint32_t n_nhop; /* optional next hop in RIPv2 */ 850Sstevel@tonic-gate uint32_t n_metric; /* cost of route */ 860Sstevel@tonic-gate }; 870Sstevel@tonic-gate #endif /* RIPv1 */ 880Sstevel@tonic-gate 890Sstevel@tonic-gate /* RIPv2 authentication */ 900Sstevel@tonic-gate struct netauth { 910Sstevel@tonic-gate uint16_t a_family; /* always RIP_AF_AUTH */ 920Sstevel@tonic-gate uint16_t a_type; 930Sstevel@tonic-gate #define RIP_AUTH_NONE 0 940Sstevel@tonic-gate #define RIP_AUTH_TRAILER htons(1) /* authentication data */ 950Sstevel@tonic-gate #define RIP_AUTH_PW htons(2) /* password type */ 960Sstevel@tonic-gate #define RIP_AUTH_MD5 htons(3) /* Keyed MD5 */ 970Sstevel@tonic-gate union { 980Sstevel@tonic-gate #define RIP_AUTH_PW_LEN 16 990Sstevel@tonic-gate uint8_t au_pw[RIP_AUTH_PW_LEN]; 1000Sstevel@tonic-gate struct a_md5 { 1010Sstevel@tonic-gate int16_t md5_pkt_len; /* RIP-II packet length */ 1020Sstevel@tonic-gate int8_t md5_keyid; /* key ID and auth data len */ 1030Sstevel@tonic-gate int8_t md5_auth_len; /* 16 */ 1040Sstevel@tonic-gate uint32_t md5_seqno; /* sequence number */ 1050Sstevel@tonic-gate uint32_t rsvd[2]; /* must be 0 */ 1060Sstevel@tonic-gate #define RIP_AUTH_MD5_LEN RIP_AUTH_PW_LEN 1070Sstevel@tonic-gate } a_md5; 1080Sstevel@tonic-gate } au; 1090Sstevel@tonic-gate }; 1100Sstevel@tonic-gate 1111676Sjpk struct rip_emetric { 1121676Sjpk uint16_t rip_metric; 1131676Sjpk uint16_t rip_mask; 1141676Sjpk uint32_t rip_token[1]; 1151676Sjpk }; 1161676Sjpk 1171676Sjpk struct rip_sec_entry { 1181676Sjpk uint32_t rip_dst; 1191676Sjpk uint32_t rip_count; 1201676Sjpk struct rip_emetric rip_emetric[1]; 1211676Sjpk }; 1221676Sjpk 1230Sstevel@tonic-gate struct rip { 1240Sstevel@tonic-gate uint8_t rip_cmd; /* request/response */ 1250Sstevel@tonic-gate uint8_t rip_vers; /* protocol version # */ 1260Sstevel@tonic-gate uint16_t rip_res1; /* pad to 32-bit boundary */ 1270Sstevel@tonic-gate union { /* variable length... */ 1280Sstevel@tonic-gate struct netinfo ru_nets[1]; /* variable length... */ 1290Sstevel@tonic-gate char ru_tracefile[1]; /* ditto ... */ 1300Sstevel@tonic-gate struct netauth ru_auth[1]; 1311676Sjpk struct { 1321676Sjpk uint32_t rip_generation; 1331676Sjpk struct rip_sec_entry rip_sec_entry[1]; 1341676Sjpk } ru_tsol; 1350Sstevel@tonic-gate } ripun; 1360Sstevel@tonic-gate #define rip_nets ripun.ru_nets 1370Sstevel@tonic-gate #define rip_tracefile ripun.ru_tracefile 1380Sstevel@tonic-gate #define rip_auths ripun.ru_auth 1391676Sjpk #define rip_tsol ripun.ru_tsol 1400Sstevel@tonic-gate }; 1410Sstevel@tonic-gate 1420Sstevel@tonic-gate struct entryinfo { 1430Sstevel@tonic-gate struct sockaddr rtu_dst; 1440Sstevel@tonic-gate struct sockaddr rtu_router; 1450Sstevel@tonic-gate short rtu_flags; 1460Sstevel@tonic-gate short rtu_state; 1470Sstevel@tonic-gate int rtu_timer; 1480Sstevel@tonic-gate int rtu_metric; 1490Sstevel@tonic-gate int int_flags; 1500Sstevel@tonic-gate char int_name[16]; 1510Sstevel@tonic-gate }; 1520Sstevel@tonic-gate 153*3284Sapersson typedef struct rdisc_info_s { 154*3284Sapersson uint_t info_type; 155*3284Sapersson uint_t info_version; 156*3284Sapersson uint_t info_num_of_routers; 157*3284Sapersson } rdisc_info_t; 158*3284Sapersson 159*3284Sapersson /* 160*3284Sapersson * Structure that is returned with the default router info. 161*3284Sapersson */ 162*3284Sapersson typedef struct defr_s { 163*3284Sapersson uint32_t defr_info_type; 164*3284Sapersson uint32_t defr_version; 165*3284Sapersson struct in_addr defr_addr; 166*3284Sapersson uint32_t defr_index; 167*3284Sapersson uint32_t defr_life; 168*3284Sapersson uint32_t defr_pref; 169*3284Sapersson } defr_t; 170*3284Sapersson 171*3284Sapersson 1720Sstevel@tonic-gate /* 1730Sstevel@tonic-gate * Packet types. 1740Sstevel@tonic-gate */ 1750Sstevel@tonic-gate #define RIPCMD_REQUEST 1 /* want info - from suppliers */ 1760Sstevel@tonic-gate #define RIPCMD_RESPONSE 2 /* responding to request */ 1770Sstevel@tonic-gate #define RIPCMD_TRACEON 3 /* turn tracing on */ 1780Sstevel@tonic-gate #define RIPCMD_TRACEOFF 4 /* turn it off */ 1790Sstevel@tonic-gate 1800Sstevel@tonic-gate /* 1810Sstevel@tonic-gate * Gated extended RIP to include a "poll" command instead of using 1820Sstevel@tonic-gate * RIPCMD_REQUEST with (RIP_AF_UNSPEC, RIP_DEFAULT). RFC 1058 says 1830Sstevel@tonic-gate * command 5 is used by Sun Microsystems for its own purposes. 1840Sstevel@tonic-gate */ 1850Sstevel@tonic-gate #define RIPCMD_POLL 5 /* like request, but anyone answers */ 1860Sstevel@tonic-gate #define RIPCMD_POLLENTRY 6 /* like poll, but for entire entry */ 1870Sstevel@tonic-gate 1881676Sjpk #define RIPCMD_SEC_RESPONSE 51 /* response includes E-metrics */ 1891676Sjpk #define RIPCMD_SEC_T_RESPONSE 52 /* tunneling */ 1901676Sjpk 1910Sstevel@tonic-gate #define RIPCMD_MAX 7 1920Sstevel@tonic-gate 193*3284Sapersson #define RDISC_SNMP_SOCKET "/var/run/in.rdisc_mib" 194*3284Sapersson 195*3284Sapersson #define RDISC_SNMP_INFO_REQ 1 196*3284Sapersson #define RDISC_SNMP_INFO_RESPONSE 2 197*3284Sapersson #define RDISC_DEF_ROUTER_INFO 3 198*3284Sapersson 199*3284Sapersson #define RDISC_SNMP_INFO_VER 1 200*3284Sapersson #define RDISC_DEF_ROUTER_VER 1 201*3284Sapersson 2020Sstevel@tonic-gate #define HOPCNT_INFINITY 16 /* per Xerox NS */ 2030Sstevel@tonic-gate #define MAXPACKETSIZE 512 /* max broadcast size */ 2040Sstevel@tonic-gate #define NETS_LEN ((MAXPACKETSIZE - sizeof (struct rip)) \ 2050Sstevel@tonic-gate / sizeof (struct netinfo) +1) 2060Sstevel@tonic-gate 2070Sstevel@tonic-gate #define INADDR_RIP_GROUP 0xe0000009U /* 224.0.0.9 */ 2080Sstevel@tonic-gate 2090Sstevel@tonic-gate /* 2100Sstevel@tonic-gate * Timer values used in managing the routing table. 2110Sstevel@tonic-gate * 2120Sstevel@tonic-gate * Complete tables are broadcast every SUPPLY_INTERVAL seconds. 2130Sstevel@tonic-gate * If changes occur between updates, dynamic updates containing only changes 2140Sstevel@tonic-gate * may be sent. When these are sent, a timer is set for a random value 2150Sstevel@tonic-gate * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates 2160Sstevel@tonic-gate * are sent until the timer expires. 2170Sstevel@tonic-gate * 2180Sstevel@tonic-gate * Every update of a routing entry forces an entry's timer to be reset. 2190Sstevel@tonic-gate * After EXPIRE_TIME without updates, the entry is marked invalid, 2200Sstevel@tonic-gate * but held onto until GARBAGE_TIME so that others may see it, to 2210Sstevel@tonic-gate * "poison" the bad route. 2220Sstevel@tonic-gate */ 2230Sstevel@tonic-gate #define TIMER_RATE 30 /* alarm clocks every 30 seconds */ 2240Sstevel@tonic-gate 2250Sstevel@tonic-gate #define SUPPLY_INTERVAL 30 /* time to supply tables */ 2260Sstevel@tonic-gate #define MIN_WAITTIME 2 /* min sec until next flash updates */ 2270Sstevel@tonic-gate #define MAX_WAITTIME 5 /* max sec until flash update */ 2280Sstevel@tonic-gate 2290Sstevel@tonic-gate #define STALE_TIME 90 /* switch to a new gateway */ 2300Sstevel@tonic-gate #define EXPIRE_TIME 180 /* time to mark entry invalid */ 2310Sstevel@tonic-gate #define GARBAGE_TIME 300 /* time to garbage collect */ 2320Sstevel@tonic-gate 2330Sstevel@tonic-gate #ifdef __cplusplus 2340Sstevel@tonic-gate } 2350Sstevel@tonic-gate #endif 2360Sstevel@tonic-gate 2370Sstevel@tonic-gate #endif /* _PROTOCOLS_ROUTED_H */ 238