Navigation


Changeset 1088:1d1a20a0779d in freeDiameter


Ignore:
Timestamp:
May 5, 2013, 4:25:27 AM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though

Files:
34 edited

Legend:

Unmodified
Added
Removed
  • extensions/_sample/sample.c

    r974 r1088  
    8585                CHECK_FCT( fd_dict_new ( fd_g_config->cnf_dict, DICT_RULE, &rule_data, example_avp_avp, NULL ));
    8686               
    87                 fd_dict_dump_object(example_avp_avp);
    8887        }
    8988        TRACE_DEBUG(INFO, "'Example-AVP' created without error");
  • extensions/app_diameap/diameap_server.c

    r1027 r1088  
    8585
    8686
    87 void diameap_cli_sess_cleanup(void * arg, char * sid, void * opaque)
    88 {
    89 
    90         struct diameap_sess_data_sm * diameap_sess_data =
    91                         (struct diameap_sess_data_sm *) arg;
     87void diameap_cli_sess_cleanup(struct sess_state * diameap_sess_data, os0_t sid, void * opaque)
     88{
     89
    9290        CHECK_PARAMS_DO( diameap_sess_data, return );
    9391
     
    141139static int diameap_initialize_diameap_sm(
    142140                struct diameap_state_machine * diameap_sm,
    143                 struct diameap_sess_data_sm * diameap_sess_data)
     141                struct sess_state * diameap_sess_data)
    144142{
    145143        TRACE_ENTRY("%p %p", diameap_sm, diameap_sess_data);
     
    10171015
    10181016static int diameap_sess_data_new(
    1019                 struct diameap_sess_data_sm *diameap_sess_data,
     1017                struct sess_state *diameap_sess_data,
    10201018                struct diameap_state_machine *diameap_sm)
    10211019{
     
    30643062        TRACE_ENTRY("%p %p %p %p", rmsg, ravp, sess, action);
    30653063
    3066         struct diameap_sess_data_sm * diameap_sess_data = NULL;
     3064        struct sess_state * diameap_sess_data = NULL;
    30673065        struct diameap_state_machine * diameap_sm = NULL;
    30683066        struct diameap_eap_interface eap_i;
     
    32583256                        TRACE_DEBUG(FULL+1,"%sStoring DiamEAP session data.",DIAMEAP_EXTENSION)
    32593257                        ;
    3260                         CHECK_MALLOC(diameap_sess_data = malloc(sizeof(struct diameap_sess_data_sm)))
    3261                         ;
    3262                         memset(diameap_sess_data, 0, sizeof(struct diameap_sess_data_sm));
     3258                        CHECK_MALLOC(diameap_sess_data = malloc(sizeof(struct sess_state)))
     3259                        ;
     3260                        memset(diameap_sess_data, 0, sizeof(struct sess_state));
    32633261                        diameap_sess_data_new(diameap_sess_data, diameap_sm);
    32643262
     
    33893387
    33903388        /*create handler for sessions */
    3391         CHECK_FCT(fd_sess_handler_create(&diameap_server_reg, diameap_cli_sess_cleanup, NULL));
     3389        CHECK_FCT(fd_sess_handler_create(&diameap_server_reg, diameap_cli_sess_cleanup, NULL, NULL));
    33923390
    33933391        /* Register the callback */
  • extensions/app_diameap/diameap_server.h

    r441 r1088  
    4040#define DIAMEAP_SERVER_H_
    4141
    42 
     42 
    4343/* session data structure to store */
    44 struct diameap_sess_data_sm
     44struct sess_state
    4545{
    4646        int invalid_eappackets; /* Number of invalid EAP Packet received*/
  • extensions/app_radgw/rgwx_acct.c

    r1027 r1088  
    160160};
    161161
     162static DECLARE_FD_DUMP_PROTOTYPE(acct_conf_session_state_dump, struct sess_state * st)
     163{
     164        return fd_dump_extend( FD_DUMP_STD_PARAMS, "[rgwx sess_state](@%p): aai:%x str:%d TC:%u", st, st->auth_appl, st->send_str, st->term_cause);
     165}
     166
    162167/* Initialize the plugin */
    163168static int acct_conf_parse(char * conffile, struct rgwp_config ** state)
     
    172177        memset(new, 0, sizeof(struct rgwp_config));
    173178       
    174         CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, free, NULL ) );
     179        CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, (void *)free, acct_conf_session_state_dump, NULL ) );
    175180        new->confstr = conffile;
    176181       
  • extensions/app_radgw/rgwx_auth.c

    r1027 r1088  
    125125};
    126126
     127struct sess_state {
     128        char req_auth[16];
     129};
     130
     131
    127132/* Initialize the plugin */
    128133static int auth_conf_parse(char * confstr, struct rgwp_config ** state)
     
    137142        memset(new, 0, sizeof(struct rgwp_config));
    138143       
    139         CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, free, NULL ) );
     144        CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, (void *)free, NULL, NULL ) );
    140145        new->confstr = confstr;
    141146       
     
    10571062        /* Store the request identifier in the session (if provided) */
    10581063        {
    1059                 unsigned char * req_auth;
    1060                 CHECK_MALLOC(req_auth = malloc(16));
    1061                 memcpy(req_auth, &rad_req->hdr->authenticator[0], 16);
     1064                struct sess_state  *st;
     1065                CHECK_MALLOC(st = malloc(sizeof(struct sess_state)));
     1066                memcpy(st->req_auth, &rad_req->hdr->authenticator[0], 16);
    10621067               
    1063                 CHECK_FCT( fd_sess_state_store( cs->sess_hdl, sess, &req_auth ) );
     1068                CHECK_FCT( fd_sess_state_store( cs->sess_hdl, sess, &st ) );
    10641069        }
    10651070       
     
    10771082        int no_str = 0; /* indicate if an STR is required for this server */
    10781083        uint8_t tuntag = 0;
    1079         unsigned char * req_auth = NULL;
     1084        struct sess_state  *st;
    10801085        int error_cause = 0;
    10811086        struct session * sess;
     
    10891094        CHECK_FCT( fd_msg_sess_get(fd_g_config->cnf_dict, *diam_ans, &sess, NULL) );
    10901095        if (sess) {
    1091                 CHECK_FCT( fd_sess_state_retrieve( cs->sess_hdl, sess, &req_auth ) );
     1096                CHECK_FCT( fd_sess_state_retrieve( cs->sess_hdl, sess, &st ) );
    10921097                CHECK_FCT( fd_sess_getsid(sess, &sid, &sidlen) );
    10931098        } /* else ? */
     
    17591764                                                                                       
    17601765                                                                                        /* We need the request authenticator */
    1761                                                                                         CHECK_PARAMS(req_auth);
     1766                                                                                        CHECK_PARAMS(st);
    17621767
    17631768                                                                                        /* Retrieve the shared secret */
     
    17781783                                                                                        addr[0] = secret;
    17791784                                                                                        len[0] = secret_len;
    1780                                                                                         addr[1] = req_auth;
     1785                                                                                        addr[1] = st->req_auth;
    17811786                                                                                        len[1] = 16;
    17821787                                                                                        addr[2] = &buf[1];
     
    18531858
    18541859                                                /* We need the request authenticator */
    1855                                                 CHECK_PARAMS(req_auth);
     1860                                                CHECK_PARAMS(st);
    18561861
    18571862                                                /* Retrieve the shared secret */
     
    18661871                                                send_len = ahdr->avp_value->os.len - recv_len;
    18671872                                               
    1868                                                 if ( ! radius_msg_add_mppe_keys(*rad_fw, req_auth, secret, secret_len,
     1873                                                if ( ! radius_msg_add_mppe_keys(*rad_fw, st->req_auth, secret, secret_len,
    18691874                                                                ahdr->avp_value->os.data + recv_len, send_len,
    18701875                                                                ahdr->avp_value->os.data, recv_len) ) {
     
    19251930       
    19261931        CHECK_FCT( fd_msg_free( aoh ) );
    1927         free(req_auth);
     1932        free(st);
    19281933       
    19291934        if (error_cause) {
  • extensions/app_radgw/rgwx_echodrop.c

    r996 r1088  
    3838#include "rgwx_echodrop.h"
    3939
     40struct sess_state {
     41        struct fd_list sentinel;
     42};
     43
    4044/* If a session is destroyed, empty the list of ed_saved_attribute */
    41 static void state_delete(void * arg, char * sid, void * opaque) {
    42         struct fd_list * list = (struct fd_list *)arg;
    43        
    44         CHECK_PARAMS_DO( list, return );
    45        
    46         while (!FD_IS_LIST_EMPTY(list)) {
    47                 struct ed_saved_attribute * esa = (struct ed_saved_attribute *)(list->next);
     45static void state_delete(struct sess_state * arg, os0_t sid, void * opaque) {
     46        while (!FD_IS_LIST_EMPTY(&arg->sentinel)) {
     47                struct ed_saved_attribute * esa = (struct ed_saved_attribute *)(arg->sentinel.next);
    4848                fd_list_unlink(&esa->chain);
    4949                free(esa);
    5050        }
    51         free(list);
    52 }
    53 
     51        free(arg);
     52}
     53
     54static DECLARE_FD_DUMP_PROTOTYPE(ed_session_state_dump, struct sess_state * st)
     55{
     56        struct fd_list * li;
     57        CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "[rgwx sess_state](@%p):\n", st), return NULL);   
     58        for (li = st->sentinel.next; li != &st->sentinel; li = li->next) {
     59                struct ed_saved_attribute * esa = (struct ed_saved_attribute *)(li);
     60                CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "[rgwx sess_state {esa}] t:%2hhx l:%2hhx d:", esa->attr.type, esa->attr.length), return NULL);
     61                CHECK_MALLOC_DO( fd_dump_extend_hexdump(FD_DUMP_STD_PARAMS, (&esa->attr.length) + 1, esa->attr.length - 2, 0,0), return NULL);
     62                CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n"), return NULL);
     63        }
     64}
    5465
    5566/* Initialize the plugin and parse the configuration. */
     
    6980       
    7081        /* Create the session handler */
    71         CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, state_delete, NULL ) );
     82        CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, state_delete, ed_session_state_dump, NULL ) );
    7283       
    7384        /* Parse the configuration file */
     
    217228        if (!FD_IS_LIST_EMPTY(&echo_list)) {
    218229                struct session * sess;
     230                struct sess_state * st;
    219231               
    220232                CHECK_FCT( fd_msg_sess_get(fd_g_config->cnf_dict, *diam_fw, &sess, NULL) );
     
    229241               
    230242                /* Move the values in a dynamically allocated list */
    231                 CHECK_MALLOC( li = malloc(sizeof(struct fd_list)) );
    232                 fd_list_init(li, NULL);
    233                 fd_list_move_end(li, &echo_list);
     243                CHECK_MALLOC( st = malloc(sizeof(struct sess_state)) );
     244                fd_list_init(&st->sentinel, NULL);
     245                fd_list_move_end(&st->sentinel, &echo_list);
    234246               
    235247                /* Save the list in the session */
    236                 CHECK_FCT( fd_sess_state_store( cs->sess_hdl, sess, &li ) );
     248                CHECK_FCT( fd_sess_state_store( cs->sess_hdl, sess, &st ) );
    237249        }
    238250       
     
    243255static int ed_diam_ans( struct rgwp_config * cs, struct msg ** diam_ans, struct radius_msg ** rad_fw, struct rgw_client * cli )
    244256{
    245         struct fd_list * list = NULL;
    246257        struct session * sess;
     258        struct sess_state * st;
    247259       
    248260        TRACE_ENTRY("%p %p %p %p", cs, diam_ans, rad_fw, cli);
     
    258270       
    259271        /* Now try and retrieve any data from the session */
    260         CHECK_FCT( fd_sess_state_retrieve( cs->sess_hdl, sess, &list ) );
    261         if (list == NULL) {
     272        CHECK_FCT( fd_sess_state_retrieve( cs->sess_hdl, sess, &st ) );
     273        if (st == NULL) {
    262274                /* No attribute saved in the session, just return */
    263275                return 0;
     
    268280        CHECK_PARAMS( rad_fw && *rad_fw);
    269281       
    270         while (! FD_IS_LIST_EMPTY(list) ) {
    271                 struct ed_saved_attribute * esa = (struct ed_saved_attribute *)(list->next);
     282        while (! FD_IS_LIST_EMPTY(&st->sentinel) ) {
     283                struct ed_saved_attribute * esa = (struct ed_saved_attribute *)(st->sentinel.next);
    272284               
    273285                fd_list_unlink(&esa->chain);
     
    280292                free(esa);
    281293        }
    282         free(list);
     294        free(st);
    283295
    284296        return 0;
  • extensions/app_radgw/rgwx_sip.c

    r1027 r1088  
    134134               
    135135        } dict; /* cache of the dictionary objects we use */
    136         struct session_handler * sess_hdl; /* We store RADIUS request authenticator information in the session */
    137136        char * confstr;
    138137        //Chained list of nonce
     
    258257        memset(new, 0, sizeof(struct rgwp_config));
    259258       
    260         CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, free, NULL ) );
    261259        new->confstr = conffile;
    262260       
     
    312310        CHECK_PARAMS_DO( state, return );
    313311       
    314         CHECK_FCT_DO( fd_sess_handler_destroy( &state->sess_hdl, NULL ),  );
    315        
    316312        nonce_deletelistnonce(state);
    317313        CHECK_POSIX_DO(pthread_mutex_destroy(&state->nonce_mutex), /*continue*/);
     
    320316        return;
    321317}
    322 
    323318
    324319/* Handle an incoming RADIUS request */
     
    717712        //fd_msg_dump_walk(1,*diam_fw);
    718713       
    719         /* Store the request identifier in the session */
    720         {
    721                 unsigned char * req_sip;
    722                 CHECK_MALLOC(req_sip = malloc(16));
    723                 memcpy(req_sip, &rad_req->hdr->authenticator[0], 16);
    724                
    725                 CHECK_FCT( fd_sess_state_store( cs->sess_hdl, sess, &req_sip ) );
    726         }
    727        
    728714       
    729715        return 0;
     
    857843        }
    858844       
    859         CHECK_FCT( fd_sess_state_retrieve( cs->sess_hdl, sess, &req_sip ) );
    860         free(req_sip);
    861        
    862845        return 0;
    863846}
  • extensions/app_sip/app_sip.c

    r1027 r1088  
    5050
    5151struct disp_hdl * app_sip_default_hdl=NULL;
    52 struct session_handler * ds_sess_hdl;
    5352
    5453//configuration stucture
     
    213212                return EINVAL;
    214213       
    215         CHECK_FCT(fd_sess_handler_create(&ds_sess_hdl, free, NULL));
    216        
    217214        //Creation of thread for Registration Termination       
    218215        if(pthread_create(&rtr_thread, NULL,rtr_socket, NULL))
     
    238235       
    239236        (void) fd_disp_unregister(&app_sip_MAR_hdl, NULL);
    240         CHECK_FCT_DO( fd_sess_handler_destroy(&ds_sess_hdl, NULL),return);
    241237       
    242238       
  • extensions/app_sip/app_sip.h

    r1034 r1088  
    212212#define CODE_SIP_USER_DATA_TYPE 388
    213213#define CODE_SIP_AOR    122
    214 
    215 struct ds_nonce
    216 {
    217         char *nonce;
    218 };
    219214
    220215//Storage for some useful AVPs
  • extensions/app_sip/multimediaauth.c

    r639 r1088  
    3636#include "app_sip.h"
    3737
     38struct sess_state
     39{
     40        char *nonce;
     41};
     42
    3843
    3944int app_sip_MAR_cb( struct msg ** msg, struct avp * paramavp, struct session * sess, void * opaque, enum disp_action * act)
     
    5661       
    5762        //The nonce we will store and retrieve in session
    58         struct ds_nonce *storednonce=NULL;
     63        struct sess_state *storednonce=NULL;
    5964       
    6065       
     
    362367                                                                       
    363368                                                                        //We store the nonce (storednonce structure) inside the session
    364                                                                         storednonce=malloc(sizeof(struct ds_nonce));
    365                                                                         memset(storednonce,0,sizeof(struct ds_nonce));
     369                                                                        storednonce=malloc(sizeof(struct sess_state));
     370                                                                        memset(storednonce,0,sizeof(struct sess_state));
    366371                                                                        CHECK_MALLOC(storednonce->nonce=malloc(NONCE_SIZE*2+1));
    367372                                                                        memcpy(storednonce->nonce,(char *)nonce,NONCE_SIZE*2+1);
  • extensions/dbg_interactive/dictionary.i

    r979 r1088  
    6060        }
    6161        void dump() {
    62                 fd_dict_dump($self);
     62                char * buf = NULL;
     63                size_t len;
     64                printf("%s", fd_dict_dump(&buf, &len, NULL, $self));
     65                free(buf);
    6366        }
    6467        PyObject * vendors_list() {
     
    128131%extend dict_object {
    129132        void dump() {
    130                 fd_dict_dump_object($self);
     133                char * buf = NULL;
     134                size_t len;
     135                printf("%s", fd_dict_dump_object(&buf, &len, NULL, $self));
     136                free(buf);
    131137        }
    132138        enum dict_object_type gettype() {
  • extensions/dbg_interactive/endpoints.i

    r978 r1088  
    126126       
    127127        void dump() {
    128                 fd_ep_dump_one( "", $self );
     128                char * buf = NULL;
     129                size_t len;
     130                printf("%s", fd_ep_dump_one(&buf, &len, NULL, $self));
     131                free(buf);
    129132        }
    130133}
  • extensions/dbg_interactive/messages.i

    r1078 r1088  
    291291        /* Dump */
    292292        void dump (int tree = 1) {
    293                 if (tree)
    294                         fd_msg_dump_walk(0, $self);
    295                 else
    296                         fd_msg_dump_one(0, $self);
     293                char * buf = NULL;
     294                size_t len;
     295                printf("%s", fd_msg_dump_treeview(&buf, &len, NULL, $self, NULL, 0, tree));
     296                free(buf);
    297297        }
    298298       
     
    570570        /* Dump */
    571571        void dump (int tree = 1) {
    572                 if (tree)
    573                         fd_msg_dump_walk(0, $self);
    574                 else
    575                         fd_msg_dump_one(0, $self);
     572                char * buf = NULL;
     573                size_t len;
     574                printf("%s", fd_msg_dump_treeview(&buf, &len, NULL, $self, NULL, 0, tree));
     575                free(buf);
    576576        }
    577577       
  • extensions/dbg_interactive/sessions.i

    r1013 r1088  
    3939
    4040%{
     41struct sess_state {
     42        PyObject * pystate;
     43};
     44
    4145/* call it (might be called from a different thread than the interpreter, when session times out) */
    42 static void call_the_python_cleanup_callback(session_state * state, os0_t sid, void * cb) {
     46static void call_the_python_cleanup_callback(struct sess_state * state, os0_t sid, void * cb) {
    4347        PyObject *result;
    4448        if (!cb) {
     
    6771                Py_XINCREF(PyCb);
    6872               
    69                 ret = fd_sess_handler_create_internal ( &hdl, call_the_python_cleanup_callback, PyCb );
     73                ret = fd_sess_handler_create ( &hdl, call_the_python_cleanup_callback, NULL, PyCb );
    7074                if (ret != 0) {
    7175                        DI_ERROR(ret, NULL, NULL);
     
    8791        }
    8892        void dump() {
    89                 fd_sess_dump_hdl(0, $self);
     93                char * buf = NULL;
     94                size_t len;
     95                printf("%s", fd_sess_dump_hdl(&buf, &len, NULL, $self));
     96                free(buf);
    9097        }
    9198}
     
    166173        }
    167174        void dump() {
    168                 fd_sess_dump(0, $self);
     175                char * buf = NULL;
     176                size_t len = 0;
     177                printf("%s", fd_sess_dump(&buf, &len, NULL, $self, 1) );
     178                free(buf);
    169179        }
    170180        void store(struct session_handler * handler, PyObject * DISOWN) {
    171181                int ret;
    172                 void * store = DISOWN;
     182                struct sess_state * st = NULL;
     183                st = malloc(sizeof(struct sess_state));
     184                st->pystate = DISOWN;
    173185                Py_XINCREF(DISOWN);
    174                 ret = fd_sess_state_store_internal(handler, $self, (void *) &store);
     186                ret = fd_sess_state_store(handler, $self, (void *) &st);
    175187                if (ret != 0) {
    176188                        DI_ERROR(ret, NULL, NULL);
     
    180192        PyObject * retrieve(struct session_handler * handler) {
    181193                int ret;
     194                struct sess_state * st = NULL;
    182195                PyObject * state = NULL;
    183                 ret = fd_sess_state_retrieve_internal(handler, $self, (void *) &state);
    184                 if (ret != 0) {
    185                         DI_ERROR(ret, NULL, NULL);
    186                         return NULL;
    187                 }
    188                 if (state == NULL) {
     196                ret = fd_sess_state_retrieve_internal(handler, $self, (void *) &st);
     197                if (ret != 0) {
     198                        DI_ERROR(ret, NULL, NULL);
     199                        return NULL;
     200                }
     201                if (st == NULL) {
    189202                        Py_INCREF(Py_None);
    190203                        return Py_None;
    191204                }
     205                state = st->pystate;
     206                free(st);
    192207                return state;
    193208        }
  • extensions/dbg_monitor/dbg_monitor.c

    r1083 r1088  
    7878        int i = 0;
    7979        fd_log_threadname("Monitor thread");
     80        char * buf = NULL;
     81        size_t len;
    8082       
    8183        /* Loop */
     
    111113                        struct peer_hdr * p = (struct peer_hdr *)li->o;
    112114                       
    113                         fd_peer_dump(p, NONE);
     115                        TRACE_DEBUG(INFO, "%s", fd_peer_dump(&buf, &len, NULL, p, 1));
    114116                       
    115117                        CHECK_FCT_DO( fd_stat_getstats(STAT_P_PSM, p, &current_count, &limit_count, &highest_count, &total_count, &total, &blocking, &last), );
     
    123125                CHECK_FCT_DO( pthread_rwlock_unlock(&fd_g_peers_rw), /* continue */ );
    124126               
    125                 CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_DUMP_SERV, 0, NULL), /* continue */);
     127                TRACE_DEBUG(INFO, "[dbg_monitor] Dumping servers information");
     128                TRACE_DEBUG(INFO, "%s", fd_servers_dump(&buf, &len, NULL));
     129               
    126130                sleep(1);
    127131        }
    128132       
     133        free(buf);
    129134        return NULL;
    130135}
     
    133138static void got_sig()
    134139{
    135         fd_log_debug("[dbg_monitor] Dumping extra information");
    136         CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_DUMP_DICT, 0, NULL), /* continue */);
    137         CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_DUMP_CONFIG, 0, NULL), /* continue */);
    138         CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_DUMP_EXT, 0, NULL), /* continue */);
     140        char * buf = NULL;
     141        size_t len;
     142        TRACE_DEBUG(INFO, "[dbg_monitor] Dumping config information");
     143        TRACE_DEBUG(INFO, "%s", fd_conf_dump(&buf, &len, NULL));
     144        TRACE_DEBUG(INFO, "[dbg_monitor] Dumping extensions information");
     145        TRACE_DEBUG(INFO, "%s", fd_ext_dump(&buf, &len, NULL));
     146        TRACE_DEBUG(INFO, "[dbg_monitor] Dumping dictionary information");
     147        TRACE_DEBUG(INFO, "%s", fd_dict_dump(&buf, &len, NULL, fd_g_config->cnf_dict));
     148        free(buf);
    139149}
    140150
  • extensions/dict_legacy_xml/dict_lxml_xml.c

    r974 r1088  
    18091809       
    18101810        TRACE_DEBUG(FULL, "Conversion from '%s' to freeDiameter internal format complete.", xmlfilename);
    1811         if (TRACE_BOOL(ANNOYING)) {
    1812                 fd_dict_dump(fd_g_config->cnf_dict);
    1813         }
    18141811       
    18151812        /* Done */
  • extensions/test_app/ta_cli.c

    r930 r1088  
    4646static struct session_handler * ta_cli_reg = NULL;
    4747
    48 struct ta_mess_info {
     48struct sess_state {
    4949        int32_t         randval;        /* a random value to store in Test-AVP */
    5050        struct timespec ts;             /* Time of sending the message */
     
    5454static void ta_cb_ans(void * data, struct msg ** msg)
    5555{
    56         struct ta_mess_info * mi = NULL;
     56        struct sess_state * mi = NULL;
    5757        struct timespec ts;
    5858        struct session * sess;
     
    177177        struct avp * avp;
    178178        union avp_value val;
    179         struct ta_mess_info * mi = NULL, *svg;
     179        struct sess_state * mi = NULL, *svg;
    180180        struct session *sess = NULL;
    181181       
     
    191191       
    192192        /* Create the random value to store with the session */
    193         mi = malloc(sizeof(struct ta_mess_info));
     193        mi = malloc(sizeof(struct sess_state));
    194194        if (mi == NULL) {
    195195                fd_log_debug("malloc failed: %s", strerror(errno));
     
    265265int ta_cli_init(void)
    266266{
    267         CHECK_FCT( fd_sess_handler_create(&ta_cli_reg, free, NULL) );
     267        CHECK_FCT( fd_sess_handler_create(&ta_cli_reg, (void *)free, NULL, NULL) );
    268268       
    269269        CHECK_FCT( fd_event_trig_regcb(ta_conf->signal, "test_app.cli", ta_cli_test_message ) );
  • extensions/test_sip/test_sip.c

    r972 r1088  
    5454
    5555struct disp_hdl * test_sip_default_hdl=NULL;
    56 struct session_handler * ts_sess_hdl;
    5756
    5857//configuration stucture
     
    214213        */
    215214       
    216         CHECK_FCT(fd_sess_handler_create(&ts_sess_hdl, free, NULL));
    217215        //CHECK_FCT( fd_event_trig_regcb(30, "test_sip", (void *)test_sipSL_LIR_cb ) );
    218216        CHECK_FCT( fd_event_trig_regcb(30, "test_sip", (void *)test_sip_SAR_cb ) );
  • freeDiameterd/main.c

    r1081 r1088  
    210210                               
    211211                        case 'd':       /* Increase verbosity of debug messages.  */
    212                                 fd_g_debug_lvl++;
     212                                fd_g_debug_lvl--;
    213213                                break;
    214214                               
     
    236236                               
    237237                        case 'q':       /* Decrease verbosity then remove debug messages.  */
    238                                 fd_g_debug_lvl--;
     238                                fd_g_debug_lvl++;
    239239                                break;
    240240
  • include/freeDiameter/libfdcore.h

    r1085 r1088  
    803803int fd_event_trig_regcb(int trigger_val, const char * module, void (*cb)(void));
    804804
     805#ifndef SWIG
    805806DECLARE_FD_DUMP_PROTOTYPE(fd_event_trig_dump);
    806807
     
    808809DECLARE_FD_DUMP_PROTOTYPE(fd_conf_dump);
    809810DECLARE_FD_DUMP_PROTOTYPE(fd_ext_dump);
     811DECLARE_FD_DUMP_PROTOTYPE(fd_servers_dump);
     812#endif /* SWIG */
    810813DECLARE_FD_DUMP_PROTOTYPE(fd_peer_dump_list, int details);
    811814DECLARE_FD_DUMP_PROTOTYPE(fd_peer_dump, struct peer_hdr * p, int details);
    812 DECLARE_FD_DUMP_PROTOTYPE(fd_servers_dump);
    813815
    814816/*============================================================*/
  • include/freeDiameter/libfdproto.h

    r1087 r1088  
    222222
    223223
    224 /* Helper function for the *dump functions that add into a buffer */
     224/* Helper functions for the *dump functions that add into a buffer */
    225225char * fd_dump_extend(char ** buf, size_t *len, size_t *offset, const char * format, ... ) _ATTRIBUTE_PRINTFLIKE_(4,5);
     226char * fd_dump_extend_hexdump(char ** buf, size_t *len, size_t *offset, uint8_t *data, size_t datalen, size_t trunc, size_t wrap );
    226227
    227228/* All dump functions follow the same prototype:
     
    18171818
    18181819/* The state information that a module associate with a session -- each module defines its own data format */
    1819 typedef void session_state;
    1820 
    1821 typedef DECLARE_FD_DUMP_PROTOTYPE(session_state_dump, session_state * st);
     1820struct sess_state; /* declare this in your own extension */
     1821
     1822typedef DECLARE_FD_DUMP_PROTOTYPE((*session_state_dump), struct sess_state * st);
    18221823
    18231824/* The following function must be called to activate the session expiry mechanism */
     
    18431844 *  ENOMEM      : Not enough memory to complete the operation
    18441845 */
    1845 int fd_sess_handler_create_internal ( struct session_handler ** handler, void (*cleanup)(session_state * state, os0_t sid, void * opaque), session_state_dump dumper, void * opaque );
    1846 /* Macro to avoid casting everywhere */
    1847 #define fd_sess_handler_create( _handler, _cleanup, _dumper, _opaque ) \
    1848         fd_sess_handler_create_internal( (_handler), (void (*)(session_state *, os0_t, void *))(_cleanup), _dumper, (void *)(_opaque) )
     1846int fd_sess_handler_create ( struct session_handler ** handler, void (*cleanup)(struct sess_state * state, os0_t sid, void * opaque), session_state_dump dumper, void * opaque );
    18491847
    18501848       
     
    20182016 *  ENOMEM      : Not enough memory to complete the operation
    20192017 */
    2020 int fd_sess_state_store_internal ( struct session_handler * handler, struct session * session, session_state ** state );
    2021 #define fd_sess_state_store( _handler, _session, _state ) \
    2022         fd_sess_state_store_internal( (_handler), (_session), (void *)(_state) )
     2018int fd_sess_state_store ( struct session_handler * handler, struct session * session, struct sess_state ** state );
    20232019
    20242020/*
     
    20402036 *  EINVAL      : A parameter is invalid.
    20412037 */
    2042 int fd_sess_state_retrieve_internal ( struct session_handler * handler, struct session * session, session_state ** state );
    2043 #define fd_sess_state_retrieve( _handler, _session, _state ) \
    2044         fd_sess_state_retrieve_internal( (_handler), (_session), (void *)(_state) )
     2038int fd_sess_state_retrieve ( struct session_handler * handler, struct session * session, struct sess_state ** state );
    20452039
    20462040
  • libfdproto/fdproto-internal.h

    r1085 r1088  
    4848void fd_sess_fini(void);
    4949
    50 /* Where debug messages are sent */
    51 extern FILE * fd_g_debug_fstr;
    52 
    5350/* Iterator on the rules of a parent object */
    5451int fd_dict_iterate_rules ( struct dict_object *parent, void * data, int (*cb)(void *, struct dict_rule_data *) );
  • libfdproto/init.c

    r974 r1088  
    5858        }
    5959       
    60         /* Set the debug stream */
    61         fd_g_debug_fstr = stdout;
    62        
    6360        /* Initialize the modules that need it */
    6461        fd_msg_eteid_init();
  • libfdproto/log.c

    r1085 r1088  
    3838#include <stdarg.h>
    3939
    40 FILE * fd_g_debug_fstr;
    41 
    4240pthread_mutex_t fd_log_lock = PTHREAD_MUTEX_INITIALIZER;
    4341pthread_key_t   fd_log_thname;
    44 int fd_g_debug_lvl = INFO;
     42int fd_g_debug_lvl = FD_LOG_NOTICE;
    4543
    4644static void fd_internal_logger( int, const char *, va_list );
     
    8886
    8987
    90 static void fd_internal_logger( int loglevel, const char *format, va_list ap )
     88static void fd_internal_logger( int printlevel, const char *format, va_list ap )
    9189{
    9290    char buf[25];
    93     FILE *fstr = fd_g_debug_fstr ?: stdout;
    94     int local_use_color = 0;
    95 
    96     /* logging has been decided by macros outside already */
     91
     92    /* Do we need to trace this ? */
     93    if (printlevel < fd_g_debug_lvl)
     94        return;
    9795
    9896    /* add timestamp */
    99     fprintf(fstr, "%s  ", fd_log_time(NULL, buf, sizeof(buf)));
     97    printf("%s  ", fd_log_time(NULL, buf, sizeof(buf)));
    10098   
    10199    /* Use colors on stdout ? */
     
    107105    }
    108106   
    109     /* now, this time log, do we use colors? */
    110     if ((fstr == stdout) && (use_colors == 1))
    111             local_use_color = 1;
     107    switch(printlevel) {
     108            case FD_LOG_ANNOYING:  printf("%s   A   ", (use_colors == 1) ? "\e[0;37m" : ""); break;
     109            case FD_LOG_DEBUG:     printf("%s DBG   ", (use_colors == 1) ? "\e[0;37m" : ""); break;
     110            case FD_LOG_NOTICE:    printf("%sNOTI   ", (use_colors == 1) ? "\e[1;37m" : ""); break;
     111            case FD_LOG_ERROR:     printf("%sERROR  ", (use_colors == 1) ? "\e[0;31m" : ""); break;
     112            case FD_LOG_FATAL:     printf("%sFATAL! ", (use_colors == 1) ? "\e[0;31m" : ""); break;
     113            default:               printf("%s ???   ", (use_colors == 1) ? "\e[0;31m" : "");
     114    }
     115    vprintf(format, ap);
     116    if (use_colors == 1)
     117             printf("\e[00m");
     118    printf("\n");
    112119   
    113     switch(loglevel) {
    114             case FD_LOG_DEBUG:  fprintf(fstr, "%s DBG   ", local_use_color ? "\e[0;37m" : ""); break;
    115             case FD_LOG_NOTICE: fprintf(fstr, "%sNOTI   ", local_use_color ? "\e[1;37m" : ""); break;
    116             case FD_LOG_ERROR:  fprintf(fstr, "%sERROR  ", local_use_color ? "\e[0;31m" : ""); break;
    117             default:            fprintf(fstr, "%s ???   ", local_use_color ? "\e[0;31m" : "");
    118     }
    119     vfprintf(fstr, format, ap);
    120     if (local_use_color)
    121              fprintf(fstr, "\e[00m");
    122     fprintf(fstr, "\n");
    123    
    124     fflush(fstr);
     120    fflush(stdout);
    125121}
    126122
     
    212208
    213209
     210static size_t sys_mempagesz = 0;
     211
     212static size_t get_mempagesz(void) {
     213        if (!sys_mempagesz) {
     214                sys_mempagesz = sysconf(_SC_PAGESIZE); /* We alloc buffer by memory pages for efficiency */
     215                if (sys_mempagesz <= 0)
     216                        sys_mempagesz = 1024; /* default size if above call failed */
     217        }
     218        return sys_mempagesz;
     219}
     220
     221
    214222/* Helper function for fd_*_dump. Prints the format string from 'offset' into '*buf', extends if needed. The location of buf can be updated by this function. */
    215223char * fd_dump_extend(char ** buf, size_t *len, size_t *offset, const char * format, ... )
     
    218226        int to_write;
    219227        size_t o = 0;
    220         static size_t mempagesz = 0;
    221        
    222         if (!mempagesz) {
    223                 mempagesz = sysconf(_SC_PAGESIZE); /* We alloc buffer by memory pages for efficiency */
    224                 if (mempagesz <= 0)
    225                         mempagesz = 1024; /* default size if above call failed */
    226         }
     228        size_t mempagesz = get_mempagesz();
    227229       
    228230        /* we do not TRACE_ENTRY this one on purpose */
     
    258260        return *buf;
    259261}
     262
     263char * fd_dump_extend_hexdump(char ** buf, size_t *len, size_t *offset, uint8_t *data, size_t datalen, size_t trunc, size_t wrap )
     264{
     265        int truncated = 0;
     266        size_t towrite = 0;
     267        size_t o = 0;
     268        int i;
     269        char * p;
     270        size_t mempagesz = get_mempagesz();
     271#define TRUNK_MARK "[...]"
     272
     273        CHECK_PARAMS_DO(buf && len && data, return NULL);
     274       
     275        if (trunc && (datalen > trunc)) {
     276                datalen = trunc;
     277                truncated = 1;
     278        }
     279       
     280        towrite = datalen * 2;
     281       
     282        if (wrap)
     283                towrite += datalen / wrap; /* add 1 '\n' every wrap byte */
     284       
     285        if (truncated)
     286                towrite += CONSTSTRLEN(TRUNK_MARK);
     287       
     288       
     289        if (offset)
     290                o = *offset;
     291       
     292        if (*buf == NULL) {
     293                /* Directly allocate the size we need */
     294                *len = (((towrite + o) / mempagesz) + 1 ) * mempagesz;
     295                CHECK_MALLOC_DO(*buf = malloc(*len), return NULL);
     296        } else if ((towrite + o) >= *len) {
     297                /* There is no room in the buffer, we extend and redo */
     298                size_t new_len = (((towrite + o) / mempagesz) + 1) * mempagesz;
     299                CHECK_MALLOC_DO(*buf = realloc(*buf, new_len), return NULL);
     300                *len = new_len;
     301        }
     302       
     303        p = *buf + o;
     304        for (i = 0; i < datalen; i++) {
     305                sprintf(p, "%2hhX", data[i]);
     306                p+=2;
     307                if ((wrap) && ((i+1) % wrap == 0)) {
     308                        *p++='\n'; *p ='\0'; /* we want to ensure the buffer is always 0-terminated */
     309                }
     310        }
     311       
     312        if (truncated)
     313                memcpy(p, TRUNK_MARK, CONSTSTRLEN(TRUNK_MARK));
     314               
     315        if (offset)
     316                *offset += towrite;
     317       
     318        return *buf;
     319}
  • libfdproto/sessions.c

    r1085 r1088  
    6969        int               eyec; /* An eye catcher also used to ensure the object is valid, must be SH_EYEC */
    7070        int               id;   /* A unique integer to identify this handler */
    71         void            (*cleanup)(session_state *, os0_t, void *); /* The cleanup function to be called for cleaning a state */
    72         session_state_dump *state_dump; /* dumper function */
     71        void            (*cleanup)(struct sess_state *, os0_t, void *); /* The cleanup function to be called for cleaning a state */
     72        session_state_dump state_dump; /* dumper function */
    7373        void             *opaque; /* a value that is passed as is to the cleanup callback */
    7474};
     
    8181struct state {
    8282        int                      eyec;  /* Must be SD_EYEC */
    83         session_state           *state; /* The state registered by the application, never NULL (or the whole object is deleted) */
     83        struct sess_state       *state; /* The state registered by the application, never NULL (or the whole object is deleted) */
    8484        struct fd_list           chain; /* Chaining in the list of session's states ordered by hdl->id */
    8585        union {
     
    274274
    275275/* Create a new handler */
    276 int fd_sess_handler_create_internal ( struct session_handler ** handler, void (*cleanup)(session_state *, os0_t, void *), session_state_dump dumper, void * opaque )
     276int fd_sess_handler_create ( struct session_handler ** handler, void (*cleanup)(struct sess_state *, os0_t, void *), session_state_dump dumper, void * opaque )
    277277{
    278278        struct session_handler *new;
     
    720720
    721721/* Save a state information with a session */
    722 int fd_sess_state_store_internal ( struct session_handler * handler, struct session * session, session_state ** state )
     722int fd_sess_state_store ( struct session_handler * handler, struct session * session, struct sess_state ** state )
    723723{
    724724        struct state *new;
     
    773773
    774774/* Get the data back */
    775 int fd_sess_state_retrieve_internal ( struct session_handler * handler, struct session * session, session_state ** state )
     775int fd_sess_state_retrieve ( struct session_handler * handler, struct session * session, struct sess_state ** state )
    776776{
    777777        struct fd_list * li;
  • tests/testcnx.c

    r974 r1088  
    715715                /* For debug: dump the object */
    716716                fd_log_debug("Dumping CER");
    717                 fd_msg_dump_walk(0, cer);
     717                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, cer, fd_g_config->cnf_dict, 0, 1));
    718718                #endif
    719719               
  • tests/testdict.c

    r788 r1088  
    192192                CHECK(1, obj ? 1 : 0 );
    193193#if 1
    194                 fd_dict_dump_object(obj);
     194                fd_log_debug("%s", fd_dict_dump_object(FD_DUMP_TEST_PARAMS, obj));
    195195#endif
    196196                CHECK( 0, fd_dict_delete(obj) );
  • tests/testdisp.c

    r1018 r1088  
    699699               
    700700                #if 0
    701                 fd_conf_dump();
     701                fd_log_debug("%s", fd_conf_dump(FD_DUMP_TEST_PARAMS));
    702702                #endif
    703703        }
  • tests/testfifo.c

    r1071 r1088  
    559559                CHECK( 14, iter );
    560560               
    561                 /* fd_fifo_dump(0, "test", queue, NULL); */
    562                
    563561                for (; i < td.nbr; i++) {
    564562                        CHECK( 0, fd_fifo_tryget(queue, &item) );
  • tests/testmesg.c

    r1047 r1088  
    6161                #if 0
    6262                /* For debug: dump the object */
    63                 fd_log_debug("Dumping Accounting-Request empty message");
    64                 fd_msg_dump_walk( 0, acr );
     63                fd_log_debug("Dumping Accounting-Request empty message:");
     64                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, acr, fd_g_config->cnf_dict, 0, 1));
    6565                #endif
    6666        }
     
    7979                /* For debug: dump the object */
    8080                fd_log_debug("Dumping Proxy-Info AVP");
    81                 fd_msg_dump_walk(0, pi);
     81                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, pi, fd_g_config->cnf_dict, 0, 1));
    8282                fd_log_debug("Dumping dictionary model");
    83                 fd_dict_dump_object(pi_model);
     83                fd_log_debug("%s", fd_dict_dump_object(FD_DUMP_TEST_PARAMS, pi_model));
    8484                #endif
    8585               
     
    107107                /* For debug: dump the object */
    108108                fd_log_debug("Dumping Accounting-Request with Proxy-Info AVP at the end");
    109                 fd_msg_dump_walk(0, acr);
     109                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, acr, fd_g_config->cnf_dict, 0, 1));
    110110                #endif
    111111        }
     
    306306                                                */
    307307                        #if 0
    308                         fd_dict_dump_object ( gavp );
     308                        fd_log_debug("%s", fd_dict_dump_object(FD_DUMP_TEST_PARAMS, gavp));
    309309                        #endif
    310310                }
    311311                #if 0
    312312                {
    313                         fd_dict_dump_object ( vendor );
     313                        fd_log_debug("%s", fd_dict_dump_object(FD_DUMP_TEST_PARAMS, vendor));
    314314                }
    315315                #endif
     
    365365                        #if 0
    366366                        fd_log_debug("AVP no vendor, value 3.1415:");
    367                         fd_msg_dump_one(0, avpi);
     367                        fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
    368368                        #endif
    369369                        CHECK( 0, fd_msg_avp_hdr ( avpi, &avpdata ) );
     
    382382                        #if 0
    383383                        fd_log_debug("AVP vendor, value 0x123456789abcdeL:");
    384                         fd_msg_dump_one(0, avpi);
     384                        fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
    385385                        #endif
    386386                        CHECK( 0, fd_msg_avp_hdr ( avpi, &avpdata ) );
     
    408408                                #if 0
    409409                                fd_log_debug("AVP enum i32, value 2 (from const):");
    410                                 fd_msg_dump_one(0, avpi);
     410                                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
    411411                                #endif
    412412                        }
     
    429429                                #if 0
    430430                                fd_log_debug("AVP enum i32, value -5 (from const):");
    431                                 fd_msg_dump_one(0, avpi);
     431                                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
    432432                                #endif
    433433                                /* Check the size is correct ( 12 for header + 4 for value ) */
     
    444444                        #if 0
    445445                        fd_log_debug("AVP vendor enum i32, value -10 (not const):");
    446                         fd_msg_dump_one(0, avpi);
     446                        fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
    447447                        #endif
    448448                       
     
    459459                                #if 0
    460460                                fd_log_debug("AVP octet string, 'This\\0 is a b...'");
    461                                 fd_msg_dump_one(0, avpi);
     461                                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
    462462                                #endif
    463463                                CHECK( 0, fd_msg_avp_hdr ( avpi, &avpdata ) );
     
    488488                                #if 0
    489489                                fd_log_debug("AVP Enumuerated OctetString (from const):");
    490                                 fd_msg_dump_one(0, avpi);
     490                                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
    491491                                #endif
    492492                                /* Check the size is correct ( 12 for header + 5 for value ) */
     
    513513                                #if 0
    514514                                fd_log_debug("AVP Enumuerated OctetString (from const):");
    515                                 fd_msg_dump_one(0, avpi);
     515                                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
    516516                                #endif
    517517                                /* Check the size is correct ( 12 for header + 3 for value ) */
     
    535535                                #if 0
    536536                                fd_log_debug("AVP octet string, '1234678'");
    537                                 fd_msg_dump_one(0, avpch);
     537                                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpch, fd_g_config->cnf_dict, 0, 0));
    538538                                #endif
    539539                                CHECK( 0, fd_msg_update_length ( avpch ) );
     
    548548                                #if 0
    549549                                fd_log_debug("AVP octet string, '12346789'");
    550                                 fd_msg_dump_one(0, avpch);
     550                                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpch, fd_g_config->cnf_dict, 0, 0));
    551551                                #endif
    552552                          }
     
    580580                        CHECK( 0, fd_msg_update_length ( msg ) );
    581581                        #if 0
    582                         fd_msg_dump_walk(0, msg);
     582                        fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
    583583                        #endif
    584584                        CHECK( 344, msgdata->msg_length );
     
    660660                        CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
    661661                        #if 0
    662                         fd_msg_dump_walk(0, msg);
     662                        fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
    663663                        #endif
    664664                       
     
    733733                               
    734734                                #if 0
    735                                 fd_msg_dump_walk(0, msg);
     735                                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
    736736                                #endif
    737737                               
     
    769769                                CHECK( 0, fd_msg_bufferize( msg, &buftmp, NULL ) );                             
    770770                               
    771                                 fd_msg_dump_walk(0, msg);
     771                                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
    772772                               
    773773                                TODO("Check the Failed-AVP is as expected");
     
    783783                        CHECK( 0, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );
    784784                        #if 0
    785                         fd_msg_dump_walk(0, msg);
     785                        fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
    786786                        #endif
    787787                }
     
    13361336                        /* Okay, now delete the message and parse the buffer, then check we obtain the same values back */
    13371337                        #if 0
    1338                         fd_msg_dump_walk(0, msg);
     1338                        fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
    13391339                        #endif
    13401340                        CHECK( 0, fd_msg_free( msg ) );
     
    13431343                        CHECK( 0, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );
    13441344                        #if 0
    1345                         fd_msg_dump_walk(0, msg);
     1345                        fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
    13461346                        #endif
    13471347                       
  • tests/testmesg_stress.c

    r1076 r1088  
    197197                                < grouped >
    198198                                                */
    199                         #if 0
    200                         fd_dict_dump_object ( gavp );
    201                         #endif
    202                 }
    203                 #if 0
    204                 {
    205                         fd_dict_dump_object ( vendor );
    206                 }
    207                 #endif
     199                }
    208200        }
    209201       
  • tests/testpeers.c

    r748 r1088  
    5757                }
    5858        }
    59         fd_peer_dump_list(0);
     59        fd_log_debug("%s", fd_peer_dump_list(FD_DUMP_TEST_PARAMS, 0));
    6060        /* Check we are able to find again any of these */
    6161        {
  • tests/tests.h

    r1078 r1088  
    6868/* Define the macro to fail a test with a message */
    6969#define FAILTEST( message... ){                         \
    70         TRACE_ERROR(message);                           \
    71         TRACE_ERROR("FAILED: %s ", __STRIPPED_FILE__);  \
     70        LOG_F(message);                                 \
     71        LOG_F("FAILED: %s ", __STRIPPED_FILE__);        \
     72        free(tbuf);                                     \
    7273        exit(FAIL);                                     \
    7374}
     
    7576/* Define the macro to pass a test */
    7677#define PASSTEST( ){                                    \
    77         TRACE_NOTICE("PASS: %s", __STRIPPED_FILE__);    \
     78        LOG_N("PASS: %s", __STRIPPED_FILE__);           \
    7879        (void)fd_core_shutdown();                       \
    7980        (void)fd_core_wait_shutdown_complete();         \
    8081        (void)fd_thr_term(&signal_thr);                 \
     82        free(tbuf);                                     \
    8183        exit(PASS);                                     \
    8284}
    8385
    84 static int test_verbo = 0;
    8586static struct fd_config conf;
    8687extern struct fd_config * fd_g_config;
    8788
     89/* for dumps */
     90static char * tbuf = NULL; size_t tbuflen = 0;
     91#define FD_DUMP_TEST_PARAMS &tbuf, &tbuflen, NULL
     92
     93
    8894/* Define the standard check routines */
    8995#define CHECK( _val, _assert ){                         \
    90         if (test_verbo > 0) {                           \
    91                 TRACE_NOTICE("CHECK( %s == %s )",       \
     96        LOG_D("CHECK( %s == %s )",                      \
    9297                                #_assert,               \
    9398                                #_val);                 \
    94         }{                                              \
     99        {                                               \
    95100        __typeof__ (_val) __ret = (_assert);            \
    96101        if (__ret != (_val)) {                          \
     
    143148                switch (c) {
    144149                        case 'd':       /* Increase verbosity of debug messages.  */
    145                                 test_verbo++;
     150                                fd_g_debug_lvl--;
    146151                                break;
    147152                               
    148153                        case 'q':       /* Decrease verbosity.  */
    149                                 test_verbo--;
     154                                fd_g_debug_lvl++;
    150155                                break;
    151156                       
     
    178183                }
    179184        }
    180         fd_g_debug_lvl = (test_verbo > 0) ? (test_verbo - 1) : 0;
    181185        if (!no_timeout) {
    182186                alarm(TEST_TIMEOUT);
  • tests/testsess.c

    r888 r1088  
    4343
    4444#define TEST_EYEC       0x7e57e1ec
    45 struct mystate {
     45struct sess_state {
    4646        int     eyec;   /* TEST_EYEC */
    4747        os0_t   sid;    /* the session with which the data was registered */
     
    5050};
    5151
    52 static void mycleanup( struct mystate * data, os0_t sid, void * opaque )
     52static void mycleanup( struct sess_state * data, os0_t sid, void * opaque )
    5353{
    5454        /* sanity */
     
    6767}
    6868
    69 static __inline__ struct mystate * new_state(os0_t sid, int *freed)
     69static __inline__ struct sess_state * new_state(os0_t sid, int *freed)
    7070{
    71         struct mystate *new;
    72         new = malloc(sizeof(struct mystate));
     71        struct sess_state *new;
     72        new = malloc(sizeof(struct sess_state));
    7373        CHECK( 1, new ? 1 : 0 );
    74         memset(new, 0, sizeof(struct mystate));
     74        memset(new, 0, sizeof(struct sess_state));
    7575        new->eyec = TEST_EYEC;
    7676        new->sid = os0dup(sid, strlen((char *)sid));
     
    106106        {
    107107                void * testptr = NULL;
    108                 CHECK( 0, fd_sess_handler_create ( &hdl1, mycleanup, NULL ) );
    109                 CHECK( 0, fd_sess_handler_create ( &hdl2, mycleanup, NULL ) );
     108                CHECK( 0, fd_sess_handler_create ( &hdl1, mycleanup, NULL, NULL ) );
     109                CHECK( 0, fd_sess_handler_create ( &hdl2, mycleanup, NULL, NULL ) );
    110110                CHECK( 0, fd_sess_handler_destroy( &hdl2, &testptr ) );
    111111                CHECK( 1, testptr == NULL ? 1 : 0 );
    112                 CHECK( 0, fd_sess_handler_create ( &hdl2, mycleanup, g_opaque ) );
    113                 #if 0
    114                 fd_sess_dump_hdl(0, hdl1);
    115                 fd_sess_dump_hdl(0, hdl2);
     112                CHECK( 0, fd_sess_handler_create ( &hdl2, mycleanup, NULL, g_opaque ) );
     113                #if 0
     114                fd_log_debug("%s\n", fd_sess_dump_hdl(FD_DUMP_TEST_PARAMS, hdl1));
     115                fd_log_debug("%s\n", fd_sess_dump_hdl(FD_DUMP_TEST_PARAMS, hdl2));
    116116                #endif
    117117        }
     
    123123                CHECK( 0, fd_sess_new( &sess2, TEST_DIAM_ID, CONSTSTRLEN(TEST_DIAM_ID), NULL, 0 ) );
    124124                #if 0
    125                 fd_sess_dump(0, sess1);
    126                 fd_sess_dump(0, sess2);
     125                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1));
     126                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1));
    127127                #endif
    128128               
     
    141141                CHECK( 0, fd_sess_new( &sess2, TEST_DIAM_ID, CONSTSTRLEN(TEST_DIAM_ID), TEST_OPT, CONSTSTRLEN(TEST_OPT_IN) - 1 ) );
    142142                #if 0
    143                 fd_sess_dump(0, sess1);
    144                 fd_sess_dump(0, sess2);
     143                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1));
     144                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1));
    145145                #endif
    146146               
     
    165165                CHECK( 0, fd_sess_new( &sess2, NULL, 0, TEST_SID, CONSTSTRLEN(TEST_SID_IN) - 1 ) );
    166166                #if 0
    167                 fd_sess_dump(0, sess1);
    168                 fd_sess_dump(0, sess2);
     167                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1));
     168                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1));
    169169                #endif
    170170                CHECK( 0, fd_sess_getsid(sess1, &str1, &str1len) );
     
    211211        /* Test fd_sess_reclaim */
    212212        {
    213                 struct mystate *tms;
     213                struct sess_state *tms;
    214214               
    215215                CHECK( 0, fd_sess_fromsid( TEST_SID, CONSTSTRLEN(TEST_SID_IN), &sess1, &new ) );
     
    271271        /* Test states operations */
    272272        {
    273                 struct mystate * ms[6], *tms;
     273                struct sess_state * ms[6], *tms;
    274274                int freed[6];
    275275                struct timespec timeout;
     
    295295               
    296296                #if 0
    297                 fd_sess_dump(0, sess1);
     297                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1));
    298298                #endif
    299299               
     
    332332               
    333333                #if 0
    334                 fd_sess_dump(0, sess1);
    335                 fd_sess_dump(0, sess2);
    336                 fd_sess_dump(0, sess3);
     334                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1));
     335                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1));
     336                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess3, 1));
    337337                #endif
    338338               
     
    357357               
    358358                #if 1
    359                 fd_sess_dump(0, sess1);
    360                 fd_sess_dump(0, sess2);
     359                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1));
     360                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1));
    361361                #endif
    362362               
     
    373373                CHECK( 0, fd_sess_settimeout( sess2, &timeout) );
    374374                #if 1
    375                 fd_sess_dump(0, sess1);
    376                 fd_sess_dump(0, sess2);
     375                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1));
     376                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1));
    377377                #endif
    378378                timeout.tv_sec = 0;
Note: See TracChangeset for help on using the changeset viewer.