use of org.restcomm.protocols.ss7.map.smstpdu.UserDataHeaderImpl in project smscgateway by RestComm.
the class MoSbbTest method testMo1_Gsm7.
@Test(groups = { "Mo" })
public void testMo1_Gsm7() throws Exception {
if (!this.cassandraDbInited)
return;
// this.clearDatabase();
// 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);
// 11==60min
ValidityPeriod validityPeriod = new ValidityPeriodImpl(11);
DataCodingScheme dataCodingScheme = new DataCodingSchemeImpl(0);
UserDataHeader decodedUserDataHeader = new UserDataHeaderImpl();
UserDataHeaderElement informationElement = new ConcatenatedShortMessagesIdentifierImpl(false, 55, 3, 1);
decodedUserDataHeader.addInformationElement(informationElement);
UserData userData = new UserDataImpl(new String("0123456789"), dataCodingScheme, decodedUserDataHeader, null);
// userData.encode();
// String decodedMessage, DataCodingScheme dataCodingScheme, UserDataHeader decodedUserDataHeader, Charset gsm8Charset
SmsTpdu tpdu = new SmsSubmitTpduImpl(false, true, false, 150, destinationAddress, protocolIdentifier, validityPeriod, userData);
// boolean rejectDuplicates, boolean replyPathExists, boolean statusReportRequest, int messageReference,
// AddressField destinationAddress, ProtocolIdentifier protocolIdentifier, ValidityPeriod validityPeriod, UserData userData
// tpdu.encodeData();
SmsSignalInfo sm_RP_UI = new SmsSignalInfoImpl(tpdu, null);
MoForwardShortMessageRequest event = new MoForwardShortMessageRequestImpl(sm_RP_DA, sm_RP_OA, sm_RP_UI, null, null);
// ActivityContextInterface aci = new SmppTransactionProxy(esme);
// Date curDate = new Date();
// this.fillSm(event, curDate, true);
// event.setShortMessage(msg);
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();
this.sbb.onMoForwardShortMessageRequest(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(), 0);
assertNull(sms.getOrigEsmeName());
assertNull(sms.getOrigSystemId());
assertNull(sms.getServiceType());
assertEquals(sms.getEsmClass() & 0xFF, 195);
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, 1));
assertEquals(sms.getDeliveryCount(), 0);
// assertDateEq(smsSet.getDueDate(), new Date(curDate.getTime() + 1 * 60 * 1000));
assertEquals(sms.getShortMessageText(), "0123456789");
assertEquals(sms.getShortMessageBin(), decodedUserDataHeader.getEncodedData());
}
use of org.restcomm.protocols.ss7.map.smstpdu.UserDataHeaderImpl in project smscgateway by RestComm.
the class MessageUtil method getNationalLanguageIdentifierUdh.
public static UserDataHeader getNationalLanguageIdentifierUdh(int nationalLanguageLockingShift, int nationalLanguageSingleShift) {
UserDataHeader udh = null;
if (nationalLanguageSingleShift > 0 || nationalLanguageLockingShift > 0) {
udh = new UserDataHeaderImpl();
if (nationalLanguageSingleShift > 0) {
NationalLanguageIdentifier nli = NationalLanguageIdentifier.getInstance(nationalLanguageSingleShift);
NationalLanguageSingleShiftIdentifier informationElement = new NationalLanguageSingleShiftIdentifierImpl(nli);
udh.addInformationElement(informationElement);
}
if (nationalLanguageLockingShift > 0) {
NationalLanguageIdentifier nli = NationalLanguageIdentifier.getInstance(nationalLanguageLockingShift);
NationalLanguageLockingShiftIdentifier informationElement = new NationalLanguageLockingShiftIdentifierImpl(nli);
udh.addInformationElement(informationElement);
}
}
return udh;
}
use of org.restcomm.protocols.ss7.map.smstpdu.UserDataHeaderImpl in project smscgateway by RestComm.
the class MessageUtil method isSmsNotLastSegment.
public static boolean isSmsNotLastSegment(Sms sms) {
boolean isPartial = false;
Tlv sarMsgRefNum = sms.getTlvSet().getOptionalParameter(SmppConstants.TAG_SAR_MSG_REF_NUM);
Tlv sarTotalSegments = sms.getTlvSet().getOptionalParameter(SmppConstants.TAG_SAR_TOTAL_SEGMENTS);
Tlv sarSegmentSeqnum = sms.getTlvSet().getOptionalParameter(SmppConstants.TAG_SAR_SEGMENT_SEQNUM);
if ((sms.getEsmClass() & SmppConstants.ESM_CLASS_UDHI_MASK) != 0) {
// message already contains UDH - checking for segment
// number
byte[] shortMessage = sms.getShortMessageBin();
if (shortMessage != null && shortMessage.length > 2) {
// UDH exists
int udhLen = (shortMessage[0] & 0xFF) + 1;
if (udhLen <= shortMessage.length) {
byte[] udhData = new byte[udhLen];
System.arraycopy(shortMessage, 0, udhData, 0, udhLen);
UserDataHeaderImpl userDataHeader = new UserDataHeaderImpl(udhData);
ConcatenatedShortMessagesIdentifier csm = userDataHeader.getConcatenatedShortMessagesIdentifier();
if (csm != null) {
int mSCount = csm.getMesageSegmentCount();
int mSNumber = csm.getMesageSegmentNumber();
if (mSNumber < mSCount)
isPartial = true;
}
}
}
} else if (sarMsgRefNum != null && sarTotalSegments != null && sarSegmentSeqnum != null) {
// count/number/reference
try {
int mSCount = sarTotalSegments.getValueAsUnsignedByte();
int mSNumber = sarSegmentSeqnum.getValueAsUnsignedByte();
if (mSNumber < mSCount)
isPartial = true;
} catch (TlvConvertException e) {
}
}
return isPartial;
}
Aggregations