Changeset 706:4ffbc9f1e922 in freeDiameter for extensions/app_radgw/rgwx_auth.c
- Timestamp:
- Feb 9, 2011, 3:26:58 PM (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/app_radgw/rgwx_auth.c
r705 r706 239 239 const char * prefix = "Diameter/"; 240 240 size_t pref_len; 241 uint8_t *dh = NULL;241 os0_t dh = NULL; 242 242 size_t dh_len = 0; 243 uint8_t *dr = NULL;243 os0_t dr = NULL; 244 244 size_t dr_len = 0; 245 uint8_t *si = NULL;245 os0_t si = NULL; 246 246 size_t si_len = 0; 247 uint8_t *un = NULL;247 os0_t un = NULL; 248 248 size_t un_len = 0; 249 249 size_t nattr_used = 0; … … 293 293 and/or to the NAS-Identifier attribute. (Note that the RADIUS 294 294 NAS-Identifier is not required to be an FQDN.) 295 -> done in rgw_ msg_create_base.295 -> done in rgw_clients_create_origin. 296 296 297 297 - The response MUST have an Origin-AAA-Protocol AVP added, … … 453 453 /* Create the session if it is not already done */ 454 454 if (*session == NULL) { 455 char * sess_str = NULL; 455 os0_t sess_str = NULL; 456 size_t sess_strlen; 456 457 457 458 if (si_len) { 458 459 /* 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) ); 460 461 } else { 461 462 /* Create a new Session-Id string */ 462 463 463 char * fqdn; 464 char * realm; 464 DiamId_t fqdn; 465 size_t fqdnlen; 466 DiamId_t realm; 467 size_t realmlen; 465 468 466 469 /* 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) ); 468 471 469 472 /* If we have a user name, create the new session with it */ 470 473 if (un) { 471 474 int len; 472 /* If not found, create a new Session-Id. Theformat is: {fqdn;hi32;lo32;username;diamid} */475 /* If not found, create a new Session-Id. Our format is: {fqdn;hi32;lo32;username;diamid} */ 473 476 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) ); 476 479 free(sess_str); 477 480 } else { … … 483 486 484 487 /* 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) ); 486 489 487 490 TRACE_DEBUG(FULL, "[auth.rgwx] Translating new message for session '%s'...", sess_str); … … 489 492 /* Add the Session-Id AVP as first AVP */ 490 493 CHECK_FCT( fd_msg_avp_new ( cs->dict.Session_Id, 0, &avp ) ); 491 value.os.data = (unsigned char *)sess_str;492 value.os.len = s trlen(sess_str);494 value.os.data = sess_str; 495 value.os.len = sess_strlen; 493 496 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); 494 497 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_FIRST_CHILD, avp) ); … … 564 567 /* This macro converts a RADIUS attribute to a Diameter AVP of type OctetString */ 565 568 #define CONV2DIAM_STR( _dictobj_ ) \ 566 CHECK_PARAMS( attr->length >= 2 );\569 CHECK_PARAMS( attr->length >= sizeof(struct radius_attr_hdr) ); \ 567 570 /* Create the AVP with the specified dictionary model */ \ 568 571 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); \ 571 574 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); \ 572 575 /* Add the AVP in the Diameter message. */ \ … … 575 578 /* Same thing, for scalar AVPs of 32 bits */ 576 579 #define CONV2DIAM_32B( _dictobj_ ) \ 577 CHECK_PARAMS( attr->length == 6 );\580 CHECK_PARAMS( attr->length == sizeof(struct radius_attr_hdr)+sizeof(uint32_t) );\ 578 581 CHECK_FCT( fd_msg_avp_new ( cs->dict._dictobj_, 0, &avp ) ); \ 579 582 { \ … … 589 592 /* And the 64b version */ 590 593 #define CONV2DIAM_64B( _dictobj_ ) \ 591 CHECK_PARAMS( attr->length == 10);\594 CHECK_PARAMS( attr->length == sizeof(struct radius_attr_hdr)+sizeof(uint64_t) );\ 592 595 CHECK_FCT( fd_msg_avp_new ( cs->dict._dictobj_, 0, &avp ) ); \ 593 596 { \ … … 609 612 - The Destination-Realm AVP is created from the information found 610 613 in the RADIUS User-Name attribute. 611 -> done in rgw_ msg_create_base614 -> done in rgw_clients_create_origin 612 615 */ 613 616 case RADIUS_ATTR_USER_NAME:
Note: See TracChangeset
for help on using the changeset viewer.