Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def gen_tpdu(ref, to, fromm, text, empty):
# See 3GPP TS 23.040 version 11.5.0 Release 11.
# TP-PID = 40 ==> short message type 0
# TP-DCS = c3 ==> disable "other message indicator" and discard message
TPPID = 0x40 if empty else 0
TPDCS = 0xc3 if empty else 0
if empty:
text = ""
pdu = SMS_DELIVER.create(
fromm, to, text, tp_pid=TPPID, tp_dcs=TPDCS).toPDU()
return [pdu]
def gen_tpdu(ref, to, text, empty):
# TP-PID = 40 ==> short message type 0
# TP-DCS = c3 ==> disable "other message indicator" and discard message
if empty:
text = ""
TPPID = 0x40 if empty else 0
TPDCS = 0xc3 if empty else 0
pdu = SMS_SUBMIT.create(None, to, text, tp_pid=TPPID, tp_dcs=TPDCS).toPDU()
return [pdu]
def parse(rp_message):
rpdu = RPDU.fromPDU(rp_message)
sms_submit = SMS_SUBMIT.fromPDU(rpdu.user_data, rpdu.rp_originator_address)
exports = [
("vbts_text", sms_submit.user_data),
("vbts_tp_user_data", smspdu_charstring_to_hex(sms_submit.tp_ud)),
("vbts_tp_data_coding_scheme", sms_submit.tp_dcs),
("vbts_tp_protocol_id", sms_submit.tp_pid),
("vbts_tp_dest_address", sms_submit.tp_da),
("vbts_tp_dest_address_type", sms_submit.tp_toa),
("vbts_tp_message_type", sms_submit.tp_mti),
("vbts_rp_dest_address", rpdu.rp_destination_address),
("vbts_rp_originator_address", rpdu.rp_originator_address),
("vbts_rp_originator_address_type", rpdu.rp_originator_address_type),
("vbts_rp_message_reference", rpdu.rp_message_reference),
("vbts_rp_message_type", rpdu.rp_mti)
]
exports = [(x, clean(y)) for (x, y) in exports]
return exports
def handle_request(self, message, addr):
to = message.uri.username
fromm = sip.parseAddress(message.headers['from'][0])[1].username
if message.method == 'MESSAGE':
rpdu = sms_utilities.rpdu.RPDU.fromPDU(message.body)
sms_deliver = SMS_DELIVER.fromPDU(rpdu.user_data,
rpdu.rp_originator_address)
self.sms_h(to, fromm, sms_deliver.user_data)
r = self.responseFromRequest(200, message)
elif message.method == 'ACK':
r = self.responseFromRequest(200, message)
elif message.method == 'INVITE':
self.call_h(to, fromm)
# We don't know how to actually handle calls.
r = self.responseFromRequest(487, message)
else:
raise Exception("Received unhandled request")
self.deliverResponse(r)
def fetch(self):
s = self.ser.readline()
self.pdu = SMS_SUBMIT.fromPDU(s)
return self.pdu