blob: 613d198c9445de0dd16328163c93a420bf566276 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
/*
* Structures for RIP protocol
*
FIXME: in V6, they insert additional entry whenever next hop differs. Such entry is identified by 0xff in metric.
*/
#include "nest/route.h"
#include "nest/password.h"
#define EA_RIP_TAG EA_CODE(EAP_RIP, 0)
#define EA_RIP_METRIC EA_CODE(EAP_RIP, 1)
#define PACKET_MAX 25
#define PACKET_MD5_MAX 18 /* FIXME */
struct rip_connection {
node n;
int num;
struct proto *proto;
ip_addr addr;
sock *send;
struct rip_interface *rif;
struct fib_iterator iter;
ip_addr daddr;
int dport;
int done;
};
struct rip_packet_heading {
u8 command;
#define RIPCMD_REQUEST 1 /* want info */
#define RIPCMD_RESPONSE 2 /* responding to request */
#define RIPCMD_TRACEON 3 /* turn tracing on */
#define RIPCMD_TRACEOFF 4 /* turn it off */
#define RIPCMD_MAX 5
u8 version;
#define RIP_V1 1
#define RIP_V2 2
u16 unused;
};
#ifndef IPV6
struct rip_block { /* 20 bytes */
u16 family; /* 0xffff on first message means this is authentication */
u16 tag;
ip_addr network;
ip_addr netmask;
ip_addr nexthop;
u32 metric;
};
#else
struct rip_block { /* IPv6 version! */
ip_addr network;
u16 tag;
u8 pxlen;
u8 metric
};
#endif
struct rip_block_auth { /* 20 bytes */
u16 mustbeFFFF;
u16 authtype;
u16 packetlen;
u8 keyid;
u8 authlen;
u32 seq;
u32 zero0;
u32 zero1;
};
struct rip_md5_tail { /* 20 bytes */
u16 mustbeFFFF;
u16 mustbe0001;
char md5[16];
};
struct rip_entry {
struct fib_node n;
ip_addr whotoldme;
ip_addr nexthop;
int metric;
u16 tag;
bird_clock_t updated, changed;
int flags;
#define RIP_F_EXTERNAL 1
};
struct rip_packet {
struct rip_packet_heading heading;
struct rip_block block[25];
};
struct rip_interface {
node n;
struct proto *proto;
struct iface *iface;
sock *sock;
struct rip_connection *busy;
struct rip_patt *patt;
int triggered;
};
struct rip_patt {
struct iface_patt i;
int metric;
int mode;
#define IM_MULTICAST 1
#define IM_BROADCAST 2
#define IM_QUIET 4
#define IM_NOLISTEN 8
#define IM_VERSION1 16
};
struct rip_proto_config {
struct proto_config c;
list iface_list; /* Patterns configured */
int infinity; /* User configurable data */
int port;
int period;
int garbage_time;
int timeout_time;
struct password_item *passwords;
int authtype;
#define AT_NONE 0
#define AT_PLAINTEXT 2
#define AT_MD5 3
int honour;
#define HO_NEVER 0
#define HO_NEIGHBOUR 1
#define HO_ALWAYS 2
};
struct rip_proto {
struct proto inherited;
timer *timer;
list connections;
struct fib rtable;
list garbage;
list interfaces; /* Interfaces we really know about */
int magic;
int tx_count; /* Do one regular update once in a while */
};
#define RIP_MAGIC 81861253
#define CHK_MAGIC do { if (P->magic != RIP_MAGIC) bug( "Not enough magic\n" ); } while (0)
void rip_init_instance(struct proto *p);
void rip_init_config(struct rip_proto_config *c);
/* Authentication functions */
int rip_incoming_authentication( struct proto *p, struct rip_block_auth *block, struct rip_packet *packet, int num );
int rip_outgoing_authentication( struct proto *p, struct rip_block_auth *block, struct rip_packet *packet, int num );
|