summaryrefslogtreecommitdiff
path: root/nest
diff options
context:
space:
mode:
Diffstat (limited to 'nest')
-rw-r--r--nest/config.Y36
-rw-r--r--nest/mrtdump.h27
-rw-r--r--nest/proto.c10
-rw-r--r--nest/protocol.h15
4 files changed, 78 insertions, 10 deletions
diff --git a/nest/config.Y b/nest/config.Y
index dbb10ada..11f0a9b2 100644
--- a/nest/config.Y
+++ b/nest/config.Y
@@ -45,7 +45,7 @@ CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE, STATES, ROUTES, FILT
CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, INTERFACES)
CF_KEYWORDS(PRIMARY, STATS, COUNT, FOR, COMMANDS, PREEXPORT, GENERATE)
CF_KEYWORDS(LISTEN, BGP, V6ONLY, ADDRESS, PORT, PASSWORDS, DESCRIPTION)
-CF_KEYWORDS(RELOAD, IN, OUT)
+CF_KEYWORDS(RELOAD, IN, OUT, MRTDUMP, MESSAGES)
CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT,
RIP, OSPF, OSPF_IA, OSPF_EXT1, OSPF_EXT2, BGP, PIPE)
@@ -58,7 +58,7 @@ CF_ENUM(T_ENUM_RTD, RTD_, ROUTER, DEVICE, BLACKHOLE, UNREACHABLE, PROHIBIT)
%type <r> rtable
%type <s> optsym
%type <ra> r_args
-%type <i> echo_mask echo_size debug_mask debug_list debug_flag export_or_preexport
+%type <i> echo_mask echo_size debug_mask debug_list debug_flag mrtdump_mask mrtdump_list mrtdump_flag export_or_preexport
%type <t> proto_patt
CF_GRAMMAR
@@ -138,6 +138,7 @@ proto_item:
}
| DISABLED bool { this_proto->disabled = $2; }
| DEBUG debug_mask { this_proto->debug = $2; }
+ | MRTDUMP mrtdump_mask { this_proto->mrtdump = $2; }
| IMPORT imexport { this_proto->in_filter = $2; }
| EXPORT imexport { this_proto->out_filter = $2; }
| TABLE rtable { this_proto->table = $2; }
@@ -166,6 +167,8 @@ debug_default:
| DEBUG COMMANDS expr { new_config->cli_debug = $3; }
;
+/* MRTDUMP PROTOCOLS is in systep/unix/config.Y */
+
/* Interface patterns */
iface_patt_node_init:
@@ -251,6 +254,24 @@ debug_flag:
| PACKETS { $$ = D_PACKETS; }
;
+/* MRTDump flags */
+
+mrtdump_mask:
+ ALL { $$ = ~0; }
+ | OFF { $$ = 0; }
+ | '{' mrtdump_list '}' { $$ = $2; }
+ ;
+
+mrtdump_list:
+ mrtdump_flag
+ | mrtdump_list ',' mrtdump_flag { $$ = $1 | $3; }
+ ;
+
+mrtdump_flag:
+ STATES { $$ = MD_STATES; }
+ | MESSAGES { $$ = MD_MESSAGES; }
+ ;
+
/* Password lists */
password_list:
@@ -450,9 +471,14 @@ CF_CLI(RELOAD IN, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protoco
CF_CLI(RELOAD OUT, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol (just exported routes)]])
{ proto_xxable($3, XX_RELOAD_OUT); } ;
-CF_CLI_HELP(DEBUG, ..., [[Control protocol debugging]])
-CF_CLI(DEBUG, proto_patt debug_mask, (<protocol> | <pattern> | all) (all | off | { states | routes | filters | events | packets }), [[Control protocol debugging]])
-{ proto_debug($2, $3); }
+CF_CLI_HELP(DEBUG, ..., [[Control protocol debugging via BIRD logs]])
+CF_CLI(DEBUG, proto_patt debug_mask, (<protocol> | <pattern> | all) (all | off | { states | routes | filters | events | packets }), [[Control protocol debugging via BIRD logs]])
+{ proto_debug($2, 0, $3); }
+ ;
+
+CF_CLI_HELP(MRTDUMP, ..., [[Control protocol debugging via MRTdump files]])
+CF_CLI(MRTDUMP, proto_patt mrtdump_mask, (<protocol> | <pattern> | all) (all | off | { states | messages }), [[Control protocol debugging via MRTdump format]])
+{ proto_debug($2, 1, $3); }
;
proto_patt:
diff --git a/nest/mrtdump.h b/nest/mrtdump.h
new file mode 100644
index 00000000..8638804a
--- /dev/null
+++ b/nest/mrtdump.h
@@ -0,0 +1,27 @@
+/*
+ * BIRD -- Password handling
+ *
+ *
+ * Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+#ifndef MRTDUMP_H
+#define MRTDUMP_H
+#include "nest/protocol.h"
+
+/* MRTDump values */
+
+#define MRTDUMP_HDR_LENGTH 12
+
+#define BGP4MP 16
+
+#define BGP4MP_MESSAGE 1
+#define BGP4MP_MESSAGE_AS4 4
+#define BGP4MP_STATE_CHANGE_AS4 5
+
+
+/* implemented in sysdep */
+void mrt_dump_message(struct proto *p, u16 type, u16 subtype, byte *buf, u32 len);
+
+#endif
+
diff --git a/nest/proto.c b/nest/proto.c
index 4f352a6f..9f0311f6 100644
--- a/nest/proto.c
+++ b/nest/proto.c
@@ -111,6 +111,7 @@ proto_new(struct proto_config *c, unsigned size)
p->cf = c;
p->debug = c->debug;
+ p->mrtdump = c->mrtdump;
p->name = c->name;
p->preference = c->preference;
p->disabled = c->disabled;
@@ -201,6 +202,7 @@ proto_config_new(struct protocol *pr, unsigned size)
c->out_filter = FILTER_REJECT;
c->table = c->global->master_rtc;
c->debug = new_config->proto_default_debug;
+ c->mrtdump = new_config->proto_default_mrtdump;
return c;
}
@@ -325,6 +327,7 @@ protos_commit(struct config *new, struct config *old, int force_reconfig, int ty
{
/* Generic attributes match, try converting them and then ask the protocol */
p->debug = nc->debug;
+ p->mrtdump = nc->mrtdump;
if (p->proto->reconfigure && p->proto->reconfigure(p, nc))
{
DBG("\t%s: same\n", oc->name);
@@ -901,14 +904,17 @@ proto_xxable(char *pattern, int xx)
}
void
-proto_debug(char *pattern, unsigned int mask)
+proto_debug(char *pattern, int which, unsigned int mask)
{
int cnt = 0;
WALK_PROTO_LIST(p)
if (patmatch(pattern, p->name))
{
cnt++;
- p->debug = mask;
+ if (which == 0)
+ p->debug = mask;
+ else
+ p->mrtdump = mask;
}
WALK_PROTO_LIST_END;
if (!cnt)
diff --git a/nest/protocol.h b/nest/protocol.h
index 21a1c1b4..5a69b33b 100644
--- a/nest/protocol.h
+++ b/nest/protocol.h
@@ -82,7 +82,8 @@ struct proto_config {
struct proto *proto; /* Instance we've created */
char *name;
char *dsc;
- unsigned debug, preference, disabled; /* Generic parameters */
+ u32 debug, mrtdump; /* Debugging bitfields, both use D_* constants */
+ unsigned preference, disabled; /* Generic parameters */
u32 router_id; /* Protocol specific router ID */
struct rtable_config *table; /* Table we're attached to */
struct filter *in_filter, *out_filter; /* Attached filters */
@@ -125,7 +126,8 @@ struct proto {
struct event *attn; /* "Pay attention" event */
char *name; /* Name of this instance (== cf->name) */
- unsigned debug; /* Debugging flags */
+ u32 debug; /* Debugging flags */
+ u32 mrtdump; /* MRTDump flags */
unsigned preference; /* Default route preference */
int min_scope; /* Minimal route scope accepted */
unsigned accept_ra_types; /* Which types of route announcements are accepted (RA_OPTIMAL or RA_ANY) */
@@ -199,7 +201,7 @@ void proto_request_feeding(struct proto *p);
void proto_show(struct symbol *, int);
struct proto *proto_get_named(struct symbol *, struct protocol *);
void proto_xxable(char *, int);
-void proto_debug(char *, unsigned int);
+void proto_debug(char *, int, unsigned int);
#define XX_DISABLE 0
#define XX_ENABLE 1
@@ -307,6 +309,13 @@ void proto_notify_state(struct proto *p, unsigned state);
#define D_PACKETS 32 /* Packets sent/received */
/*
+ * MRTDump flags
+ */
+
+#define MD_STATES 1 /* Protocol state changes (BGP4MP_MESSAGE_AS4) */
+#define MD_MESSAGES 2 /* Protocol packets (BGP4MP_MESSAGE_AS4) */
+
+/*
* Known unique protocol instances as referenced by config routines
*/