Navigation



Ignore:
Timestamp:
Aug 31, 2009, 5:32:22 PM (15 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Added a global debug level var

File:
1 edited

Legend:

Unmodified
Added
Removed
  • include/freeDiameter/libfreeDiameter.h

    r1 r2  
    122122char * fd_log_time ( char * buf, size_t len );
    123123
    124 /************************** DEBUG MACROS ************************************/
    125124
    126125/* levels definitions */
     
    137136#endif /* TRACE_LEVEL */
    138137
    139 /* The level of the file being compiled */
     138/* The level of the file being compiled. */
    140139static int local_debug_level = TRACE_LEVEL;
    141140
    142 /* helper macros (pre-processor hacks) */
     141/* A global level, changed by configuration or cmd line for example. default is 0. */
     142extern int fd_g_debug_lvl;
     143
     144/* helper macros (pre-processor hacks to allow macro arguments) */
    143145#define __str( arg )  #arg
    144146#define _stringize( arg ) __str( arg )
     
    146148#define _aggregate( arg1, arg2 ) __agr( arg1, arg2 )
    147149
    148 /* Some portability tricks to get nice function name in __PRETTY_FUNCTION__ */
     150/* Some portability code to get nice function name in __PRETTY_FUNCTION__ */
    149151#if __STDC_VERSION__ < 199901L
    150152# if __GNUC__ >= 2
     
    159161
    160162/* Boolean for tracing at a certain level */
    161 #define TRACE_BOOL(_level_) ( (_level_) <= local_debug_level )
    162 
    163 /* The general debug macro, each call results in two lines of debug messages */
     163#define TRACE_BOOL(_level_) ( (_level_) <= local_debug_level + fd_g_debug_lvl )
     164
     165/* The general debug macro, each call results in two lines of debug messages (change the macro for more compact output) */
    164166#define TRACE_DEBUG(level,format,args... ) {                                                                                    \
    165167        if ( TRACE_BOOL(level) ) {                                                                                              \
     
    173175}
    174176
    175 /* Helper for function entry */
     177/* Helper for function entry -- for very detailed trace of the execution */
    176178#define TRACE_ENTRY(_format,_args... ) \
    177179        TRACE_DEBUG(FCTS, "->%s (" #_args ") = (" _format ") >", __PRETTY_FUNCTION__, ##_args );
    178180
    179 /* Helper for debugging by adding traces */
     181/* Helper for debugging by adding traces -- for debuging a specific location of the code */
    180182#define TRACE_HERE()    \
    181         TRACE_DEBUG(INFO, " -- debug checkpoint -- ");
    182 
    183 /* Helper for tracing the CHECK_* macros bellow */
     183        TRACE_DEBUG(NONE, " -- debug checkpoint -- ");
     184
     185/* Helper for tracing the CHECK_* macros bellow -- very very verbose code execution! */
    184186#define TRACE_DEBUG_ALL( str )  \
    185187        TRACE_DEBUG(CALL, str );
     
    403405}
    404406
    405 /* Cleanups for cancellation (all threads should be safely cancelable!) */
     407/* Cleanups for cancellation (all threads should be safely cancelable...) */
    406408static __inline__ void fd_cleanup_mutex( void * mutex )
    407409{
     
    12741276#define ER_DIAMETER_REDIRECT_INDICATION         3006
    12751277
    1276 /* Iterator on the rules of a parent object */
    1277 int fd_dict_iterate_rules ( struct dict_object *parent, void * data, int (*cb)(void *, struct dict_rule_data *) );
     1278
     1279/*============================================================*/
     1280/*                         SESSIONS                           */
     1281/*============================================================*/
     1282
     1283
     1284
     1285/*
     1286 * The libfreeDiameter does not provide a full support of the sessions state machines as described in the RFC3588.
     1287 * It only provides a basic support allowing an extension to associate some state with a session identifier, and retrieve
     1288 * this data later.
     1289 *
     1290 * A session is an opaque object, associated with a value of a Session-Id AVP.
     1291 * An extension that wants to associate data with the session must first register as session module client
     1292 * with the sess_regext function to get an identifier object (sess_reg_t).
     1293 *
     1294 * The module manages tuplets ( sess_id_t *, sess_reg_t *, void *). The following functions are used to manage these tuplets:
     1295 * sess_data_reg  : associate a pointer with a given session for a given module client.
     1296 * sess_data_dereg: removes an association.
     1297 * sess_data_get  : get the pointer associated with an association without changing it.
     1298 *
     1299 * Note that creating an association calls sess_link as a side effect, and removing the association calls sess_unlink.
     1300 *
     1301 * QUICK TUTORIAL:
     1302 *  For an extension that wants to implement a session state machine, here is a quick guide.
     1303 *
     1304 * First, the extension must define a structure to save the session state, for example appstate_t.
     1305 *
     1306 * Since the extension will use the session module, it creates a sess_reg_t by calling sess_regext.
     1307 *
     1308 * If the extension behaves as a client, it receives external events that trig the start of a new sessions.
     1309 * When such event occurs, the extension calls sess_new with the appropriate parameters to create a new session.
     1310 * It initializes an appstate_t structure with the data of this session and creates an association with sess_data_reg (%).
     1311 * Then it creates a message (application-specific) to request authentication and/or authorization for the service
     1312 * and the message is sent.
     1313 *
     1314 * Later, assuming that the extension has registered appropriate callbacks in the dispatcher module, when a message
     1315 * is received, the extension can retrieve the state of the session with the sess_data_get function.
     1316 *
     1317 * Finaly, when the extension decides to terminate the session (timer, or as result of a message exchange), it
     1318 * calls sess_data_dereg in order to destroy the binding in the daemon. When last message refering this session is freed,
     1319 * the session data is freed.
     1320 *
     1321 * (%) A this time, the extension must call sess_unlink in order to counter the effects of the sess_new function.
     1322 * This allows to have the session destroyed when no more data is associated to it.
     1323
     1324
     1325
     1326/*============================================================*/
     1327/*                         DISPATCH                           */
     1328/*============================================================*/
     1329
     1330/* The dispatch process consists in passing a message to some handlers
     1331 (typically provided by extensions) based on its content (app id, cmd code...) */
     1332
     1333/* The dispatch module has two main roles:
     1334 *  - help determine if a message can be handled locally (during the routing step)
     1335 *  - pass the message to the callback(s) that will handle it (during the dispatch step)
     1336 *
     1337 * These are the possibilities for registering a callback:
     1338 *
     1339 * -> For All messages.
     1340 *  This callback is called for all messages that are handled locally. This should be used only
     1341 *  internally by the daemon, or for debug purpose.
     1342 *
     1343 * -> by AVP value (constants).
     1344 *  This callback will be called when a message is received and contains a certain AVP with a specified value.
     1345 *
     1346 * -> by AVP.
     1347 *  This callback will be called when the received message contains a certain AVP.
     1348 *
     1349 * -> by command-code.
     1350 *  This callback will be called when the message is a specific command.
     1351 *
     1352 * -> by application.
     1353 *  This callback will be called when the message has a specific application-id.
     1354 *
     1355 * ( by vendor: would this be useful? it may be added later)
     1356 *
     1357 * Note that several criteria may be selected at the same time, for example command-code AND application id.
     1358 *
     1359 * When a callback is called, it receives the message as parameter, and eventually a pointer to
     1360 * the AVP in the message when this is appropriate.
     1361 *
     1362 * The callback must process the message, and eventually create an answer to it. See the definition
     1363 * bellow for more information.
     1364 *
     1365 * If no callback has handled the message, a default handler will be called with the effect of
     1366 * requeuing the message for forwarding on the network to another peer (for requests, if possible), or
     1367 * discarding the message (for answers).
     1368 */
     1369
     1370
    12781371
    12791372
Note: See TracChangeset for help on using the changeset viewer.