/smpp/pdu/constants.py

https://github.com/mozes/smpp.pdu · Python · 522 lines · 487 code · 32 blank · 3 comment · 30 complexity · 09273693867d5d1a636f020a33743f3a MD5 · raw file

  1. """
  2. Copyright 2009-2010 Mozes, Inc.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. """
  13. command_status_value_map = {
  14. 0x00000000L : {
  15. 'name' : 'ESME_ROK',
  16. 'description' : 'No error',
  17. },
  18. 0x00000001L : {
  19. 'name' : 'ESME_RINVMSGLEN',
  20. 'description': 'Message Length is invalid',
  21. },
  22. 0x00000002L : {
  23. 'name' : 'ESME_RINVCMDLEN',
  24. 'description': 'Command Length is invalid',
  25. },
  26. 0x00000003L : {
  27. 'name' : 'ESME_RINVCMDID',
  28. 'description': 'Invalid Command ID',
  29. },
  30. 0x00000004L : {
  31. 'name' : 'ESME_RINVBNDSTS',
  32. 'description': 'Invalid BIND Status for given command',
  33. },
  34. 0x00000005L : {
  35. 'name' : 'ESME_RALYBND',
  36. 'description': 'ESME Already in Bound State',
  37. },
  38. 0x00000006L : {
  39. 'name' : 'ESME_RINVPRTFLG',
  40. 'description': 'Invalid Priority Flag',
  41. },
  42. 0x00000007L : {
  43. 'name' : 'ESME_RINVREGDLVFLG',
  44. 'description': 'Invalid Registered Delivery Flag',
  45. },
  46. 0x00000008L : {
  47. 'name' : 'ESME_RSYSERR',
  48. 'description': 'System Error',
  49. },
  50. 0x0000000AL : {
  51. 'name' : 'ESME_RINVSRCADR',
  52. 'description': 'Invalid Source Address',
  53. },
  54. 0x0000000BL : {
  55. 'name' : 'ESME_RINVDSTADR',
  56. 'description': 'Invalid Dest Addr',
  57. },
  58. 0x0000000CL : {
  59. 'name' : 'ESME_RINVMSGID',
  60. 'description': 'Message ID is invalid',
  61. },
  62. 0x0000000DL : {
  63. 'name' : 'ESME_RBINDFAIL',
  64. 'description': 'Bind Failed',
  65. },
  66. 0x0000000EL : {
  67. 'name' : 'ESME_RINVPASWD',
  68. 'description': 'Invalid Password',
  69. },
  70. 0x0000000FL : {
  71. 'name' : 'ESME_RINVSYSID',
  72. 'description': 'Invalid System ID',
  73. },
  74. 0x00000011L : {
  75. 'name' : 'ESME_RCANCELFAIL',
  76. 'description': 'Cancel SM Failed',
  77. },
  78. 0x00000013L : {
  79. 'name' : 'ESME_RREPLACEFAIL',
  80. 'description': 'Replace SM Failed',
  81. },
  82. 0x00000014L : {
  83. 'name' : 'ESME_RMSGQFUL',
  84. 'description': 'Message Queue Full',
  85. },
  86. 0x00000015L : {
  87. 'name' : 'ESME_RINVSERTYP',
  88. 'description': 'Invalid Service Type',
  89. },
  90. 0x00000033L : {
  91. 'name' : 'ESME_RINVNUMDESTS',
  92. 'description': 'Invalid number of destinations',
  93. },
  94. 0x00000034L : {
  95. 'name' : 'ESME_RINVDLNAME',
  96. 'description': 'Invalid Distribution List Name',
  97. },
  98. 0x00000040L : {
  99. 'name' : 'ESME_RINVDESTFLAG',
  100. 'description': 'Destination flag is invalid (submit_multi)',
  101. },
  102. 0x00000042L : {
  103. 'name' : 'ESME_RINVSUBREP',
  104. 'description': 'Invalid submit with replace request (i.e. submit_sm with replace_if_present_flag set)',
  105. },
  106. 0x00000043L : {
  107. 'name' : 'ESME_RINVESMCLASS',
  108. 'description': 'Invalid esm_class field data',
  109. },
  110. 0x00000044L : {
  111. 'name' : 'ESME_RCNTSUBDL',
  112. 'description': 'Cannot Submit to Distribution List',
  113. },
  114. 0x00000045L : {
  115. 'name' : 'ESME_RSUBMITFAIL',
  116. 'description': 'submit_sm or submit_multi failed',
  117. },
  118. 0x00000048L : {
  119. 'name' : 'ESME_RINVSRCTON',
  120. 'description': 'Invalid Source address TON',
  121. },
  122. 0x00000049L : {
  123. 'name' : 'ESME_RINVSRCNPI',
  124. 'description': 'Invalid Source address NPI',
  125. },
  126. 0x00000050L : {
  127. 'name' : 'ESME_RINVDSTTON',
  128. 'description': 'Invalid Destination address TON',
  129. },
  130. 0x00000051L : {
  131. 'name' : 'ESME_RINVDSTNPI',
  132. 'description': 'Invalid Destination address NPI',
  133. },
  134. 0x00000053L : {
  135. 'name' : 'ESME_RINVSYSTYP',
  136. 'description': 'Invalid system_type field',
  137. },
  138. 0x00000054L : {
  139. 'name' : 'ESME_RINVREPFLAG',
  140. 'description': 'Invalid replace_if_present flag',
  141. },
  142. 0x00000055L : {
  143. 'name' : 'ESME_RINVNUMMSGS',
  144. 'description': 'Invalid number of messages',
  145. },
  146. 0x00000058L : {
  147. 'name' : 'ESME_RTHROTTLED',
  148. 'description': 'Throttling error (ESME has exceeded allowed message limits',
  149. },
  150. 0x00000061L : {
  151. 'name' : 'ESME_RINVSCHED',
  152. 'description': 'Invalid Scheduled Delivery Time',
  153. },
  154. 0x00000062L : {
  155. 'name' : 'ESME_RINVEXPIRY',
  156. 'description': 'Invalid message validity period (Expiry time)',
  157. },
  158. 0x00000063L : {
  159. 'name' : 'ESME_RINVDFTMSGID',
  160. 'description': 'Predefined Message Invalid or Not Found',
  161. },
  162. 0x00000064L : {
  163. 'name' : 'ESME_RX_T_APPN',
  164. 'description': 'ESME Receiver Temporary App Error Code',
  165. },
  166. 0x00000065L : {
  167. 'name' : 'ESME_RX_P_APPN',
  168. 'description': 'ESME Receiver Permanent App Error Code',
  169. },
  170. 0x00000066L : {
  171. 'name' : 'ESME_RX_R_APPN',
  172. 'description': 'ESME Receiver Reject Message Error Code',
  173. },
  174. 0x00000067L : {
  175. 'name' : 'ESME_RQUERYFAIL',
  176. 'description': 'query_sm request failed',
  177. },
  178. 0x000000C0L : {
  179. 'name' : 'ESME_RINVOPTPARSTREAM',
  180. 'description': 'Error in the optional part of the PDU Body',
  181. },
  182. 0x000000C1L : {
  183. 'name' : 'ESME_ROPTPARNOTALLWD',
  184. 'description': 'Optional Parameter not allowed',
  185. },
  186. 0x000000C2L : {
  187. 'name' : 'ESME_RINVPARLEN',
  188. 'description': 'Invalid Parameter Length',
  189. },
  190. 0x000000C3L : {
  191. 'name' : 'ESME_RMISSINGOPTPARAM',
  192. 'description': 'Expected Optional Parameter missing',
  193. },
  194. 0x000000C4L : {
  195. 'name' : 'ESME_RINVOPTPARAMVAL',
  196. 'description': 'Invalid Optional Parameter Value',
  197. },
  198. 0x000000FEL : {
  199. 'name' : 'ESME_RDELIVERYFAILURE',
  200. 'description': 'Delivery Failure (used for data_sm_resp)',
  201. },
  202. 0x000000FFL : {
  203. 'name' : 'ESME_RUNKNOWNERR',
  204. 'description': 'Unknown Error',
  205. },
  206. }
  207. command_status_name_map = dict([(val['name'], key) for (key, val) in command_status_value_map.items()])
  208. command_id_name_map = {
  209. 'generic_nack': 0x80000000,
  210. 'bind_receiver': 0x00000001,
  211. 'bind_receiver_resp': 0x80000001,
  212. 'bind_transmitter': 0x00000002,
  213. 'bind_transmitter_resp': 0x80000002,
  214. 'query_sm': 0x00000003,
  215. 'query_sm_resp': 0x80000003,
  216. 'submit_sm': 0x00000004,
  217. 'submit_sm_resp': 0x80000004,
  218. 'deliver_sm': 0x00000005,
  219. 'deliver_sm_resp': 0x80000005,
  220. 'unbind': 0x00000006,
  221. 'unbind_resp': 0x80000006,
  222. 'replace_sm': 0x00000007,
  223. 'replace_sm_resp': 0x80000007,
  224. 'cancel_sm': 0x00000008,
  225. 'cancel_sm_resp': 0x80000008,
  226. 'bind_transceiver': 0x00000009,
  227. 'bind_transceiver_resp': 0x80000009,
  228. 'outbind': 0x0000000B,
  229. 'enquire_link': 0x00000015,
  230. 'enquire_link_resp': 0x80000015,
  231. 'submit_multi': 0x00000021,
  232. 'submit_multi_resp': 0x80000021,
  233. 'alert_notification': 0x00000102,
  234. 'data_sm': 0x00000103,
  235. 'data_sm_resp': 0x80000103,
  236. }
  237. command_id_value_map = dict([(val, key) for (key, val) in command_id_name_map.items()])
  238. tag_name_map = {
  239. 'dest_addr_subunit': 0x0005,
  240. 'dest_network_type': 0x0006,
  241. 'dest_bearer_type': 0x0007,
  242. 'dest_telematics_id': 0x0008,
  243. 'source_addr_subunit': 0x000D,
  244. 'source_network_type': 0x000E,
  245. 'source_bearer_type': 0x000F,
  246. 'source_telematics_id': 0x0010,
  247. 'qos_time_to_live': 0x0017,
  248. 'payload_type': 0x0019,
  249. 'additional_status_info_text': 0x001D,
  250. 'receipted_message_id': 0x001E,
  251. 'ms_msg_wait_facilities': 0x0030,
  252. 'privacy_indicator': 0x0201,
  253. 'source_subaddress': 0x0202,
  254. 'dest_subaddress': 0x0203,
  255. 'user_message_reference': 0x0204,
  256. 'user_response_code': 0x0205,
  257. 'source_port': 0x020A,
  258. 'destination_port': 0x020B,
  259. 'sar_msg_ref_num': 0x020C,
  260. 'language_indicator': 0x020D,
  261. 'sar_total_segments': 0x020E,
  262. 'sar_segment_seqnum': 0x020F,
  263. 'sc_interface_version': 0x0210,
  264. 'callback_num_pres_ind': 0x0302,
  265. 'callback_num_atag': 0x0303,
  266. 'number_of_messages': 0x0304,
  267. 'callback_num': 0x0381,
  268. 'dpf_result': 0x0420,
  269. 'set_dpf': 0x0421,
  270. 'ms_availability_status': 0x0422,
  271. 'network_error_code': 0x0423,
  272. 'message_payload': 0x0424,
  273. 'delivery_failure_reason': 0x0425,
  274. 'more_messages_to_send': 0x0426,
  275. 'message_state': 0x0427,
  276. 'ussd_service_op': 0x0501,
  277. 'display_time': 0x1201,
  278. 'sms_signal': 0x1203,
  279. 'ms_validity': 0x1204,
  280. 'alert_on_message_delivery': 0x130C,
  281. 'its_reply_type': 0x1380,
  282. 'its_session_info': 0x1383,
  283. }
  284. tag_value_map = dict([(val, key) for (key, val) in tag_name_map.items()])
  285. esm_class_mode_name_map = {
  286. 'DEFAULT': 0x0,
  287. 'DATAGRAM': 0x1,
  288. 'FORWARD': 0x2,
  289. 'STORE_AND_FORWARD': 0x3,
  290. }
  291. esm_class_mode_value_map = dict([(val, key) for (key, val) in esm_class_mode_name_map.items()])
  292. esm_class_type_name_map = {
  293. 'DEFAULT': 0x00,
  294. 'SMSC_DELIVERY_RECEIPT': 0x04,
  295. 'DELIVERY_ACKNOWLEDGEMENT': 0x08,
  296. 'MANUAL_ACKNOWLEDGMENT': 0x10,
  297. 'CONVERSATION_ABORT': 0x18,
  298. 'INTERMEDIATE_DELIVERY_NOTIFICATION': 0x20,
  299. }
  300. esm_class_type_value_map = dict([(val, key) for (key, val) in esm_class_type_name_map.items()])
  301. esm_class_gsm_features_name_map = {
  302. 'UDHI_INDICATOR_SET': 0x40,
  303. 'SET_REPLY_PATH': 0x80,
  304. }
  305. esm_class_gsm_features_value_map = dict([(val, key) for (key, val) in esm_class_gsm_features_name_map.items()])
  306. registered_delivery_receipt_name_map = {
  307. 'NO_SMSC_DELIVERY_RECEIPT_REQUESTED': 0x00,
  308. 'SMSC_DELIVERY_RECEIPT_REQUESTED': 0x01,
  309. 'SMSC_DELIVERY_RECEIPT_REQUESTED_FOR_FAILURE': 0x02,
  310. }
  311. registered_delivery_receipt_value_map = dict([(val, key) for (key, val) in registered_delivery_receipt_name_map.items()])
  312. registered_delivery_sme_originated_acks_name_map = {
  313. 'SME_DELIVERY_ACK_REQUESTED': 0x04,
  314. 'SME_MANUAL_ACK_REQUESTED': 0x08,
  315. }
  316. registered_delivery_sme_originated_acks_value_map = dict([(val, key) for (key, val) in registered_delivery_sme_originated_acks_name_map.items()])
  317. addr_subunit_name_map = {
  318. 'UNKNOWN': 0x00,
  319. 'MS_DISPLAY': 0x01,
  320. 'MOBILE_EQUIPMENT': 0x2,
  321. 'SMART_CARD_1': 0x3,
  322. 'EXTERNAL_UNIT_1': 0x4,
  323. }
  324. addr_subunit_value_map = dict([(val, key) for (key, val) in addr_subunit_name_map.items()])
  325. addr_ton_name_map = {
  326. 'UNKNOWN': 0x00,
  327. 'INTERNATIONAL': 0x01,
  328. 'NATIONAL': 0x02,
  329. 'NETWORK_SPECIFIC': 0x03,
  330. 'SUBSCRIBER_NUMBER': 0x04,
  331. 'ALPHANUMERIC': 0x05,
  332. 'ABBREVIATED': 0x06,
  333. }
  334. addr_ton_value_map = dict([(val, key) for (key, val) in addr_ton_name_map.items()])
  335. addr_npi_name_map = {
  336. 'UNKNOWN': 0x00,
  337. 'ISDN': 0x01,
  338. 'DATA': 0x03,
  339. 'TELEX': 0x04,
  340. 'LAND_MOBILE': 0x06,
  341. 'NATIONAL': 0x08,
  342. 'PRIVATE': 0x09,
  343. 'ERMES': 0x0a,
  344. 'INTERNET': 0x0e,
  345. 'WAP_CLIENT_ID': 0x12,
  346. }
  347. addr_npi_value_map = dict([(val, key) for (key, val) in addr_npi_name_map.items()])
  348. priority_flag_name_map = {
  349. 'LEVEL_0': 0x00,
  350. 'LEVEL_1': 0x01,
  351. 'LEVEL_2': 0x02,
  352. 'LEVEL_3': 0x03,
  353. }
  354. priority_flag_value_map = dict([(val, key) for (key, val) in priority_flag_name_map.items()])
  355. replace_if_present_flap_name_map = {
  356. 'DO_NOT_REPLACE': 0x00,
  357. 'REPLACE': 0x01,
  358. }
  359. replace_if_present_flap_value_map = dict([(val, key) for (key, val) in replace_if_present_flap_name_map.items()])
  360. more_messages_to_send_name_map = {
  361. 'NO_MORE_MESSAGES': 0x00,
  362. 'MORE_MESSAGES': 0x01,
  363. }
  364. more_messages_to_send_value_map = dict([(val, key) for (key, val) in more_messages_to_send_name_map.items()])
  365. data_coding_scheme_name_map = {
  366. 'GSM_MESSAGE_CLASS': 0xf0,
  367. }
  368. data_coding_scheme_value_map = dict([(val, key) for (key, val) in data_coding_scheme_name_map.items()])
  369. data_coding_default_name_map = {
  370. 'SMSC_DEFAULT_ALPHABET': 0x00,
  371. 'IA5_ASCII': 0x01,
  372. 'OCTET_UNSPECIFIED': 0x02,
  373. 'LATIN_1': 0x03,
  374. 'OCTET_UNSPECIFIED_COMMON': 0x04,
  375. 'JIS': 0x05,
  376. 'CYRILLIC': 0x06,
  377. 'ISO_8859_8': 0x07,
  378. 'UCS2': 0x08,
  379. 'PICTOGRAM': 0x09,
  380. 'ISO_2022_JP': 0x0a,
  381. 'EXTENDED_KANJI_JIS': 0x0d,
  382. 'KS_C_5601': 0x0e,
  383. }
  384. data_coding_default_value_map = dict([(val, key) for (key, val) in data_coding_default_name_map.items()])
  385. data_coding_gsm_message_coding_name_map = {
  386. 'DEFAULT_ALPHABET': 0x00,
  387. 'DATA_8BIT': 0x04,
  388. }
  389. data_coding_gsm_message_coding_value_map = dict([(val, key) for (key, val) in data_coding_gsm_message_coding_name_map.items()])
  390. data_coding_gsm_message_class_name_map = {
  391. 'NO_MESSAGE_CLASS': 0x00,
  392. 'CLASS_1': 0x01,
  393. 'CLASS_2': 0x02,
  394. 'CLASS_3': 0x03,
  395. }
  396. data_coding_gsm_message_class_value_map = dict([(val, key) for (key, val) in data_coding_gsm_message_class_name_map.items()])
  397. dest_flag_name_map = {
  398. 'SME_ADDRESS': 0x01,
  399. 'DISTRIBUTION_LIST_NAME': 0x02,
  400. }
  401. dest_flag_value_map = dict([(val, key) for (key, val) in dest_flag_name_map.items()])
  402. message_state_name_map = {
  403. 'ENROUTE': 0x01,
  404. 'DELIVERED': 0x02,
  405. 'EXPIRED': 0x03,
  406. 'DELETED': 0x04,
  407. 'UNDELIVERABLE': 0x05,
  408. 'ACCEPTED': 0x06,
  409. 'UNKNOWN': 0x07,
  410. 'REJECTED': 0x08,
  411. }
  412. message_state_value_map = dict([(val, key) for (key, val) in message_state_name_map.items()])
  413. callback_num_digit_mode_indicator_name_map = {
  414. 'TBCD': 0x00,
  415. 'ASCII': 0x01,
  416. }
  417. callback_num_digit_mode_indicator_value_map = dict([(val, key) for (key, val) in callback_num_digit_mode_indicator_name_map.items()])
  418. subaddress_type_tag_name_map = {
  419. 'NSAP_EVEN': 0x80,
  420. 'NSAP_ODD': 0x88,
  421. 'USER_SPECIFIED': 0xa0,
  422. }
  423. subaddress_type_tag_value_map = dict([(val, key) for (key, val) in subaddress_type_tag_name_map.items()])
  424. ms_availability_status_name_map = {
  425. 'AVAILABLE': 0x00,
  426. 'DENIED': 0x01,
  427. 'UNAVAILABLE': 0x02,
  428. }
  429. ms_availability_status_value_map = dict([(val, key) for (key, val) in ms_availability_status_name_map.items()])
  430. network_type_name_map = {
  431. 'UNKNOWN': 0x00,
  432. 'GSM': 0x01,
  433. 'TDMA': 0x02,
  434. 'CDMA': 0x03,
  435. 'PDC': 0x04,
  436. 'PHS': 0x05,
  437. 'IDEN': 0x06,
  438. 'AMPS': 0x07,
  439. 'PAGING_NETWORK': 0x08,
  440. }
  441. network_type_value_map = dict([(val, key) for (key, val) in network_type_name_map.items()])
  442. bearer_type_name_map = {
  443. 'UNKNOWN': 0x00,
  444. 'SMS': 0x01,
  445. 'CSD': 0x02,
  446. 'PACKET_DATA': 0x03,
  447. 'USSD': 0x04,
  448. 'CDPD': 0x05,
  449. 'DATATAC': 0x06,
  450. 'FLEX_REFLEX': 0x07,
  451. 'CELL_BROADCAST': 0x08,
  452. }
  453. bearer_type_value_map = dict([(val, key) for (key, val) in bearer_type_name_map.items()])
  454. payload_type_name_map = {
  455. 'DEFAULT': 0x00,
  456. 'WCMP': 0x01,
  457. }
  458. payload_type_value_map = dict([(val, key) for (key, val) in payload_type_name_map.items()])
  459. privacy_indicator_name_map = {
  460. 'NOT_RESTRICTED': 0x00,
  461. 'RESTRICTED': 0x01,
  462. 'CONFIDENTIAL': 0x02,
  463. 'SECRET': 0x03,
  464. }
  465. privacy_indicator_value_map = dict([(val, key) for (key, val) in privacy_indicator_name_map.items()])
  466. language_indicator_name_map = {
  467. 'UNSPECIFIED': 0x00,
  468. 'ENGLISH': 0x01,
  469. 'FRENCH': 0x02,
  470. 'SPANISH': 0x03,
  471. 'GERMAN': 0x04,
  472. 'PORTUGUESE': 0x05,
  473. }
  474. language_indicator_value_map = dict([(val, key) for (key, val) in language_indicator_name_map.items()])
  475. display_time_name_map = {
  476. 'TEMPORARY': 0x00,
  477. 'DEFAULT': 0x01,
  478. 'INVOKE': 0x02,
  479. }
  480. display_time_value_map = dict([(val, key) for (key, val) in display_time_name_map.items()])
  481. delivery_failure_reason_name_map = {
  482. 'DESTINATION_UNAVAILABLE': 0x00,
  483. 'DESTINATION_ADDRESS_INVALID': 0x01,
  484. 'PERMANENT_NETWORK_ERROR': 0x02,
  485. 'TEMPORARY_NETWORK_ERROR': 0x03,
  486. }
  487. delivery_failure_reason_value_map = dict([(val, key) for (key, val) in delivery_failure_reason_name_map.items()])