Navigation


Changeset 1120:c473581adff2 in freeDiameter for libfdproto


Ignore:
Timestamp:
May 14, 2013, 1:32:28 PM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Cleanup some traces

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfdproto/messages.c

    r1119 r1120  
    804804        CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "  Command Code: %u\n", msg->msg_public.msg_code), return NULL);
    805805        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);
    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);
     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%08X\n", msg->msg_public.msg_eteid), return NULL);
    808808        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);
    809809       
     
    10711071                        CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " {"), return NULL);
    10721072                } 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);
    10741074                }
    10751075        }
     
    11311131                /* For embedded AVPs, we only display (vendor,) code & length */
    11321132                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);
    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);
     1133                        CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "V:%u/", avp->avp_public.avp_vendor), return NULL);
     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);
    11361136        }
    11371137       
     
    13421342
    13431343/* Associate source peer */
    1344 int fd_msg_source_set( struct msg * msg, DiamId_t diamid, size_t diamidlen, int add_rr, struct dictionary * dict )
    1345 {
    1346         TRACE_ENTRY( "%p %p %zd %d %p", msg, diamid, diamidlen, add_rr, dict);
     1344int fd_msg_source_set( struct msg * msg, DiamId_t diamid, size_t diamidlen )
     1345{
     1346        TRACE_ENTRY( "%p %p %zd", msg, diamid, diamidlen);
    13471347       
    13481348        /* Check we received a valid message */
    1349         CHECK_PARAMS( CHECK_MSG(msg) && ( (! add_rr) || dict ) );
     1349        CHECK_PARAMS( CHECK_MSG(msg) );
    13501350       
    13511351        /* Cleanup any previous source */
     
    13601360        CHECK_MALLOC( msg->msg_src_id = os0dup(diamid, diamidlen) );
    13611361        msg->msg_src_id_len = diamidlen;
    1362        
    1363        
    1364         if (add_rr) {
    1365                 struct dict_object      *avp_rr_model = NULL;
    1366                 avp_code_t               code = AC_ROUTE_RECORD;
    1367                 struct avp              *avp;
    1368                 union avp_value          val;
    1369                
    1370                 /* Lock the cached values */
     1362        /* done */
     1363        return 0;
     1364}
     1365
     1366/* Associate source peer */
     1367int fd_msg_source_setrr( struct msg * msg, DiamId_t diamid, size_t diamidlen, struct dictionary * dict )
     1368{
     1369        struct dict_object      *avp_rr_model = NULL;
     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 */
    13711392                CHECK_POSIX( pthread_mutex_lock(&cached_avp_rr_lock) );
    1372                 if (cached_avp_rr_dict == dict) {
    1373                         avp_rr_model = cached_avp_rr_model;
    1374                 }
     1393                cached_avp_rr_dict  = dict;
     1394                cached_avp_rr_model = avp_rr_model;
    13751395                CHECK_POSIX( pthread_mutex_unlock(&cached_avp_rr_lock) );
    1376                
    1377                 /* If it was not cached */
    1378                 if (!avp_rr_model) {
    1379                         /* Find the model for Route-Record in the dictionary */
    1380                         CHECK_FCT( fd_dict_search ( dict, DICT_AVP, AVP_BY_CODE, &code, &avp_rr_model, ENOENT) );
    1381                        
    1382                         /* Now cache this result */
    1383                         CHECK_POSIX( pthread_mutex_lock(&cached_avp_rr_lock) );
    1384                         cached_avp_rr_dict  = dict;
    1385                         cached_avp_rr_model = avp_rr_model;
    1386                         CHECK_POSIX( pthread_mutex_unlock(&cached_avp_rr_lock) );
    1387                 }
    1388                
    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         }
     1396        }
     1397
     1398        /* Create the AVP with this model */
     1399        CHECK_FCT( fd_msg_avp_new ( avp_rr_model, 0, &avp ) );
     1400
     1401        /* Set the AVP value with the diameter id */
     1402        memset(&val, 0, sizeof(val));
     1403        val.os.data = (uint8_t *)diamid;
     1404        val.os.len  = diamidlen;
     1405        CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) );
     1406
     1407        /* Add the AVP in the message */
     1408        CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp ) );
    14011409       
    14021410        /* done */
Note: See TracChangeset for help on using the changeset viewer.