Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (3.87 KB)

1
/*
2
 * Structures for RIP protocol
3
 *
4
   FIXME: in V6, they insert additional entry whenever next hop differs. Such entry is identified by 0xff in metric.
5
 */
6

    
7
#include "nest/route.h"
8
#include "nest/password.h"
9
#include "nest/locks.h"
10

    
11
#define EA_RIP_TAG        EA_CODE(EAP_RIP, 0)
12
#define EA_RIP_METRIC        EA_CODE(EAP_RIP, 1)
13

    
14
#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

    
28
struct rip_connection {
29
  node n;
30

    
31
  int num;
32
  struct proto *proto;
33
  ip_addr addr;
34
  sock *send;
35
  struct rip_interface *rif;
36
  struct fib_iterator iter;
37

    
38
  ip_addr daddr;
39
  int dport;
40
  int done;
41
};
42

    
43
struct rip_packet_heading {                /* 4 bytes */
44
  u8 command;
45
#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
  u8 version;
51
#define RIP_V1                        1
52
#define RIP_V2                        2
53
#define RIP_NG                         1        /* this is verion 1 of RIPng */
54
  u16 unused;
55
};
56

    
57
#ifndef IPV6
58
struct rip_block {        /* 20 bytes */
59
  u16 family;        /* 0xffff on first message means this is authentication */
60
  u16 tag;
61
  ip_addr network;
62
  ip_addr netmask;
63
  ip_addr nexthop;
64
  u32 metric;
65
};
66
#else
67
struct rip_block { /* IPv6 version!, 20 bytes, too */
68
  ip_addr network;
69
  u16 tag;
70
  u8 pxlen;
71
  u8 metric;
72
};
73
#endif
74

    
75
struct rip_block_auth { /* 20 bytes */
76
  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
struct rip_md5_tail {        /* 20 bytes */
87
  u16 mustbeFFFF;
88
  u16 mustbe0001;
89
  char md5[16];
90
};
91

    
92
struct rip_entry {
93
  struct fib_node n;
94

    
95
  ip_addr whotoldme;
96
  ip_addr nexthop;
97
  int metric;
98
  u16 tag;
99

    
100
  bird_clock_t updated, changed;
101
  int flags;
102
};
103

    
104
struct rip_packet {
105
  struct rip_packet_heading heading;
106
  struct rip_block block[PACKET_MAX];
107
};
108

    
109
struct rip_interface {
110
  node n;
111
  struct proto *proto;
112
  struct iface *iface;
113
  sock *sock;
114
  struct rip_connection *busy;
115
  int metric;                        /* You don't want to put struct rip_patt *patt here -- think about reconfigure */
116
  int mode;
117
  int triggered;
118
  struct object_lock *lock;
119
  int multicast;
120
};
121

    
122
struct rip_patt {
123
  struct iface_patt i;
124

    
125
  int metric;                /* If you add entries here, don't forget to modify patt_compare! */
126
  int mode;
127
#define IM_BROADCAST 2
128
#define IM_QUIET 4
129
#define IM_NOLISTEN 8
130
#define IM_VERSION1 16
131
};
132

    
133
struct rip_proto_config {
134
  struct proto_config c;
135
  list iface_list;        /* Patterns configured -- keep it first; see rip_reconfigure why */
136
  list *passwords;        /* Passwords, keep second */
137

    
138
  int infinity;                /* User configurable data; must be comparable with memcmp */
139
  int port;
140
  int period;
141
  int garbage_time;
142
  int timeout_time;
143

    
144
  int authtype;
145
#define AT_NONE 0
146
#define AT_PLAINTEXT 2
147
#define AT_MD5 3
148
  int honor;
149
#define HO_NEVER 0
150
#define HO_NEIGHBOR 1
151
#define HO_ALWAYS 2
152
};
153

    
154
struct rip_proto {
155
  struct proto inherited;
156
  timer *timer;
157
  list connections;
158
  struct fib rtable;
159
  list garbage;
160
  list interfaces;        /* Interfaces we really know about */
161
#ifdef LOCAL_DEBUG
162
  int magic;
163
#endif
164
  int tx_count;                /* Do one regular update once in a while */
165
  int rnd_count;        /* Randomize sending time */
166
};
167

    
168
#ifdef LOCAL_DEBUG
169
#define RIP_MAGIC 81861253
170
#define CHK_MAGIC do { if (P->magic != RIP_MAGIC) bug( "Not enough magic" ); } while (0)
171
#else
172
#define CHK_MAGIC do { } while (0)
173
#endif
174

    
175

    
176
void rip_init_instance(struct proto *p);
177
void rip_init_config(struct rip_proto_config *c);
178

    
179
/* Authentication functions */
180

    
181
int rip_incoming_authentication( struct proto *p, struct rip_block_auth *block, struct rip_packet *packet, int num, ip_addr whotoldme );
182
int rip_outgoing_authentication( struct proto *p, struct rip_block_auth *block, struct rip_packet *packet, int num );