17c478bd9Sstevel@tonic-gate /* 245916cd2Sjpk * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 37c478bd9Sstevel@tonic-gate * Use is subject to license terms. 47c478bd9Sstevel@tonic-gate */ 57c478bd9Sstevel@tonic-gate 67c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 77c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 87c478bd9Sstevel@tonic-gate 97c478bd9Sstevel@tonic-gate /* 107c478bd9Sstevel@tonic-gate * Copyright (c) 1983, 1989, 1993 117c478bd9Sstevel@tonic-gate * The Regents of the University of California. All rights reserved. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without 147c478bd9Sstevel@tonic-gate * modification, are permitted provided that the following conditions 157c478bd9Sstevel@tonic-gate * are met: 167c478bd9Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright 177c478bd9Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer. 187c478bd9Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright 197c478bd9Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the 207c478bd9Sstevel@tonic-gate * documentation and/or other materials provided with the distribution. 217c478bd9Sstevel@tonic-gate * 3. All advertising materials mentioning features or use of this software 227c478bd9Sstevel@tonic-gate * must display the following acknowledgment: 237c478bd9Sstevel@tonic-gate * This product includes software developed by the University of 247c478bd9Sstevel@tonic-gate * California, Berkeley and its contributors. 257c478bd9Sstevel@tonic-gate * 4. Neither the name of the University nor the names of its contributors 267c478bd9Sstevel@tonic-gate * may be used to endorse or promote products derived from this software 277c478bd9Sstevel@tonic-gate * without specific prior written permission. 287c478bd9Sstevel@tonic-gate * 297c478bd9Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 307c478bd9Sstevel@tonic-gate * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 317c478bd9Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 327c478bd9Sstevel@tonic-gate * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 337c478bd9Sstevel@tonic-gate * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 347c478bd9Sstevel@tonic-gate * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 357c478bd9Sstevel@tonic-gate * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 367c478bd9Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 377c478bd9Sstevel@tonic-gate * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 387c478bd9Sstevel@tonic-gate * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 397c478bd9Sstevel@tonic-gate * SUCH DAMAGE. 407c478bd9Sstevel@tonic-gate */ 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* 437c478bd9Sstevel@tonic-gate * Routing Information Protocol 447c478bd9Sstevel@tonic-gate * 457c478bd9Sstevel@tonic-gate * Derived from Xerox NS Routing Information Protocol 467c478bd9Sstevel@tonic-gate * by changing 32-bit net numbers to sockaddr's and 477c478bd9Sstevel@tonic-gate * padding stuff to 32-bit boundaries. 487c478bd9Sstevel@tonic-gate */ 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate #ifndef _PROTOCOLS_ROUTED_H 517c478bd9Sstevel@tonic-gate #define _PROTOCOLS_ROUTED_H 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate #ifdef __cplusplus 567c478bd9Sstevel@tonic-gate extern "C" { 577c478bd9Sstevel@tonic-gate #endif 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate /* The RIPv2 protocol is described in RFC 2453 */ 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate #define RIPv1 1 627c478bd9Sstevel@tonic-gate #define RIPv2 2 637c478bd9Sstevel@tonic-gate #ifndef RIPVERSION 647c478bd9Sstevel@tonic-gate #define RIPVERSION RIPv1 657c478bd9Sstevel@tonic-gate #endif 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate #define RIP_PORT 520 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate #if RIPVERSION == RIPv1 707c478bd9Sstevel@tonic-gate struct netinfo { 717c478bd9Sstevel@tonic-gate struct sockaddr rip_dst; /* destination net/host */ 727c478bd9Sstevel@tonic-gate uint32_t rip_metric; /* cost of route */ 737c478bd9Sstevel@tonic-gate }; 747c478bd9Sstevel@tonic-gate #else 757c478bd9Sstevel@tonic-gate struct netinfo { 767c478bd9Sstevel@tonic-gate uint16_t n_family; 777c478bd9Sstevel@tonic-gate #define RIP_AF_INET htons(AF_INET) 787c478bd9Sstevel@tonic-gate #define RIP_AF_UNSPEC 0 797c478bd9Sstevel@tonic-gate #define RIP_AF_AUTH 0xffff 807c478bd9Sstevel@tonic-gate uint16_t n_tag; /* optional in RIPv2 */ 817c478bd9Sstevel@tonic-gate uint32_t n_dst; /* destination net or host */ 827c478bd9Sstevel@tonic-gate #define RIP_DEFAULT 0 837c478bd9Sstevel@tonic-gate uint32_t n_mask; /* netmask in RIPv2 */ 847c478bd9Sstevel@tonic-gate uint32_t n_nhop; /* optional next hop in RIPv2 */ 857c478bd9Sstevel@tonic-gate uint32_t n_metric; /* cost of route */ 867c478bd9Sstevel@tonic-gate }; 877c478bd9Sstevel@tonic-gate #endif /* RIPv1 */ 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate /* RIPv2 authentication */ 907c478bd9Sstevel@tonic-gate struct netauth { 917c478bd9Sstevel@tonic-gate uint16_t a_family; /* always RIP_AF_AUTH */ 927c478bd9Sstevel@tonic-gate uint16_t a_type; 937c478bd9Sstevel@tonic-gate #define RIP_AUTH_NONE 0 947c478bd9Sstevel@tonic-gate #define RIP_AUTH_TRAILER htons(1) /* authentication data */ 957c478bd9Sstevel@tonic-gate #define RIP_AUTH_PW htons(2) /* password type */ 967c478bd9Sstevel@tonic-gate #define RIP_AUTH_MD5 htons(3) /* Keyed MD5 */ 977c478bd9Sstevel@tonic-gate union { 987c478bd9Sstevel@tonic-gate #define RIP_AUTH_PW_LEN 16 997c478bd9Sstevel@tonic-gate uint8_t au_pw[RIP_AUTH_PW_LEN]; 1007c478bd9Sstevel@tonic-gate struct a_md5 { 1017c478bd9Sstevel@tonic-gate int16_t md5_pkt_len; /* RIP-II packet length */ 1027c478bd9Sstevel@tonic-gate int8_t md5_keyid; /* key ID and auth data len */ 1037c478bd9Sstevel@tonic-gate int8_t md5_auth_len; /* 16 */ 1047c478bd9Sstevel@tonic-gate uint32_t md5_seqno; /* sequence number */ 1057c478bd9Sstevel@tonic-gate uint32_t rsvd[2]; /* must be 0 */ 1067c478bd9Sstevel@tonic-gate #define RIP_AUTH_MD5_LEN RIP_AUTH_PW_LEN 1077c478bd9Sstevel@tonic-gate } a_md5; 1087c478bd9Sstevel@tonic-gate } au; 1097c478bd9Sstevel@tonic-gate }; 1107c478bd9Sstevel@tonic-gate 11145916cd2Sjpk struct rip_emetric { 11245916cd2Sjpk uint16_t rip_metric; 11345916cd2Sjpk uint16_t rip_mask; 11445916cd2Sjpk uint32_t rip_token[1]; 11545916cd2Sjpk }; 11645916cd2Sjpk 11745916cd2Sjpk struct rip_sec_entry { 11845916cd2Sjpk uint32_t rip_dst; 11945916cd2Sjpk uint32_t rip_count; 12045916cd2Sjpk struct rip_emetric rip_emetric[1]; 12145916cd2Sjpk }; 12245916cd2Sjpk 1237c478bd9Sstevel@tonic-gate struct rip { 1247c478bd9Sstevel@tonic-gate uint8_t rip_cmd; /* request/response */ 1257c478bd9Sstevel@tonic-gate uint8_t rip_vers; /* protocol version # */ 1267c478bd9Sstevel@tonic-gate uint16_t rip_res1; /* pad to 32-bit boundary */ 1277c478bd9Sstevel@tonic-gate union { /* variable length... */ 1287c478bd9Sstevel@tonic-gate struct netinfo ru_nets[1]; /* variable length... */ 1297c478bd9Sstevel@tonic-gate char ru_tracefile[1]; /* ditto ... */ 1307c478bd9Sstevel@tonic-gate struct netauth ru_auth[1]; 13145916cd2Sjpk struct { 13245916cd2Sjpk uint32_t rip_generation; 13345916cd2Sjpk struct rip_sec_entry rip_sec_entry[1]; 13445916cd2Sjpk } ru_tsol; 1357c478bd9Sstevel@tonic-gate } ripun; 1367c478bd9Sstevel@tonic-gate #define rip_nets ripun.ru_nets 1377c478bd9Sstevel@tonic-gate #define rip_tracefile ripun.ru_tracefile 1387c478bd9Sstevel@tonic-gate #define rip_auths ripun.ru_auth 13945916cd2Sjpk #define rip_tsol ripun.ru_tsol 1407c478bd9Sstevel@tonic-gate }; 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate struct entryinfo { 1437c478bd9Sstevel@tonic-gate struct sockaddr rtu_dst; 1447c478bd9Sstevel@tonic-gate struct sockaddr rtu_router; 1457c478bd9Sstevel@tonic-gate short rtu_flags; 1467c478bd9Sstevel@tonic-gate short rtu_state; 1477c478bd9Sstevel@tonic-gate int rtu_timer; 1487c478bd9Sstevel@tonic-gate int rtu_metric; 1497c478bd9Sstevel@tonic-gate int int_flags; 1507c478bd9Sstevel@tonic-gate char int_name[16]; 1517c478bd9Sstevel@tonic-gate }; 1527c478bd9Sstevel@tonic-gate 153*3173664eSapersson typedef struct rdisc_info_s { 154*3173664eSapersson uint_t info_type; 155*3173664eSapersson uint_t info_version; 156*3173664eSapersson uint_t info_num_of_routers; 157*3173664eSapersson } rdisc_info_t; 158*3173664eSapersson 159*3173664eSapersson /* 160*3173664eSapersson * Structure that is returned with the default router info. 161*3173664eSapersson */ 162*3173664eSapersson typedef struct defr_s { 163*3173664eSapersson uint32_t defr_info_type; 164*3173664eSapersson uint32_t defr_version; 165*3173664eSapersson struct in_addr defr_addr; 166*3173664eSapersson uint32_t defr_index; 167*3173664eSapersson uint32_t defr_life; 168*3173664eSapersson uint32_t defr_pref; 169*3173664eSapersson } defr_t; 170*3173664eSapersson 171*3173664eSapersson 1727c478bd9Sstevel@tonic-gate /* 1737c478bd9Sstevel@tonic-gate * Packet types. 1747c478bd9Sstevel@tonic-gate */ 1757c478bd9Sstevel@tonic-gate #define RIPCMD_REQUEST 1 /* want info - from suppliers */ 1767c478bd9Sstevel@tonic-gate #define RIPCMD_RESPONSE 2 /* responding to request */ 1777c478bd9Sstevel@tonic-gate #define RIPCMD_TRACEON 3 /* turn tracing on */ 1787c478bd9Sstevel@tonic-gate #define RIPCMD_TRACEOFF 4 /* turn it off */ 1797c478bd9Sstevel@tonic-gate 1807c478bd9Sstevel@tonic-gate /* 1817c478bd9Sstevel@tonic-gate * Gated extended RIP to include a "poll" command instead of using 1827c478bd9Sstevel@tonic-gate * RIPCMD_REQUEST with (RIP_AF_UNSPEC, RIP_DEFAULT). RFC 1058 says 1837c478bd9Sstevel@tonic-gate * command 5 is used by Sun Microsystems for its own purposes. 1847c478bd9Sstevel@tonic-gate */ 1857c478bd9Sstevel@tonic-gate #define RIPCMD_POLL 5 /* like request, but anyone answers */ 1867c478bd9Sstevel@tonic-gate #define RIPCMD_POLLENTRY 6 /* like poll, but for entire entry */ 1877c478bd9Sstevel@tonic-gate 18845916cd2Sjpk #define RIPCMD_SEC_RESPONSE 51 /* response includes E-metrics */ 18945916cd2Sjpk #define RIPCMD_SEC_T_RESPONSE 52 /* tunneling */ 19045916cd2Sjpk 1917c478bd9Sstevel@tonic-gate #define RIPCMD_MAX 7 1927c478bd9Sstevel@tonic-gate 193*3173664eSapersson #define RDISC_SNMP_SOCKET "/var/run/in.rdisc_mib" 194*3173664eSapersson 195*3173664eSapersson #define RDISC_SNMP_INFO_REQ 1 196*3173664eSapersson #define RDISC_SNMP_INFO_RESPONSE 2 197*3173664eSapersson #define RDISC_DEF_ROUTER_INFO 3 198*3173664eSapersson 199*3173664eSapersson #define RDISC_SNMP_INFO_VER 1 200*3173664eSapersson #define RDISC_DEF_ROUTER_VER 1 201*3173664eSapersson 2027c478bd9Sstevel@tonic-gate #define HOPCNT_INFINITY 16 /* per Xerox NS */ 2037c478bd9Sstevel@tonic-gate #define MAXPACKETSIZE 512 /* max broadcast size */ 2047c478bd9Sstevel@tonic-gate #define NETS_LEN ((MAXPACKETSIZE - sizeof (struct rip)) \ 2057c478bd9Sstevel@tonic-gate / sizeof (struct netinfo) +1) 2067c478bd9Sstevel@tonic-gate 2077c478bd9Sstevel@tonic-gate #define INADDR_RIP_GROUP 0xe0000009U /* 224.0.0.9 */ 2087c478bd9Sstevel@tonic-gate 2097c478bd9Sstevel@tonic-gate /* 2107c478bd9Sstevel@tonic-gate * Timer values used in managing the routing table. 2117c478bd9Sstevel@tonic-gate * 2127c478bd9Sstevel@tonic-gate * Complete tables are broadcast every SUPPLY_INTERVAL seconds. 2137c478bd9Sstevel@tonic-gate * If changes occur between updates, dynamic updates containing only changes 2147c478bd9Sstevel@tonic-gate * may be sent. When these are sent, a timer is set for a random value 2157c478bd9Sstevel@tonic-gate * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates 2167c478bd9Sstevel@tonic-gate * are sent until the timer expires. 2177c478bd9Sstevel@tonic-gate * 2187c478bd9Sstevel@tonic-gate * Every update of a routing entry forces an entry's timer to be reset. 2197c478bd9Sstevel@tonic-gate * After EXPIRE_TIME without updates, the entry is marked invalid, 2207c478bd9Sstevel@tonic-gate * but held onto until GARBAGE_TIME so that others may see it, to 2217c478bd9Sstevel@tonic-gate * "poison" the bad route. 2227c478bd9Sstevel@tonic-gate */ 2237c478bd9Sstevel@tonic-gate #define TIMER_RATE 30 /* alarm clocks every 30 seconds */ 2247c478bd9Sstevel@tonic-gate 2257c478bd9Sstevel@tonic-gate #define SUPPLY_INTERVAL 30 /* time to supply tables */ 2267c478bd9Sstevel@tonic-gate #define MIN_WAITTIME 2 /* min sec until next flash updates */ 2277c478bd9Sstevel@tonic-gate #define MAX_WAITTIME 5 /* max sec until flash update */ 2287c478bd9Sstevel@tonic-gate 2297c478bd9Sstevel@tonic-gate #define STALE_TIME 90 /* switch to a new gateway */ 2307c478bd9Sstevel@tonic-gate #define EXPIRE_TIME 180 /* time to mark entry invalid */ 2317c478bd9Sstevel@tonic-gate #define GARBAGE_TIME 300 /* time to garbage collect */ 2327c478bd9Sstevel@tonic-gate 2337c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2347c478bd9Sstevel@tonic-gate } 2357c478bd9Sstevel@tonic-gate #endif 2367c478bd9Sstevel@tonic-gate 2377c478bd9Sstevel@tonic-gate #endif /* _PROTOCOLS_ROUTED_H */ 238