summaryrefslogtreecommitdiffstats
path: root/nest/proto.c
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>2000-03-07 21:49:48 +0100
committerMartin Mares <mj@ucw.cz>2000-03-07 21:49:48 +0100
commit96d8e3bff242d5c9d0eb75fa04a21f6c09d8dbcf (patch)
treef24438e8463e414eb0f5c27b19994ef3b2f52ce4 /nest/proto.c
parentc801e1fbabee49838287a9e96814d3d0bf84ffa2 (diff)
downloadbird-96d8e3bff242d5c9d0eb75fa04a21f6c09d8dbcf.tar
bird-96d8e3bff242d5c9d0eb75fa04a21f6c09d8dbcf.zip
Added protocol debugging flags (protocol.h: D_xxx), parsing of them
in configuration files and commands for manipulating them. Current debug message policy: o D_STATES, D_ROUTES and D_FILTERS are handled in generic code. o Other debug flags should be handled in the protocols and whenever the flag is set, the corresponding messages should be printed using calls to log(L_TRACE, ...), each message prefixed with the name of the protocol instance. These messages should cover the whole normal operation of the protocol and should be useful for an administrator trying to understand what does the protocol behave on his network or who is attempting to diagnose network problems. If your messages don't fit to the categories I've defined, feel free to add your own ones (by adding them to protocol.h and on two places in nest/config.Y), but please try to keep the categories as general as possible (i.e., not tied to your protocol). o Internal debug messages not interesting even to an experienced user should be printed by calling DBG() which is either void or a call to debug() depending on setting of the LOCAL_DEBUG symbol at the top of your source. o Dump functions (proto->dump etc.) should call debug() to print their messages. o If you are doing any internal consistency checks, use ASSERT or bug(). o Nobody shall ever call printf() or any other stdio functions. Also please try to log any protocol errors you encounter and tag them with the appropriate message category (usually L_REMOTE or L_AUTH). Always carefully check contents of any message field you receive and verify all IP addresses you work with (by calling ipa_classify() or by using the neighbour cache if you want to check direct connectedness as well).
Diffstat (limited to 'nest/proto.c')
-rw-r--r--nest/proto.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/nest/proto.c b/nest/proto.c
index 68975ad..b2f296b 100644
--- a/nest/proto.c
+++ b/nest/proto.c
@@ -139,7 +139,6 @@ proto_config_new(struct protocol *pr, unsigned size)
add_tail(&new_config->protos, &c->n);
c->global = new_config;
c->protocol = pr;
- c->debug = pr->debug;
c->name = pr->name;
c->out_filter = FILTER_REJECT;
c->table = c->global->master_rtc;
@@ -603,3 +602,20 @@ proto_xxable(char *pattern, int xx)
else
cli_msg(0, "");
}
+
+void
+proto_debug(char *pattern, unsigned int mask)
+{
+ int cnt = 0;
+ WALK_PROTO_LIST(p)
+ if (patmatch(pattern, p->name))
+ {
+ cnt++;
+ p->debug = mask;
+ }
+ WALK_PROTO_LIST_END;
+ if (!cnt)
+ cli_msg(8003, "No protocols match");
+ else
+ cli_msg(0, "");
+}