home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tcp30tkt.zip / PGMG1.ZIP / INCLUDE / NET / ROUTE.H < prev   
Text File  |  1995-12-04  |  4KB  |  115 lines

  1. /********************************************************copyrite.xmc***/
  2. /*                                                                     */
  3. /*   Licensed Materials - Property of IBM                              */
  4. /*                                                                     */
  5. /*   This module is "Restricted Materials of IBM":                     */
  6. /*      Program Number:   5798RXW                                      */
  7. /*      Program Name:     IBM TCP/IP Version 1.2 for OS/2              */
  8. /*   (C) Copyright IBM Corporation. 1990, 1991.                        */
  9. /*                                                                     */
  10. /*   See IBM Copyright Instructions.                                   */
  11. /*                                                                     */
  12. /********************************************************copyrite.xmc***/
  13. #ifndef __ROUTE_32H
  14. #define __ROUTE_32H
  15.  
  16. /*
  17.  * Copyright (c) 1980, 1986 Regents of the University of California.
  18.  * All rights reserved.
  19.  *
  20.  * Redistribution and use in source and binary forms are permitted
  21.  * provided that this notice is preserved and that due credit is given
  22.  * to the University of California at Berkeley. The name of the University
  23.  * may not be used to endorse or promote products derived from this
  24.  * software without specific prior written permission. This software
  25.  * is provided ``as is'' without express or implied warranty.
  26.  *
  27.  *      @(#)route.h     7.3 (Berkeley) 12/30/87
  28.  */
  29.  
  30. /*
  31.  * Kernel resident routing tables.
  32.  *
  33.  * The routing tables are initialized when interface addresses
  34.  * are set by making entries for all directly connected interfaces.
  35.  */
  36.  
  37. /*
  38.  * We distinguish between routes to hosts and routes to networks,
  39.  * preferring the former if available.  For each route we infer
  40.  * the interface to use from the gateway address supplied when
  41.  * the route was entered.  Routes that forward packets through
  42.  * gateways are marked so that the output routines know to address the
  43.  * gateway rather than the ultimate destination.
  44.  */
  45.  
  46. #ifndef __IF_32H
  47. #include <net/if.h>
  48. #endif
  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.         long  metric1;                  /* routing metrics for SNMP and Co */
  59.         long  metric2;
  60.         long  metric3;
  61.         long  metric4;
  62. };
  63.  
  64. /*
  65.  * A route consists of a destination address and a reference
  66.  * to a routing entry.  These are often held by protocols
  67.  * in their control blocks, e.g. inpcb.
  68.  */
  69. struct route {
  70.         struct  rtentry *ro_rt;
  71.         struct  sockaddr ro_dst;
  72. };
  73.  
  74.  
  75. #define RTF_UP          0x1             /* route useable */
  76. #define RTF_GATEWAY     0x2             /* destination is a gateway */
  77. #define RTF_HOST        0x4             /* host entry (net otherwise) */
  78. #define RTF_DYNAMIC     0x10            /* created dynamically (by redirect) */
  79. #define RTF_MODIFIED    0x20            /* modified dynamically (by redirect) */
  80.  
  81. /*
  82.  * Routing statistics.
  83.  */
  84. struct  rtstat {
  85.         short   rts_badredirect;        /* bogus redirect calls */
  86.         short   rts_dynamic;            /* routes created by redirects */
  87.         short   rts_newgateway;         /* routes modified by redirects */
  88.         short   rts_unreach;            /* lookups which failed */
  89.         short   rts_wildcard;           /* lookups satisfied by a wildcard */
  90. };
  91.  
  92. #ifdef KERNEL
  93. #define RTFREE(rt) \
  94.         if ((rt)->rt_refcnt == 1) \
  95.                 rtfree(rt); \
  96.         else \
  97.                 (rt)->rt_refcnt--;
  98.  
  99. #ifdef  GATEWAY
  100. #define RTHASHSIZ       64
  101. #else
  102. #define RTHASHSIZ       8
  103. #endif
  104. #if     (RTHASHSIZ & (RTHASHSIZ - 1)) == 0
  105. #define RTHASHMOD(h)    ((h) & (RTHASHSIZ - 1))
  106. #else
  107. #define RTHASHMOD(h)    ((h) % RTHASHSIZ)
  108. #endif
  109. struct  mbuf *rthost[RTHASHSIZ];
  110. struct  mbuf *rtnet[RTHASHSIZ];
  111. struct  rtstat  rtstat;
  112. #endif
  113.  
  114. #endif /* __ROUTE_32H */
  115.