home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilss / sockets / include / net / h / route < prev    next >
Encoding:
Text File  |  1995-01-11  |  2.8 KB  |  108 lines

  1. /* -*-C-*-
  2.  *
  3.  * $Header: /ax/networking:include/net/route.h:networking  1.1  $
  4.  * $Source: /ax/networking:include/net/route.h: $
  5.  *
  6.  * Copyright (c) 1988 Acorn Computers Ltd., Cambridge, England
  7.  *
  8.  * $Log:    route.h,v $
  9.  * Revision 1.1  95/01/11  10:14:50  kwelton
  10.  * Initial revision
  11.  * 
  12.  * Revision 1.3     88/06/17  20:25:28  beta
  13.  * Acorn Unix initial beta version
  14.  * 
  15.  */
  16. /* @(#)route.h    1.1 87/07/01 3.2/4.3NFSSRC */
  17. /*
  18.  * Copyright (c) 1980, 1986 Regents of the University of California.
  19.  * All rights reserved.     The Berkeley software License Agreement
  20.  * specifies the terms and conditions for redistribution.
  21.  *
  22.  *    @(#)route.h    7.1 (Berkeley) 6/4/86
  23.  */
  24.  
  25. /*
  26.  * Kernel resident routing tables.
  27.  * 
  28.  * The routing tables are initialized when interface addresses
  29.  * are set by making entries for all directly connected interfaces.
  30.  */
  31.  
  32. /*
  33.  * A route consists of a destination address and a reference
  34.  * to a routing entry.    These are often held by protocols
  35.  * in their control blocks, e.g. inpcb.
  36.  */
  37. struct route {
  38.     struct    rtentry *ro_rt;
  39.     struct    sockaddr ro_dst;
  40. };
  41.  
  42. /*
  43.  * We distinguish between routes to hosts and routes to networks,
  44.  * preferring the former if available.    For each route we infer
  45.  * the interface to use from the gateway address supplied when
  46.  * the route was entered.  Routes that forward packets through
  47.  * gateways are marked so that the output routines know to address the
  48.  * gateway rather than the ultimate destination.
  49.  */
  50. struct rtentry {
  51.     u_long    rt_hash;        /* to speed lookups */
  52.     struct    sockaddr rt_dst;    /* key */
  53.     struct    sockaddr rt_gateway;    /* value */
  54.     short    rt_flags;        /* up/down?, host/net */
  55.     short    rt_refcnt;        /* # held references */
  56.     u_long    rt_use;            /* raw # packets forwarded */
  57.     struct    ifnet *rt_ifp;        /* the answer: interface to use */
  58. };
  59.  
  60. #define RTF_UP        0x1        /* route useable */
  61. #define RTF_GATEWAY    0x2        /* destination is a gateway */
  62. #define RTF_HOST    0x4        /* host entry (net otherwise) */
  63. #define RTF_DYNAMIC    0x10        /* created dynamically (by redirect) */
  64. #define RTF_MODIFIED    0x20        /* modified dynamically (by redirect) */
  65.  
  66. /*
  67.  * Routing statistics.
  68.  */
  69. struct    rtstat {
  70.     short    rts_badredirect;    /* bogus redirect calls */
  71.     short    rts_dynamic;        /* routes created by redirects */
  72.     short    rts_newgateway;        /* routes modified by redirects */
  73.     short    rts_unreach;        /* lookups which failed */
  74.     short    rts_wildcard;        /* lookups satisfied by a wildcard */
  75. };
  76.  
  77. #ifdef __riscos
  78. struct rttinfo {
  79.     int    r_rthashsize;
  80.     char    *r_rthost;
  81.     char    *r_rtnet;
  82. };
  83. #endif
  84.  
  85. #ifdef KERNEL
  86. #define RTFREE(rt) \
  87.     if ((rt)->rt_refcnt == 1) \
  88.         rtfree(rt); \
  89.     else \
  90.         (rt)->rt_refcnt--;
  91.  
  92. #ifdef    GATEWAY
  93. #define RTHASHSIZ    64
  94. #else
  95. #define RTHASHSIZ    8
  96. #endif
  97. #if    (RTHASHSIZ & (RTHASHSIZ - 1)) == 0
  98. #define RTHASHMOD(h)    ((h) & (RTHASHSIZ - 1))
  99. #else
  100. #define RTHASHMOD(h)    ((h) % RTHASHSIZ)
  101. #endif
  102. struct    mbuf *rthost[RTHASHSIZ];
  103. struct    mbuf *rtnet[RTHASHSIZ];
  104. struct    rtstat    rtstat;
  105. #endif
  106.  
  107. /* EOF route.h */
  108.