Navigation


Changeset 1088:1d1a20a0779d in freeDiameter for extensions/app_radgw


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

Location:
extensions/app_radgw
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.