table.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:7k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* table.h - definitions for managing RIP internal routing table */
  2. /* Copyright 1984 - 2002 Wind River Systems, Inc. */
  3. /*
  4.  * Copyright (c) 1983, 1993
  5.  * The Regents of the University of California.  All rights reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  * 1. Redistributions of source code must retain the above copyright
  11.  *    notice, this list of conditions and the following disclaimer.
  12.  * 2. Redistributions in binary form must reproduce the above copyright
  13.  *    notice, this list of conditions and the following disclaimer in the
  14.  *    documentation and/or other materials provided with the distribution.
  15.  * 3. All advertising materials mentioning features or use of this software
  16.  *    must display the following acknowledgement:
  17.  * This product includes software developed by the University of
  18.  * California, Berkeley and its contributors.
  19.  * 4. Neither the name of the University nor the names of its contributors
  20.  *    may be used to endorse or promote products derived from this software
  21.  *    without specific prior written permission.
  22.  *
  23.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  24.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  27.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  28.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  29.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  30.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  32.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  33.  * SUCH DAMAGE.
  34.  *
  35.  * @(#)table.h 8.1 (Berkeley) 6/5/93
  36.  */
  37. /*
  38. modification history
  39. --------------------
  40. 01i,28apr02,rae  added extern C jazz (SPR #76303)
  41. 01h,22mar02,niq  Merged from Synth view, tor3_x.synth branch, ver 01k
  42. 01g,24jan02,niq  SPR 72415 - Added support for Route tags
  43. 01f,12oct01,rae  merge from truestack ver 01h, base 01e
  44. 01e,16mar99,spm  recovered orphaned code from tor1_0_1.sens1_1 (SPR #25770)
  45. 01d,29sep98,spm  added support for IP group MIB (SPR #9374); removed unused 
  46.                  entries from rt_entry structure (SPR #22535)
  47. 01c,11sep98,spm  updated contents to prevent compilation problems (SPR #22352)
  48. 01b,24feb97,gnn  Reworked the rt_entry structure.
  49. 01a,26nov96,gnn  created from BSD4.4 routed
  50. */
  51. #ifndef __INCtableh
  52. #define __INCtableh
  53. #ifdef __cplusplus
  54. extern "C" {
  55. #endif
  56. #include "net/route.h"
  57. /*
  58.  * Routing table management daemon.
  59.  */
  60. #if ((CPU_FAMILY==I960) && (defined __GNUC__))
  61. #pragma align 1                 /* tell gcc960 not to optimize alignments */
  62. #endif  /* CPU_FAMILY==I960 */
  63. /*
  64.  * Routing table structure; differs a bit from kernel tables.
  65.  *
  66.  * Note: the union below must agree in the first 4 members
  67.  * so the ioctl's will work.
  68.  */
  69. struct rthash {
  70. struct rt_entry *rt_forw;
  71. struct rt_entry *rt_back;
  72. };
  73. struct rt_entry
  74.     {
  75.     struct rt_entry *rt_forw;
  76.     struct rt_entry *rt_back;
  77.     BOOL  inKernel; /* Route has been added to the kernel*/
  78.     int  rt_tag; /* Route tag - for RIP v2 only */
  79.     short  rt_refcnt;  /* How many additional interfaces */
  80.        /* need this route */
  81.     short  rt_subnets_cnt;/* How many subnetted interfaces */
  82.        /* need an "internal" classful */
  83.        /* network route. Set only for a */
  84. /* classful route (internal or  */
  85.        /* otherwise) when atleast two */
  86. /* subnetted interfaces or one */
  87.        /* non-subnetted and atleast one */
  88. /* subnetted interface exists */
  89. /* for the network */
  90.     struct rtuentry 
  91.         {
  92.         u_long rtu_hash;
  93.         struct sockaddr rtu_dst;
  94.         struct sockaddr rtu_router; /* Route's gateway - route supplier */
  95.    /* for V1 or V2 with unspecified next*/
  96.    /* hop. Set to next hop value for */
  97.    /* V2 if specified */
  98.         struct sockaddr rtu_netmask;
  99. int             rtu_orgrouter; /* router from whom route was */
  100.    /* received. For V1 will be same as */
  101.    /* rtu_router. For V2 might be */
  102.    /* diffrent from rtu_router */
  103.         int rtu_flags;
  104.         int rtu_state;
  105.         int rtu_timer; /* Route timer */
  106.         int rtu_metric; /* Route metric */
  107. int rtu_proto; /* Protocol that owns the route */
  108.         struct interface *rtu_ifp; /* Interface through which the */
  109.    /* gateway is reachable */
  110.         } rtu_entry;
  111. };
  112. #if ((CPU_FAMILY==I960) && (defined __GNUC__))
  113. #pragma align 0                 /* turn off alignment requirement */
  114. #endif  /* CPU_FAMILY==I960 */
  115. #define rt_hash rtu_entry.rtu_hash /* for net or host */
  116. #define rt_dst rtu_entry.rtu_dst /* match value */
  117. #define rt_router rtu_entry.rtu_router /* who to forward to */
  118. #define rt_orgrouter rtu_entry.rtu_orgrouter /* who received from */
  119. #define rt_netmask rtu_entry.rtu_netmask /* who to forward to */
  120. #define rt_flags rtu_entry.rtu_flags /* kernel flags */
  121. #define rt_timer rtu_entry.rtu_timer /* for invalidation */
  122. #define rt_state rtu_entry.rtu_state /* see below */
  123. #define rt_metric rtu_entry.rtu_metric /* cost of route */
  124. #define rt_ifp rtu_entry.rtu_ifp /* interface to take */
  125. #define rt_proto rtu_entry.rtu_proto /* protocol that owns this */
  126. /* route */
  127. #define ROUTEHASHSIZ 32 /* must be a power of 2 */
  128. #define ROUTEHASHMASK (ROUTEHASHSIZ - 1)
  129. /*
  130.  * "State" of routing table entry.
  131.  */
  132. #define RTS_CHANGED 0x1 /* route has been altered recently */
  133. #define RTS_EXTERNAL 0x2 /* extern info, not installed or sent */
  134. #define RTS_INTERNAL 0x4 /* internal route, not installed */
  135. #define RTS_PASSIVE IFF_PASSIVE /* don't time out route */
  136. #define RTS_INTERFACE IFF_INTERFACE /* route is for network interface */
  137. #define RTS_REMOTE IFF_REMOTE /* route is for ``remote'' entity */
  138. #define RTS_SUBNET IFF_SUBNET /* route is for network subnet */
  139. #define RTS_OTHER 0x1000000 /* route installed by another */
  140.                                         /* protocol */
  141. #define RTS_PRIMARY 0x2000000 /* This is a primary route */
  142. /*
  143.  * Flags are same as kernel, with this addition for af_rtflags:
  144.  */
  145. #define RTF_SUBNET 0x80000 /* pseudo: route to subnet */
  146. #ifndef VIRTUAL_STACK
  147. struct rthash nethash[ROUTEHASHSIZ];
  148. struct rthash hosthash[ROUTEHASHSIZ];
  149. #endif
  150. struct rt_entry *rtlookup();
  151. struct rt_entry *rtfind();
  152. IMPORT STATUS mPrivRouteEntryAdd (long, long, long, int, int, int, 
  153.                                   struct rtentry **);
  154. IMPORT STATUS mPrivRouteEntryDelete (long, long, long, int, int, int, 
  155.                                      struct rtentry *);
  156. #ifdef __cplusplus
  157. }
  158. #endif
  159. #endif /* __INCtableh */