Cleaning up the code and removing hacks for UDH headers. Also code now complies to all the test scenarios.
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user