1998-07-09 19:39:04 +00:00
|
|
|
/*
|
|
|
|
* Structures for RIP protocol
|
1999-10-11 14:19:29 +00:00
|
|
|
*
|
|
|
|
FIXME: in V6, they insert additional entry whenever next hop differs. Such entry is identified by 0xff in metric.
|
1998-07-09 19:39:04 +00:00
|
|
|
*/
|
|
|
|
|
2015-03-17 11:39:10 +00:00
|
|
|
#include "nest/bird.h"
|
1998-12-22 19:41:04 +00:00
|
|
|
#include "nest/route.h"
|
1999-05-26 14:37:47 +00:00
|
|
|
#include "nest/password.h"
|
2000-03-22 14:26:03 +00:00
|
|
|
#include "nest/locks.h"
|
2015-03-17 11:39:10 +00:00
|
|
|
#include "nest/iface.h"
|
|
|
|
#include "lib/socket.h"
|
1998-12-22 19:41:04 +00:00
|
|
|
|
1999-05-31 19:16:22 +00:00
|
|
|
#define EA_RIP_TAG EA_CODE(EAP_RIP, 0)
|
|
|
|
#define EA_RIP_METRIC EA_CODE(EAP_RIP, 1)
|
|
|
|
|
2012-03-15 11:38:08 +00:00
|
|
|
#define PACKET_MAX 25
|
|
|
|
#define PACKET_MD5_MAX 18 /* FIXME */
|
|
|
|
|
|
|
|
|
|
|
|
#define RIP_V1 1
|
|
|
|
#define RIP_V2 2
|
|
|
|
#define RIP_NG 1 /* A new version numbering */
|
|
|
|
|
|
|
|
#ifndef IPV6
|
|
|
|
#define RIP_PORT 520 /* RIP for IPv4 */
|
|
|
|
#else
|
|
|
|
#define RIP_PORT 521 /* RIPng */
|
|
|
|
#endif
|
1999-08-18 13:19:33 +00:00
|
|
|
|
1998-07-09 19:39:04 +00:00
|
|
|
struct rip_connection {
|
1998-07-28 21:44:11 +00:00
|
|
|
node n;
|
|
|
|
|
|
|
|
int num;
|
|
|
|
struct proto *proto;
|
1998-07-09 19:39:04 +00:00
|
|
|
ip_addr addr;
|
|
|
|
sock *send;
|
1998-10-26 15:35:19 +00:00
|
|
|
struct rip_interface *rif;
|
1998-12-22 19:41:04 +00:00
|
|
|
struct fib_iterator iter;
|
1998-10-26 15:35:19 +00:00
|
|
|
|
|
|
|
ip_addr daddr;
|
|
|
|
int dport;
|
1998-12-22 19:41:04 +00:00
|
|
|
int done;
|
1998-07-09 19:39:04 +00:00
|
|
|
};
|
|
|
|
|
1999-11-25 15:03:12 +00:00
|
|
|
struct rip_packet_heading { /* 4 bytes */
|
1998-07-09 19:39:04 +00:00
|
|
|
u8 command;
|
1998-07-28 21:44:11 +00: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-09 19:39:04 +00:00
|
|
|
u8 version;
|
2012-03-15 11:38:08 +00:00
|
|
|
#define RIP_V1 1
|
|
|
|
#define RIP_V2 2
|
|
|
|
#define RIP_NG 1 /* this is verion 1 of RIPng */
|
1998-07-09 19:39:04 +00:00
|
|
|
u16 unused;
|
|
|
|
};
|
|
|
|
|
1999-10-11 14:19:29 +00:00
|
|
|
#ifndef IPV6
|
1999-11-25 14:54:08 +00:00
|
|
|
struct rip_block { /* 20 bytes */
|
1998-07-09 19:39:04 +00:00
|
|
|
u16 family; /* 0xffff on first message means this is authentication */
|
|
|
|
u16 tag;
|
1998-07-28 21:44:11 +00:00
|
|
|
ip_addr network;
|
|
|
|
ip_addr netmask;
|
|
|
|
ip_addr nexthop;
|
1998-07-09 19:39:04 +00:00
|
|
|
u32 metric;
|
|
|
|
};
|
1999-10-11 14:19:29 +00:00
|
|
|
#else
|
2000-06-05 15:41:44 +00:00
|
|
|
struct rip_block { /* IPv6 version!, 20 bytes, too */
|
1999-10-11 14:19:29 +00:00
|
|
|
ip_addr network;
|
|
|
|
u16 tag;
|
|
|
|
u8 pxlen;
|
1999-12-16 13:14:32 +00:00
|
|
|
u8 metric;
|
1999-10-11 14:19:29 +00:00
|
|
|
};
|
|
|
|
#endif
|
1998-07-09 19:39:04 +00:00
|
|
|
|
1999-11-25 14:54:08 +00:00
|
|
|
struct rip_block_auth { /* 20 bytes */
|
1999-05-31 17:12:38 +00:00
|
|
|
u16 mustbeFFFF;
|
|
|
|
u16 authtype;
|
|
|
|
u16 packetlen;
|
|
|
|
u8 keyid;
|
|
|
|
u8 authlen;
|
|
|
|
u32 seq;
|
|
|
|
u32 zero0;
|
|
|
|
u32 zero1;
|
|
|
|
};
|
|
|
|
|
1999-11-25 14:54:08 +00:00
|
|
|
struct rip_md5_tail { /* 20 bytes */
|
1999-05-31 19:16:22 +00:00
|
|
|
u16 mustbeFFFF;
|
|
|
|
u16 mustbe0001;
|
|
|
|
char md5[16];
|
|
|
|
};
|
|
|
|
|
1998-07-09 19:39:04 +00:00
|
|
|
struct rip_entry {
|
1998-12-22 19:41:04 +00:00
|
|
|
struct fib_node n;
|
1998-07-09 19:39:04 +00:00
|
|
|
|
1998-10-07 19:33:50 +00:00
|
|
|
ip_addr whotoldme;
|
1998-07-09 19:39:04 +00:00
|
|
|
ip_addr nexthop;
|
|
|
|
int metric;
|
|
|
|
u16 tag;
|
|
|
|
|
|
|
|
bird_clock_t updated, changed;
|
1998-10-07 19:33:50 +00:00
|
|
|
int flags;
|
1998-07-09 19:39:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct rip_packet {
|
|
|
|
struct rip_packet_heading heading;
|
2000-04-26 11:07:57 +00:00
|
|
|
struct rip_block block[PACKET_MAX];
|
1998-07-09 19:39:04 +00:00
|
|
|
};
|
|
|
|
|
1998-10-26 15:35:19 +00:00
|
|
|
struct rip_interface {
|
|
|
|
node n;
|
|
|
|
struct proto *proto;
|
|
|
|
struct iface *iface;
|
|
|
|
sock *sock;
|
|
|
|
struct rip_connection *busy;
|
2000-05-10 13:23:21 +00:00
|
|
|
int metric; /* You don't want to put struct rip_patt *patt here -- think about reconfigure */
|
|
|
|
int mode;
|
2013-06-25 13:33:00 +00:00
|
|
|
int check_ttl; /* Check incoming packets for TTL 255 */
|
1999-11-25 13:38:25 +00:00
|
|
|
int triggered;
|
2000-03-22 14:26:03 +00:00
|
|
|
struct object_lock *lock;
|
2000-03-26 18:01:27 +00:00
|
|
|
int multicast;
|
1999-01-12 16:40:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct rip_patt {
|
|
|
|
struct iface_patt i;
|
|
|
|
|
2000-05-16 14:58:06 +00:00
|
|
|
int metric; /* If you add entries here, don't forget to modify patt_compare! */
|
1999-01-12 16:40:55 +00:00
|
|
|
int mode;
|
1999-05-31 19:43:08 +00:00
|
|
|
#define IM_BROADCAST 2
|
|
|
|
#define IM_QUIET 4
|
|
|
|
#define IM_NOLISTEN 8
|
|
|
|
#define IM_VERSION1 16
|
2013-06-24 14:37:30 +00:00
|
|
|
int tx_tos;
|
|
|
|
int tx_priority;
|
2013-06-25 13:33:00 +00:00
|
|
|
int ttl_security; /* bool + 2 for TX only (send, but do not check on RX) */
|
1998-10-26 15:35:19 +00:00
|
|
|
};
|
|
|
|
|
1999-02-15 13:34:43 +00:00
|
|
|
struct rip_proto_config {
|
1999-03-01 21:18:01 +00:00
|
|
|
struct proto_config c;
|
2000-05-10 13:05:39 +00:00
|
|
|
list iface_list; /* Patterns configured -- keep it first; see rip_reconfigure why */
|
2004-06-26 20:11:14 +00:00
|
|
|
list *passwords; /* Passwords, keep second */
|
1999-02-15 13:34:43 +00:00
|
|
|
|
2000-05-16 14:58:06 +00:00
|
|
|
int infinity; /* User configurable data; must be comparable with memcmp */
|
1999-02-15 13:34:43 +00:00
|
|
|
int port;
|
|
|
|
int period;
|
|
|
|
int garbage_time;
|
1999-11-10 11:52:36 +00:00
|
|
|
int timeout_time;
|
1999-05-11 09:53:45 +00:00
|
|
|
|
|
|
|
int authtype;
|
|
|
|
#define AT_NONE 0
|
|
|
|
#define AT_PLAINTEXT 2
|
1999-05-31 17:12:38 +00:00
|
|
|
#define AT_MD5 3
|
2000-05-04 20:08:34 +00:00
|
|
|
int honor;
|
1999-08-18 13:19:33 +00:00
|
|
|
#define HO_NEVER 0
|
2000-05-04 20:08:34 +00:00
|
|
|
#define HO_NEIGHBOR 1
|
1999-08-18 13:19:33 +00:00
|
|
|
#define HO_ALWAYS 2
|
1999-02-15 13:34:43 +00:00
|
|
|
};
|
|
|
|
|
1998-12-04 11:45:51 +00:00
|
|
|
struct rip_proto {
|
1998-07-09 19:39:04 +00:00
|
|
|
struct proto inherited;
|
|
|
|
timer *timer;
|
|
|
|
list connections;
|
1998-12-22 19:41:04 +00:00
|
|
|
struct fib rtable;
|
1998-10-20 16:12:43 +00:00
|
|
|
list garbage;
|
1998-12-04 11:45:51 +00:00
|
|
|
list interfaces; /* Interfaces we really know about */
|
2004-06-23 21:34:26 +00:00
|
|
|
#ifdef LOCAL_DEBUG
|
1998-07-09 19:39:04 +00:00
|
|
|
int magic;
|
2004-06-23 21:34:26 +00:00
|
|
|
#endif
|
1999-11-25 13:38:25 +00:00
|
|
|
int tx_count; /* Do one regular update once in a while */
|
2013-02-23 23:43:08 +00:00
|
|
|
int rnd_count; /* Randomize sending time */
|
1998-07-09 19:39:04 +00:00
|
|
|
};
|
|
|
|
|
2004-06-23 21:34:26 +00:00
|
|
|
#ifdef LOCAL_DEBUG
|
1998-07-09 19:39:04 +00:00
|
|
|
#define RIP_MAGIC 81861253
|
2000-06-04 19:56:06 +00:00
|
|
|
#define CHK_MAGIC do { if (P->magic != RIP_MAGIC) bug( "Not enough magic" ); } while (0)
|
2004-06-23 21:34:26 +00:00
|
|
|
#else
|
|
|
|
#define CHK_MAGIC do { } while (0)
|
|
|
|
#endif
|
|
|
|
|
1998-11-27 21:08:37 +00:00
|
|
|
|
1999-03-01 21:18:01 +00:00
|
|
|
void rip_init_config(struct rip_proto_config *c);
|
1999-05-11 09:53:45 +00:00
|
|
|
|
|
|
|
/* Authentication functions */
|
|
|
|
|
1999-12-01 12:52:57 +00:00
|
|
|
int rip_incoming_authentication( struct proto *p, struct rip_block_auth *block, struct rip_packet *packet, int num, ip_addr whotoldme );
|
1999-11-25 14:54:08 +00:00
|
|
|
int rip_outgoing_authentication( struct proto *p, struct rip_block_auth *block, struct rip_packet *packet, int num );
|