MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / dm_send_acct

Function dm_send_acct

modules/aaa_diameter/dm_peer.c:249–401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247
248
249static int dm_send_acct(struct dm_message *msg)
250{
251 struct msg *dmsg;
252 struct avp *avp;
253 struct dm_avp *dm_avp;
254 struct list_head *it;
255 union avp_value val;
256 struct dict_object *acr; /* Accounting-Request (ACR, code: 271) */
257
258 FD_CHECK(fd_dict_search(fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME,
259 "Accounting-Request", &acr, ENOENT));
260
261 FD_CHECK(fd_msg_new(acr, MSGFL_ALLOC_ETEID, &dmsg));
262
263 /* App id */
264 {
265 struct msg_hdr *h;
266 FD_CHECK(fd_msg_hdr(dmsg, &h));
267 h->msg_appl = AAA_APP_ACCOUNTING;
268 }
269
270 //if ((rc = fd_msg_new_session(dmsg, (os0_t)STR_L("app_opensips"))) < 0) {
271 // LM_ERR("failed to create new acc session, rc: %d\n", rc);
272 // return -1;
273 //}
274
275 FD_CHECK(dm_add_session(dmsg, acr));
276
277 /* Origin-* */
278 FD_CHECK(fd_msg_add_origin(dmsg, 0));
279
280 /* Destination-Realm */
281 {
282 FD_CHECK(fd_msg_avp_new(dm_dict.Destination_Realm, 0, &avp));
283
284 memset(&val, 0, sizeof val);
285 val.os.data = (unsigned char *)dm_realm.s;
286 val.os.len = dm_realm.len;
287 FD_CHECK(fd_msg_avp_setvalue(avp, &val));
288 FD_CHECK(fd_msg_avp_add(dmsg, MSG_BRW_LAST_CHILD, avp));
289 }
290
291 /* Accounting-Record-Type */
292 {
293 FD_CHECK(fd_msg_avp_new(dm_dict.Accounting_Record_Type, 0, &avp));
294
295 memset(&val, 0, sizeof val);
296 val.i32 = EVENT_RECORD;
297 FD_CHECK(fd_msg_avp_setvalue(avp, &val));
298 FD_CHECK(fd_msg_avp_add(dmsg, MSG_BRW_LAST_CHILD, avp));
299 }
300
301 /* Accounting-Record-Number */
302 {
303 FD_CHECK(fd_msg_avp_new(dm_dict.Accounting_Record_Number, 0, &avp));
304
305 memset(&val, 0, sizeof val);
306 val.i32 = 0; /* just 0; the Session-Id makes it unique anyway */

Callers 1

dm_peer_send_msgFunction · 0.85

Calls 4

dm_add_sessionFunction · 0.85
str_matchFunction · 0.85
_strClass · 0.85
list_entryClass · 0.50

Tested by

no test coverage detected