use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class CreditControlMessageFactoryImpl method createCreditControlRequest.
/*
* (non-Javadoc)
*
* @see net.java.slee.resource.diameter.cca.CreditControlMessageFactory#createCreditControlRequest()
*/
public CreditControlRequest createCreditControlRequest() {
CreditControlRequest req = (CreditControlRequest) createCreditControlMessage(null, new DiameterAvp[0]);
req.setOriginRealm(new DiameterIdentity(stack.getMetaData().getLocalPeer().getRealmName()));
req.setOriginHost(new DiameterIdentity(stack.getMetaData().getLocalPeer().getUri().getFQDN().toString()));
if (session != null) {
req.setSessionId(session.getSessionId());
}
return req;
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class CreditControlMessageFactoryImpl method addAvp.
protected void addAvp(DiameterAvp avp, AvpSet set) {
// proper function?
if (avp instanceof GroupedAvp) {
AvpSet avpSet = set.addGroupedAvp(avp.getCode(), avp.getVendorId(), avp.getMandatoryRule() == 1, avp.getProtectedRule() == 1);
DiameterAvp[] groupedAVPs = ((GroupedAvp) avp).getExtensionAvps();
for (DiameterAvp avpFromGroup : groupedAVPs) {
addAvp(avpFromGroup, avpSet);
}
} else if (avp != null) {
set.addAvp(avp.getCode(), avp.byteArrayValue(), avp.getVendorId(), avp.getMandatoryRule() == 1, avp.getProtectedRule() == 1);
}
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class CreditControlMessageFactoryImpl method createCreditControlAnswer.
/*
* (non-Javadoc)
*
* @see net.java.slee.resource.diameter.cca.CreditControlMessageFactory#createCreditControlAnswer
* (net.java.slee.resource.diameter.cca.events.CreditControlRequest)
*/
public CreditControlAnswer createCreditControlAnswer(CreditControlRequest request) {
// Create the answer from the request
CreditControlRequestImpl ccr = (CreditControlRequestImpl) request;
// DiameterAvp sessionIdAvp = null;
// try {
// sessionIdAvp = creditControlAvpFactory.getBaseFactory().createAvp(0, DiameterAvpCodes.SESSION_ID, this.session.getSessionId());
// }
// catch (NoSuchAvpException e1) {
// logger.error("Session-Id AVP not found in message", e1);
// }
CreditControlAnswerImpl msg = (CreditControlAnswerImpl) createCreditControlMessage(ccr.getHeader(), new DiameterAvp[0]);
msg.getGenericData().getAvps().removeAvp(DiameterAvpCodes.DESTINATION_HOST);
msg.getGenericData().getAvps().removeAvp(DiameterAvpCodes.DESTINATION_REALM);
msg.getGenericData().getAvps().removeAvp(DiameterAvpCodes.ORIGIN_HOST);
msg.getGenericData().getAvps().removeAvp(DiameterAvpCodes.ORIGIN_REALM);
msg.setSessionId(request.getSessionId());
// Now copy the needed AVPs
DiameterAvp[] messageAvps = request.getAvps();
if (messageAvps != null) {
for (DiameterAvp a : messageAvps) {
try {
if (ids.contains(a.getCode())) {
msg.addAvp(a);
}
} catch (Exception e) {
logger.error("Failed to add AVP to answer. Code[" + a.getCode() + "]", e);
}
}
}
addOrigin(msg);
return msg;
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class CxDxClientSessionImpl method createRegistrationTerminationAnswer.
/* (non-Javadoc)
* @see net.java.slee.resource.diameter.cxdx.CxDxClientSession#createRegistrationTerminationRequest()
*/
public RegistrationTerminationAnswer createRegistrationTerminationAnswer() {
// Make sure we have the correct type of Request
if (!(lastRequest instanceof RegistrationTerminationRequest)) {
logger.warn("Invalid type of answer for this activity.");
return null;
}
try {
// Create the answer
RegistrationTerminationAnswer rta = (RegistrationTerminationAnswer) this.cxdxMessageFactory.createCxDxMessage(lastRequest.getHeader(), new DiameterAvp[] {}, RegistrationTerminationAnswer.COMMAND_CODE, cxdxMessageFactory.getApplicationId());
// Fill session related AVPs, if present
fillSessionAVPs(rta);
return rta;
} catch (InternalException e) {
logger.error("Failed to create Registration-Termination-Answer.", e);
}
return null;
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class CxDxServerSessionImpl method createLocationInfoAnswer.
/*
* (non-Javadoc)
* @see net.java.slee.resource.diameter.cxdx.CxDxServerSession#createLocationInfoAnswer()
*/
public LocationInfoAnswer createLocationInfoAnswer() {
// Make sure we have the correct type of Request
if (!(lastRequest instanceof LocationInfoRequest)) {
logger.warn("Invalid type of answer for this activity.");
return null;
}
try {
// Create the answer
LocationInfoAnswer lia = (LocationInfoAnswer) this.cxdxMessageFactory.createCxDxMessage(lastRequest.getHeader(), new DiameterAvp[] {}, LocationInfoAnswer.COMMAND_CODE, cxdxMessageFactory.getApplicationId());
// Fill session related AVPs, if present
fillSessionAVPs(lia);
return lia;
} catch (InternalException e) {
logger.error("Failed to create Location-Info-Answer.", e);
}
return null;
}
Aggregations