Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
3.0 KiB

  1. /*
  2. * Copyright (c) 1980, 1986 Regents of the University of California.
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms are permitted
  6. * provided that the above copyright notice and this paragraph are
  7. * duplicated in all such forms and that any documentation,
  8. * advertising materials, and other materials related to such
  9. * distribution and use acknowledge that the software was developed
  10. * by the University of California, Berkeley. The name of the
  11. * University may not be used to endorse or promote products derived
  12. * from this software without specific prior written permission.
  13. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  14. * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  15. * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  16. *
  17. * @(#)route.h 7.4 (Berkeley) 6/27/88
  18. */
  19. /*
  20. * Kernel resident routing tables.
  21. *
  22. * The routing tables are initialized when interface addresses
  23. * are set by making entries for all directly connected interfaces.
  24. */
  25. /*
  26. * A route consists of a destination address and a reference
  27. * to a routing entry. These are often held by protocols
  28. * in their control blocks, e.g. inpcb.
  29. */
  30. struct route {
  31. struct rtentry *ro_rt;
  32. struct sockaddr ro_dst;
  33. };
  34. /*
  35. * We distinguish between routes to hosts and routes to networks,
  36. * preferring the former if available. For each route we infer
  37. * the interface to use from the gateway address supplied when
  38. * the route was entered. Routes that forward packets through
  39. * gateways are marked so that the output routines know to address the
  40. * gateway rather than the ultimate destination.
  41. */
  42. struct rtentry {
  43. u_long rt_hash; /* to speed lookups */
  44. struct sockaddr rt_dst; /* key */
  45. struct sockaddr rt_gateway; /* value */
  46. short rt_flags; /* up/down?, host/net */
  47. short rt_refcnt; /* # held references */
  48. u_long rt_use; /* raw # packets forwarded */
  49. struct ifnet *rt_ifp; /* the answer: interface to use */
  50. };
  51. #define RTF_UP 0x1 /* route useable */
  52. #define RTF_GATEWAY 0x2 /* destination is a gateway */
  53. #define RTF_HOST 0x4 /* host entry (net otherwise) */
  54. #define RTF_DYNAMIC 0x10 /* created dynamically (by redirect) */
  55. #define RTF_MODIFIED 0x20 /* modified dynamically (by redirect) */
  56. /*
  57. * Routing statistics.
  58. */
  59. struct rtstat {
  60. short rts_badredirect; /* bogus redirect calls */
  61. short rts_dynamic; /* routes created by redirects */
  62. short rts_newgateway; /* routes modified by redirects */
  63. short rts_unreach; /* lookups which failed */
  64. short rts_wildcard; /* lookups satisfied by a wildcard */
  65. };
  66. #ifdef KERNEL
  67. #define RTFREE(rt) \
  68. if ((rt)->rt_refcnt == 1) \
  69. rtfree(rt); \
  70. else \
  71. (rt)->rt_refcnt--;
  72. #ifdef GATEWAY
  73. #define RTHASHSIZ 64
  74. #else
  75. #define RTHASHSIZ 8
  76. #endif
  77. #if (RTHASHSIZ & (RTHASHSIZ - 1)) == 0
  78. #define RTHASHMOD(h) ((h) & (RTHASHSIZ - 1))
  79. #else
  80. #define RTHASHMOD(h) ((h) % RTHASHSIZ)
  81. #endif
  82. struct mbuf *rthost[RTHASHSIZ];
  83. struct mbuf *rtnet[RTHASHSIZ];
  84. struct rtstat rtstat;
  85. #endif