protocol.h 2.23 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/*
 *	BIRD Internet Routing Daemon -- Protocols
 *
 *	(c) 1998 Martin Mares <mj@ucw.cz>
 *
 *	Can be freely distributed and used under the terms of the GNU GPL.
 */

#ifndef _BIRD_PROTOCOL_H_
#define _BIRD_PROTOCOL_H_

12
#include "lib/lists.h"
13
#include "lib/resource.h"
14

15 16 17 18
struct iface;
struct rte;
struct neighbor;
struct rtattr;
19
struct network;
20

21 22 23 24 25
/*
 *	Routing Protocol
 */

struct protocol {
26
  node n;
27 28 29 30 31 32 33 34
  char *name;
  unsigned debug;			/* Default debugging flags */

  void (*init)(struct protocol *);	/* Boot time */
  void (*preconfig)(struct protocol *);	/* Just before configuring */
  void (*postconfig)(struct protocol *); /* After configuring */
};

35
void protos_build(void);
36 37 38
void protos_init(void);
void protos_preconfig(void);
void protos_postconfig(void);
39
void protos_start(void);
40
void protos_dump_all(void);
41 42

extern list protocol_list;
43 44 45 46 47

/*
 *	Known protocols
 */

48
extern struct protocol proto_device;
49
extern struct protocol proto_rip;
50 51 52 53 54 55

/*
 *	Routing Protocol Instance
 */

struct proto {
56
  node n;
57 58 59 60 61
  struct protocol *proto;		/* Protocol */
  char *name;				/* Name of this instance */
  unsigned debug;			/* Debugging flags */
  pool *pool;				/* Local objects */
  unsigned preference;			/* Default route preference */
62
  unsigned state;			/* PRS_... */
63
  unsigned disabled;			/* Manually disabled */
64

65
  void (*if_notify)(struct proto *, unsigned flags, struct iface *new, struct iface *old);
66
  void (*rt_notify)(struct proto *, struct network *net, struct rte *new, struct rte *old);
67
  void (*neigh_notify)(struct neighbor *neigh);
68
  void (*dump)(struct proto *);			/* Debugging dump */
69 70 71
  void (*start)(struct proto *);		/* Start the instance */
  void (*shutdown)(struct proto *, int time);	/* Stop the instance */

72 73
  int (*rta_same)(struct rtattr *, struct rtattr *);
  int (*rte_better)(struct rte *, struct rte *);
74 75
  void (*rte_insert)(struct network *, struct rte *);
  void (*rte_remove)(struct network *, struct rte *);
76

77 78 79 80 81 82 83 84
  /* Reconfigure function? */
  /* Interface patterns */
  /* Input/output filters */
  /* Connection to routing tables? */

  /* Hic sunt protocol-specific data */
};

85 86 87 88
#define PRS_DOWN 0			/* Inactive */
#define PRS_STARTING 1
#define PRS_UP 2

89 90
void *proto_new(struct protocol *, unsigned size);

91
extern list proto_list, inactive_proto_list;
92

93
#endif