1*17067Skarels /* route.h 6.3 84/08/29 */ 26332Ssam 36332Ssam /* 46412Ssam * Kernel resident routing tables. 56412Ssam * 67156Swnj * The routing tables are initialized at boot time by 77156Swnj * making entries for all directly connected interfaces. 86332Ssam */ 96332Ssam 107156Swnj /* 117156Swnj * A route consists of a destination address and a reference 127156Swnj * to a routing entry. These are often held by protocols 137156Swnj * in their control blocks, e.g. inpcb. 147156Swnj */ 156332Ssam struct route { 166332Ssam struct rtentry *ro_rt; 176332Ssam struct sockaddr ro_dst; 187156Swnj #ifdef notdef 197156Swnj caddr_t ro_pcb; /* not used yet */ 207156Swnj #endif 216332Ssam }; 226332Ssam 236332Ssam /* 247156Swnj * We distinguish between routes to hosts and routes to networks, 257156Swnj * preferring the former if available. For each route we infer 267156Swnj * the interface to use from the gateway address supplied when 277156Swnj * the route was entered. Routes that forward packets through 287156Swnj * gateways are marked so that the output routines know to address the 297156Swnj * gateway rather than the ultimate destination. 306332Ssam */ 317156Swnj struct rtentry { 327156Swnj u_long rt_hash; /* to speed lookups */ 337156Swnj struct sockaddr rt_dst; /* key */ 347156Swnj struct sockaddr rt_gateway; /* value */ 357156Swnj short rt_flags; /* up/down?, host/net */ 367156Swnj short rt_refcnt; /* # held references */ 377156Swnj u_long rt_use; /* raw # packets forwarded */ 387156Swnj struct ifnet *rt_ifp; /* the answer: interface to use */ 397156Swnj }; 407156Swnj 416339Ssam #define RTF_UP 0x1 /* route useable */ 427156Swnj #define RTF_GATEWAY 0x2 /* destination is a gateway */ 436377Ssam #define RTF_HOST 0x4 /* host entry (net otherwise) */ 446332Ssam 4512832Ssam /* 4612832Ssam * Routing statistics. 4712832Ssam */ 4812832Ssam struct rtstat { 4912832Ssam short rts_badredirect; /* bogus redirect calls */ 5012832Ssam short rts_dynamic; /* routes created by redirects */ 5112832Ssam short rts_newgateway; /* routes modified by redirects */ 5212832Ssam short rts_unreach; /* lookups which failed */ 5312832Ssam short rts_wildcard; /* lookups satisfied by a wildcard */ 5412832Ssam }; 5512832Ssam 5612832Ssam #ifdef KERNEL 576412Ssam #define RTFREE(rt) \ 586412Ssam if ((rt)->rt_refcnt == 1) \ 596412Ssam rtfree(rt); \ 606412Ssam else \ 616412Ssam (rt)->rt_refcnt--; 6212832Ssam 63*17067Skarels #ifdef GATEWAY 64*17067Skarels #define RTHASHSIZ 64 65*17067Skarels #else 6616554Skarels #define RTHASHSIZ 8 67*17067Skarels #endif 6816554Skarels #if (RTHASHSIZ & (RTHASHSIZ - 1)) == 0 6916554Skarels #define RTHASHMOD(h) ((h) & (RTHASHSIZ - 1)) 7016554Skarels #else 7116554Skarels #define RTHASHMOD(h) ((h) % RTHASHSIZ) 7216554Skarels #endif 7312832Ssam struct mbuf *rthost[RTHASHSIZ]; 7412832Ssam struct mbuf *rtnet[RTHASHSIZ]; 7512832Ssam struct rtstat rtstat; 7612832Ssam #endif 77