summaryrefslogtreecommitdiffstats
path: root/proto/rip/rip.h
blob: b87ca1a121ca00853dc968308c8667a6a3fd85ee (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
/*
 * Structures for RIP protocol
 */

struct rip_connection {
  node n;

  int num;
  struct proto *proto;
  ip_addr addr;
  struct rip_entry *sendptr;
  sock *send;
  struct rip_interface *rif;

  ip_addr daddr;
  int dport;
};

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;
};

struct rip_block {
  u16 family;	/* 0xffff on first message means this is authentication */
  u16 tag;
  ip_addr network;
  ip_addr netmask;
  ip_addr nexthop;
  u32 metric;
};

struct rip_entry {
  node n;

  ip_addr whotoldme;
  ip_addr network;
  int pxlen;
  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_data {
  struct proto inherited;
  timer *timer;
  list connections;
  list rtable;
  list garbage;
  list interfaces;
  int magic;
};

#define P ((struct rip_data *) p)
#define E ((struct rip_entry *) e)

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

void rip_init_instance(struct proto *p);