diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2013-09-16 23:57:40 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2013-09-16 23:57:40 +0200 |
commit | 6a8d3f1c1ffbd964e4d11b452c73e1ea70310af3 (patch) | |
tree | ffad2ba5c281d87ec64f3b9f419b17251ef616a6 /proto/bfd/bfd.h | |
parent | bf139664aa2ae9956b520ba4813bb6e03bf1a3e8 (diff) |
BFD work in progress.
Now it compiles and mostly works.
Diffstat (limited to 'proto/bfd/bfd.h')
-rw-r--r-- | proto/bfd/bfd.h | 67 |
1 files changed, 62 insertions, 5 deletions
diff --git a/proto/bfd/bfd.h b/proto/bfd/bfd.h index a54053d3..97ccb507 100644 --- a/proto/bfd/bfd.h +++ b/proto/bfd/bfd.h @@ -1,7 +1,28 @@ +/* + * BIRD -- Bidirectional Forwarding Detection (BFD) + * + * Can be freely distributed and used under the terms of the GNU GPL. + */ #ifndef _BIRD_BFD_H_ #define _BIRD_BFD_H_ +#include <pthread.h> + +#include "nest/bird.h" +#include "nest/cli.h" +#include "nest/iface.h" +#include "nest/protocol.h" +#include "nest/route.h" +#include "conf/conf.h" +#include "lib/hash.h" +#include "lib/resource.h" +#include "lib/socket.h" +#include "lib/string.h" + +#include "io.h" + + #define BFD_CONTROL_PORT 3784 #define BFD_ECHO_PORT 3785 #define BFD_MULTI_CTL_PORT 4784 @@ -15,7 +36,7 @@ struct bfd_config { struct proto_config c; - list neighbors; /* List of struct bfd_neighbor */ + list neigh_list; /* List of struct bfd_neighbor */ }; struct bfd_session_config @@ -42,12 +63,21 @@ struct bfd_neighbor struct bfd_proto { struct proto p; + struct birdloop *loop; + pool *tpool; + pthread_spinlock_t lock; slab *session_slab; HASH(struct bfd_session) session_hash_id; HASH(struct bfd_session) session_hash_ip; - list sockets; + sock *notify_rs; + sock *notify_ws; + list notify_list; + + sock *rx_1; + sock *rx_m; + list sock_list; }; struct bfd_socket @@ -60,16 +90,20 @@ struct bfd_socket struct bfd_session { node n; + ip_addr addr; /* Address of session */ struct bfd_session *next_id; /* Next in bfd.session_hash_id */ struct bfd_session *next_ip; /* Next in bfd.session_hash_ip */ + struct bfd_proto *bfd; u8 opened; + u8 passive; u8 poll_active; u8 poll_scheduled; u8 loc_state; u8 rem_state; u8 loc_diag; + u8 rem_diag; u32 loc_id; /* Local session ID (local discriminator) */ u32 rem_id; /* Remote session ID (remote discriminator) */ u32 des_min_tx_int; /* Desired min rx interval, local option */ @@ -83,11 +117,13 @@ struct bfd_session u8 detect_mult; /* Announced detect_mult, local option */ u8 rem_detect_mult; /* Last received detect_mult */ - xxx_time last_tx; /* Time of last sent periodic control packet */ - xxx_time last_rx; /* Time of last received valid control packet */ + btime last_tx; /* Time of last sent periodic control packet */ + btime last_rx; /* Time of last received valid control packet */ timer2 *tx_timer; /* Periodic control packet timer */ timer2 *hold_timer; /* Timer for session down detection time */ + + struct bfd_socket *bsock; /* Socket associated with session */ }; @@ -110,9 +146,30 @@ struct bfd_session #define BFD_POLL_TX 1 #define BFD_POLL_RX 2 +#define BFD_FLAG_POLL (1 << 5) +#define BFD_FLAG_FINAL (1 << 4) +#define BFD_FLAG_CPI (1 << 3) +#define BFD_FLAG_AP (1 << 2) +#define BFD_FLAG_DEMAND (1 << 1) +#define BFD_FLAG_MULTIPOINT (1 << 0) + + +static inline void bfd_lock_sessions(struct bfd_proto *p) { pthread_spin_lock(&p->lock); } +static inline void bfd_unlock_sessions(struct bfd_proto *p) { pthread_spin_unlock(&p->lock); } + +/* bfd.c */ +struct bfd_session * bfd_find_session_by_id(struct bfd_proto *p, u32 id); +struct bfd_session * bfd_find_session_by_addr(struct bfd_proto *p, ip_addr addr); +void bfd_session_process_ctl(struct bfd_session *s, u8 flags, u32 old_tx_int, u32 old_rx_int); +void bfd_show_sessions(struct proto *P); +/* packets.c */ +void bfd_send_ctl(struct bfd_proto *p, struct bfd_session *s, int final); +sock * bfd_open_rx_sk(struct bfd_proto *p, int multihop); +struct bfd_socket * bfd_get_socket(struct bfd_proto *p, ip_addr local, struct iface *ifa); +void bfd_free_socket(struct bfd_socket *sk); -#endif _BIRD_BFD_H_ +#endif /* _BIRD_BFD_H_ */ |