Navigation


Changeset 706:4ffbc9f1e922 in freeDiameter for extensions/app_radgw/rgwx_auth.c


Ignore:
Timestamp:
Feb 9, 2011, 3:26:58 PM (13 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Large UNTESTED commit with the following changes:

  • Improved DiameterIdentity? handling (esp. interationalization issues), and improve efficiency of some string operations in peers, sessions, and dictionary modules (closes #7)
  • Cleanup in the session module to free only unreferenced sessions (#16)
  • Removed fd_cpu_flush_cache(), replaced by more robust alternatives.
  • Improved peer state machine algorithm to counter SCTP multistream race condition.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/app_radgw/rgwx_auth.c

    r705 r706  
    239239        const char * prefix = "Diameter/";
    240240        size_t pref_len;
    241         uint8_t * dh = NULL;
     241        os0_t dh = NULL;
    242242        size_t dh_len = 0;
    243         uint8_t * dr = NULL;
     243        os0_t dr = NULL;
    244244        size_t dr_len = 0;
    245         uint8_t * si = NULL;
     245        os0_t si = NULL;
    246246        size_t si_len = 0;
    247         uint8_t * un = NULL;
     247        os0_t un = NULL;
    248248        size_t un_len = 0;
    249249        size_t nattr_used = 0;
     
    293293                 and/or to the NAS-Identifier attribute.  (Note that the RADIUS
    294294                 NAS-Identifier is not required to be an FQDN.)
    295                      -> done in rgw_msg_create_base.
     295                     -> done in rgw_clients_create_origin.
    296296
    297297              -  The response MUST have an Origin-AAA-Protocol AVP added,
     
    453453        /* Create the session if it is not already done */
    454454        if (*session == NULL) {
    455                 char * sess_str = NULL;
     455                os0_t sess_str = NULL;
     456                size_t sess_strlen;
    456457               
    457458                if (si_len) {
    458459                        /* We already have the Session-Id, just use it */
    459                         CHECK_FCT( fd_sess_fromsid ( (char *) /* this cast will be removed later */ si, si_len, session, NULL) );
     460                        CHECK_FCT( fd_sess_fromsid ( si, si_len, session, NULL) );
    460461                } else {
    461462                        /* Create a new Session-Id string */
    462463                       
    463                         char * fqdn;
    464                         char * realm;
     464                        DiamId_t fqdn;
     465                        size_t fqdnlen;
     466                        DiamId_t realm;
     467                        size_t realmlen;
    465468                       
    466469                        /* Get information on the RADIUS client */
    467                         CHECK_FCT( rgw_clients_get_origin(cli, &fqdn, &realm) );
     470                        CHECK_FCT( rgw_clients_get_origin(cli, &fqdn, &fqdnlen, &realm, &realmlen) );
    468471                       
    469472                        /* If we have a user name, create the new session with it */
    470473                        if (un) {
    471474                                int len;
    472                                 /* If not found, create a new Session-Id. The format is: {fqdn;hi32;lo32;username;diamid} */
     475                                /* If not found, create a new Session-Id. Our format is: {fqdn;hi32;lo32;username;diamid} */
    473476                                CHECK_MALLOC( sess_str = malloc(un_len + 1 /* ';' */ + fd_g_config->cnf_diamid_len + 1 /* '\0' */) );
    474                                 len = sprintf(sess_str, "%.*s;%s", (int)un_len, un, fd_g_config->cnf_diamid);
    475                                 CHECK_FCT( fd_sess_new(session, fqdn, sess_str, len) );
     477                                len = sprintf((char *)sess_str, "%.*s;%s", (int)un_len, un, fd_g_config->cnf_diamid);
     478                                CHECK_FCT( fd_sess_new(session, fqdn, fqdnlen, sess_str, len) );
    476479                                free(sess_str);
    477480                        } else {
     
    483486               
    484487                /* Now, add the Session-Id AVP at beginning of Diameter message */
    485                 CHECK_FCT( fd_sess_getsid(*session, &sess_str) );
     488                CHECK_FCT( fd_sess_getsid(*session, &sess_str, &sess_strlen) );
    486489               
    487490                TRACE_DEBUG(FULL, "[auth.rgwx] Translating new message for session '%s'...", sess_str);
     
    489492                /* Add the Session-Id AVP as first AVP */
    490493                CHECK_FCT( fd_msg_avp_new ( cs->dict.Session_Id, 0, &avp ) );
    491                 value.os.data = (unsigned char *)sess_str;
    492                 value.os.len = strlen(sess_str);
     494                value.os.data = sess_str;
     495                value.os.len = sess_strlen;
    493496                CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
    494497                CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_FIRST_CHILD, avp) );
     
    564567                        /* This macro converts a RADIUS attribute to a Diameter AVP of type OctetString */
    565568                        #define CONV2DIAM_STR( _dictobj_ )      \
    566                                 CHECK_PARAMS( attr->length >= 2 );                                              \
     569                                CHECK_PARAMS( attr->length >= sizeof(struct radius_attr_hdr) );                 \
    567570                                /* Create the AVP with the specified dictionary model */                        \
    568571                                CHECK_FCT( fd_msg_avp_new ( cs->dict._dictobj_, 0, &avp ) );                    \
    569                                 value.os.len = attr->length - 2;                                                \
    570                                 value.os.data = (unsigned char *)(attr + 1);                                    \
     572                                value.os.len = attr->length - sizeof(struct radius_attr_hdr);                   \
     573                                value.os.data = (os0_t)(attr + 1);                                              \
    571574                                CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );                               \
    572575                                /* Add the AVP in the Diameter message. */                                      \
     
    575578                        /* Same thing, for scalar AVPs of 32 bits */
    576579                        #define CONV2DIAM_32B( _dictobj_ )      \
    577                                 CHECK_PARAMS( attr->length == 6 );                                              \
     580                                CHECK_PARAMS( attr->length == sizeof(struct radius_attr_hdr)+sizeof(uint32_t) );\
    578581                                CHECK_FCT( fd_msg_avp_new ( cs->dict._dictobj_, 0, &avp ) );                    \
    579582                                {                                                                               \
     
    589592                        /* And the 64b version */
    590593                        #define CONV2DIAM_64B( _dictobj_ )      \
    591                                 CHECK_PARAMS( attr->length == 10);                                              \
     594                                CHECK_PARAMS( attr->length == sizeof(struct radius_attr_hdr)+sizeof(uint64_t) );\
    592595                                CHECK_FCT( fd_msg_avp_new ( cs->dict._dictobj_, 0, &avp ) );                    \
    593596                                {                                                                               \
     
    609612                              -  The Destination-Realm AVP is created from the information found
    610613                                 in the RADIUS User-Name attribute.
    611                                         -> done in rgw_msg_create_base
     614                                        -> done in rgw_clients_create_origin
    612615                        */
    613616                        case RADIUS_ATTR_USER_NAME:
Note: See TracChangeset for help on using the changeset viewer.