Changeset 996:cf09fde3d7f5 in freeDiameter for extensions/app_radgw/rgwx_acct.c
- Timestamp:
- Mar 20, 2013, 12:13:14 AM (11 years ago)
- Branch:
- default
- Children:
- 997:632913581c37, 998:ad6c1ee04d2d
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/app_radgw/rgwx_acct.c
r974 r996 289 289 290 290 /* Incoming RADIUS request */ 291 static int acct_rad_req( struct rgwp_config * cs, struct session ** session, structradius_msg * rad_req, struct radius_msg ** rad_ans, struct msg ** diam_fw, struct rgw_client * cli )291 static int acct_rad_req( struct rgwp_config * cs, struct radius_msg * rad_req, struct radius_msg ** rad_ans, struct msg ** diam_fw, struct rgw_client * cli ) 292 292 { 293 293 int idx; … … 303 303 union avp_value value; 304 304 struct avp ** avp_tun = NULL, *avp = NULL; 305 struct session * sess; 305 306 306 307 const char * prefix = "Diameter/"; … … 311 312 size_t un_len = 0; 312 313 313 TRACE_ENTRY("%p %p %p %p %p %p", cs, session, rad_req, rad_ans, diam_fw, cli);314 TRACE_ENTRY("%p %p %p %p %p", cs, rad_req, rad_ans, diam_fw, cli); 314 315 CHECK_PARAMS(rad_req && (rad_req->hdr->code == RADIUS_CODE_ACCOUNTING_REQUEST) && rad_ans && diam_fw && *diam_fw); 315 316 … … 452 453 if (status_type == RADIUS_ACCT_STATUS_TYPE_ACCOUNTING_OFF) { 453 454 TRACE_DEBUG(FULL, "[acct.rgwx] Received Accounting-Off Acct-Status-Type attribute, we must terminate all active sessions."); 454 TODO("RADIUS side is rebooting, send STR on all sessions? ");455 TODO("RADIUS side is rebooting, send STR on all sessions???"); 455 456 return ENOTSUP; 456 457 } 457 458 458 459 /* Check if we got a valid session information, otherwise the server will not be able to handle the data... */ 459 if (! *session && !si) {460 if (!si) { 460 461 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)); 461 462 return EINVAL; … … 483 484 } 484 485 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); 485 CHECK_FCT( fd_msg_avp_add ( *diam_fw, *session ? MSG_BRW_LAST_CHILD :MSG_BRW_FIRST_CHILD, avp) );486 487 /* Create the Session-Id AVP if needed*/488 if (!*session){489 CHECK_FCT( fd_sess_fromsid ( si, si_len, session, NULL) );486 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_FIRST_CHILD, avp) ); 487 488 /* Create the Session-Id AVP */ 489 { 490 CHECK_FCT( fd_sess_fromsid_msg ( si, si_len, &sess, NULL) ); 490 491 491 492 TRACE_DEBUG(FULL, "[acct.rgwx] Translating new accounting message for session '%.*s'...", si_len, si); … … 497 498 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); 498 499 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_FIRST_CHILD, avp) ); 500 CHECK_FCT( fd_msg_sess_set(*diam_fw, sess) ); 499 501 } 500 502 … … 1177 1179 { 1178 1180 struct sess_state * st; 1179 CHECK_PARAMS(session);1180 1181 1181 1182 CHECK_MALLOC( st = malloc(sizeof(struct sess_state)) ); … … 1186 1187 } 1187 1188 st->term_cause = str_cause; 1188 CHECK_FCT( fd_sess_state_store( cs->sess_hdl, *session, &st ) );1189 CHECK_FCT( fd_sess_state_store( cs->sess_hdl, sess, &st ) ); 1189 1190 } 1190 1191 … … 1222 1223 } 1223 1224 1224 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)1225 static int acct_diam_ans( struct rgwp_config * cs, struct msg ** diam_ans, struct radius_msg ** rad_fw, struct rgw_client * cli ) 1225 1226 { 1227 struct session * sess; 1226 1228 struct sess_state * st = NULL, stloc; 1227 1229 struct avp *avp, *next; 1228 struct avp_hdr *ahdr, *sid, *oh, *or; 1229 1230 TRACE_ENTRY("%p %p %p %p %p", cs, session, diam_ans, rad_fw, cli); 1230 struct avp_hdr *ahdr, *oh, *or; 1231 os0_t sid = NULL; 1232 size_t sidlen; 1233 1234 TRACE_ENTRY("%p %p %p %p", cs, diam_ans, rad_fw, cli); 1231 1235 CHECK_PARAMS(cs); 1232 1236 1233 if (session) { 1234 CHECK_FCT( fd_sess_state_retrieve( cs->sess_hdl, session, &st ) ); 1237 CHECK_FCT( fd_msg_sess_get(fd_g_config->cnf_dict, *diam_ans, &sess, NULL) ); 1238 if (sess) { 1239 CHECK_FCT( fd_sess_state_retrieve( cs->sess_hdl, sess, &st ) ); 1240 CHECK_FCT( fd_sess_getsid(sess, &sid, &sidlen) ); 1235 1241 } 1236 1242 … … 1246 1252 1247 1253 /* Search these AVPs first */ 1248 CHECK_FCT( fd_msg_search_avp (*diam_ans, cs->dict.Session_Id, &avp) );1249 CHECK_FCT( fd_msg_avp_hdr ( avp, &sid ) );1250 1251 1254 CHECK_FCT( fd_msg_search_avp (*diam_ans, cs->dict.Origin_Host, &avp) ); 1252 1255 CHECK_FCT( fd_msg_avp_hdr ( avp, &oh ) ); … … 1269 1272 ahdr->avp_value->u32, 1270 1273 oh->avp_value->os.len, oh->avp_value->os.data, 1271 sid ->avp_value->os.len, sid->avp_value->os.data);1274 sidlen, sid); 1272 1275 CHECK_FCT( fd_msg_search_avp (*diam_ans, cs->dict.Error_Message, &avp) ); 1273 1276 if (avp) { … … 1310 1313 CHECK_FCT( fd_msg_new ( cs->dict.Session_Termination_Request, MSGFL_ALLOC_ETEID, &str ) ); 1311 1314 1312 /* Set the application-id to the auth application if available, accou ting otherwise (not sure what is actually expected...) */1315 /* Set the application-id to the auth application if available, accounting otherwise (not sure what is actually expected...) */ 1313 1316 CHECK_FCT( fd_msg_hdr ( str, &hdr ) ); 1314 1317 hdr->msg_appl = st->auth_appl ?: AI_ACCT; … … 1316 1319 /* Add the Session-Id AVP as first AVP */ 1317 1320 CHECK_FCT( fd_msg_avp_new ( cs->dict.Session_Id, 0, &avp ) ); 1318 CHECK_FCT( fd_msg_avp_setvalue ( avp, sid->avp_value ) ); 1321 avp_val.os.data = sid; 1322 avp_val.os.len = sidlen; 1323 CHECK_FCT( fd_msg_avp_setvalue ( avp, &avp_val ) ); 1319 1324 CHECK_FCT( fd_msg_avp_add ( str, MSG_BRW_FIRST_CHILD, avp) ); 1325 CHECK_FCT( fd_sess_ref_msg(sess) ); 1320 1326 1321 1327 /* Add the Destination-Realm as next AVP */
Note: See TracChangeset
for help on using the changeset viewer.