use of org.restcomm.protocols.ss7.map.api.smstpdu.AddressField in project smscgateway by RestComm.
the class MoSbbTest method testMo4_Gsm8.
@Test(groups = { "Mo" })
public void testMo4_Gsm8() throws Exception {
if (!this.cassandraDbInited)
return;
// SmppSessionsProxy smppServerSessions = new SmppSessionsProxy();
// this.sbb.setSmppServerSessions(smppServerSessions);
AddressString serviceCentreAddressDA = new AddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "1111");
SM_RP_DA sm_RP_DA = new SM_RP_DAImpl(serviceCentreAddressDA);
ISDNAddressString msisdn = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "4444");
SM_RP_OAImpl sm_RP_OA = new SM_RP_OAImpl();
sm_RP_OA.setMsisdn(msisdn);
AddressField destinationAddress = new AddressFieldImpl(TypeOfNumber.InternationalNumber, NumberingPlanIdentification.ISDNTelephoneNumberingPlan, "5555");
ProtocolIdentifier protocolIdentifier = new ProtocolIdentifierImpl(12);
DataCodingScheme dataCodingScheme = new DataCodingSchemeImpl(4);
UserDataHeader decodedUserDataHeader = new UserDataHeaderImpl();
UserDataHeaderElement informationElement = new ConcatenatedShortMessagesIdentifierImpl(false, 55, 3, 1);
decodedUserDataHeader.addInformationElement(informationElement);
UserData userData = new UserDataImpl("abc 01234567890", dataCodingScheme, decodedUserDataHeader, isoCharset);
SmsTpdu tpdu = new SmsSubmitTpduImpl(false, false, false, 150, destinationAddress, protocolIdentifier, null, userData);
// isoCharset
SmsSignalInfo sm_RP_UI_0 = new SmsSignalInfoImpl(tpdu, null);
ForwardShortMessageRequestImpl event0 = new ForwardShortMessageRequestImpl(sm_RP_DA, sm_RP_OA, sm_RP_UI_0, false);
AsnOutputStream aos = new AsnOutputStream();
event0.encodeAll(aos);
ForwardShortMessageRequestImpl event = new ForwardShortMessageRequestImpl();
AsnInputStream ais = new AsnInputStream(aos.toByteArray());
ais.readTag();
event.decodeAll(ais);
long dueSlot = this.pers.c2_getDueSlotForTime(new Date());
PreparedStatementCollection psc = this.pers.getStatementCollection(new Date());
int b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
long b2 = this.pers.c2_getDueSlotForTargetId(psc, ta1.getTargetId());
assertEquals(b1, 0);
assertEquals(b2, 0L);
MAPProviderProxy proxy = new MAPProviderProxy();
MAPDialogSmsProxy dialog = new MAPDialogSmsProxy(new MAPServiceSmsProxy(proxy), null, null, null);
event.setMAPDialog(dialog);
Date curDate = new Date();
MAPApplicationContext act = MAPApplicationContext.getInstance(MAPApplicationContextName.shortMsgMORelayContext, MAPApplicationContextVersion.version2);
dialog.setApplicationContext(act);
this.sbb.onForwardShortMessageRequest(event, null);
b2 = this.pers.c2_getDueSlotForTargetId(psc, ta1.getTargetId());
dueSlot = b2;
b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
assertEquals(b1, 1);
assertEquals(b2, dueSlot);
assertEquals(dialog.getResponseCount(), 1);
assertEquals(dialog.getErrorList().size(), 0);
SmsSet smsSet = this.pers.c2_getRecordListForTargeId(dueSlot, ta1.getTargetId());
assertEquals(smsSet.getDestAddr(), "5555");
assertEquals(smsSet.getDestAddrTon(), SmppConstants.TON_INTERNATIONAL);
assertEquals(smsSet.getDestAddrNpi(), SmppConstants.NPI_E164);
assertEquals(smsSet.getInSystem(), 0);
assertEquals(smsSet.getDueDelay(), 0);
assertNull(smsSet.getStatus());
assertFalse(smsSet.isAlertingSupported());
Sms sms = smsSet.getSms(0);
assertNotNull(sms);
assertEquals(sms.getSourceAddr(), "4444");
assertEquals(sms.getSourceAddrTon(), SmppConstants.TON_INTERNATIONAL);
assertEquals(sms.getSourceAddrNpi(), SmppConstants.NPI_E164);
assertEquals(sms.getMessageId(), DBOperations.MESSAGE_ID_LAG + 1);
assertEquals(sms.getMoMessageRef(), 150);
assertEquals(sms.getDataCoding(), 4);
assertNull(sms.getOrigEsmeName());
assertNull(sms.getOrigSystemId());
assertNull(sms.getServiceType());
assertEquals(sms.getEsmClass() & 0xFF, 67);
assertEquals(sms.getRegisteredDelivery(), 0);
assertEquals(sms.getProtocolId(), 12);
assertEquals(sms.getPriority(), 0);
assertEquals(sms.getReplaceIfPresent(), 0);
assertEquals(sms.getDefaultMsgId(), 0);
assertEquals(sms.getTlvSet().getOptionalParameterCount(), 0);
assertNull(sms.getScheduleDeliveryTime());
assertDateEq(sms.getValidityPeriod(), MessageUtil.addHours(curDate, 24 * 3));
assertEquals(sms.getDeliveryCount(), 0);
assertEquals(sms.getShortMessageText(), "abc 01234567890");
assertEquals(sms.getShortMessageBin(), decodedUserDataHeader.getEncodedData());
}
use of org.restcomm.protocols.ss7.map.api.smstpdu.AddressField in project smscgateway by RestComm.
the class MtTest2 method Ucs2Test3.
@Test(groups = { "Mt" })
public void Ucs2Test3() throws Exception {
String s11 = "ura nus";
byte[] buf = s11.getBytes();
UserDataImpl ud = new UserDataImpl(s11, new DataCodingSchemeImpl(16), null, null);
AddressField originatingAddress = new AddressFieldImpl(TypeOfNumber.InternationalNumber, NumberingPlanIdentification.ISDNTelephoneNumberingPlan, "123456");
ProtocolIdentifier pi = new ProtocolIdentifierImpl(0);
AbsoluteTimeStamp serviceCentreTimeStamp = new AbsoluteTimeStampImpl(05, 3, 4, 5, 6, 7, 0);
SmsDeliverTpduImpl smsDeliverTpduImpl = new SmsDeliverTpduImpl(false, false, false, true, originatingAddress, pi, serviceCentreTimeStamp, ud);
SmsSignalInfoImpl SmsSignalInfoImpl = new SmsSignalInfoImpl(smsDeliverTpduImpl, null);
int gg = 0;
gg++;
}
use of org.restcomm.protocols.ss7.map.api.smstpdu.AddressField in project smscgateway by RestComm.
the class MtTest2 method Ucs2Test.
@Test(groups = { "Mt" })
public void Ucs2Test() throws Exception {
// Long msgId = 15L;
// String s1 = msgId.toString(10);
// String sss2 = String.format("%010d", 15L);
String s11 = "زمانیکه بررسی";
Charset ucs2Charset = Charset.forName("UTF-16BE");
Charset utf8 = Charset.forName("UTF-8");
// ByteBuffer bb = ByteBuffer.wrap(textPart);
// CharBuffer bf = ucs2Charset.decode(bb);
// msg = bf.toString();
ByteBuffer bb = utf8.encode(s11);
byte[] buf = new byte[bb.limit()];
bb.get(buf, 0, bb.limit());
String s2 = new String(buf);
UserDataImpl ud = new UserDataImpl(s2, new DataCodingSchemeImpl(8), null, null);
AddressField originatingAddress = new AddressFieldImpl(TypeOfNumber.InternationalNumber, NumberingPlanIdentification.ISDNTelephoneNumberingPlan, "123456");
ProtocolIdentifier pi = new ProtocolIdentifierImpl(0);
AbsoluteTimeStamp serviceCentreTimeStamp = new AbsoluteTimeStampImpl(05, 3, 4, 5, 6, 7, 0);
SmsDeliverTpduImpl smsDeliverTpduImpl = new SmsDeliverTpduImpl(false, false, false, true, originatingAddress, pi, serviceCentreTimeStamp, ud);
SmsSignalInfoImpl SmsSignalInfoImpl = new SmsSignalInfoImpl(smsDeliverTpduImpl, null);
int gg = 0;
gg++;
}
use of org.restcomm.protocols.ss7.map.api.smstpdu.AddressField in project smscgateway by RestComm.
the class MoSbb method processMtMessage.
// *********
// incoming message processing
private Sms processMtMessage(SM_RP_OA smRPOA, SM_RP_DA smRPDA, SmsSignalInfo smsSignalInfo, int networkId, String originatorSccpAddress, boolean isMoOperation, MAPDialogSms dialog, SmsMessage evt, long invokeId) throws SmscProcessingException {
Sms sms = null;
smsSignalInfo.setGsm8Charset(isoCharset);
IMSI destinationImsi = smRPDA.getIMSI();
if (destinationImsi == null) {
throw new SmscProcessingException("Home routing: Mt DA IMSI is absent", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
}
// obtaining correlationId
String correlationID = destinationImsi.getData();
CorrelationIdValue civ;
try {
civ = SmsSetCache.getInstance().getCorrelationIdCacheElement(correlationID);
} catch (Exception e) {
throw new SmscProcessingException("Home routing: Error when getting of CorrelationIdCacheElement", SmppConstants.STATUS_SYSERR, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e);
}
if (civ == null) {
smscStatAggregator.updateHomeRoutingCorrIdFail();
throw new SmscProcessingException("Home routing: No data is found for: CorrelationId=" + correlationID, SmppConstants.STATUS_SYSERR, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
}
SmsTpdu smsTpdu = null;
try {
smsTpdu = smsSignalInfo.decodeTpdu(false);
logger.fine("Home routing: The SmsTpduType is " + smsTpdu.getSmsTpduType());
switch(smsTpdu.getSmsTpduType()) {
case SMS_DELIVER:
SmsDeliverTpdu smsDeliverTpdu = (SmsDeliverTpdu) smsTpdu;
if (this.logger.isInfoEnabled()) {
this.logger.info("Home routing: Received SMS_DELIVER = " + smsDeliverTpdu);
}
// AddressField af = smsSubmitTpdu.getDestinationAddress();
sms = this.handleSmsDeliverTpdu(smsDeliverTpdu, civ, networkId, originatorSccpAddress, isMoOperation, dialog, evt, invokeId);
break;
default:
this.logger.severe("Home routing: Received non SMS_DELIVER = " + smsTpdu);
break;
}
} catch (MAPException e1) {
logger.severe("Home routing: Error while decoding SmsSignalInfo ", e1);
}
return sms;
}
use of org.restcomm.protocols.ss7.map.api.smstpdu.AddressField in project smscgateway by RestComm.
the class MoSbb method createDestTargetAddress.
// *********
// private methods
// private TargetAddress createDestTargetAddress(IMSI imsi, int networkId) throws SmscProcessingException {
// if (imsi == null || imsi.getData() == null || imsi.getData().isEmpty()) {
// throw new SmscProcessingException("Mt DA IMSI digits are absent", SmppConstants.STATUS_SYSERR,
// MAPErrorCode.unexpectedDataValue, null);
// }
//
// // TODO is this correct?
// int destTon = 1;//International
// int destNpi = 6;//Land Mobile (E.212)
//
// TargetAddress ta = new TargetAddress(destTon, destNpi, imsi.getData(), networkId);
// return ta;
// }
private TargetAddress createDestTargetAddress(AddressField af, int networkId) throws SmscProcessingException {
if (af == null || af.getAddressValue() == null || af.getAddressValue().isEmpty()) {
throw new SmscProcessingException("MO DestAddress digits are absent", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
}
String digits = af.getAddressValue();
int destTon, destNpi;
if (af.getTypeOfNumber() == TypeOfNumber.Alphanumeric) {
destTon = TypeOfNumber.Alphanumeric.getCode();
destNpi = NumberingPlanIdentification.Unknown.getCode();
} else {
destTon = af.getTypeOfNumber().getCode();
destNpi = af.getNumberingPlanIdentification().getCode();
}
TargetAddress ta = new TargetAddress(destTon, destNpi, digits, networkId);
return ta;
}
Aggregations