diff options
Diffstat (limited to 'nest')
-rw-r--r-- | nest/bfd.h | 51 | ||||
-rw-r--r-- | nest/cmds.c | 10 | ||||
-rw-r--r-- | nest/proto.c | 8 | ||||
-rw-r--r-- | nest/protocol.h | 8 |
4 files changed, 70 insertions, 7 deletions
diff --git a/nest/bfd.h b/nest/bfd.h new file mode 100644 index 00000000..79c3c921 --- /dev/null +++ b/nest/bfd.h @@ -0,0 +1,51 @@ +/* + * BIRD -- Bidirectional Forwarding Detection (BFD) + * + * Can be freely distributed and used under the terms of the GNU GPL. + */ + +#ifndef _BIRD_NBFD_H_ +#define _BIRD_NBFD_H_ + +#include "lib/lists.h" +#include "lib/resource.h" + +struct bfd_session; + +struct bfd_request { + resource r; + node n; + + ip_addr addr; + ip_addr local; + struct iface *iface; + + void (*hook)(struct bfd_request *); + void *data; + + struct bfd_session *session; + + u8 state; + u8 diag; + u8 old_state; + u8 down; +}; + + +#ifdef CONFIG_BFD + +struct bfd_request * bfd_request_session(pool *p, ip_addr addr, ip_addr local, struct iface *iface, void (*hook)(struct bfd_request *), void *data); + +static inline void cf_check_bfd(int use) { } + +#else + +static inline struct bfd_request * bfd_request_session(pool *p, ip_addr addr, ip_addr local, struct iface *iface, void (*hook)(struct bfd_request *), void *data) { return NULL; } + +static inline void cf_check_bfd(int use) { if (use) cf_error("BFD not available"); } + +#endif /* CONFIG_BFD */ + + + +#endif /* _BIRD_NBFD_H_ */ diff --git a/nest/cmds.c b/nest/cmds.c index 9bdd66cd..ec6bc762 100644 --- a/nest/cmds.c +++ b/nest/cmds.c @@ -92,13 +92,10 @@ cmd_show_memory(void) cli_msg(0, ""); } -extern const char *log_buffer_ptr; - void cmd_eval(struct f_inst *expr) { struct f_val v = f_eval(expr, this_cli->parser_pool); - log_reset(); if (v.type == T_RETURN) { @@ -106,7 +103,8 @@ cmd_eval(struct f_inst *expr) return; } - val_print(v); - cli_msg(23, "%s", log_buffer_ptr); - log_reset(); + buffer buf; + LOG_BUFFER_INIT(buf); + val_format(v, &buf); + cli_msg(23, "%s", buf.start); } diff --git a/nest/proto.c b/nest/proto.c index 140ec943..75ba10dd 100644 --- a/nest/proto.c +++ b/nest/proto.c @@ -699,6 +699,9 @@ proto_build(struct protocol *p) } } +/* FIXME: convert this call to some protocol hook */ +extern void bfd_init_all(void); + /** * protos_build - build a protocol list * @@ -736,6 +739,11 @@ protos_build(void) #ifdef CONFIG_BGP proto_build(&proto_bgp); #endif +#ifdef CONFIG_BFD + proto_build(&proto_bfd); + bfd_init_all(); +#endif + proto_pool = rp_new(&root_pool, "Protocols"); proto_flush_event = ev_new(proto_pool); proto_flush_event->hook = proto_flush_loop; diff --git a/nest/protocol.h b/nest/protocol.h index 033a0ede..96923447 100644 --- a/nest/protocol.h +++ b/nest/protocol.h @@ -75,7 +75,7 @@ void protos_dump_all(void); extern struct protocol proto_device, proto_radv, proto_rip, proto_static, - proto_ospf, proto_pipe, proto_bgp; + proto_ospf, proto_pipe, proto_bgp, proto_bfd; /* * Routing Protocol Instance @@ -358,6 +358,12 @@ void proto_notify_state(struct proto *p, unsigned state); #define D_EVENTS 16 /* Protocol events */ #define D_PACKETS 32 /* Packets sent/received */ +#ifndef PARSER +#define TRACE(flags, msg, args...) \ + do { if (p->p.debug & flags) log(L_TRACE "%s: " msg, p->p.name , ## args ); } while(0) +#endif + + /* * MRTDump flags */ |