Exemple #1
0
/**
 * 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;	
}	
Exemple #2
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;	
		
}	
Exemple #3
0
void AAADropAuthSession(AAAAuthSession* auth)
{
	/*Maybe there is no authlist yet.. so lets create one*/
	if (auth_list==NULL)
			return;
		
	remove_auth_session(auth);
	shm_free(auth->st);
	AAADropSession(auth->sid);
	shm_free(auth->fqdn);
	shm_free(auth->call_id->s);
	shm_free(auth->call_id);
	shm_free(auth);
}
Exemple #4
0
/**
 * Deallocates the memory taken by a Accounting Session (Credit Control - RFC 4006)
 */
void AAADropCCAccSession(AAASession *s)
{
	AAADropSession(s);
}
Exemple #5
0
/**
 * Deallocates the memory taken by a Authorization Session
 * \note Must be called with a lock on the s->hash - will unlock it, so don't use the session after this
 */
void AAADropAuthSession(AAASession *s)
{
	AAADropSession(s);
}