use of org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl in project jain-slee.diameter by RestComm.
the class AvpFlagsTest method testCorrectFlagsBaseExample.
@Test
public void testCorrectFlagsBaseExample() throws NoSuchAvpException {
List<DiameterAvp> avps = new ArrayList<DiameterAvp>();
avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.SESSION_ID, "accesspoint7.acme.com;1876543210;523;mobile@200.1.1.88".getBytes()));
DiameterAvp avpVendorId = baseAvpFactory.createAvp(DiameterAvpCodes.VENDOR_ID, 193);
DiameterAvp avpAcctApplicationId = baseAvpFactory.createAvp(DiameterAvpCodes.ACCT_APPLICATION_ID, 19302);
avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.VENDOR_SPECIFIC_APPLICATION_ID, new DiameterAvp[] { avpVendorId, avpAcctApplicationId }));
avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.ORIGIN_HOST, "127.0.0.1".getBytes()));
avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.ORIGIN_REALM, "mobicents.org".getBytes()));
avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.DESTINATION_HOST, ("127.0.0.1" + ":" + "3868").getBytes()));
avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.DESTINATION_REALM, "mobicents.org".getBytes()));
// Subscription ID
DiameterAvp subscriptionIdType = baseAvpFactory.createAvp(193, 555, 0);
DiameterAvp subscriptionIdData = baseAvpFactory.createAvp(193, 554, "00001000");
avps.add(baseAvpFactory.createAvp(193, 553, new DiameterAvp[] { subscriptionIdType, subscriptionIdData }));
// Requested Service Unit
DiameterAvp unitType = baseAvpFactory.createAvp(193, 611, 2);
DiameterAvp valueDigits = baseAvpFactory.createAvp(193, 617, 10L);
DiameterAvp unitValue = baseAvpFactory.createAvp(193, 612, new DiameterAvp[] { valueDigits });
avps.add(baseAvpFactory.createAvp(193, 606, new DiameterAvp[] { unitType, unitValue }));
// Record Number and Type
avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.ACCOUNTING_RECORD_NUMBER, 0));
avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.ACCOUNTING_RECORD_TYPE, 1));
// Requested action
avps.add(baseAvpFactory.createAvp(193, 615, 0));
// Service Parameter Type
DiameterAvp serviceParameterType = baseAvpFactory.createAvp(193, 608, 0);
DiameterAvp serviceParameterValue = baseAvpFactory.createAvp(193, 609, "510");
avps.add(baseAvpFactory.createAvp(193, 607, new DiameterAvp[] { serviceParameterType, serviceParameterValue }));
// Service Parameter Type
DiameterAvp serviceParameterType2 = baseAvpFactory.createAvp(193, 608, 14);
DiameterAvp serviceParameterValue2 = baseAvpFactory.createAvp(193, 609, "20");
avps.add(baseAvpFactory.createAvp(193, 607, new DiameterAvp[] { serviceParameterType2, serviceParameterValue2 }));
DiameterAvp[] avpArray = new DiameterAvp[avps.size()];
avpArray = avps.toArray(avpArray);
AccountingRequest acr = baseMessageFactory.createAccountingRequest();
acr.setExtensionAvps(avpArray);
ArrayList<String> failures = checkAvpFlags(((DiameterMessageImpl) acr).getGenericData().getAvps());
if (failures.size() > 0) {
System.err.println("The following AVPs flags have failed to check against dictionary:");
for (String failure : failures) {
System.err.println(failure);
}
Assert.fail(failures.toString());
}
// Test going through other way for adding avp's
acr = baseMessageFactory.createAccountingRequest(avpArray);
failures = checkAvpFlags(((DiameterMessageImpl) acr).getGenericData().getAvps());
if (failures.size() > 0) {
System.err.println("The following AVPs flags have failed to check against dictionary:");
for (String failure : failures) {
System.err.println(failure);
}
Assert.fail(failures.toString());
}
}
use of org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl in project jain-slee.diameter by RestComm.
the class CreditControlClientSessionImpl method sendCreditControlRequest.
/*
* (non-Javadoc)
*
* @seenet.java.slee.resource.diameter.cca.CreditControlClientSession#
* sendCreditControlRequest
* (net.java.slee.resource.diameter.cca.events.CreditControlRequest)
*/
public void sendCreditControlRequest(CreditControlRequest ccr) throws IOException {
// fetchCurrentState(ccr);
DiameterMessageImpl msg = (DiameterMessageImpl) ccr;
validateState(ccr);
try {
session.sendCreditControlRequest(new JCreditControlRequestImpl((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 org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl in project jain-slee.diameter by RestComm.
the class CreditControlClientSessionImpl method sendUpdateCreditControlRequest.
/*
* (non-Javadoc)
*
* @seenet.java.slee.resource.diameter.cca.CreditControlClientSession#
* sendUpdateCreditControlRequest
* (net.java.slee.resource.diameter.cca.events.CreditControlRequest)
*/
public void sendUpdateCreditControlRequest(CreditControlRequest ccr) throws IOException {
// FIXME: Should this come already in the CCR?
ccr.setCcRequestType(CcRequestType.UPDATE_REQUEST);
validateState(ccr);
DiameterMessageImpl msg = (DiameterMessageImpl) ccr;
try {
session.sendCreditControlRequest(new JCreditControlRequestImpl((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 org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl in project jain-slee.diameter by RestComm.
the class CxDxClientSessionImpl method sendPushProfileAnswer.
/* (non-Javadoc)
* @see net.java.slee.resource.diameter.cxdx.CxDxClientSession#sendPushProfileAnswer(net.java.slee.resource.diameter.cxdx.events.PushProfileAnswer)
*/
public void sendPushProfileAnswer(PushProfileAnswer pushProfileAnswer) throws IOException {
try {
DiameterMessageImpl msg = (DiameterMessageImpl) pushProfileAnswer;
appSession.sendPushProfileAnswer(new JPushProfileAnswerImpl((Answer) msg.getGenericData()));
} catch (org.jdiameter.api.validation.AvpNotAllowedException anae) {
throw new AvpNotAllowedException(anae.getMessage(), anae.getAvpCode(), anae.getVendorId());
} catch (Exception e) {
throw new IOException(e.getMessage());
}
}
use of org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl in project jain-slee.diameter by RestComm.
the class CxDxServerSessionImpl method sendLocationInfoAnswer.
/*
* (non-Javadoc)
* @see net.java.slee.resource.diameter.cxdx.CxDxServerSession#sendLocationInfoAnswer(net.java.slee.resource.diameter.cxdx.events.LocationInfoAnswer)
*/
public void sendLocationInfoAnswer(LocationInfoAnswer locationInfoAnswer) throws IOException {
DiameterMessageImpl msg = (DiameterMessageImpl) locationInfoAnswer;
JLocationInfoAnswerImpl answer = new JLocationInfoAnswerImpl((Answer) msg.getGenericData());
try {
appSession.sendLocationInformationAnswer(answer);
} catch (org.jdiameter.api.validation.AvpNotAllowedException anae) {
throw new AvpNotAllowedException(anae.getMessage(), anae.getAvpCode(), anae.getVendorId());
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("Failed to send message.", e);
}
throw new IOException(e.getMessage());
}
}
Aggregations