Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (3.5 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 bce8a34b Pavel Machek
#define PACKET_MAX 25
15
#define PACKET_MD5_MAX 18        /* FIXME */
16
17 a103373f Pavel Machek
struct rip_connection {
18 279f4c7b Pavel Machek
  node n;
19
20
  int num;
21
  struct proto *proto;
22 a103373f Pavel Machek
  ip_addr addr;
23
  sock *send;
24 c3e9b2ab Pavel Machek
  struct rip_interface *rif;
25 6996f459 Pavel Machek
  struct fib_iterator iter;
26 c3e9b2ab Pavel Machek
27
  ip_addr daddr;
28
  int dport;
29 6996f459 Pavel Machek
  int done;
30 a103373f Pavel Machek
};
31
32 1a509a63 Pavel Machek
struct rip_packet_heading {                /* 4 bytes */
33 a103373f Pavel Machek
  u8 command;
34 279f4c7b Pavel Machek
#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 a103373f Pavel Machek
  u8 version;
40
#define RIP_V1 1
41
#define RIP_V2 2
42
  u16 unused;
43
};
44
45 c79ec2ec Pavel Machek
#ifndef IPV6
46 d3702d57 Pavel Machek
struct rip_block {        /* 20 bytes */
47 a103373f Pavel Machek
  u16 family;        /* 0xffff on first message means this is authentication */
48
  u16 tag;
49 279f4c7b Pavel Machek
  ip_addr network;
50
  ip_addr netmask;
51
  ip_addr nexthop;
52 a103373f Pavel Machek
  u32 metric;
53
};
54 c79ec2ec Pavel Machek
#else
55 d3702d57 Pavel Machek
struct rip_block { /* IPv6 version! */
56 c79ec2ec Pavel Machek
  ip_addr network;
57
  u16 tag;
58
  u8 pxlen;
59 3f996d46 Martin Mares
  u8 metric;
60 c79ec2ec Pavel Machek
};
61
#endif
62 a103373f Pavel Machek
63 d3702d57 Pavel Machek
struct rip_block_auth { /* 20 bytes */
64 10915c96 Pavel Machek
  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 d3702d57 Pavel Machek
struct rip_md5_tail {        /* 20 bytes */
75 91c7c741 Pavel Machek
  u16 mustbeFFFF;
76
  u16 mustbe0001;
77
  char md5[16];
78
};
79
80 a103373f Pavel Machek
struct rip_entry {
81 6996f459 Pavel Machek
  struct fib_node n;
82 a103373f Pavel Machek
83 1d941de4 Pavel Machek
  ip_addr whotoldme;
84 a103373f Pavel Machek
  ip_addr nexthop;
85
  int metric;
86
  u16 tag;
87
88
  bird_clock_t updated, changed;
89 1d941de4 Pavel Machek
  int flags;
90 a103373f Pavel Machek
};
91
92
struct rip_packet {
93
  struct rip_packet_heading heading;
94 7f704c06 Pavel Machek
  struct rip_block block[PACKET_MAX];
95 a103373f Pavel Machek
};
96
97 c3e9b2ab Pavel Machek
struct rip_interface {
98
  node n;
99
  struct proto *proto;
100
  struct iface *iface;
101
  sock *sock;
102
  struct rip_connection *busy;
103 3e474192 Pavel Machek
  int metric;                        /* You don't want to put struct rip_patt *patt here -- think about reconfigure */
104
  int mode;
105 7e61cac3 Pavel Machek
  int triggered;
106 ff8ed632 Pavel Machek
  struct object_lock *lock;
107 8c86f96f Pavel Machek
  int multicast;
108 50e89a6e Pavel Machek
};
109
110
struct rip_patt {
111
  struct iface_patt i;
112
113 898fdd85 Pavel Machek
  int metric;                /* If you add entries here, don't forget to modify patt_compare! */
114 50e89a6e Pavel Machek
  int mode;
115 9607536d Pavel Machek
#define IM_BROADCAST 2
116
#define IM_QUIET 4
117
#define IM_NOLISTEN 8
118
#define IM_VERSION1 16
119 c3e9b2ab Pavel Machek
};
120
121 293e313e Pavel Machek
struct rip_proto_config {
122 c748cdb9 Pavel Machek
  struct proto_config c;
123 30aa02d7 Pavel Machek
  list iface_list;        /* Patterns configured -- keep it first; see rip_reconfigure why */
124 3e474192 Pavel Machek
  struct password_item *passwords;        /* Passwords, keep second */
125 293e313e Pavel Machek
126 898fdd85 Pavel Machek
  int infinity;                /* User configurable data; must be comparable with memcmp */
127 293e313e Pavel Machek
  int port;
128
  int period;
129
  int garbage_time;
130 3918b1b0 Pavel Machek
  int timeout_time;
131 1b16029c Pavel Machek
132
  int authtype;
133
#define AT_NONE 0
134
#define AT_PLAINTEXT 2
135 10915c96 Pavel Machek
#define AT_MD5 3
136 9b63e3a5 Pavel Machek
  int honor;
137 bce8a34b Pavel Machek
#define HO_NEVER 0
138 9b63e3a5 Pavel Machek
#define HO_NEIGHBOR 1
139 bce8a34b Pavel Machek
#define HO_ALWAYS 2
140 293e313e Pavel Machek
};
141
142 2d9290e9 Pavel Machek
struct rip_proto {
143 a103373f Pavel Machek
  struct proto inherited;
144
  timer *timer;
145
  list connections;
146 6996f459 Pavel Machek
  struct fib rtable;
147 feb6abe0 Pavel Machek
  list garbage;
148 2d9290e9 Pavel Machek
  list interfaces;        /* Interfaces we really know about */
149 a103373f Pavel Machek
  int magic;
150 7e61cac3 Pavel Machek
  int tx_count;                /* Do one regular update once in a while */
151 a103373f Pavel Machek
};
152
153
154
#define RIP_MAGIC 81861253
155 df49d4e1 Martin Mares
#define CHK_MAGIC do { if (P->magic != RIP_MAGIC) bug( "Not enough magic" ); } while (0)
156 93fb60d5 Martin Mares
157
void rip_init_instance(struct proto *p);
158 c748cdb9 Pavel Machek
void rip_init_config(struct rip_proto_config *c);
159 1b16029c Pavel Machek
160
/* Authentication functions */
161
162 639e6285 Pavel Machek
int rip_incoming_authentication( struct proto *p, struct rip_block_auth *block, struct rip_packet *packet, int num, ip_addr whotoldme );
163 d3702d57 Pavel Machek
int rip_outgoing_authentication( struct proto *p, struct rip_block_auth *block, struct rip_packet *packet, int num );