Merge branch 'qasimakhan-master'
This commit is contained in:
+13
-5
@@ -372,21 +372,29 @@ function longSms(pduObj) {
|
|||||||
// reference number is of one octet otherwise it consists of 2 octets. Other fields can
|
// reference number is of one octet otherwise it consists of 2 octets. Other fields can
|
||||||
// be found from below reference.
|
// be found from below reference.
|
||||||
// reference: https://en.wikipedia.org/wiki/Concatenated_SMS
|
// reference: https://en.wikipedia.org/wiki/Concatenated_SMS
|
||||||
var longSmsId = pduObj.params.source_addr + '_' + pduObj.params.destination_addr + '_' + pduObj.params.udhHeader.reference;
|
var udhHeaderSize = pduObj.params.short_message[0], // First octet is the size of UDH Header
|
||||||
|
headerSize = pduObj.params.short_message[2], // Header size other than first 2 octets
|
||||||
|
csmsReference = pduObj.params.short_message.slice(3, 3 + headerSize - 2), // CSMS Reference starts from
|
||||||
|
// 4th octet and length is
|
||||||
|
// header size -2 octets
|
||||||
|
partsCount = pduObj.params.short_message[2 + csmsReference.length + 1],
|
||||||
|
partNr = pduObj.params.short_message[2 + csmsReference.length + 1];
|
||||||
|
|
||||||
|
var longSmsId = pduObj.params.source_addr + '_' + pduObj.params.destination_addr + '_' + csmsReference;
|
||||||
|
|
||||||
if (this.longSmses[longSmsId] === undefined) {
|
if (this.longSmses[longSmsId] === undefined) {
|
||||||
this.longSmses[longSmsId] = {
|
this.longSmses[longSmsId] = {
|
||||||
'created': new Date(),
|
'created': new Date(),
|
||||||
'partsCount': pduObj.params.udhHeader.totalParts,
|
'partsCount': partsCount,
|
||||||
'udhSize': pduObj.params.udhHeader.size, // Saving udh size to remove garbage from message
|
'udhSize': udhHeaderSize, // Saving udh size to remove garbage from message
|
||||||
'pduObjs': [{
|
'pduObjs': [{
|
||||||
'partNr': pduObj.params.udhHeader.partNr, // We save this here to easier sort the array later on
|
'partNr': partNr, // We save this here to easier sort the array later on
|
||||||
'pduObj': pduObj
|
'pduObj': pduObj
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
this.longSmses[longSmsId].pduObjs.push({
|
this.longSmses[longSmsId].pduObjs.push({
|
||||||
'partNr': pduObj.params.udhHeader.partNr, // We save this here to easier sort the array later on
|
'partNr': partNr, // We save this here to easier sort the array later on
|
||||||
'pduObj': pduObj
|
'pduObj': pduObj
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -272,23 +272,6 @@ function pduToObj(pdu, stupidNullByte, callback) {
|
|||||||
|
|
||||||
log.silly('larvitsmpp: lib/utils.js: pduToObj() - Reading param "' + param + '" at offset ' + offset + ' with calculated size: ' + paramSize + ' content in hex: ' + pdu.slice(offset, offset + paramSize).toString('hex'));
|
log.silly('larvitsmpp: lib/utils.js: pduToObj() - Reading param "' + param + '" at offset ' + offset + ' with calculated size: ' + paramSize + ' content in hex: ' + pdu.slice(offset, offset + paramSize).toString('hex'));
|
||||||
if (param === 'short_message') {
|
if (param === 'short_message') {
|
||||||
if ((retObj.params.esm_class & 0x40) === 0x40) {
|
|
||||||
// This is a part of long sms. We should save UDH header information in params.
|
|
||||||
retObj.params.udhHeader = {};
|
|
||||||
retObj.params.udhHeader.size = parseInt('0x' + pdu.slice(offset, offset + paramSize).toString('hex').slice(0, 2));
|
|
||||||
|
|
||||||
// If hsize is >5 then CSMS Reference consist of two parts
|
|
||||||
if (retObj.params.udhHeader.size === 5) {
|
|
||||||
retObj.params.udhHeader.reference = parseInt('0x' + pdu.slice(offset, offset + paramSize).toString('hex').slice(6, 8));
|
|
||||||
retObj.params.udhHeader.totalParts = parseInt('0x' + pdu.slice(offset, offset + paramSize).toString('hex').slice(8, 10));
|
|
||||||
retObj.params.udhHeader.partNr = parseInt('0x' + pdu.slice(offset, offset + paramSize).toString('hex').slice(10, 12));
|
|
||||||
} else {
|
|
||||||
retObj.params.udhHeader.reference = (parseInt('0x' + pdu.slice(offset, offset + paramSize).toString('hex').slice(6, 8)) * 256) + parseInt('0x' + pdu.slice(offset, offset + paramSize).toString('hex').slice(8, 10)),
|
|
||||||
retObj.params.udhHeader.totalParts = parseInt('0x' + pdu.slice(offset, offset + paramSize).toString('hex').slice(10, 12)),
|
|
||||||
retObj.params.udhHeader.partNr = parseInt('0x' + pdu.slice(offset, offset + paramSize).toString('hex').slice(12, 14));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if we have a trailing NULL octet after the short_message. Some idiot thought that would be a good idea
|
// Check if we have a trailing NULL octet after the short_message. Some idiot thought that would be a good idea
|
||||||
// in some implementations, so we need to account for that.
|
// in some implementations, so we need to account for that.
|
||||||
if (stupidNullByte === true) {
|
if (stupidNullByte === true) {
|
||||||
|
|||||||
Reference in New Issue
Block a user