comparison libfdproto/messages.c @ 1120:c473581adff2

Cleanup some traces
author Sebastien Decugis <sdecugis@freediameter.net>
date Tue, 14 May 2013 12:32:28 +0800
parents 79dd22145f52
children ccbd1426e04a
comparison
equal deleted inserted replaced
1119:79dd22145f52 1120:c473581adff2
801 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Version: 0x%02hhX\n", msg->msg_public.msg_version), return NULL); 801 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Version: 0x%02hhX\n", msg->msg_public.msg_version), return NULL);
802 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Length: %d\n", msg->msg_public.msg_length), return NULL); 802 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Length: %d\n", msg->msg_public.msg_length), return NULL);
803 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Flags: 0x%02hhX (" DUMP_CMDFL_str ")\n", msg->msg_public.msg_flags, DUMP_CMDFL_val(msg->msg_public.msg_flags)), return NULL); 803 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Flags: 0x%02hhX (" DUMP_CMDFL_str ")\n", msg->msg_public.msg_flags, DUMP_CMDFL_val(msg->msg_public.msg_flags)), return NULL);
804 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Command Code: %u\n", msg->msg_public.msg_code), return NULL); 804 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Command Code: %u\n", msg->msg_public.msg_code), return NULL);
805 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " ApplicationId: %d\n", msg->msg_public.msg_appl), return NULL); 805 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " ApplicationId: %d\n", msg->msg_public.msg_appl), return NULL);
806 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Hop-by-Hop Identifier: 0x%8X\n", msg->msg_public.msg_hbhid), return NULL); 806 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Hop-by-Hop Identifier: 0x%08X\n", msg->msg_public.msg_hbhid), return NULL);
807 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " End-to-End Identifier: 0x%8X\n", msg->msg_public.msg_eteid), return NULL); 807 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " End-to-End Identifier: 0x%08X\n", msg->msg_public.msg_eteid), return NULL);
808 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " {debug data}: src:%s(%zd) rwb:%p rt:%d cb:%p,%p(%p) qry:%p asso:%d sess:%p", msg->msg_src_id?:"(nil)", msg->msg_src_id_len, msg->msg_rawbuffer, msg->msg_routable, msg->msg_cb.anscb, msg->msg_cb.expirecb, msg->msg_cb.data, msg->msg_query, msg->msg_associated, msg->msg_sess), return NULL); 808 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " {debug data}: src:%s(%zd) rwb:%p rt:%d cb:%p,%p(%p) qry:%p asso:%d sess:%p", msg->msg_src_id?:"(nil)", msg->msg_src_id_len, msg->msg_rawbuffer, msg->msg_routable, msg->msg_cb.anscb, msg->msg_cb.expirecb, msg->msg_cb.data, msg->msg_query, msg->msg_associated, msg->msg_sess), return NULL);
809 809
810 return *buf; 810 return *buf;
811 } 811 }
812 812
1068 1068
1069 if (level) { 1069 if (level) {
1070 if (first) { 1070 if (first) {
1071 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " {"), return NULL); 1071 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " {"), return NULL);
1072 } else { 1072 } else {
1073 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "+"), return NULL); 1073 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, ","), return NULL);
1074 } 1074 }
1075 } 1075 }
1076 1076
1077 if (!CHECK_AVP(avp)) { 1077 if (!CHECK_AVP(avp)) {
1078 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "INVALID"), return NULL); 1078 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "INVALID"), return NULL);
1128 } 1128 }
1129 } 1129 }
1130 } else { 1130 } else {
1131 /* For embedded AVPs, we only display (vendor,) code & length */ 1131 /* For embedded AVPs, we only display (vendor,) code & length */
1132 if (avp->avp_public.avp_flags & AVP_FLAG_VENDOR) { 1132 if (avp->avp_public.avp_flags & AVP_FLAG_VENDOR) {
1133 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "V=%u,", avp->avp_public.avp_vendor), return NULL); 1133 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "V:%u/", avp->avp_public.avp_vendor), return NULL);
1134 } 1134 }
1135 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "C=%u,L=%d", avp->avp_public.avp_code, avp->avp_public.avp_len), return NULL); 1135 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "C:%u/l:%d", avp->avp_public.avp_code, avp->avp_public.avp_len), return NULL);
1136 } 1136 }
1137 1137
1138 end: 1138 end:
1139 if ((level) && (last)) { 1139 if ((level) && (last)) {
1140 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "}"), return NULL); 1140 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "}"), return NULL);
1339 static struct dict_object *cached_avp_rr_model = NULL; 1339 static struct dict_object *cached_avp_rr_model = NULL;
1340 static struct dictionary *cached_avp_rr_dict = NULL; 1340 static struct dictionary *cached_avp_rr_dict = NULL;
1341 static pthread_mutex_t cached_avp_rr_lock = PTHREAD_MUTEX_INITIALIZER; 1341 static pthread_mutex_t cached_avp_rr_lock = PTHREAD_MUTEX_INITIALIZER;
1342 1342
1343 /* Associate source peer */ 1343 /* Associate source peer */
1344 int fd_msg_source_set( struct msg * msg, DiamId_t diamid, size_t diamidlen, int add_rr, struct dictionary * dict ) 1344 int fd_msg_source_set( struct msg * msg, DiamId_t diamid, size_t diamidlen )
1345 { 1345 {
1346 TRACE_ENTRY( "%p %p %zd %d %p", msg, diamid, diamidlen, add_rr, dict); 1346 TRACE_ENTRY( "%p %p %zd", msg, diamid, diamidlen);
1347 1347
1348 /* Check we received a valid message */ 1348 /* Check we received a valid message */
1349 CHECK_PARAMS( CHECK_MSG(msg) && ( (! add_rr) || dict ) ); 1349 CHECK_PARAMS( CHECK_MSG(msg) );
1350 1350
1351 /* Cleanup any previous source */ 1351 /* Cleanup any previous source */
1352 free(msg->msg_src_id); msg->msg_src_id = NULL; msg->msg_src_id_len = 0; 1352 free(msg->msg_src_id); msg->msg_src_id = NULL; msg->msg_src_id_len = 0;
1353 1353
1354 /* If the request is to cleanup the source, we are done */ 1354 /* If the request is to cleanup the source, we are done */
1357 } 1357 }
1358 1358
1359 /* Otherwise save the new informations */ 1359 /* Otherwise save the new informations */
1360 CHECK_MALLOC( msg->msg_src_id = os0dup(diamid, diamidlen) ); 1360 CHECK_MALLOC( msg->msg_src_id = os0dup(diamid, diamidlen) );
1361 msg->msg_src_id_len = diamidlen; 1361 msg->msg_src_id_len = diamidlen;
1362 1362 /* done */
1363 1363 return 0;
1364 if (add_rr) { 1364 }
1365 struct dict_object *avp_rr_model = NULL; 1365
1366 avp_code_t code = AC_ROUTE_RECORD; 1366 /* Associate source peer */
1367 struct avp *avp; 1367 int fd_msg_source_setrr( struct msg * msg, DiamId_t diamid, size_t diamidlen, struct dictionary * dict )
1368 union avp_value val; 1368 {
1369 1369 struct dict_object *avp_rr_model = NULL;
1370 /* Lock the cached values */ 1370 avp_code_t code = AC_ROUTE_RECORD;
1371 struct avp *avp;
1372 union avp_value val;
1373
1374 TRACE_ENTRY( "%p %p %zd %p", msg, diamid, diamidlen, dict);
1375
1376 /* Check we received a valid message */
1377 CHECK_PARAMS( CHECK_MSG(msg) && dict );
1378
1379 /* Lock the cached values */
1380 CHECK_POSIX( pthread_mutex_lock(&cached_avp_rr_lock) );
1381 if (cached_avp_rr_dict == dict) {
1382 avp_rr_model = cached_avp_rr_model;
1383 }
1384 CHECK_POSIX( pthread_mutex_unlock(&cached_avp_rr_lock) );
1385
1386 /* If it was not cached */
1387 if (!avp_rr_model) {
1388 /* Find the model for Route-Record in the dictionary */
1389 CHECK_FCT( fd_dict_search ( dict, DICT_AVP, AVP_BY_CODE, &code, &avp_rr_model, ENOENT) );
1390
1391 /* Now cache this result */
1371 CHECK_POSIX( pthread_mutex_lock(&cached_avp_rr_lock) ); 1392 CHECK_POSIX( pthread_mutex_lock(&cached_avp_rr_lock) );
1372 if (cached_avp_rr_dict == dict) { 1393 cached_avp_rr_dict = dict;
1373 avp_rr_model = cached_avp_rr_model; 1394 cached_avp_rr_model = avp_rr_model;
1374 }
1375 CHECK_POSIX( pthread_mutex_unlock(&cached_avp_rr_lock) ); 1395 CHECK_POSIX( pthread_mutex_unlock(&cached_avp_rr_lock) );
1376 1396 }
1377 /* If it was not cached */ 1397
1378 if (!avp_rr_model) { 1398 /* Create the AVP with this model */
1379 /* Find the model for Route-Record in the dictionary */ 1399 CHECK_FCT( fd_msg_avp_new ( avp_rr_model, 0, &avp ) );
1380 CHECK_FCT( fd_dict_search ( dict, DICT_AVP, AVP_BY_CODE, &code, &avp_rr_model, ENOENT) ); 1400
1381 1401 /* Set the AVP value with the diameter id */
1382 /* Now cache this result */ 1402 memset(&val, 0, sizeof(val));
1383 CHECK_POSIX( pthread_mutex_lock(&cached_avp_rr_lock) ); 1403 val.os.data = (uint8_t *)diamid;
1384 cached_avp_rr_dict = dict; 1404 val.os.len = diamidlen;
1385 cached_avp_rr_model = avp_rr_model; 1405 CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) );
1386 CHECK_POSIX( pthread_mutex_unlock(&cached_avp_rr_lock) ); 1406
1387 } 1407 /* Add the AVP in the message */
1388 1408 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp ) );
1389 /* Create the AVP with this model */
1390 CHECK_FCT( fd_msg_avp_new ( avp_rr_model, 0, &avp ) );
1391
1392 /* Set the AVP value with the diameter id */
1393 memset(&val, 0, sizeof(val));
1394 val.os.data = (uint8_t *)diamid;
1395 val.os.len = diamidlen;
1396 CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) );
1397
1398 /* Add the AVP in the message */
1399 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp ) );
1400 }
1401 1409
1402 /* done */ 1410 /* done */
1403 return 0; 1411 return 0;
1404 } 1412 }
1405 1413
"Welcome to our mercurial repository"