home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 024 / psi110g.zip / RIP.H < prev    next >
C/C++ Source or Header  |  1994-04-17  |  7KB  |  211 lines

  1. #ifndef _RIP_H
  2. #define _RIP_H
  3.   
  4. /* Routing Information Protocol (RIP)
  5.  *
  6.  *  This code is derived from the 4.2 BSD version which was
  7.  * used as a spec since no formal specification is known to exist.
  8.  * See RFC 1009, Gateway Requirements, for more details. AGB 4-29-88
  9.  *
  10.  * The draft RIP RFC was used to develop most of this code. The above
  11.  * referred to the basics of the rip_recv() function of RIP.C. The RIP
  12.  * RFC has now been issued as RFC1058. AGB 7-23-88
  13.  *
  14.  * Substantially rewritten and integrated into NOS 9/1989 by KA9Q
  15.  *
  16.  * Mods by PA0GRI
  17.  *
  18.  * Rehack for RIP-2 (RFC1388) by N0POY 4/1993
  19.  *
  20.  * Beta release 8/12/93 V0.9
  21.  *
  22.  * 2/19/94 release V1.0
  23.  *
  24.  *
  25.  */
  26.   
  27. #ifndef _MBUF_H
  28. #include "mbuf.h"
  29. #endif
  30.   
  31. #ifndef _IFACE_H
  32. #include "iface.h"
  33. #endif
  34.   
  35. #ifndef _UDP_H
  36. #include "udp.h"
  37. #endif
  38.   
  39. #define  RIP_VERSION_0           0
  40. #define  RIP_VERSION_1           1
  41. #define  RIP_VERSION_2           2
  42. #define  RIP_VERSIONS            3
  43.   
  44. #define  RIP_METRIC_UNREACHABLE  16
  45. #define  RIP_INFINITY            RIP_METRIC_UNREACHABLE
  46. #define  RIP_METRIC_SHUTDOWN     (RIP_METRIC_UNREACHABLE - 1)
  47.   
  48. #define  RIP_AUTH_SIZE           16
  49.   
  50. #define  RIP_PKTSIZE             512
  51. #define  RIP_HEADER              4
  52. #define  RIP_ENTRY               20
  53. #define  RIP_ADDR_MC             0xe0000009  /* 224.0.0.9 */
  54. #define  RIP_PORT                520
  55. #define  RIP_HOP                 1        /* Minimum hop count when passing through */
  56.   
  57. #define  RIP_AF_UNSPEC           0        /* Unknown family */
  58. #define  RIP_AF_INET             2        /* IP Family */
  59. #define  RIP_AF_AUTH             0xffff   /* Authetication header */
  60. #define  RIP_NO_AUTH             "NONE"   /* No authentication */
  61.   
  62. #define  RIP_AUTH_NONE           0
  63. #define  RIP_AUTH_SIMPLE         2
  64. #define  RIP_TTL                 240      /* Default time-to-live for an entry */
  65.   
  66. /*
  67.  * Packet types.
  68.  */
  69.   
  70. #define  RIPCMD_REQUEST          1        /* want info */
  71. #define  RIPCMD_RESPONSE         2        /* responding to request */
  72. #define  RIPCMD_TRACEON          3        /* turn tracing on */
  73. #define  RIPCMD_TRACEOFF         4        /* turn it off */
  74. #define  RIPCMD_POLL             5        /* like request, but anyone answers */
  75. #define  RIPCMD_POLLENTRY        6        /* like poll, but for entire entry */
  76. #define  RIPCMD_MAX              7
  77.   
  78.   
  79. /* RIP Flags */
  80.   
  81. #define  RIP_SPLIT               0x01     /* Do split horizon processing */
  82. #define  RIP_US                  0x02     /* Include ourselves in the list */
  83. #define  RIP_BROADCAST           0x04     /* Broadcast RIP packets */
  84. #define  RIP_MULTICAST           0x08     /* Multicast RIP packets */
  85. #define  RIP_POISON              0x10     /* Poisoned reverse on */
  86. #define  RIP_AUTHENTICATE        0x20     /* Authenticate each packet */
  87.   
  88.   
  89. /* RIP statistics counters */
  90. struct rip_stat {
  91.     struct version_data {
  92.         int32 output;        /* Packets sent */
  93.         int32 rcvd;          /* Packets received */
  94.         int32 request;       /* Number of request packets received */
  95.         int32 response;      /* Number of responses received */
  96.         int32 unknown;       /* Number of unknown command pkts received */
  97.     } vdata[RIP_VERSIONS];
  98.     int32 version;          /* Number of version errors */
  99.     int32 addr_family;      /* Number of address family errors */
  100.     int32 refusals;         /* Number of packets dropped from a host
  101.                               on the refuse list */
  102.     int32 wrong_domain;     /* Refused due to wrong domain for interface */
  103.     int32 auth_fail;        /* Authentication failures */
  104.     int32 unknown_auth;     /* Unknown authentication type */
  105. };
  106.   
  107. struct rip_list {
  108.     struct rip_list *prev;
  109.     struct rip_list *next;   /* doubly linked list */
  110.   
  111.    /* address to scream at periodically:
  112.     * this address must have a direct network interface route and an
  113.     * ARP entry for the appropriate  hardware broadcast address, if approp.
  114.     */
  115.     int32 dest;
  116.   
  117.    /* basic rate of RIP clocks on this net interface */
  118.     int32 interval;
  119.   
  120.     struct timer rip_time;     /* time to output next on this net. iface */
  121.   
  122.     /* the interface to transmit on  and receive from */
  123.     struct iface *iface;
  124.     char  rip_version;         /* Type of RIP packets */
  125.     int16 flags;
  126.     int16 domain;              /* Routing domain in */
  127.     int16 route_tag;           /* Route tag to send */
  128.     int32 proxy_route;         /* For Proxy RIP-2, 0 if none */
  129.     char rip_auth_code[RIP_AUTH_SIZE+1];
  130.                               /* Authentication code to send */
  131. };
  132. #define  NULLRL   (struct rip_list *)0
  133.   
  134. struct rip_refuse {
  135.     struct rip_refuse *prev;
  136.     struct rip_refuse *next;
  137.     int32    target;
  138. };
  139. #define  NULLREF  (struct rip_refuse *)0
  140.   
  141. struct rip_auth {
  142.     struct rip_auth *prev;
  143.     struct rip_auth *next;
  144.     char *ifc_name;            /* Name of the interface */
  145.     int16 domain;              /* Check against valid routing domain */
  146.     char rip_auth_code[RIP_AUTH_SIZE+1];
  147.                               /* Authentication password accepted */
  148. };
  149. #define  NULLAUTH (struct rip_auth *)0
  150. #define  DEFAULTIFC     "DEFAULT"
  151.   
  152. /* Host format for the RIP-II header */
  153.   
  154. struct rip_head {
  155.     unsigned char rip_cmd;
  156.     unsigned char rip_vers;
  157.     unsigned short rip_domain;
  158. };
  159.   
  160. /* Host format of a single entry in a RIP response packet */
  161. struct rip_route {
  162.     int16 rip_family;
  163.     int16 rip_tag;
  164.     int32 rip_dest;
  165.     int32 rip_dest_mask;
  166.     int32 rip_router;
  167.     int32 rip_metric;
  168. };
  169.   
  170. /* Host format of an authentication packet */
  171. struct rip_authenticate {
  172.     int16 rip_family;
  173.     int16 rip_auth_type;
  174.     char  rip_auth_str[RIP_AUTH_SIZE];
  175. };
  176.   
  177. /* RIP primitives */
  178.   
  179. int rip_init __ARGS((void));
  180. void rt_timeout __ARGS((void *s));
  181. void rip_trigger __ARGS((void));
  182. int rip_add __ARGS((int32 dest,int32 interval,char flags, char version,
  183. char authpass[RIP_AUTH_SIZE], int16 domain, int16 route_tag, int32 proxy));
  184. int riprefadd __ARGS((int32 gateway));
  185. int riprefdrop __ARGS((int32 gateway));
  186. int ripreq __ARGS((int32 dest,int16 replyport,int16 version));
  187. int rip_drop __ARGS((int32 dest,int16 domain));
  188. int ripauthdrop __ARGS((char *ifcname,int16 domain));
  189. int ripauthadd __ARGS((char *ifcname,int16 domain,char *password));
  190. int nbits __ARGS((int32 target));
  191. void pullentry __ARGS((struct rip_route *ep,struct mbuf **bpp));
  192. void rip_shout __ARGS((void *p));
  193.   
  194. /* RIP Definition */
  195.   
  196. extern int16 Rip_trace;
  197. extern FILE *Rip_trace_file;
  198. extern char *Rip_trace_fname;
  199. extern int16 Rip_merge;
  200. extern int32 Rip_ttl;
  201. extern int16 Rip_ver_refuse;
  202. extern int16 Rip_default_refuse;
  203. extern struct rip_stat Rip_stat;
  204. extern struct rip_list *Rip_list;
  205. extern struct rip_refuse *Rip_refuse;
  206. extern struct rip_auth *Rip_auth;
  207. extern struct udp_cb *Rip_cb;
  208.   
  209. #endif  /* _RIP_H */
  210.   
  211.