Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for user-defined TLVs #231

Open
aguerrieri opened this issue Jun 14, 2023 · 0 comments
Open

Support for user-defined TLVs #231

aguerrieri opened this issue Jun 14, 2023 · 0 comments

Comments

@aguerrieri
Copy link

aguerrieri commented Jun 14, 2023

It would be a great feature to add support for user-defined TLVS. From what I could see testing the code –and assuming I'm not doing something wrong–, only pre-defined TLVs are supported.

From what I could see, the library recognizes the TLVs and includes them in the PDUs with the HEX value converted to a number and passed as a string. But if I try to use the same approach when sending a message, the TLV is not passed downstream.

EXAMPLE 1 – Sent a message using a server instance, passing a custom TLV, 0x3C02 with the value "TEST" and in the PDU dump I've got:

'15362': <Buffer 41 4c 45 58>

Then I tried to send it using a client instance like this:

import smpp from 'smpp'

const session = smpp.connect({
    url: 'smpp://127.0.0.1:2775',
    auto_enquire_link_period: 30000,
    debug: true
}, function () {
    session.bind_transceiver({
        system_id: 'test',
        password: 'test'
    }, function (pdu) {
        if (pdu.command_status === 0) {
            session.submit_sm({
                destination_addr: '11234567890',
                short_message: 'Test TLV',
                '15362': Buffer.from('TEST')
            }, function (pdu) {
                if (pdu.command_status === 0) {
                    console.log(pdu.message_id)
                }
            })
        }
    })
})

The TLV is not in the MT PDU:

example_1

Then I edited the "tlvs" variable in defs.js and added this at the end:

//Adding my own TLV.
my_own_tlv: {
	id: 0x3c02,
	type: types.tlv.buffer
}

Then tried again using the added TLV:

import smpp from 'smpp'

const session = smpp.connect({
    url: 'smpp://127.0.0.1:2775',
    auto_enquire_link_period: 30000,
    debug: true
}, function () {
    session.bind_transceiver({
        system_id: 'test',
        password: 'test'
    }, function (pdu) {
        if (pdu.command_status === 0) {
            session.submit_sm({
                destination_addr: '11234567890',
                short_message: 'Test TLV',
                my_own_tlv: Buffer.from('TEST')
            }, function (pdu) {
                if (pdu.command_status === 0) {
                    console.log(pdu.message_id)
                }
            })
        }
    })
})

Now the TLV shows up on the packet capture:

example_2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant