1998-07-10 03:39:04 +08:00
|
|
|
/*
|
|
|
|
* Structures for RIP protocol
|
1999-10-11 22:19:29 +08:00
|
|
|
*
|
|
|
|
FIXME: in V6, they insert additional entry whenever next hop differs. Such entry is identified by 0xff in metric.
|
1998-07-10 03:39:04 +08:00
|
|
|
*/
|
|
|
|
|
1998-12-23 03:41:04 +08:00
|
|
|
#include "nest/route.h"
|
1999-05-26 22:37:47 +08:00
|
|
|
#include "nest/password.h"
|
1998-12-23 03:41:04 +08:00
|
|
|
|
1999-06-01 03:16:22 +08:00
|
|
|
#define EA_RIP_TAG EA_CODE(EAP_RIP, 0)
|
|
|
|
#define EA_RIP_METRIC EA_CODE(EAP_RIP, 1)
|
|
|
|
|
1999-08-18 21:19:33 +08:00
|
|
|
#define PACKET_MAX 25
|
|
|
|
#define PACKET_MD5_MAX 18 /* FIXME */
|
|
|
|
|
1998-07-10 03:39:04 +08:00
|
|
|
struct rip_connection {
|
1998-07-29 05:44:11 +08:00
|
|
|
node n;
|
|
|
|
|
|
|
|
int num;
|
|
|
|
struct proto *proto;
|
1998-07-10 03:39:04 +08:00
|
|
|
ip_addr addr;
|
|
|
|
sock *send;
|
1998-10-26 23:35:19 +08:00
|
|
|
struct rip_interface *rif;
|
1998-12-23 03:41:04 +08:00
|
|
|
struct fib_iterator iter;
|
1998-10-26 23:35:19 +08:00
|
|
|
|
|
|
|
ip_addr daddr;
|
|
|
|
int dport;
|
1998-12-23 03:41:04 +08:00
|
|
|
int done;
|
1998-07-10 03:39:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct rip_packet_heading {
|
|
|
|
u8 command;
|
1998-07-29 05:44:11 +08:00
|
|
|
#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
|
1998-07-10 03:39:04 +08:00
|
|
|
u8 version;
|
|
|
|
#define RIP_V1 1
|
|
|
|
#define RIP_V2 2
|
|
|
|
u16 unused;
|
|
|
|
};
|
|
|
|
|
1999-10-11 22:19:29 +08:00
|
|
|
#ifndef IPV6
|
1998-07-10 03:39:04 +08:00
|
|
|
struct rip_block {
|
|
|
|
u16 family; /* 0xffff on first message means this is authentication */
|
|
|
|
u16 tag;
|
1998-07-29 05:44:11 +08:00
|
|
|
ip_addr network;
|
|
|
|
ip_addr netmask;
|
|
|
|
ip_addr nexthop;
|
1998-07-10 03:39:04 +08:00
|
|
|
u32 metric;
|
|
|
|
};
|
1999-10-11 22:19:29 +08:00
|
|
|
#else
|
|
|
|
struct rip_block {
|
|
|
|
ip_addr network;
|
|
|
|
u16 tag;
|
|
|
|
u8 pxlen;
|
|
|
|
u8 metric
|
|
|
|
};
|
|
|
|
#endif
|
1998-07-10 03:39:04 +08:00
|
|
|
|
1999-06-01 01:12:38 +08:00
|
|
|
struct rip_block_auth {
|
|
|
|
u16 mustbeFFFF;
|
|
|
|
u16 authtype;
|
|
|
|
u16 packetlen;
|
|
|
|
u8 keyid;
|
|
|
|
u8 authlen;
|
|
|
|
u32 seq;
|
|
|
|
u32 zero0;
|
|
|
|
u32 zero1;
|
|
|
|
};
|
|
|
|
|
1999-06-01 03:16:22 +08:00
|
|
|
struct rip_md5_tail {
|
|
|
|
u16 mustbeFFFF;
|
|
|
|
u16 mustbe0001;
|
|
|
|
char md5[16];
|
|
|
|
};
|
|
|
|
|
1998-07-10 03:39:04 +08:00
|
|
|
struct rip_entry {
|
1998-12-23 03:41:04 +08:00
|
|
|
struct fib_node n;
|
1998-07-10 03:39:04 +08:00
|
|
|
|
1998-10-08 03:33:50 +08:00
|
|
|
ip_addr whotoldme;
|
1998-07-10 03:39:04 +08:00
|
|
|
ip_addr nexthop;
|
|
|
|
int metric;
|
|
|
|
u16 tag;
|
|
|
|
|
|
|
|
bird_clock_t updated, changed;
|
1998-10-08 03:33:50 +08:00
|
|
|
int flags;
|
|
|
|
#define RIP_F_EXTERNAL 1
|
1998-07-10 03:39:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct rip_packet {
|
|
|
|
struct rip_packet_heading heading;
|
|
|
|
struct rip_block block[25];
|
|
|
|
};
|
|
|
|
|
1998-10-26 23:35:19 +08:00
|
|
|
struct rip_interface {
|
|
|
|
node n;
|
|
|
|
struct proto *proto;
|
|
|
|
struct iface *iface;
|
|
|
|
sock *sock;
|
|
|
|
struct rip_connection *busy;
|
1999-01-13 00:50:38 +08:00
|
|
|
struct rip_patt *patt;
|
1999-11-25 21:38:25 +08:00
|
|
|
int triggered;
|
1999-01-13 00:40:55 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct rip_patt {
|
|
|
|
struct iface_patt i;
|
|
|
|
|
|
|
|
int metric;
|
|
|
|
int mode;
|
1999-06-01 03:43:08 +08:00
|
|
|
#define IM_MULTICAST 1
|
|
|
|
#define IM_BROADCAST 2
|
|
|
|
#define IM_QUIET 4
|
|
|
|
#define IM_NOLISTEN 8
|
|
|
|
#define IM_VERSION1 16
|
1998-10-26 23:35:19 +08:00
|
|
|
};
|
|
|
|
|
1999-02-15 21:34:43 +08:00
|
|
|
struct rip_proto_config {
|
1999-03-02 05:18:01 +08:00
|
|
|
struct proto_config c;
|
1999-02-15 21:34:43 +08:00
|
|
|
list iface_list; /* Patterns configured */
|
|
|
|
|
|
|
|
int infinity; /* User configurable data */
|
|
|
|
int port;
|
|
|
|
int period;
|
|
|
|
int garbage_time;
|
1999-11-10 19:52:36 +08:00
|
|
|
int timeout_time;
|
1999-05-11 17:53:45 +08:00
|
|
|
|
1999-05-26 22:37:47 +08:00
|
|
|
struct password_item *passwords;
|
1999-05-11 17:53:45 +08:00
|
|
|
int authtype;
|
|
|
|
#define AT_NONE 0
|
|
|
|
#define AT_PLAINTEXT 2
|
1999-06-01 01:12:38 +08:00
|
|
|
#define AT_MD5 3
|
1999-08-18 21:19:33 +08:00
|
|
|
int honour;
|
|
|
|
#define HO_NEVER 0
|
|
|
|
#define HO_NEIGHBOUR 1
|
|
|
|
#define HO_ALWAYS 2
|
1999-02-15 21:34:43 +08:00
|
|
|
};
|
|
|
|
|
1998-12-04 19:45:51 +08:00
|
|
|
struct rip_proto {
|
1998-07-10 03:39:04 +08:00
|
|
|
struct proto inherited;
|
|
|
|
timer *timer;
|
|
|
|
list connections;
|
1998-12-23 03:41:04 +08:00
|
|
|
struct fib rtable;
|
1998-10-21 00:12:43 +08:00
|
|
|
list garbage;
|
1998-12-04 19:45:51 +08:00
|
|
|
list interfaces; /* Interfaces we really know about */
|
1998-07-10 03:39:04 +08:00
|
|
|
int magic;
|
1999-11-25 21:38:25 +08:00
|
|
|
int tx_count; /* Do one regular update once in a while */
|
1998-07-10 03:39:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#define RIP_MAGIC 81861253
|
1998-12-20 22:26:57 +08:00
|
|
|
#define CHK_MAGIC do { if (P->magic != RIP_MAGIC) bug( "Not enough magic\n" ); } while (0)
|
1998-11-28 05:08:37 +08:00
|
|
|
|
|
|
|
void rip_init_instance(struct proto *p);
|
1999-03-02 05:18:01 +08:00
|
|
|
void rip_init_config(struct rip_proto_config *c);
|
1999-05-11 17:53:45 +08:00
|
|
|
|
|
|
|
/* Authentication functions */
|
|
|
|
|
1999-06-01 01:12:38 +08:00
|
|
|
int rip_incoming_authentication( struct proto *p, struct rip_block_auth *block, struct rip_packet *packet, int num );
|
|
|
|
void rip_outgoing_authentication( struct proto *p, struct rip_block_auth *block, struct rip_packet *packet, int num );
|