Navigation


Changes in / [1002:7ca81c10ba06:997:632913581c37] in freeDiameter


Ignore:
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • include/freeDiameter/libfdproto.h

    r998 r992  
    312312
    313313/* Helper for tracing the CHECK_* macros below -- very very verbose code execution! */
    314 #define TRACE_DEBUG_ALL( str... )       \
     314#define TRACE_DEBUG_ALL( str )  \
    315315        TRACE_DEBUG(CALL, str );
    316316
     
    479479#define CHECK_SYS_DO( __call__, __fallback__  ) {                                       \
    480480        int __ret__;                                                                    \
    481         TRACE_DEBUG_ALL( "Check SYS: %s", #__call__ );                                  \
     481        TRACE_DEBUG_ALL( "Check SYS: " #__call__ );                                     \
    482482        __ret__ = (__call__);                                                           \
    483483        if (__ret__ < 0) {                                                              \
    484484                int __err__ = errno;    /* We may handle EINTR here */                  \
    485                 TRACE_ERROR("ERROR: in '%s' :\t%s",  #__call__ , strerror(__err__));    \
     485                TRACE_ERROR("ERROR: in '" #__call__ "' :\t%s", strerror(__err__));\
    486486                __fallback__;                                                           \
    487487        }                                                                               \
     
    490490#define CHECK_SYS( __call__  ) {                                                        \
    491491        int __ret__;                                                                    \
    492         TRACE_DEBUG_ALL( "Check SYS: %s", #__call__ );                                  \
     492        TRACE_DEBUG_ALL( "Check SYS: " #__call__ );                                     \
    493493        __ret__ = (__call__);                                                           \
    494494        if (__ret__ < 0) {                                                              \
    495495                int __err__ = errno;    /* We may handle EINTR here */                  \
    496                 TRACE_ERROR("ERROR: in '%s' :\t%s", #__call__ , strerror(__err__));     \
     496                TRACE_ERROR("ERROR: in '" #__call__ "' :\t%s", strerror(__err__));\
    497497                return __err__;                                                         \
    498498        }                                                                               \
     
    502502#define CHECK_POSIX_DO2( __call__, __speval__, __fallback1__, __fallback2__ ) {                 \
    503503        int __ret__;                                                                            \
    504         TRACE_DEBUG_ALL( "Check POSIX: %s", #__call__ );                                        \
     504        TRACE_DEBUG_ALL( "Check POSIX: " #__call__ );                                           \
    505505        __ret__ = (__call__);                                                                   \
    506506        if (__ret__ != 0) {                                                                     \
     
    508508                        __fallback1__;                                                          \
    509509                } else {                                                                        \
    510                         TRACE_ERROR("ERROR: in '%s':\t%s", #__call__, strerror(__ret__));       \
     510                        TRACE_ERROR("ERROR: in '" #__call__ "':\t%s", strerror(__ret__));       \
    511511                        __fallback2__;                                                          \
    512512                }                                                                               \
     
    527527#define CHECK_MALLOC_DO( __call__, __fallback__ ) {                                     \
    528528        void *  __ret__;                                                                \
    529         TRACE_DEBUG_ALL( "Check MALLOC: %s", #__call__ );                               \
     529        TRACE_DEBUG_ALL( "Check MALLOC: " #__call__ );                                  \
    530530        __ret__ = (void *)( __call__ );                                                 \
    531531        if (__ret__ == NULL) {                                                          \
    532532                int __err__ = errno;                                                    \
    533                 TRACE_ERROR("ERROR: in '%s':\t%s", #__call__, strerror(__err__));       \
     533                TRACE_ERROR("ERROR: in '" #__call__ "':\t%s", strerror(__err__));       \
    534534                __fallback__;                                                           \
    535535        }                                                                               \
     
    543543/* Check parameters at function entry, execute fallback on error */
    544544#define CHECK_PARAMS_DO( __bool__, __fallback__ )                                               \
    545         TRACE_DEBUG_ALL( "Check PARAMS: %s", #__bool__ );                                       \
     545        TRACE_DEBUG_ALL( "Check PARAMS: " #__bool__ );                                          \
    546546        if ( ! (__bool__) ) {                                                                   \
    547                 TRACE_ERROR("Warning: Invalid parameter received in '%s'", #__bool__);          \
     547                TRACE_ERROR("Warning: Invalid parameter received in '" #__bool__ "'");  \
    548548                __fallback__;                                                                   \
    549549        }
     
    555555#define CHECK_FCT_DO( __call__, __fallback__ ) {                                        \
    556556        int __ret__;                                                                    \
    557         TRACE_DEBUG_ALL( "Check FCT: %s", #__call__ );                                  \
     557        TRACE_DEBUG_ALL( "Check FCT: " #__call__ );                                     \
    558558        __ret__ = (__call__);                                                           \
    559559        if (__ret__ != 0) {                                                             \
    560                 TRACE_ERROR("ERROR: in '%s':\t%s", #__call__, strerror(__ret__));       \
     560                TRACE_ERROR("ERROR: in '" #__call__ "':\t%s", strerror(__ret__));       \
    561561                __fallback__;                                                           \
    562562        }                                                                               \
  • libfdcore/cnxctx.c

    r999 r982  
    12081208                                snprintf(buf, sizeof(buf), "\t - Certificate serial number: ");
    12091209                                for (j = 0; j < size; j++) {
    1210                                         snprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), "%02hhx", serial[j]);
     1210                                        snprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), "%02.2hhx", serial[j]);
    12111211                                }
    12121212                                fd_log_debug(buf);
  • libfdproto/lists.c

    r1001 r740  
    7575void fd_list_move_end(struct fd_list * ref, struct fd_list * senti)
    7676{
    77         struct fd_list * li;
    7877        ASSERT(ref->head == ref);
    7978        ASSERT(senti->head == senti);
     
    8180        if (senti->next == senti)
    8281                return;
    83        
    84         for (li = senti->next; li != senti; li = li->next)
    85                 li->head = ref;
    8682       
    8783        senti->next->prev = ref->prev;
  • libfdproto/messages.c

    r1001 r995  
    303303static int bufferize_avp(unsigned char * buffer, size_t buflen, size_t * offset,  struct avp * avp);
    304304static int parsebuf_list(unsigned char * buf, size_t buflen, struct fd_list * head);
    305 static int parsedict_do_chain(struct dictionary * dict, struct fd_list * head, int mandatory, struct fd_pei *error_info);
    306 
    307305
    308306/* Create answer from a request */
     
    368366        if (! (flags & MSGFL_ANSW_NOPROXYINFO)) {
    369367                struct avp * avp;
    370                 struct fd_pei pei;
    371                 struct fd_list avpcpylist = FD_LIST_INITIALIZER(avpcpylist);
    372                
    373368                CHECK_FCT(  fd_msg_browse(qry, MSG_BRW_FIRST_CHILD, &avp, NULL)  );
    374369                while (avp) {
     
    381376                                size_t offset = 0;
    382377
    383                                 /* Create a buffer with the content of the AVP. This is easier than going through the list */
    384378                                CHECK_FCT(  fd_msg_update_length(avp)  );
    385379                                CHECK_MALLOC(  buf = malloc(avp->avp_public.avp_len)  );
    386380                                CHECK_FCT( bufferize_avp(buf, avp->avp_public.avp_len, &offset, avp)  );
    387381
    388                                 /* Now we parse this buffer to create a copy AVP */
    389                                 CHECK_FCT( parsebuf_list(buf, avp->avp_public.avp_len, &avpcpylist) );
    390                                
    391                                 /* Parse dictionary objects now to remove the dependency on the buffer */
    392                                 CHECK_FCT( parsedict_do_chain(dict, &avpcpylist, 0, &pei) );
     382                                /* Now we directly parse this buffer into the new message list */
     383                                CHECK_FCT( parsebuf_list(buf, avp->avp_public.avp_len, &ans->msg_chain.children) );
    393384
    394385                                /* Done for this AVP */
    395386                                free(buf);
    396 
    397                                 /* We move this AVP now so that we do not parse again in next loop */
    398                                 fd_list_move_end(&ans->msg_chain.children, &avpcpylist);
    399387                        }
    400388                        /* move to next AVP in the message, we can have several Proxy-Info instances */
    401389                        CHECK_FCT( fd_msg_browse(avp, MSG_BRW_NEXT, &avp, NULL) );
    402390                }
     391                CHECK_FCT( fd_msg_parse_dict( ans, dict, NULL ) );
    403392        }
    404393
     
    15691558                CHECK_PARAMS( avp->avp_source || avp->avp_rawdata );
    15701559               
    1571                 if ( avp->avp_rawdata != NULL ) {
    1572                         /* the content was stored in rawdata */
    1573                         memcpy(&buffer[*offset], avp->avp_rawdata, avp->avp_rawlen);
    1574                         *offset += PAD4(avp->avp_rawlen);
    1575                 } else {
     1560                if ( avp->avp_source != NULL ) {
    15761561                        /* the message was not parsed completely */
    15771562                        size_t datalen = avp->avp_public.avp_len - GETAVPHDRSZ(avp->avp_public.avp_flags);
    15781563                        memcpy(&buffer[*offset], avp->avp_source, datalen);
    15791564                        *offset += PAD4(datalen);
     1565                } else {
     1566                        /* the content was stored in rawdata */
     1567                        memcpy(&buffer[*offset], avp->avp_rawdata, avp->avp_rawlen);
     1568                        *offset += PAD4(avp->avp_rawlen);
    15801569                }
    15811570               
     
    18241813 */
    18251814
     1815static int parsedict_do_chain(struct dictionary * dict, struct fd_list * head, int mandatory, struct fd_pei *error_info);
     1816
    18261817static char error_message[256];
    18271818
     
    18301821{
    18311822        struct dict_avp_data dictdata;
    1832         uint8_t * source;
    18331823       
    18341824        TRACE_ENTRY("%p %p %d %p", dict, avp, mandatory, error_info);
     
    19231913        }
    19241914       
    1925         source = avp->avp_source;
    1926         avp->avp_source = NULL;
    1927 
    19281915        /* Now get the value inside */
    19291916        switch (dictdata.avp_basetype) {
     
    19321919                       
    19331920                        /* This is a grouped AVP, so let's parse the list of AVPs inside */
    1934                         CHECK_FCT_DO(  ret = parsebuf_list(source, avp->avp_public.avp_len - GETAVPHDRSZ( avp->avp_public.avp_flags ), &avp->avp_chain.children),
     1921                        CHECK_FCT_DO(  ret = parsebuf_list(avp->avp_source, avp->avp_public.avp_len - GETAVPHDRSZ( avp->avp_public.avp_flags ), &avp->avp_chain.children),
    19351922                                {
    19361923                                        if ((ret == EBADMSG) && (error_info)) {
     
    19401927                                                error_info->pei_message = error_message;
    19411928                                        }
    1942                                         avp->avp_source = source;
    19431929                                        return ret;
    19441930                                }  );
     
    19551941                                                error_info->pei_avp = avp;
    19561942                                        }
    1957                                         avp->avp_source = source;
    19581943                                        return EBADMSG;
    19591944                                } );
    19601945                        avp->avp_storage.os.len = avp->avp_public.avp_len - GETAVPHDRSZ( avp->avp_public.avp_flags );
    1961                         CHECK_MALLOC(  avp->avp_storage.os.data = os0dup(source, avp->avp_storage.os.len)  );
     1946                        CHECK_MALLOC(  avp->avp_storage.os.data = os0dup(avp->avp_source, avp->avp_storage.os.len)  );
    19621947                        avp->avp_mustfreeos = 1;
    19631948                        break;
    19641949               
    19651950                case AVP_TYPE_INTEGER32:
    1966                         avp->avp_storage.i32 = (int32_t)ntohl(*(uint32_t *)source);
     1951                        avp->avp_storage.i32 = (int32_t)ntohl(*(uint32_t *)avp->avp_source);
    19671952                        break;
    19681953       
     
    19711956                        {
    19721957                                uint64_t __stor;
    1973                                 memcpy(&__stor, source, sizeof(__stor));
     1958                                memcpy(&__stor, avp->avp_source, sizeof(__stor));
    19741959                                avp->avp_storage.i64 = (int64_t)ntohll(__stor);
    19751960                        }
     
    19781963                case AVP_TYPE_UNSIGNED32:
    19791964                case AVP_TYPE_FLOAT32: /* For float, we must not cast, or the value is changed. Instead we use implicit cast by changing the member of the union */
    1980                         avp->avp_storage.u32 = (uint32_t)ntohl(*(uint32_t *)source);
     1965                        avp->avp_storage.u32 = (uint32_t)ntohl(*(uint32_t *)avp->avp_source);
    19811966                        break;
    19821967       
     
    19851970                        {
    19861971                                uint64_t __stor;
    1987                                 memcpy(&__stor, source, sizeof(__stor));
     1972                                memcpy(&__stor, avp->avp_source, sizeof(__stor));
    19881973                                avp->avp_storage.u64 = (uint64_t)ntohll(__stor);
    19891974                        }
  • tests/tests.h

    r1000 r995  
    6969#define FAILTEST( message... ){                         \
    7070        TRACE_ERROR(message);                           \
    71         TRACE_ERROR("FAILED: %s ", __STRIPPED_FILE__);  \
     71        TRACE_NOTICE("Test %s failed", __FILE__);       \
    7272        exit(FAIL);                                     \
    7373}
     
    7575/* Define the macro to pass a test */
    7676#define PASSTEST( ){                                    \
    77         TRACE_NOTICE("PASS: %s", __STRIPPED_FILE__);    \
     77        TRACE_NOTICE("Test %s passed", __FILE__);       \
    7878        (void)fd_core_shutdown();                       \
    7979        (void)fd_core_wait_shutdown_complete();         \
     
    8989#define CHECK( _val, _assert ){                         \
    9090        if (test_verbo > 0) {                           \
    91                 TRACE_NOTICE("CHECK( %s == %s )",       \
    92                                 #_assert,               \
    93                                 #_val);                 \
     91                TRACE_DEBUG(INFO,                       \
     92                        "%s:%-4d: CHECK( " #_assert " == "\
     93                                #_val " )",             \
     94                        __FILE__,                       \
     95                        __LINE__);                      \
    9496        }{                                              \
    9597        __typeof__ (_val) __ret = (_assert);            \
    9698        if (__ret != (_val)) {                          \
    9799                FAILTEST( "%s:%d: CHECK FAILED : %s == %lx != %lx",     \
    98                         __STRIPPED_FILE__,              \
     100                        __FILE__,                       \
    99101                        __LINE__,                       \
    100102                        #_assert,                       \
     
    197199        CHECK( 0, fd_libproto_init() );
    198200       
    199         fd_log_threadname(fname);
     201        fd_log_threadname(basename(fname));
    200202       
    201203        /* Parse the command line */
     
    227229        return;
    228230}
    229 #define INIT_FD()  test_init(argc, argv, __STRIPPED_FILE__)
     231#define INIT_FD()  test_init(argc, argv, __FILE__);
    230232
    231233#endif /* _TESTS_H */
Note: See TracChangeset for help on using the changeset viewer.