Statistics
| Branch: | Revision:

iof-bird-daemon / proto / rip / rip.h @ 9b63e3a5

History | View | Annotate | Download (3.28 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
struct rip_connection {
18
  node n;
19

    
20
  int num;
21
  struct proto *proto;
22
  ip_addr addr;
23
  sock *send;
24
  struct rip_interface *rif;
25
  struct fib_iterator iter;
26

    
27
  ip_addr daddr;
28
  int dport;
29
  int done;
30
};
31

    
32
struct rip_packet_heading {                /* 4 bytes */
33
  u8 command;
34
#define RIPCMD_REQUEST          1       /* want info */
35
#define RIPCMD_RESPONSE         2       /* responding to request */
36
#define RIPCMD_TRACEON          3       /* turn tracing on */
37
#define RIPCMD_TRACEOFF         4       /* turn it off */
38
#define RIPCMD_MAX              5
39
  u8 version;
40
#define RIP_V1 1
41
#define RIP_V2 2
42
  u16 unused;
43
};
44

    
45
#ifndef IPV6
46
struct rip_block {        /* 20 bytes */
47
  u16 family;        /* 0xffff on first message means this is authentication */
48
  u16 tag;
49
  ip_addr network;
50
  ip_addr netmask;
51
  ip_addr nexthop;
52
  u32 metric;
53
};
54
#else
55
struct rip_block { /* IPv6 version! */
56
  ip_addr network;
57
  u16 tag;
58
  u8 pxlen;
59
  u8 metric;
60
};
61
#endif
62

    
63
struct rip_block_auth { /* 20 bytes */
64
  u16 mustbeFFFF;
65
  u16 authtype;
66
  u16 packetlen;
67
  u8 keyid;
68
  u8 authlen;
69
  u32 seq;
70
  u32 zero0;
71
  u32 zero1;
72
};
73

    
74
struct rip_md5_tail {        /* 20 bytes */
75
  u16 mustbeFFFF;
76
  u16 mustbe0001;
77
  char md5[16];
78
};
79

    
80
struct rip_entry {
81
  struct fib_node n;
82

    
83
  ip_addr whotoldme;
84
  ip_addr nexthop;
85
  int metric;
86
  u16 tag;
87

    
88
  bird_clock_t updated, changed;
89
  int flags;
90
#define RIP_F_EXTERNAL 1
91
};
92

    
93
struct rip_packet {
94
  struct rip_packet_heading heading;
95
  struct rip_block block[PACKET_MAX];
96
};
97

    
98
struct rip_interface {
99
  node n;
100
  struct proto *proto;
101
  struct iface *iface;
102
  sock *sock;
103
  struct rip_connection *busy;
104
  struct rip_patt *patt;  
105
  int triggered;
106
  struct object_lock *lock;
107
  int multicast;
108
};
109

    
110
struct rip_patt {
111
  struct iface_patt i;
112

    
113
  int metric;
114
  int mode;
115
#define IM_BROADCAST 2
116
#define IM_QUIET 4
117
#define IM_NOLISTEN 8
118
#define IM_VERSION1 16
119
};
120

    
121
struct rip_proto_config {
122
  struct proto_config c;
123
  list iface_list;        /* Patterns configured */
124

    
125
  int infinity;                /* User configurable data */
126
  int port;
127
  int period;
128
  int garbage_time;
129
  int timeout_time;
130

    
131
  struct password_item *passwords;
132
  int authtype;
133
#define AT_NONE 0
134
#define AT_PLAINTEXT 2
135
#define AT_MD5 3
136
  int honor;
137
#define HO_NEVER 0
138
#define HO_NEIGHBOR 1
139
#define HO_ALWAYS 2
140
};
141

    
142
struct rip_proto {
143
  struct proto inherited;
144
  timer *timer;
145
  list connections;
146
  struct fib rtable;
147
  list garbage;
148
  list interfaces;        /* Interfaces we really know about */
149
  int magic;
150
  int tx_count;                /* Do one regular update once in a while */
151
};
152

    
153

    
154
#define RIP_MAGIC 81861253
155
#define CHK_MAGIC do { if (P->magic != RIP_MAGIC) bug( "Not enough magic\n" ); } while (0)
156

    
157
void rip_init_instance(struct proto *p);
158
void rip_init_config(struct rip_proto_config *c);
159

    
160
/* Authentication functions */
161

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