| 247 | |
| 248 | |
| 249 | static 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 */ |
no test coverage detected