1 #ifndef _NET_ROUTE_H_ 2 #define _NET_ROUTE_H_ 3 /* 4 * Generic Routing Routines 5 * 6 * Copyright © 1994-2000 AmiTCP/IP Group, 7 * Network Solutions Development, Inc. 8 * All rights reserved. 9 * 10 * $Id: route.h,v 1.1.1.1 2005/03/15 16:00:46 laire Exp $ 11 */ 12 13 #include <sys/socket.h> 14 15 #pragma pack(2) 16 17 18 /* 19 * These numbers are used by reliable protocols for determining 20 * retransmission behavior and are included in the routing structure. 21 */ 22 struct rt_metrics { 23 u_long rmx_locks; /* Kernel must leave these values alone */ 24 u_long rmx_mtu; /* MTU for this path */ 25 u_long rmx_hopcount; /* max hops expected */ 26 u_long rmx_expire; /* lifetime for route, e.g. redirect */ 27 u_long rmx_recvpipe; /* inbound delay-bandwith product */ 28 u_long rmx_sendpipe; /* outbound delay-bandwith product */ 29 u_long rmx_ssthresh; /* outbound gateway buffer limit */ 30 u_long rmx_rtt; /* estimated round trip time */ 31 u_long rmx_rttvar; /* estimated rtt variance */ 32 }; 33 34 /* 35 * rmx_rtt and rmx_rttvar are stored as microseconds; 36 * RTTTOPRHZ(rtt) converts to a value suitable for use 37 * by a protocol slowtimo counter. 38 */ 39 #define RTM_RTTUNIT 1000000 /* units for rtt, rttvar, as units per sec */ 40 #define RTTTOPRHZ(r) ((r) / (RTM_RTTUNIT / PR_SLOWHZ)) 41 42 #define RTF_UP 0x1 /* route useable */ 43 #define RTF_GATEWAY 0x2 /* destination is a gateway */ 44 #define RTF_HOST 0x4 /* host entry (net otherwise) */ 45 #define RTF_REJECT 0x8 /* host or net unreachable */ 46 #define RTF_DYNAMIC 0x10 /* created dynamically (by redirect) */ 47 #define RTF_MODIFIED 0x20 /* modified dynamically (by redirect) */ 48 #define RTF_DONE 0x40 /* message confirmed */ 49 #define RTF_MASK 0x80 /* subnet mask present */ 50 #define RTF_CLONING 0x100 /* generate new routes on use */ 51 #define RTF_XRESOLVE 0x200 /* external daemon resolves name */ 52 #define RTF_LLINFO 0x400 /* generated by ARP or ESIS */ 53 #define RTF_PROTO2 0x4000 /* protocol specific routing flag */ 54 #define RTF_PROTO1 0x8000 /* protocol specific routing flag */ 55 56 /* 57 * Routing statistics. 58 */ 59 struct rtstat { 60 short rts_badredirect; /* bogus redirect calls */ 61 short rts_dynamic; /* routes created by redirects */ 62 short rts_newgateway; /* routes modified by redirects */ 63 short rts_unreach; /* lookups which failed */ 64 short rts_wildcard; /* lookups satisfied by a wildcard */ 65 }; 66 67 /* 68 * Following structure necessary for 4.3 compatibility; 69 * We should eventually move it to a compat file. 70 */ 71 struct ortentry { 72 u_long rt_hash; /* to speed lookups */ 73 struct sockaddr rt_dst; /* key */ 74 struct sockaddr rt_gateway; /* value */ 75 short rt_flags; /* up/down?, host/net */ 76 short rt_refcnt; /* # held references */ 77 u_long rt_use; /* raw # packets forwarded */ 78 #ifdef AMITCP 79 char rt_pad[4]; 80 #else 81 struct ifnet *rt_ifp; /* the answer: interface to use */ 82 #endif 83 }; 84 85 /* 86 * Structures for routing messages. 87 */ 88 struct rt_msghdr { 89 u_short rtm_msglen; /* to skip over non-understood messages */ 90 u_char rtm_version; /* future binary compatability */ 91 u_char rtm_type; /* message type */ 92 u_short rtm_index; /* index for associated ifp */ 93 pid_t rtm_pid; /* identify sender */ 94 int rtm_addrs; /* bitmask identifying sockaddrs in msg */ 95 int rtm_seq; /* for sender to identify action */ 96 int rtm_errno; /* why failed */ 97 int rtm_flags; /* flags, incl. kern & message, e.g. DONE */ 98 int rtm_use; /* from rtentry */ 99 u_long rtm_inits; /* which metrics we are initializing */ 100 struct rt_metrics rtm_rmx; /* metrics themselves */ 101 }; 102 103 struct route_cb { 104 int ip_count; 105 int ns_count; 106 int iso_count; 107 int any_count; 108 }; 109 110 #define RTM_VERSION 2 /* Up the ante and ignore older versions */ 111 112 #define RTM_ADD 0x1 /* Add Route */ 113 #define RTM_DELETE 0x2 /* Delete Route */ 114 #define RTM_CHANGE 0x3 /* Change Metrics or flags */ 115 #define RTM_GET 0x4 /* Report Metrics */ 116 #define RTM_LOSING 0x5 /* Kernel Suspects Partitioning */ 117 #define RTM_REDIRECT 0x6 /* Told to use different route */ 118 #define RTM_MISS 0x7 /* Lookup failed on this address */ 119 #define RTM_LOCK 0x8 /* fix specified metrics */ 120 #define RTM_OLDADD 0x9 /* caused by SIOCADDRT */ 121 #define RTM_OLDDEL 0xa /* caused by SIOCDELRT */ 122 #define RTM_RESOLVE 0xb /* req to resolve dst to LL addr */ 123 124 #define RTV_MTU 0x1 /* init or lock _mtu */ 125 #define RTV_HOPCOUNT 0x2 /* init or lock _hopcount */ 126 #define RTV_EXPIRE 0x4 /* init or lock _hopcount */ 127 #define RTV_RPIPE 0x8 /* init or lock _recvpipe */ 128 #define RTV_SPIPE 0x10 /* init or lock _sendpipe */ 129 #define RTV_SSTHRESH 0x20 /* init or lock _ssthresh */ 130 #define RTV_RTT 0x40 /* init or lock _rtt */ 131 #define RTV_RTTVAR 0x80 /* init or lock _rttvar */ 132 133 #define RTA_DST 0x1 /* destination sockaddr present */ 134 #define RTA_GATEWAY 0x2 /* gateway sockaddr present */ 135 #define RTA_NETMASK 0x4 /* netmask sockaddr present */ 136 #define RTA_GENMASK 0x8 /* cloning mask sockaddr present */ 137 #define RTA_IFP 0x10 /* interface name sockaddr present */ 138 #define RTA_IFA 0x20 /* interface addr sockaddr present */ 139 #define RTA_AUTHOR 0x40 /* sockaddr for author of redirect */ 140 141 142 #pragma pack() 143 144 #endif /* !_NET_ROUTE_H_ */