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

Use correct TON and NPI from Jasmin Interceptor #4

Open
cypherlou opened this issue Apr 26, 2024 · 1 comment
Open

Use correct TON and NPI from Jasmin Interceptor #4

cypherlou opened this issue Apr 26, 2024 · 1 comment

Comments

@cypherlou
Copy link

Background

I've been compelled to add an mtinterceptor to Jasmin to support a sensitive SMPP gateway. The requirement is broadly to define a TON and NPI as follows;

  1. short code with a ton=2 and npi=1
  2. long code awith a ton=1 and npi=1
  3. text overwrite (alphanumeric source address) with a ton=5 and npi=0

In the last example I have;

    routable.pdu.params['source_addr_ton'] = AddrTon.ALPHANUMERIC
    routable.pdu.params['source_addr_npi'] = AddrNpi.UNKNOWN

The problem

As things stand the TON values defined in smpp/pdu/constants.py (using the NPI as the example), as seen from the Jasmin Interceptor - list(AddrNPI) are;

[
 <AddrNpi.UNKNOWN: 1>
 <AddrNpi.ISDN: 2>,
 <AddrNpi.DATA: 3>,
 <AddrNpi.TELEX: 4>,
 <AddrNpi.LAND_MOBILE: 5>,
 <AddrNpi.NATIONAL: 6>,
 <AddrNpi.PRIVATE: 7>,
 <AddrNpi.ERMES: 8>,
 <AddrNpi.INTERNET: 9>,
 <AddrNpi.WAP_CLIENT_ID: 10>
]

This obviously doesn't match the corresponding values defined in smpp/pdu/constants.py;

addr_npi_name_map = {
    'UNKNOWN': 0x00,
    'ISDN': 0x01,
    'DATA': 0x03,
    'TELEX': 0x04,
    'LAND_MOBILE': 0x06,
    'NATIONAL': 0x08,
    'PRIVATE': 0x09,
    'ERMES': 0x0a,
    'INTERNET': 0x0e,
    'WAP_CLIENT_ID': 0x12,
}

The values (as seen form the Jasmin Interceptor) as defined as the order of the entry in the dict and not the actual value.

@cypherlou
Copy link
Author

I'm getting a rejection pushing my branch;

git push --set-upstream origin 4-use-correct-TON-and-NPI 
remote: Permission to jookies/smpp.pdu.git denied to whorlou.
fatal: unable to access 'https://github.com/jookies/smpp.pdu.git/': The requested URL returned error: 403

My change is pretty simple;

git diff master 4-use-correct-TON-and-NPI 
diff --git a/smpp/pdu/pdu_types.py b/smpp/pdu/pdu_types.py
index d2469c2..72a4b8b 100644
--- a/smpp/pdu/pdu_types.py
+++ b/smpp/pdu/pdu_types.py
@@ -55,8 +55,8 @@ class RegisteredDelivery(RegisteredDeliveryBase):
     def __repr__(self):
         return 'RegisteredDelivery[receipt: %s, smeOriginatedAcks: %s, intermediateNotification: %s]' % (self.receipt, self.smeOriginatedAcks, self.intermediateNotification)
 
-AddrTon = Enum('AddrTon', list(constants.addr_ton_name_map.keys()))
-AddrNpi = Enum('AddrNpi', list(constants.addr_npi_name_map.keys()))
+AddrTon = Enum('AddrTon', {key: value for key, value in constants.addr_ton_name_map.items()})
+AddrNpi = Enum('AddrNpi', {key: value for key, value in constants.addr_npi_name_map.items()})
 PriorityFlag = Enum('PriorityFlag', list(constants.priority_flag_name_map.keys()))
 ReplaceIfPresentFlag = Enum('ReplaceIfPresentFlag', list(constants.replace_if_present_flap_name_map.keys()))

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