Navigation


Changeset 358:7ea43915cade in freeDiameter


Ignore:
Timestamp:
Jul 1, 2010, 4:02:43 PM (14 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Fix: added the Destination-Realm also

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/app_radgw/rgwx_acct.c

    r356 r358  
    304304        char * si = NULL;
    305305        size_t si_len = 0;
     306        char * un = NULL;
     307        size_t un_len = 0;
    306308       
    307309        TRACE_ENTRY("%p %p %p %p %p %p", cs, session, rad_req, rad_ans, diam_fw, cli);
     
    320322                struct radius_attr_hdr * attr = (struct radius_attr_hdr *)(rad_req->buf + rad_req->attr_pos[idx]);
    321323                uint8_t * v = (uint8_t *)(attr + 1);
     324                size_t attr_len = attr->length - sizeof(struct radius_attr_hdr);
     325               
    322326                switch (attr->type) {
    323327                        case RADIUS_ATTR_NAS_IP_ADDRESS:
     
    352356                               
    353357                        case RADIUS_ATTR_CLASS:
    354                                 {
    355                                         char * attr_val = (char *)(attr + 1);
    356                                         size_t attr_len = attr->length - sizeof(struct radius_attr_hdr);
    357                                         if ((attr_len > pref_len ) && ! strncmp(attr_val, prefix, pref_len)) {
    358                                                 int i;
    359                                                 si = attr_val + pref_len;
    360                                                 si_len = attr_len - pref_len;
    361                                                 TRACE_DEBUG(ANNOYING, "Found Class attribute with '%s' prefix (attr #%d), SI:'%.*s'.", prefix, idx, si_len, si);
    362                                                 /* Remove from the message */
    363                                                 for (i = idx + 1; i < rad_req->attr_used; i++)
    364                                                         rad_req->attr_pos[i - 1] = rad_req->attr_pos[i];
    365                                                 rad_req->attr_used -= 1;
    366                                                 break;
    367                                         }
     358                                if ((attr_len > pref_len ) && ! strncmp((char *)v, prefix, pref_len)) {
     359                                        int i;
     360                                        si = (char *)v + pref_len;
     361                                        si_len = attr_len - pref_len;
     362                                        TRACE_DEBUG(ANNOYING, "Found Class attribute with '%s' prefix (attr #%d), SI:'%.*s'.", prefix, idx, si_len, si);
     363                                        /* Remove from the message */
     364                                        for (i = idx + 1; i < rad_req->attr_used; i++)
     365                                                rad_req->attr_pos[i - 1] = rad_req->attr_pos[i];
     366                                        rad_req->attr_used -= 1;
    368367                                }
    369368                                break;
    370369
     370                        case RADIUS_ATTR_USER_NAME:
     371                                if (attr_len) {
     372                                        un = (char *)v;
     373                                        un_len = attr_len;
     374                                        TRACE_DEBUG(ANNOYING, "Found a User-Name attribute: '%.*s'", un_len, un);
     375                                }
     376                                break;
     377                       
    371378                }
    372379        }
     
    451458        }
    452459       
     460        /* Add the Destination-Realm */
     461        CHECK_FCT( fd_msg_avp_new ( cs->dict.Destination_Realm, 0, &avp ) );
     462        idx = 0;
     463        if (un) {
     464                /* Is there an '@' in the user name? We don't care for decorated NAI here */
     465                for (idx = un_len - 2; idx > 0; idx--) {
     466                        if (un[idx] == '@') {
     467                                idx++;
     468                                break;
     469                        }
     470                }
     471        }
     472        if (idx == 0) {
     473                /* Not found in the User-Name => we use the local domain of this gateway */
     474                value.os.data = fd_g_config->cnf_diamrlm;
     475                value.os.len  = fd_g_config->cnf_diamrlm_len;
     476        } else {
     477                value.os.data = un + idx;
     478                value.os.len  = un_len - idx;
     479        }
     480        CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
     481        CHECK_FCT( fd_msg_avp_add ( *diam_fw, *session ? MSG_BRW_LAST_CHILD : MSG_BRW_FIRST_CHILD, avp) );
     482       
    453483        /* Create the Session-Id AVP if needed */
    454484        if (!*session) {
     
    464494                CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_FIRST_CHILD, avp) );
    465495        }
     496       
    466497               
    467498        /* Add the command code */
Note: See TracChangeset for help on using the changeset viewer.