routed.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*-
  2. * Copyright (c) 1983, 1989, 1993
  3. * The Regents of the University of California. 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. * 4. Neither the name of the University nor the names of its contributors
  14. * may be used to endorse or promote products derived from this software
  15. * without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  18. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  21. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27. * SUCH DAMAGE.
  28. *
  29. * @(#)routed.h 8.1 (Berkeley) 6/2/93
  30. */
  31. #ifndef _PROTOCOLS_ROUTED_H
  32. #define _PROTOCOLS_ROUTED_H 1
  33. #include <sys/socket.h>
  34. /*
  35. * Routing Information Protocol
  36. *
  37. * Derived from Xerox NS Routing Information Protocol
  38. * by changing 32-bit net numbers to sockaddr's and
  39. * padding stuff to 32-bit boundaries.
  40. */
  41. #define RIPVERSION 1
  42. struct netinfo {
  43. struct sockaddr rip_dst; /* destination net/host */
  44. int rip_metric; /* cost of route */
  45. };
  46. struct rip {
  47. u_char rip_cmd; /* request/response */
  48. u_char rip_vers; /* protocol version # */
  49. u_char rip_res1[2]; /* pad to 32-bit boundary */
  50. union {
  51. struct netinfo ru_nets[1]; /* variable length... */
  52. char ru_tracefile[1]; /* ditto ... */
  53. } ripun;
  54. #define rip_nets ripun.ru_nets
  55. #define rip_tracefile ripun.ru_tracefile
  56. };
  57. /*
  58. * Packet types.
  59. */
  60. #define RIPCMD_REQUEST 1 /* want info */
  61. #define RIPCMD_RESPONSE 2 /* responding to request */
  62. #define RIPCMD_TRACEON 3 /* turn tracing on */
  63. #define RIPCMD_TRACEOFF 4 /* turn it off */
  64. #define RIPCMD_MAX 5
  65. #ifdef RIPCMDS
  66. char *ripcmds[RIPCMD_MAX] =
  67. { "#0", "REQUEST", "RESPONSE", "TRACEON", "TRACEOFF" };
  68. #endif
  69. #define HOPCNT_INFINITY 16 /* per Xerox NS */
  70. #define MAXPACKETSIZE 512 /* max broadcast size */
  71. /*
  72. * Timer values used in managing the routing table.
  73. * Complete tables are broadcast every SUPPLY_INTERVAL seconds.
  74. * If changes occur between updates, dynamic updates containing only changes
  75. * may be sent. When these are sent, a timer is set for a random value
  76. * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates
  77. * are sent until the timer expires.
  78. *
  79. * Every update of a routing entry forces an entry's timer to be reset.
  80. * After EXPIRE_TIME without updates, the entry is marked invalid,
  81. * but held onto until GARBAGE_TIME so that others may
  82. * see it "be deleted".
  83. */
  84. #define TIMER_RATE 30 /* alarm clocks every 30 seconds */
  85. #define SUPPLY_INTERVAL 30 /* time to supply tables */
  86. #define MIN_WAITTIME 2 /* min. interval to broadcast changes */
  87. #define MAX_WAITTIME 5 /* max. time to delay changes */
  88. #define EXPIRE_TIME 180 /* time to mark entry invalid */
  89. #define GARBAGE_TIME 240 /* time to garbage collect */
  90. #endif /* protocols/routed.h */