17c478bd9Sstevel@tonic-gate /* 2*45916cd2Sjpk * 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 111*45916cd2Sjpk struct rip_emetric { 112*45916cd2Sjpk uint16_t rip_metric; 113*45916cd2Sjpk uint16_t rip_mask; 114*45916cd2Sjpk uint32_t rip_token[1]; 115*45916cd2Sjpk }; 116*45916cd2Sjpk 117*45916cd2Sjpk struct rip_sec_entry { 118*45916cd2Sjpk uint32_t rip_dst; 119*45916cd2Sjpk uint32_t rip_count; 120*45916cd2Sjpk struct rip_emetric rip_emetric[1]; 121*45916cd2Sjpk }; 122*45916cd2Sjpk 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]; 131*45916cd2Sjpk struct { 132*45916cd2Sjpk uint32_t rip_generation; 133*45916cd2Sjpk struct rip_sec_entry rip_sec_entry[1]; 134*45916cd2Sjpk } 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 139*45916cd2Sjpk #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 1537c478bd9Sstevel@tonic-gate /* 1547c478bd9Sstevel@tonic-gate * Packet types. 1557c478bd9Sstevel@tonic-gate */ 1567c478bd9Sstevel@tonic-gate #define RIPCMD_REQUEST 1 /* want info - from suppliers */ 1577c478bd9Sstevel@tonic-gate #define RIPCMD_RESPONSE 2 /* responding to request */ 1587c478bd9Sstevel@tonic-gate #define RIPCMD_TRACEON 3 /* turn tracing on */ 1597c478bd9Sstevel@tonic-gate #define RIPCMD_TRACEOFF 4 /* turn it off */ 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate /* 1627c478bd9Sstevel@tonic-gate * Gated extended RIP to include a "poll" command instead of using 1637c478bd9Sstevel@tonic-gate * RIPCMD_REQUEST with (RIP_AF_UNSPEC, RIP_DEFAULT). RFC 1058 says 1647c478bd9Sstevel@tonic-gate * command 5 is used by Sun Microsystems for its own purposes. 1657c478bd9Sstevel@tonic-gate */ 1667c478bd9Sstevel@tonic-gate #define RIPCMD_POLL 5 /* like request, but anyone answers */ 1677c478bd9Sstevel@tonic-gate #define RIPCMD_POLLENTRY 6 /* like poll, but for entire entry */ 1687c478bd9Sstevel@tonic-gate 169*45916cd2Sjpk #define RIPCMD_SEC_RESPONSE 51 /* response includes E-metrics */ 170*45916cd2Sjpk #define RIPCMD_SEC_T_RESPONSE 52 /* tunneling */ 171*45916cd2Sjpk 1727c478bd9Sstevel@tonic-gate #define RIPCMD_MAX 7 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate #define HOPCNT_INFINITY 16 /* per Xerox NS */ 1757c478bd9Sstevel@tonic-gate #define MAXPACKETSIZE 512 /* max broadcast size */ 1767c478bd9Sstevel@tonic-gate #define NETS_LEN ((MAXPACKETSIZE - sizeof (struct rip)) \ 1777c478bd9Sstevel@tonic-gate / sizeof (struct netinfo) +1) 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate #define INADDR_RIP_GROUP 0xe0000009U /* 224.0.0.9 */ 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate /* 1827c478bd9Sstevel@tonic-gate * Timer values used in managing the routing table. 1837c478bd9Sstevel@tonic-gate * 1847c478bd9Sstevel@tonic-gate * Complete tables are broadcast every SUPPLY_INTERVAL seconds. 1857c478bd9Sstevel@tonic-gate * If changes occur between updates, dynamic updates containing only changes 1867c478bd9Sstevel@tonic-gate * may be sent. When these are sent, a timer is set for a random value 1877c478bd9Sstevel@tonic-gate * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates 1887c478bd9Sstevel@tonic-gate * are sent until the timer expires. 1897c478bd9Sstevel@tonic-gate * 1907c478bd9Sstevel@tonic-gate * Every update of a routing entry forces an entry's timer to be reset. 1917c478bd9Sstevel@tonic-gate * After EXPIRE_TIME without updates, the entry is marked invalid, 1927c478bd9Sstevel@tonic-gate * but held onto until GARBAGE_TIME so that others may see it, to 1937c478bd9Sstevel@tonic-gate * "poison" the bad route. 1947c478bd9Sstevel@tonic-gate */ 1957c478bd9Sstevel@tonic-gate #define TIMER_RATE 30 /* alarm clocks every 30 seconds */ 1967c478bd9Sstevel@tonic-gate 1977c478bd9Sstevel@tonic-gate #define SUPPLY_INTERVAL 30 /* time to supply tables */ 1987c478bd9Sstevel@tonic-gate #define MIN_WAITTIME 2 /* min sec until next flash updates */ 1997c478bd9Sstevel@tonic-gate #define MAX_WAITTIME 5 /* max sec until flash update */ 2007c478bd9Sstevel@tonic-gate 2017c478bd9Sstevel@tonic-gate #define STALE_TIME 90 /* switch to a new gateway */ 2027c478bd9Sstevel@tonic-gate #define EXPIRE_TIME 180 /* time to mark entry invalid */ 2037c478bd9Sstevel@tonic-gate #define GARBAGE_TIME 300 /* time to garbage collect */ 2047c478bd9Sstevel@tonic-gate 2057c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2067c478bd9Sstevel@tonic-gate } 2077c478bd9Sstevel@tonic-gate #endif 2087c478bd9Sstevel@tonic-gate 2097c478bd9Sstevel@tonic-gate #endif /* _PROTOCOLS_ROUTED_H */ 210