void Send_ASR(cdp_session_t* s, AAAMessage* msg) { AAAMessage *asr = 0; AAA_AVP *avp = 0; peer *p = 0; char x[4]; LM_DBG("Send_ASR() : sending ASR\n"); asr = AAACreateRequest(s->application_id, IMS_ASR, Flag_Proxyable, s); if (!asr) { LM_ERR("Send_ASR(): error creating ASR!\n"); return; } set_4bytes(x, s->application_id); avp = AAACreateAVP(AVP_Auth_Application_Id, AAA_AVP_FLAG_MANDATORY, 0, x, 4, AVP_DUPLICATE_DATA); AAAAddAVPToMessage(asr, avp, asr->avpList.tail); set_4bytes(x, 3); // Not specified avp = AAACreateAVP(AVP_IMS_Abort_Cause, AAA_AVP_FLAG_MANDATORY, 0, x, 4, AVP_DUPLICATE_DATA); AAAAddAVPToMessage(asr, avp, asr->avpList.tail); //todo - add all the other avps p = get_routing_peer(s, asr); if (!p) { LM_ERR("unable to get routing peer in Send_ASR \n"); if (asr) AAAFreeMessage(&asr); //needed in frequency } if (!peer_send_msg(p, asr)) { if (asr) AAAFreeMessage(&asr); //needed in frequency } else LM_DBG("success sending ASR\n"); }
/** * Create and send an Credit Control Request and returns the Answer received for it. * This function credit control messages to the OCS * @param session_id - the ID number for the session * @param user_subscriber - user name, e.g. Alice * @param ohost - the origin host * @param orealm - the origin realm * @param auth_app_id - the authorization application ID * @param service_context_id - the service context ID, to identify type of service * @param cc_type - the Credit Control Type (e.g. START, INTERIM, STOP) * @param cc_number - the Credit Control Number * @param dhost - the destination host * @param crdtonce - once-off charge value * @param crdtpsec - Duration charge value * @param crdtpMb - Volume charge value * @returns the CCA */ AAAMessage *Ro_CCR(int session_id, str user_subscriber, str ohost, str orealm, str auth_app_id, str service_context_id, unsigned int cc_type, str cc_number, str dhost, int crdtonce, int crdtpsec, int crdtpMb) { LOG(L_DBG,"DBG: Ro_CCR() - Preparing accounting request for %s\n",user_subscriber.s); AAAMessage *ccr=0,*cca=0; AAASessionId sessId={0,0}; AAATransaction *trans=0; unsigned int hash=0,label=0; //char buf[200]; sessId = AAACreateSession(); trans=AAACreateTransaction(IMS_Ro,IMS_CCR); ccr = AAACreateRequest(IMS_Ro,IMS_CCR,Flag_Proxyable,&sessId); if (!ccr) goto error; if (!Ro_add_origin_realm(ccr, orealm)) goto error; if (!Ro_add_cc_request_type(ccr, cc_type)) goto error; if (!Ro_add_cc_request_number(ccr, cc_number)) goto error; if (!Ro_add_auth_application_id(ccr, auth_app_id)) goto error; if (!Ro_add_service_context_id(ccr, service_context_id)) goto error; if (!Ro_add_subscriber(ccr, user_subscriber)) goto error; if (!Ro_add_Call_Record_Id(ccr, session_id)) goto error; if (!Ro_add_Credit_onceoff(ccr, crdtonce)) goto error; if (!Ro_add_Credit_persec(ccr, crdtpsec)) goto error; if (!Ro_add_Credit_perMbyte(ccr, crdtpMb)) goto error; if (!Ro_add_destination_host(ccr, dhost)) goto error; if (!Ro_add_origin_host(ccr, ohost)) goto error; trans->hash=hash; trans->label=label; LOG(L_INFO,"INFO: sending Diameter Credit Control Request to: %s\n",ccr->dest_host->data.s); cca = AAASendRecvMessageToPeer(ccr,&dhost); if(!cca) { LOG(L_ERR,"Error: Ro_CCR - No message in the accounting reply\n"); return 0; } AAADropSession(&sessId); AAADropTransaction(trans); return cca; error: if (trans) AAADropTransaction(trans); if (sessId.s) AAADropSession(&sessId); if (ccr) AAAFreeMessage(&ccr); return 0; }
/** * Create and send an Accounting Request * This function sends accounting data (CDR) to the CDF * @param session_id - ID for the session * @param user_subscriber - User name, e.g., Alice * @param ohost - the origin host * @param orealm - the origin realm * @param drealm - the destination realm * @param acc_type - the accounting record type (eg start, interim, stop, event) * @param acc_number - the number of the ACR * @param dhost - the destination host * @param crdtonce - once-off charge value * @param crdtpsec - Duration charge value * @param crdtpMb - Volume charge value * @returns the ACA - accounting answer */ AAAMessage *Rf_ACR(int session_id, str user_subscriber, str ohost, str orealm, str drealm, unsigned int acc_type, str acc_number, str dhost, int crdtonce, int crdtpsec, int crdtpMb) { LOG(L_DBG,"INFO: Rf_ACR() - Preparing accounting request\n"); AAAMessage *acr=0,*aca=0; AAASessionId sessId={0,0}; AAATransaction *trans=0; unsigned int hash=0,label=0; sessId = AAACreateSession(); trans = AAACreateTransaction(IMS_Rf,IMS_ACR); acr = AAACreateRequest(IMS_Rf,IMS_ACR,Flag_Proxyable,&sessId); if (!acr) goto error; if (!Rf_add_vendor_specific_appid(acr,IMS_vendor_id_3GPP,IMS_Rf,0 /*IMS_Rf*/)) goto error; if (!Rf_add_origin_realm(acr, orealm)) goto error; if (!Rf_add_destination_realm(acr, drealm)) goto error; if (!Rf_add_Accounting_Record_Type(acr, acc_type)) goto error; if (!Rf_add_Accounting_Record_Number(acr, acc_number)) goto error; if (!Rf_add_Call_Record_Id(acr, session_id)) goto error; if (!Rf_add_subscriber(acr, user_subscriber)) goto error; if (!Rf_add_Credit_onceoff(acr, crdtonce)) goto error; if (!Rf_add_Credit_persec(acr, crdtpsec)) goto error; if (!Rf_add_Credit_perMbyte(acr, crdtpMb)) goto error; if (!Rf_add_destination_host(acr, dhost)) goto error; if (!Rf_add_origin_host(acr, ohost)) goto error; trans->hash=hash; trans->label=label; LOG(L_INFO,"INFO: sending Diameter Accounting Request to: %s\n",acr->dest_host->data.s); aca = AAASendRecvMessageToPeer(acr,&dhost); //send a charging request or answer if(!aca) { LOG(L_ERR,"ERROR: Rf_ACR - No message in the accounting reply\n"); return 0; } AAADropSession(&sessId); AAADropTransaction(trans); return aca; error: if (trans) AAADropTransaction(trans); if (sessId.s) AAADropSession(&sessId); if (acr) AAAFreeMessage(&acr); return 0; }
void Send_STR(cdp_session_t* s, AAAMessage* msg) { AAAMessage *str=0; AAA_AVP *avp=0; peer *p=0; char x[4]; LOG(L_DBG, "sending STR\n"); //if (msg) LOG(L_DBG,"Send_STR() : sending STR for %d, flags %#1x endtoend %u hopbyhop %u\n",msg->commandCode,msg->flags,msg->endtoendId,msg->hopbyhopId); //else LOG(L_DBG,"Send_STR() called from AAATerminateAuthSession or some other event\n"); str = AAACreateRequest(s->application_id,IMS_STR,Flag_Proxyable,s); if (!str) { LOG(L_ERR,"ERR:Send_STR(): error creating STR!\n"); return; } if(!dup_routing_avps(msg, str)){ LOG(L_ERR,"ERR:Send_STR(): error duplicating routing AVPs!\n"); AAAFreeMessage(&str); return; } if(s->vendor_id!=0 && !add_vendor_specific_application_id_group(str,s->vendor_id,s->application_id)){ LOG(L_ERR,"ERR:Send_STR(): error adding Vendor-Id-Specific-Application-Id Group!\n"); AAAFreeMessage(&str); return; } set_4bytes(x,s->application_id); avp = AAACreateAVP(AVP_Auth_Application_Id,AAA_AVP_FLAG_MANDATORY,0,x,4,AVP_DUPLICATE_DATA); AAAAddAVPToMessage(str,avp,str->avpList.tail); set_4bytes(x,4); // Diameter_administrative avp = AAACreateAVP(AVP_Termination_Cause,AAA_AVP_FLAG_MANDATORY,0,x,4,AVP_DUPLICATE_DATA); AAAAddAVPToMessage(str,avp,str->avpList.tail); //todo - add all the other avps p = get_routing_peer(str); if (!p) { LOG(L_ERR,"unable to get routing peer in Send_STR \n"); if (str) AAAFreeMessage(&str); //needed in frequency return; } //if (str) LOG(L_CRIT,"Send_STR() : sending STR %d, flags %#1x endtoend %u hopbyhop %u\n",str->commandCode,str->flags,str->endtoendId,str->hopbyhopId); if (!peer_send_msg(p,str)) { LOG(L_DBG,"Send_STR peer_send_msg return error!\n"); if (str) AAAFreeMessage(&str); //needed in frequency } else { LOG(L_DBG,"success sending STR\n"); } }
void Send_STR(cdp_session_t* s, AAAMessage* msg) { AAAMessage *str = 0; AAA_AVP *avp = 0; peer *p = 0; char x[4]; LM_DBG("sending STR\n"); //if (msg) LM_DBG("Send_STR() : sending STR for %d, flags %#1x endtoend %u hopbyhop %u\n",msg->commandCode,msg->flags,msg->endtoendId,msg->hopbyhopId); //else LM_DBG("Send_STR() called from AAATerminateAuthSession or some other event\n"); str = AAACreateRequest(s->application_id, IMS_STR, Flag_Proxyable, s); if (!str) { LM_ERR("Send_STR(): error creating STR!\n"); return; } if (!dup_routing_avps(msg, str)) { LM_ERR("Send_STR(): error duplicating routing AVPs!\n"); AAAFreeMessage(&str); return; } if (s->vendor_id != 0 && !add_vendor_specific_application_id_group(str, s->vendor_id, s->application_id)) { LM_ERR("Send_STR(): error adding Vendor-Id-Specific-Application-Id Group!\n"); AAAFreeMessage(&str); return; } //Richard added this - if timers expire dest realm is not here! LM_DBG("Adding dest realm if not there already...\n"); LM_DBG("Destination realm: [%.*s] \n", s->dest_realm.len, s->dest_realm.s); /* Add Destination-Realm AVP, if not already there */ avp = AAAFindMatchingAVP(str, str->avpList.head, AVP_Destination_Realm, 0, AAA_FORWARD_SEARCH); if (!avp) { avp = AAACreateAVP(AVP_Destination_Realm, AAA_AVP_FLAG_MANDATORY, 0, s->dest_realm.s, s->dest_realm.len, AVP_DUPLICATE_DATA); AAAAddAVPToMessage(str, avp, str->avpList.tail); } set_4bytes(x, s->application_id); avp = AAACreateAVP(AVP_Auth_Application_Id, AAA_AVP_FLAG_MANDATORY, 0, x, 4, AVP_DUPLICATE_DATA); AAAAddAVPToMessage(str, avp, str->avpList.tail); set_4bytes(x, 4); // Diameter_administrative avp = AAACreateAVP(AVP_Termination_Cause, AAA_AVP_FLAG_MANDATORY, 0, x, 4, AVP_DUPLICATE_DATA); AAAAddAVPToMessage(str, avp, str->avpList.tail); //todo - add all the other avps /* we are already locked on the auth session*/ p = get_routing_peer(s, str); if (!p) { LM_ERR("unable to get routing peer in Send_STR \n"); if (str) AAAFreeMessage(&str); //needed in frequency return; } //if (str) LM_CRIT("Send_STR() : sending STR %d, flags %#1x endtoend %u hopbyhop %u\n",str->commandCode,str->flags,str->endtoendId,str->hopbyhopId); if (!peer_send_msg(p, str)) { LM_DBG("Send_STR peer_send_msg return error!\n"); if (str) AAAFreeMessage(&str); //needed in frequency } else { LM_DBG("success sending STR\n"); } }