From 96d8e3bff242d5c9d0eb75fa04a21f6c09d8dbcf Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 7 Mar 2000 20:49:48 +0000 Subject: 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). --- nest/protocol.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'nest/protocol.h') diff --git a/nest/protocol.h b/nest/protocol.h index 0dacccbd..f4ce3843 100644 --- a/nest/protocol.h +++ b/nest/protocol.h @@ -34,7 +34,6 @@ struct protocol { node n; char *name; char *template; /* Template for automatic generation of names */ - unsigned debug; /* Default debugging flags */ int name_counter; /* Counter for automatic name generation */ void (*preconfig)(struct protocol *, struct config *); /* Just before configuring */ @@ -156,6 +155,7 @@ void *proto_config_new(struct protocol *, unsigned size); 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); extern list active_proto_list; @@ -234,6 +234,16 @@ void proto_notify_state(struct proto *p, unsigned state); #define FS_HAPPY 2 #define FS_FLUSHING 3 +/* + * Debugging flags + */ + +#define D_STATES 1 /* [core] State transitions */ +#define D_ROUTES 2 /* [core] Routes passed by the filters */ +#define D_FILTERS 4 /* [core] Filtering of routes */ +#define D_EVENTS 8 /* Protocol events */ +#define D_PACKETS 16 /* Packets sent/received */ + /* * Known unique protocol instances as referenced by config routines */ -- cgit v1.2.3