Change in osmo-hlr[master]: esme_dgsm.py: add --always-fail option for debugging SMPP

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

neels gerrit-no-reply at lists.osmocom.org
Fri Jan 10 15:28:26 UTC 2020


neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-hlr/+/16793 )


Change subject: esme_dgsm.py: add --always-fail option for debugging SMPP
......................................................................

esme_dgsm.py: add --always-fail option for debugging SMPP

Change-Id: Ibacf2676cae40712c89b57ced34085311d9a416d
---
M contrib/dgsm/esme_dgsm.py
1 file changed, 26 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/93/16793/1

diff --git a/contrib/dgsm/esme_dgsm.py b/contrib/dgsm/esme_dgsm.py
index 75cf93d..9d7e040 100755
--- a/contrib/dgsm/esme_dgsm.py
+++ b/contrib/dgsm/esme_dgsm.py
@@ -100,6 +100,9 @@
         time.sleep(args.sleep)
         logging.info("Sleep done")
 
+    if args.always_fail is not None:
+        return args.always_fail
+
     result = query_mslookup("smpp.sms", msisdn)
     if 'v4' not in result or not result['v4']:
         logging.info('No IPv4 result from mslookup! This example only'
@@ -147,12 +150,35 @@
     parser.add_argument('--sleep', default=0, type=float,
                         help='sleep time in seconds before forwarding an SMS,'
                              ' to test multithreading (default: 0)')
+    parser.add_argument('--always-fail', default=None, metavar='SMPP_ESME_ERRCODE',
+                        help='test delivery failure: always return an error code on Deliver-SM,'
+                        ' pass an smpplib error code name like RDELIVERYFAILURE (see smpplib/consts.py),'
+                        ' or an SMPP error code in hex digits')
     args = parser.parse_args()
 
     logging.basicConfig(level=logging.INFO, format='[%(asctime)s]'
                         ' (%(threadName)s) %(message)s', datefmt="%H:%M:%S")
+
+    if args.always_fail:
+        resolved = None
+        name = 'SMPP_ESME_' + args.always_fail
+        if hasattr(smpplib.consts, name):
+            resolved = getattr(smpplib.consts, name)
+        if resolved is None:
+            try:
+                resolved = int(args.always_fail, 16)
+            except ValueError:
+                resolved = None
+        if resolved is None:
+            print('Invalid argument for --always-fail: %r' % args.always_fail)
+            exit(1)
+        args.always_fail = resolved
+        logging.info('--always-fail: returning error code %s to all Deliver-SM' % hex(args.always_fail))
+
     smpp_bind()
 
 
 if __name__ == "__main__":
     main()
+
+# vim: expandtab tabstop=4 shiftwidth=4

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/16793
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: Ibacf2676cae40712c89b57ced34085311d9a416d
Gerrit-Change-Number: 16793
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200110/bb89fca9/attachment.htm>


More information about the gerrit-log mailing list