home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / N / TCPIP / NETKIT-B.05 / NETKIT-B / NetKit-B-0.05 / routed / table.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-23  |  4.1 KB  |  111 lines

  1. /*
  2.  * Copyright (c) 1983 Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  *    from: @(#)table.h    5.8 (Berkeley) 6/1/90
  34.  *    $Id: table.h,v 1.1 1994/05/23 09:08:12 rzsfl Exp rzsfl $
  35.  */
  36.  
  37. /*
  38.  * Routing table management daemon.
  39.  */
  40.  
  41. /*
  42.  * Routing table structure; differs a bit from kernel tables.
  43.  *
  44.  * Note: the union below must agree in the first 4 members
  45.  * so the ioctl's will work.
  46.  */
  47. struct rthash {
  48.     struct    rt_entry *rt_forw;
  49.     struct    rt_entry *rt_back;
  50. };
  51. #ifdef RTM_ADD
  52. #define rtentry ortentry
  53. #endif
  54.  
  55. struct rt_entry {
  56.     struct    rt_entry *rt_forw;
  57.     struct    rt_entry *rt_back;
  58.     union {
  59.         struct    rtentry rtu_rt;
  60.         struct {
  61.             u_long    rtu_hash;
  62.             struct    sockaddr rtu_dst;
  63.             struct    sockaddr rtu_router;
  64.             struct    sockaddr rtu_genmask;
  65.             short    rtu_flags;
  66.             short    rtu_state;
  67.             int    rtu_timer;
  68.             int    rtu_metric;
  69.             struct    interface *rtu_ifp;
  70.             int    rtu_ifmetric;
  71.             char    *rtu_dev;
  72.         } rtu_entry;
  73.     } rt_rtu;
  74. };
  75.  
  76. #define    rt_rt        rt_rtu.rtu_rt            /* pass to ioctl */
  77. #define    rt_hash        rt_rtu.rtu_entry.rtu_hash    /* for net or host */
  78. #define    rt_dst        rt_rtu.rtu_entry.rtu_dst    /* match value */
  79. #define    rt_router    rt_rtu.rtu_entry.rtu_router    /* who to forward to */
  80. #define    rt_flags    rt_rtu.rtu_entry.rtu_flags    /* kernel flags */
  81. #define    rt_timer    rt_rtu.rtu_entry.rtu_timer    /* for invalidation */
  82. #define    rt_state    rt_rtu.rtu_entry.rtu_state    /* see below */
  83. #define    rt_metric    rt_rtu.rtu_entry.rtu_metric    /* cost of route */
  84. #define    rt_ifmetric    rt_rtu.rtu_entry.rtu_ifmetric    /* cost of route if */
  85. #define    rt_ifp        rt_rtu.rtu_entry.rtu_ifp    /* interface to take */
  86. #define rt_dev        rt_rtu.rtu_entry.rtu_dev
  87.  
  88. #define    ROUTEHASHSIZ    32        /* must be a power of 2 */
  89. #define    ROUTEHASHMASK    (ROUTEHASHSIZ - 1)
  90.  
  91. /*
  92.  * "State" of routing table entry.
  93.  */
  94. #define    RTS_CHANGED    0x1        /* route has been altered recently */
  95. #define    RTS_EXTERNAL    0x2        /* extern info, not installed or sent */
  96. #define    RTS_INTERNAL    0x4        /* internal route, not installed */
  97. #define    RTS_PASSIVE    IFF_PASSIVE    /* don't time out route */
  98. #define    RTS_INTERFACE    IFF_INTERFACE    /* route is for network interface */
  99. #define    RTS_REMOTE    IFF_REMOTE    /* route is for ``remote'' entity */
  100. #define    RTS_SUBNET    IFF_SUBNET    /* route is for network subnet */
  101.  
  102. /*
  103.  * Flags are same as kernel, with this addition for af_rtflags:
  104.  */
  105. #define    RTF_SUBNET    0x8000        /* pseudo: route to subnet */
  106.  
  107. struct    rthash nethash[ROUTEHASHSIZ];
  108. struct    rthash hosthash[ROUTEHASHSIZ];
  109. struct    rt_entry *rtlookup();
  110. struct    rt_entry *rtfind();
  111.