Statistics
| Branch: | Revision:

iof-bird-daemon / proto / rip / rip.h @ a9c38203

History | View | Annotate | Download (3.87 KB)

1 a103373f Pavel Machek
/*
2
 * Structures for RIP protocol
3 c79ec2ec Pavel Machek
 *
4
   FIXME: in V6, they insert additional entry whenever next hop differs. Such entry is identified by 0xff in metric.
5 a103373f Pavel Machek
 */
6
7 6996f459 Pavel Machek
#include "nest/route.h"
8 fd5f8704 Pavel Machek
#include "nest/password.h"
9 ff8ed632 Pavel Machek
#include "nest/locks.h"
10 6996f459 Pavel Machek
11 91c7c741 Pavel Machek
#define EA_RIP_TAG        EA_CODE(EAP_RIP, 0)
12
#define EA_RIP_METRIC        EA_CODE(EAP_RIP, 1)
13
14 e2bf812f Ondrej Zajicek
#define PACKET_MAX        25
15
#define PACKET_MD5_MAX        18        /* FIXME */
16
17
18
#define RIP_V1                1
19
#define RIP_V2                2
20
#define RIP_NG                1        /* A new version numbering */
21
22
#ifndef IPV6
23
#define RIP_PORT        520        /* RIP for IPv4 */
24
#else
25
#define RIP_PORT        521        /* RIPng */
26
#endif
27 bce8a34b Pavel Machek
28 a103373f Pavel Machek
struct rip_connection {
29 279f4c7b Pavel Machek
  node n;
30
31
  int num;
32
  struct proto *proto;
33 a103373f Pavel Machek
  ip_addr addr;
34
  sock *send;
35 c3e9b2ab Pavel Machek
  struct rip_interface *rif;
36 6996f459 Pavel Machek
  struct fib_iterator iter;
37 c3e9b2ab Pavel Machek
38
  ip_addr daddr;
39
  int dport;
40 6996f459 Pavel Machek
  int done;
41 a103373f Pavel Machek
};
42
43 1a509a63 Pavel Machek
struct rip_packet_heading {                /* 4 bytes */
44 a103373f Pavel Machek
  u8 command;
45 279f4c7b Pavel Machek
#define RIPCMD_REQUEST          1       /* want info */
46
#define RIPCMD_RESPONSE         2       /* responding to request */
47
#define RIPCMD_TRACEON          3       /* turn tracing on */
48
#define RIPCMD_TRACEOFF         4       /* turn it off */
49
#define RIPCMD_MAX              5
50 a103373f Pavel Machek
  u8 version;
51 e2bf812f Ondrej Zajicek
#define RIP_V1                        1
52
#define RIP_V2                        2
53
#define RIP_NG                         1        /* this is verion 1 of RIPng */
54 a103373f Pavel Machek
  u16 unused;
55
};
56
57 c79ec2ec Pavel Machek
#ifndef IPV6
58 d3702d57 Pavel Machek
struct rip_block {        /* 20 bytes */
59 a103373f Pavel Machek
  u16 family;        /* 0xffff on first message means this is authentication */
60
  u16 tag;
61 279f4c7b Pavel Machek
  ip_addr network;
62
  ip_addr netmask;
63
  ip_addr nexthop;
64 a103373f Pavel Machek
  u32 metric;
65
};
66 c79ec2ec Pavel Machek
#else
67 8b79c4cc Pavel Machek
struct rip_block { /* IPv6 version!, 20 bytes, too */
68 c79ec2ec Pavel Machek
  ip_addr network;
69
  u16 tag;
70
  u8 pxlen;
71 3f996d46 Martin Mares
  u8 metric;
72 c79ec2ec Pavel Machek
};
73
#endif
74 a103373f Pavel Machek
75 d3702d57 Pavel Machek
struct rip_block_auth { /* 20 bytes */
76 10915c96 Pavel Machek
  u16 mustbeFFFF;
77
  u16 authtype;
78
  u16 packetlen;
79
  u8 keyid;
80
  u8 authlen;
81
  u32 seq;
82
  u32 zero0;
83
  u32 zero1;
84
};
85
86 d3702d57 Pavel Machek
struct rip_md5_tail {        /* 20 bytes */
87 91c7c741 Pavel Machek
  u16 mustbeFFFF;
88
  u16 mustbe0001;
89
  char md5[16];
90
};
91
92 a103373f Pavel Machek
struct rip_entry {
93 6996f459 Pavel Machek
  struct fib_node n;
94 a103373f Pavel Machek
95 1d941de4 Pavel Machek
  ip_addr whotoldme;
96 a103373f Pavel Machek
  ip_addr nexthop;
97
  int metric;
98
  u16 tag;
99
100
  bird_clock_t updated, changed;
101 1d941de4 Pavel Machek
  int flags;
102 a103373f Pavel Machek
};
103
104
struct rip_packet {
105
  struct rip_packet_heading heading;
106 7f704c06 Pavel Machek
  struct rip_block block[PACKET_MAX];
107 a103373f Pavel Machek
};
108
109 c3e9b2ab Pavel Machek
struct rip_interface {
110
  node n;
111
  struct proto *proto;
112
  struct iface *iface;
113
  sock *sock;
114
  struct rip_connection *busy;
115 3e474192 Pavel Machek
  int metric;                        /* You don't want to put struct rip_patt *patt here -- think about reconfigure */
116
  int mode;
117 7e61cac3 Pavel Machek
  int triggered;
118 ff8ed632 Pavel Machek
  struct object_lock *lock;
119 8c86f96f Pavel Machek
  int multicast;
120 50e89a6e Pavel Machek
};
121
122
struct rip_patt {
123
  struct iface_patt i;
124
125 898fdd85 Pavel Machek
  int metric;                /* If you add entries here, don't forget to modify patt_compare! */
126 50e89a6e Pavel Machek
  int mode;
127 9607536d Pavel Machek
#define IM_BROADCAST 2
128
#define IM_QUIET 4
129
#define IM_NOLISTEN 8
130
#define IM_VERSION1 16
131 c3e9b2ab Pavel Machek
};
132
133 293e313e Pavel Machek
struct rip_proto_config {
134 c748cdb9 Pavel Machek
  struct proto_config c;
135 30aa02d7 Pavel Machek
  list iface_list;        /* Patterns configured -- keep it first; see rip_reconfigure why */
136 5236fb03 Ondrej Filip
  list *passwords;        /* Passwords, keep second */
137 293e313e Pavel Machek
138 898fdd85 Pavel Machek
  int infinity;                /* User configurable data; must be comparable with memcmp */
139 293e313e Pavel Machek
  int port;
140
  int period;
141
  int garbage_time;
142 3918b1b0 Pavel Machek
  int timeout_time;
143 1b16029c Pavel Machek
144
  int authtype;
145
#define AT_NONE 0
146
#define AT_PLAINTEXT 2
147 10915c96 Pavel Machek
#define AT_MD5 3
148 9b63e3a5 Pavel Machek
  int honor;
149 bce8a34b Pavel Machek
#define HO_NEVER 0
150 9b63e3a5 Pavel Machek
#define HO_NEIGHBOR 1
151 bce8a34b Pavel Machek
#define HO_ALWAYS 2
152 293e313e Pavel Machek
};
153
154 2d9290e9 Pavel Machek
struct rip_proto {
155 a103373f Pavel Machek
  struct proto inherited;
156
  timer *timer;
157
  list connections;
158 6996f459 Pavel Machek
  struct fib rtable;
159 feb6abe0 Pavel Machek
  list garbage;
160 2d9290e9 Pavel Machek
  list interfaces;        /* Interfaces we really know about */
161 3fe5f899 Ondrej Filip
#ifdef LOCAL_DEBUG
162 a103373f Pavel Machek
  int magic;
163 3fe5f899 Ondrej Filip
#endif
164 7e61cac3 Pavel Machek
  int tx_count;                /* Do one regular update once in a while */
165 a9c38203 Ondrej Filip
  int rnd_count;        /* Randomize sending time */
166 a103373f Pavel Machek
};
167
168 3fe5f899 Ondrej Filip
#ifdef LOCAL_DEBUG
169 a103373f Pavel Machek
#define RIP_MAGIC 81861253
170 df49d4e1 Martin Mares
#define CHK_MAGIC do { if (P->magic != RIP_MAGIC) bug( "Not enough magic" ); } while (0)
171 3fe5f899 Ondrej Filip
#else
172
#define CHK_MAGIC do { } while (0)
173
#endif
174
175 93fb60d5 Martin Mares
176
void rip_init_instance(struct proto *p);
177 c748cdb9 Pavel Machek
void rip_init_config(struct rip_proto_config *c);
178 1b16029c Pavel Machek
179
/* Authentication functions */
180
181 639e6285 Pavel Machek
int rip_incoming_authentication( struct proto *p, struct rip_block_auth *block, struct rip_packet *packet, int num, ip_addr whotoldme );
182 d3702d57 Pavel Machek
int rip_outgoing_authentication( struct proto *p, struct rip_block_auth *block, struct rip_packet *packet, int num );