Changeset 2:d8ce06172629 in freeDiameter
- Timestamp:
- Aug 31, 2009, 5:32:22 PM (15 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
freeDiameter/CMakeLists.txt
r1 r2 18 18 TARGET_LINK_LIBRARIES(freeDiameterd libfreeDiameter ${FD_LIBS}) 19 19 20 # Save the list of files, if needed 21 SET(FD_COMMON_SRC ${FD_COMMON_SRC} PARENT_SCOPE) 22 20 23 # The unary tests directory 21 24 OPTION(SKIP_TESTS "Skip compilation of the tests?" OFF) -
freeDiameter/tests/CMakeLists.txt
r1 r2 20 20 # Some parameters for the tests 21 21 22 # Add this flag to add some debug information in the tests themselves23 22 ADD_DEFINITIONS(-DTEST_DEBUG) 23 ADD_DEFINITIONS(-DTRACE_LEVEL=NONE) 24 24 25 25 INCLUDE_DIRECTORIES( ".." ) 26 INCLUDE_DIRECTORIES( "../../libfreeDiameter" ) 26 27 27 28 SET(TEST_COMMON_SRC "") … … 35 36 # ENDFOREACH(SRC_FILE) 36 37 38 FOREACH( SRC_FILE ${LFD_SRC}) 39 SET(TEST_COMMON_SRC ${TEST_COMMON_SRC} "../../libfreeDiameter/${SRC_FILE}") 40 ENDFOREACH(SRC_FILE) 41 37 42 # Create an archive with the daemon common files (all but main) 38 43 ADD_LIBRARY(fDcore STATIC ${TEST_COMMON_SRC}) … … 43 48 FOREACH( TEST ${TEST_LIST} ) 44 49 ADD_EXECUTABLE(${TEST} ${TEST}.c tests.h) 45 TARGET_LINK_LIBRARIES(${TEST} libfreeDiameterfDcore ${FD_LIBS})50 TARGET_LINK_LIBRARIES(${TEST} fDcore ${FD_LIBS}) 46 51 ADD_TEST(${TEST} ${EXECUTABLE_OUTPUT_PATH}/${TEST}) 47 52 ENDFOREACH( TEST ) -
freeDiameter/tests/testmesg.c
r1 r2 436 436 memset(&buf, 0, sizeof(buf)); /* Test that the OS value is really copied */ 437 437 CHECK( 0, fd_msg_update_length ( avpi ) ); 438 #if 1438 #if 0 439 439 fd_log_debug("AVP octet string, 'This\\0 is a b...'\n"); 440 440 fd_msg_dump_one(0, avpi); -
freeDiameter/tests/tests.h
r1 r2 52 52 #endif /* TEST_TIMEOUT */ 53 53 54 static int test_verbosity = 0;55 56 54 /* Standard includes */ 57 55 #include <getopt.h> … … 76 74 } 77 75 76 static int test_verbo = 0; 77 78 78 /* Define the standard check routines */ 79 79 #define CHECK( _val, _assert ){ \ 80 if (test_verbo sity > 0) {\80 if (test_verbo > 0) { \ 81 81 fprintf(stderr, \ 82 82 "%s:%-4d: CHECK( " #_assert " == "\ … … 111 111 switch (c) { 112 112 case 'd': /* Increase verbosity of debug messages. */ 113 test_verbo sity++;113 test_verbo++; 114 114 break; 115 115 116 case 'q': /* Decrease verbosity then remove debug messages. */117 test_verbo sity--;116 case 'q': /* Decrease verbosity. */ 117 test_verbo--; 118 118 break; 119 119 … … 126 126 } 127 127 } 128 fd_g_debug_lvl = (test_verbo > 0) ? (test_verbo - 1) : 0; 128 129 if (!no_timeout) 129 130 alarm(TEST_TIMEOUT); -
include/freeDiameter/libfreeDiameter.h
r1 r2 122 122 char * fd_log_time ( char * buf, size_t len ); 123 123 124 /************************** DEBUG MACROS ************************************/125 124 126 125 /* levels definitions */ … … 137 136 #endif /* TRACE_LEVEL */ 138 137 139 /* The level of the file being compiled */138 /* The level of the file being compiled. */ 140 139 static int local_debug_level = TRACE_LEVEL; 141 140 142 /* helper macros (pre-processor hacks) */ 141 /* A global level, changed by configuration or cmd line for example. default is 0. */ 142 extern int fd_g_debug_lvl; 143 144 /* helper macros (pre-processor hacks to allow macro arguments) */ 143 145 #define __str( arg ) #arg 144 146 #define _stringize( arg ) __str( arg ) … … 146 148 #define _aggregate( arg1, arg2 ) __agr( arg1, arg2 ) 147 149 148 /* Some portability tricksto get nice function name in __PRETTY_FUNCTION__ */150 /* Some portability code to get nice function name in __PRETTY_FUNCTION__ */ 149 151 #if __STDC_VERSION__ < 199901L 150 152 # if __GNUC__ >= 2 … … 159 161 160 162 /* 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) */ 164 166 #define TRACE_DEBUG(level,format,args... ) { \ 165 167 if ( TRACE_BOOL(level) ) { \ … … 173 175 } 174 176 175 /* Helper for function entry */177 /* Helper for function entry -- for very detailed trace of the execution */ 176 178 #define TRACE_ENTRY(_format,_args... ) \ 177 179 TRACE_DEBUG(FCTS, "->%s (" #_args ") = (" _format ") >", __PRETTY_FUNCTION__, ##_args ); 178 180 179 /* Helper for debugging by adding traces */181 /* Helper for debugging by adding traces -- for debuging a specific location of the code */ 180 182 #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! */ 184 186 #define TRACE_DEBUG_ALL( str ) \ 185 187 TRACE_DEBUG(CALL, str ); … … 403 405 } 404 406 405 /* Cleanups for cancellation (all threads should be safely cancelable !) */407 /* Cleanups for cancellation (all threads should be safely cancelable...) */ 406 408 static __inline__ void fd_cleanup_mutex( void * mutex ) 407 409 { … … 1274 1276 #define ER_DIAMETER_REDIRECT_INDICATION 3006 1275 1277 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 1278 1371 1279 1372 -
libfreeDiameter/CMakeLists.txt
r1 r2 24 24 TARGET_LINK_LIBRARIES(libfreeDiameter ${FD_LIBS}) 25 25 26 # Save the list of files for testcases in the daemon's directory 27 SET(LFD_SRC ${LFD_SRC} PARENT_SCOPE) 28 -
libfreeDiameter/libfD.h
r1 r2 46 46 void fd_msg_eteid_init(void); 47 47 48 /* Iterator on the rules of a parent object */ 49 int fd_dict_iterate_rules ( struct dict_object *parent, void * data, int (*cb)(void *, struct dict_rule_data *) ); 50 51 48 52 49 53 #endif /* _LIBFD_H */ -
libfreeDiameter/log.c
r1 r2 40 40 pthread_mutex_t fd_log_lock = PTHREAD_MUTEX_INITIALIZER; 41 41 pthread_key_t fd_log_thname; 42 int fd_g_debug_lvl = 0; 42 43 43 44 /* Log a debug message */
Note: See TracChangeset
for help on using the changeset viewer.