use of net.java.slee.resource.diameter.ro.events.RoCreditControlRequest in project charging-server by RestComm.
the class DiameterChargingServerSbb method onCreditControlRequestInitialEventSelect.
// --------------------------------- IES ----------------------------------
public InitialEventSelector onCreditControlRequestInitialEventSelect(InitialEventSelector ies) {
RoCreditControlRequest event = (RoCreditControlRequest) ies.getEvent();
String sid = event.getSessionId();
ies.setCustomName(sid);
// ammendonca: only INITIAL are initial events
boolean isInitial = (event.getCcRequestType() == CcRequestType.INITIAL_REQUEST || event.getCcRequestType() == CcRequestType.EVENT_REQUEST);
if (tracer.isFineEnabled()) {
tracer.fine("[--] SID<" + limitString(sid, 9, 9, "..") + "> Received CCR is " + (isInitial ? "" : "non-") + "initial.");
}
ies.setInitialEvent(isInitial);
return ies;
}
use of net.java.slee.resource.diameter.ro.events.RoCreditControlRequest in project smscgateway by RestComm.
the class ChargingSbb method setupChargingRequestInterface.
// public void onActivityEndEvent(ActivityEndEvent event, ActivityContextInterface aci) {
// logger.info(" Activity Ended[" + aci.getActivity() + "]");
// }
// Setup charging request
public void setupChargingRequestInterface(ChargingMedium chargingType, Sms sms) {
if (logger.isFineEnabled()) {
logger.fine("ChargingSbb: received message for process charging process: chargingType=" + chargingType + ", message=[" + sms + "]");
}
ChargingData chargingData = new ChargingData();
chargingData.setSms(sms);
chargingData.setChargingType(chargingType);
this.setChargingData(chargingData);
String sourceAddress = sms.getSourceAddr();
int sourceTon = sms.getSourceAddrTon();
String originatorSccpAddress = sms.getOriginatorSccpAddress();
String origMoServiceCentreAddressDA = sms.getOrigMoServiceCentreAddressDA();
if (origMoServiceCentreAddressDA == null) {
origMoServiceCentreAddressDA = smscPropertiesManagement.getServiceCenterGt(sms.getSmsSet().getNetworkId());
}
String recipientAddress = sms.getSmsSet().getDestAddr();
int destTon = sms.getSmsSet().getDestAddrTon();
int dataCodingScheme = sms.getDataCoding();
String interfaceId = Integer.toString(sms.getSmsSet().getNetworkId());
String interfaceText = sms.getOrigEsmeName();
try {
DiameterIdentity destHost = null;
if (smscPropertiesManagement.getDiameterDestHost() != null && !smscPropertiesManagement.getDiameterDestHost().equals("")) {
// destHost = new DiameterIdentity("aaa://" +
// smscPropertiesManagement.getDiameterDestHost() + ":" +
// smscPropertiesManagement.getDiameterDestPort());
destHost = new DiameterIdentity(smscPropertiesManagement.getDiameterDestHost());
}
DiameterIdentity destRealm = new DiameterIdentity(smscPropertiesManagement.getDiameterDestRealm());
RoClientSessionActivity activity = this.roProvider.createRoClientSessionActivity(destHost, destRealm);
ActivityContextInterface roACI = acif.getActivityContextInterface(activity);
roACI.attach(getSbbContext().getSbbLocalObject());
RoCreditControlRequest ccr = activity.createRoCreditControlRequest(CcRequestType.EVENT_REQUEST);
// ccr.setDestinationRealm(destRealm);
// ccr.setAuthApplicationId(APPLICATION_ID_OF_THE_DIAMETER_CREDIT_CONTROL_APPLICATION);
ccr.setServiceContextId(SERVICE_CONTEXT_ID_SMSC);
ccr.setCcRequestNumber(0);
// ((SipUri)fromHeader.getAddress().getURI()).getUser();
if (smscPropertiesManagement.getDiameterUserName() != null && !smscPropertiesManagement.getDiameterUserName().equals("")) {
ccr.setUserName(smscPropertiesManagement.getDiameterUserName());
}
// This field contains the state associated to the CTF
// do not know how to use it
// a monotonically increasing value that is advanced whenever a
// Diameter
// entity restarts with loss of previous state, for example upon
// reboot
// ccr.setOriginStateId(smscRebootStep);
// do not know if we need it
ccr.setEventTimestamp(Calendar.getInstance().getTime());
SubscriptionIdAvp subId = avpFactory.createSubscriptionId(SubscriptionIdType.END_USER_E164, sourceAddress);
ccr.setSubscriptionId(subId);
ccr.setRequestedAction(RequestedActionType.DIRECT_DEBITING);
// ccr.setMultipleServicesIndicator(MultipleServicesIndicatorType.MULTIPLE_SERVICES_NOT_SUPPORTED);
// requested units
int messageCount = 1;
int serviceIdentifier = 1;
MultipleServicesCreditControlAvp multipleServicesCreditControl = avpFactory.createMultipleServicesCreditControl();
RequestedServiceUnitAvp requestedServiceUnit = avpFactory.createRequestedServiceUnit();
requestedServiceUnit.setCreditControlServiceSpecificUnits(messageCount);
multipleServicesCreditControl.setRequestedServiceUnit(requestedServiceUnit);
multipleServicesCreditControl.setServiceIdentifier(serviceIdentifier);
ccr.setMultipleServicesCreditControl(multipleServicesCreditControl);
// RequestedServiceUnitAvp RSU =
// avpFactory.createRequestedServiceUnit();
// RSU.setCreditControlTime(_FIRST_CHARGE_TIME);
// ccr.setRequestedServiceUnit(RSU);
// ServiceInformation - SMS info 2000
ArrayList<DiameterAvp> smsInfoAvpLst = new ArrayList<DiameterAvp>();
int vendorID = 10415;
// Originator-SCCP-Address 2008
if (originatorSccpAddress != null) {
byte[] originatorSccpAddressAddrPartByteArr = originatorSccpAddress.getBytes(utf8Charset);
byte[] originatorSccpAddressByteArr = new byte[2 + originatorSccpAddressAddrPartByteArr.length];
originatorSccpAddressByteArr[1] = 8;
System.arraycopy(originatorSccpAddressAddrPartByteArr, 0, originatorSccpAddressByteArr, 2, originatorSccpAddressAddrPartByteArr.length);
DiameterAvp avpOriginatorSccpAddress = avpFactory.getBaseFactory().createAvp(vendorID, 2008, originatorSccpAddressByteArr);
smsInfoAvpLst.add(avpOriginatorSccpAddress);
}
// SMSC-Address 2017
if (origMoServiceCentreAddressDA != null) {
byte[] origMoServiceCentreAddressDAPartByteArr = origMoServiceCentreAddressDA.getBytes(utf8Charset);
byte[] origMoServiceCentreAddressDAByteArr = new byte[2 + origMoServiceCentreAddressDAPartByteArr.length];
origMoServiceCentreAddressDAByteArr[1] = 8;
System.arraycopy(origMoServiceCentreAddressDAPartByteArr, 0, origMoServiceCentreAddressDAByteArr, 2, origMoServiceCentreAddressDAPartByteArr.length);
DiameterAvp avpOrigMoServiceCentreAddressDA = avpFactory.getBaseFactory().createAvp(vendorID, 2017, origMoServiceCentreAddressDAByteArr);
smsInfoAvpLst.add(avpOrigMoServiceCentreAddressDA);
}
// Data-Coding-Scheme 2001
DiameterAvp avpDataCodingScheme = avpFactory.getBaseFactory().createAvp(vendorID, 2001, dataCodingScheme);
smsInfoAvpLst.add(avpDataCodingScheme);
// SM-Message-Type 2007
DiameterAvp avpSmMessageType = avpFactory.getBaseFactory().createAvp(vendorID, 2007, SmMessageTypeEnum.SUBMISSION.getValue());
smsInfoAvpLst.add(avpSmMessageType);
// Originator-Interface 2009
ArrayList<DiameterAvp> originatorInterfaceAvpLst = new ArrayList<DiameterAvp>();
DiameterAvp avpInterfaceId = avpFactory.getBaseFactory().createAvp(vendorID, 2003, interfaceId);
originatorInterfaceAvpLst.add(avpInterfaceId);
if (interfaceText != null) {
DiameterAvp avpInterfaceText = avpFactory.getBaseFactory().createAvp(vendorID, 2005, interfaceText);
originatorInterfaceAvpLst.add(avpInterfaceText);
}
DiameterAvp[] originatorInterfaceAvpArr = new DiameterAvp[originatorInterfaceAvpLst.size()];
originatorInterfaceAvpLst.toArray(originatorInterfaceAvpArr);
DiameterAvp avpOriginatorInterface = avpFactory.getBaseFactory().createAvp(vendorID, 2009, originatorInterfaceAvpArr);
smsInfoAvpLst.add(avpOriginatorInterface);
// Recipient-Address 1201
ArrayList<DiameterAvp> recipientAddressAvpLst = new ArrayList<DiameterAvp>();
DiameterAvp avpAddressType;
if (destTon == 1)
avpAddressType = avpFactory.getBaseFactory().createAvp(vendorID, 899, AddressTypeEnum.Msisdn.getValue());
else
avpAddressType = avpFactory.getBaseFactory().createAvp(vendorID, 899, AddressTypeEnum.Others.getValue());
recipientAddressAvpLst.add(avpAddressType);
DiameterAvp avpAddressData = avpFactory.getBaseFactory().createAvp(vendorID, 897, recipientAddress);
recipientAddressAvpLst.add(avpAddressData);
DiameterAvp[] recipientAddressAvpArr = new DiameterAvp[recipientAddressAvpLst.size()];
recipientAddressAvpLst.toArray(recipientAddressAvpArr);
DiameterAvp avpRecipientAddress = avpFactory.getBaseFactory().createAvp(vendorID, 1201, recipientAddressAvpArr);
// Recipient-Info 2026
ArrayList<DiameterAvp> recipientInfoAvpLst = new ArrayList<DiameterAvp>();
recipientInfoAvpLst.add(avpRecipientAddress);
DiameterAvp[] recipientInfoAvpArr = new DiameterAvp[recipientInfoAvpLst.size()];
recipientInfoAvpLst.toArray(recipientInfoAvpArr);
DiameterAvp avpRecipientInfo = avpFactory.getBaseFactory().createAvp(vendorID, 2026, recipientInfoAvpArr);
smsInfoAvpLst.add(avpRecipientInfo);
// Originator-Received-Address 2027
ArrayList<DiameterAvp> originatorReceivedAddressAvpLst = new ArrayList<DiameterAvp>();
if (sourceTon == 1)
avpAddressType = avpFactory.getBaseFactory().createAvp(vendorID, 899, AddressTypeEnum.Msisdn.getValue());
else
avpAddressType = avpFactory.getBaseFactory().createAvp(vendorID, 899, AddressTypeEnum.Others.getValue());
originatorReceivedAddressAvpLst.add(avpAddressType);
avpAddressData = avpFactory.getBaseFactory().createAvp(vendorID, 897, sourceAddress);
originatorReceivedAddressAvpLst.add(avpAddressData);
DiameterAvp[] originatorReceivedAddressAvpArr = new DiameterAvp[originatorReceivedAddressAvpLst.size()];
originatorReceivedAddressAvpLst.toArray(originatorReceivedAddressAvpArr);
DiameterAvp avpOriginatorReceivedAddress = avpFactory.getBaseFactory().createAvp(vendorID, 2027, originatorReceivedAddressAvpArr);
smsInfoAvpLst.add(avpOriginatorReceivedAddress);
// final assembling
DiameterAvp[] smsInfoAvpArr = new DiameterAvp[smsInfoAvpLst.size()];
smsInfoAvpLst.toArray(smsInfoAvpArr);
DiameterAvp[] smsInfo = new DiameterAvp[1];
smsInfo[0] = avpFactory.getBaseFactory().createAvp(vendorID, 2000, smsInfoAvpArr);
ServiceInformation si = avpFactory.createServiceInformation();
si.setExtensionAvps(smsInfo);
ccr.setServiceInformation(si);
activity.sendEventRoCreditControlRequest(ccr);
if (logger.isFineEnabled()) {
logger.fine("Sent INITIAL CCR: \n" + ccr);
}
// set new timer for the case we will not get CCA in time
timerFacility.setTimer(roACI, null, System.currentTimeMillis() + (CCR_TIMEOUT * 1000), defaultTimerOptions);
} catch (Exception e1) {
logger.severe("setupChargingRequestInterface(): error while sending RoCreditControlRequest: " + e1.getMessage(), e1);
generateCDR(sms, CdrGenerator.CDR_SUBMIT_FAILED_CHARGING, e1.getMessage(), false, true);
}
}
use of net.java.slee.resource.diameter.ro.events.RoCreditControlRequest in project jain-slee.diameter by RestComm.
the class RoClientSessionActivityImpl method sendEventRoCreditControlRequest.
/*
* (non-Javadoc)
* @see net.java.slee.resource.diameter.ro.RoClientSessionActivity#sendEventRoCreditControlRequest(net.java.slee.resource.diameter.ro.events.RoCreditControlRequest)
*/
public void sendEventRoCreditControlRequest(RoCreditControlRequest ccr) throws IOException {
// fetchCurrentState(ccr);
DiameterMessageImpl msg = (DiameterMessageImpl) ccr;
validateState(ccr);
try {
session.sendCreditControlRequest(new RoCreditControlRequestImpl((Request) msg.getGenericData()));
} catch (org.jdiameter.api.validation.AvpNotAllowedException e) {
throw new AvpNotAllowedException("Message validation failed.", e, e.getAvpCode(), e.getVendorId());
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("Failed to send message.", e);
}
throw new IOException("Failed to send message, due to: " + e);
}
}
use of net.java.slee.resource.diameter.ro.events.RoCreditControlRequest in project jain-slee.diameter by RestComm.
the class RoClientSessionActivityImpl method sendTerminationRoCreditControlRequest.
/*
* (non-Javadoc)
* @see net.java.slee.resource.diameter.ro.RoClientSessionActivity#sendTerminationRoCreditControlRequest(net.java.slee.resource.diameter.ro.events.RoCreditControlRequest)
*/
public void sendTerminationRoCreditControlRequest(RoCreditControlRequest ccr) throws IOException {
// This should not be used to terminate sub-sessions!
validateState(ccr);
DiameterMessageImpl msg = (DiameterMessageImpl) ccr;
try {
session.sendCreditControlRequest(new RoCreditControlRequestImpl((Request) msg.getGenericData()));
} catch (org.jdiameter.api.validation.AvpNotAllowedException e) {
throw new AvpNotAllowedException("Message validation failed.", e, e.getAvpCode(), e.getVendorId());
} catch (Exception e) {
throw new IOException("Failed to send message, due to: " + e);
}
}
use of net.java.slee.resource.diameter.ro.events.RoCreditControlRequest in project jain-slee.diameter by RestComm.
the class RoClientSessionActivityImpl method createRoCreditControlRequest.
/*
* (non-Javadoc)
* @see net.java.slee.resource.diameter.ro.RoClientSessionActivity#createRoCreditControlRequest(net.java.slee.resource.diameter.cca.events.avp.CcRequestType)
*/
public RoCreditControlRequest createRoCreditControlRequest(CcRequestType type) {
// Create the request
RoCreditControlRequest request = super.getRoMessageFactory().createRoCreditControlRequest(super.getSessionId());
request.setCcRequestType(type);
// If there's a Destination-Host, add the AVP
if (destinationHost != null) {
request.setDestinationHost(destinationHost);
}
if (destinationRealm != null) {
request.setDestinationRealm(destinationRealm);
}
return request;
}
Aggregations