Changeset 356:e203fc0c95e3 in freeDiameter for extensions/app_radgw/rgwx_acct.c
- Timestamp:
- Jul 1, 2010, 3:47:34 PM (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/app_radgw/rgwx_acct.c
r296 r356 285 285 286 286 /* Incoming RADIUS request */ 287 static int acct_rad_req( struct rgwp_config * cs, struct session * session, struct radius_msg * rad_req, struct radius_msg ** rad_ans, struct msg ** diam_fw, struct rgw_client * cli )287 static int acct_rad_req( struct rgwp_config * cs, struct session ** session, struct radius_msg * rad_req, struct radius_msg ** rad_ans, struct msg ** diam_fw, struct rgw_client * cli ) 288 288 { 289 289 int idx; … … 300 300 struct avp ** avp_tun = NULL, *avp = NULL; 301 301 302 const char * prefix = "Diameter/"; 303 size_t pref_len; 304 char * si = NULL; 305 size_t si_len = 0; 306 302 307 TRACE_ENTRY("%p %p %p %p %p %p", cs, session, rad_req, rad_ans, diam_fw, cli); 303 308 CHECK_PARAMS(rad_req && (rad_req->hdr->code == RADIUS_CODE_ACCOUNTING_REQUEST) && rad_ans && diam_fw && *diam_fw); 309 310 pref_len = strlen(prefix); 304 311 305 312 /* … … 309 316 port or the NAS does not distinguish among its ports. 310 317 */ 318 /* We also enforce that the message contains a CLASS attribute with Diameter/ prefix containing the Session-Id. */ 311 319 for (idx = 0; idx < rad_req->attr_used; idx++) { 312 320 struct radius_attr_hdr * attr = (struct radius_attr_hdr *)(rad_req->buf + rad_req->attr_pos[idx]); … … 342 350 | v[3] ; 343 351 break; 352 353 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 } 368 } 369 break; 370 344 371 } 345 372 } … … 418 445 } 419 446 447 /* Check if we got a valid session information, otherwise the server will not be able to handle the data... */ 448 if (!*session && !si) { 449 TRACE_DEBUG(INFO, "[acct.rgwx] RADIUS Account-Request from %s did not contain a CLASS attribute with Diameter session information, reject.", rgw_clients_id(cli)); 450 return EINVAL; 451 } 452 453 /* Create the Session-Id AVP if needed */ 454 if (!*session) { 455 CHECK_FCT( fd_sess_fromsid ( si, si_len, session, NULL) ); 456 457 TRACE_DEBUG(FULL, "[auth.rgwx] Translating new accounting message for session '%.*s'...", si_len, si); 458 459 /* Add the Session-Id AVP as first AVP */ 460 CHECK_FCT( fd_msg_avp_new ( cs->dict.Session_Id, 0, &avp ) ); 461 value.os.data = (unsigned char *)si; 462 value.os.len = si_len; 463 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); 464 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_FIRST_CHILD, avp) ); 465 } 466 420 467 /* Add the command code */ 421 468 { … … 1092 1139 } 1093 1140 st->term_cause = str_cause; 1094 CHECK_FCT( fd_sess_state_store( cs->sess_hdl, session, &st ) );1141 CHECK_FCT( fd_sess_state_store( cs->sess_hdl, *session, &st ) ); 1095 1142 } 1096 1143 … … 1128 1175 } 1129 1176 1130 static int acct_diam_ans( struct rgwp_config * cs, struct session * session, struct msg ** diam_ans, struct radius_msg ** rad_fw, struct rgw_client * cli )1177 static int acct_diam_ans( struct rgwp_config * cs, struct session * session, struct msg ** diam_ans, struct radius_msg ** rad_fw, struct rgw_client * cli, int * stateful ) 1131 1178 { 1132 1179 struct sess_state * st = NULL;
Note: See TracChangeset
for help on using the changeset viewer.