Cleaning up the code and removing hacks for UDH headers. Also code now complies to all the test scenarios.

This commit is contained in:
Qasim Ayyaz Khan
2016-06-03 04:46:59 -04:00
parent fc629ddfdb
commit bc6b9f2146
2 changed files with 13 additions and 22 deletions
-17
View File
@@ -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'));
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
// in some implementations, so we need to account for that.
if (stupidNullByte === true) {