Statistics
| Branch: | Revision:

iof-bird-daemon / proto / rip / rip.h @ 9607536d

History | View | Annotate | Download (2.79 KB)

1
/*
2
 * Structures for RIP protocol
3
 */
4

    
5
#include "nest/route.h"
6
#include "nest/password.h"
7

    
8
#define EA_RIP_TAG        EA_CODE(EAP_RIP, 0)
9
#define EA_RIP_METRIC        EA_CODE(EAP_RIP, 1)
10

    
11
struct rip_connection {
12
  node n;
13

    
14
  int num;
15
  struct proto *proto;
16
  ip_addr addr;
17
  sock *send;
18
  struct rip_interface *rif;
19
  struct fib_iterator iter;
20

    
21
  ip_addr daddr;
22
  int dport;
23
  int done;
24
};
25

    
26
struct rip_packet_heading {
27
  u8 command;
28
#define RIPCMD_REQUEST          1       /* want info */
29
#define RIPCMD_RESPONSE         2       /* responding to request */
30
#define RIPCMD_TRACEON          3       /* turn tracing on */
31
#define RIPCMD_TRACEOFF         4       /* turn it off */
32
#define RIPCMD_MAX              5
33
  u8 version;
34
#define RIP_V1 1
35
#define RIP_V2 2
36
  u16 unused;
37
};
38

    
39
struct rip_block {
40
  u16 family;        /* 0xffff on first message means this is authentication */
41
  u16 tag;
42
  ip_addr network;
43
  ip_addr netmask;
44
  ip_addr nexthop;
45
  u32 metric;
46
};
47

    
48
struct rip_block_auth {
49
  u16 mustbeFFFF;
50
  u16 authtype;
51
  u16 packetlen;
52
  u8 keyid;
53
  u8 authlen;
54
  u32 seq;
55
  u32 zero0;
56
  u32 zero1;
57
};
58

    
59
struct rip_md5_tail {
60
  u16 mustbeFFFF;
61
  u16 mustbe0001;
62
  char md5[16];
63
};
64

    
65
struct rip_entry {
66
  struct fib_node n;
67

    
68
  ip_addr whotoldme;
69
  ip_addr nexthop;
70
  int metric;
71
  u16 tag;
72

    
73
  bird_clock_t updated, changed;
74
  int flags;
75
#define RIP_F_EXTERNAL 1
76
};
77

    
78
struct rip_packet {
79
  struct rip_packet_heading heading;
80
  struct rip_block block[25];
81
};
82

    
83
struct rip_interface {
84
  node n;
85
  struct proto *proto;
86
  struct iface *iface;
87
  sock *sock;
88
  struct rip_connection *busy;
89
  struct rip_patt *patt;  
90
};
91

    
92
struct rip_patt {
93
  struct iface_patt i;
94

    
95
  int metric;
96
  int mode;
97
#define IM_MULTICAST 1
98
#define IM_BROADCAST 2
99
#define IM_QUIET 4
100
#define IM_NOLISTEN 8
101
#define IM_VERSION1 16
102
};
103

    
104
struct rip_proto_config {
105
  struct proto_config c;
106
  list iface_list;        /* Patterns configured */
107

    
108
  int infinity;                /* User configurable data */
109
  int port;
110
  int period;
111
  int garbage_time;
112

    
113
  struct password_item *passwords;
114
  int authtype;
115
#define AT_NONE 0
116
#define AT_PLAINTEXT 2
117
#define AT_MD5 3
118
};
119

    
120
struct rip_proto {
121
  struct proto inherited;
122
  timer *timer;
123
  list connections;
124
  struct fib rtable;
125
  list garbage;
126
  list interfaces;        /* Interfaces we really know about */
127
  int magic;
128
};
129

    
130

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

    
134
void rip_init_instance(struct proto *p);
135
void rip_init_config(struct rip_proto_config *c);
136
struct rip_interface *new_iface(struct proto *p, struct iface *new, unsigned long flags, struct iface_patt *patt);
137

    
138
/* Authentication functions */
139

    
140
int rip_incoming_authentication( struct proto *p, struct rip_block_auth *block, struct rip_packet *packet, int num );
141
void rip_outgoing_authentication( struct proto *p, struct rip_block_auth *block, struct rip_packet *packet, int num );