Fix bug trying to use encode method on byte object

Traceback (most recent call last):
  File "/tmp/s1ap_reiniger.py", line 242, in <module>
    handle_pcap(sys.argv[1], sys.argv[2])
  File "/tmp/s1ap_reiniger.py", line 213, in handle_pcap
    pkt = handle_sctp_pkt(pkt)
  File "/tmp/s1ap_reiniger.py", line 192, in handle_sctp_pkt
    success = handle_sctp_chunk(chunk)
  File "/tmp/s1ap_reiniger.py", line 166, in handle_sctp_chunk
    handle_s1ap(s1ap())
  File "/tmp/s1ap_reiniger.py", line 152, in handle_s1ap
    find_and_handle_s1ap_nas_pdu(msg[1]['value'], dl = False)
  File "/tmp/s1ap_reiniger.py", line 103, in find_and_handle_s1ap_nas_pdu
    pdu = handle_nas_pdu(ie['value'][1], dl)
  File "/tmp/s1ap_reiniger.py", line 30, in handle_nas_pdu
    log.debug("Processing %s NAS PDU: %s" % ("Downlink" if dl else "Uplink", pdu.encode('hex')))
AttributeError: 'bytes' object has no attribute 'encode'
This commit is contained in:
Harald Welte 2019-09-27 09:34:07 +02:00
parent 521d22c553
commit 4626b5c2f0
1 changed files with 2 additions and 2 deletions

View File

@ -27,7 +27,7 @@ from pycrate_asn1dir import S1AP
from pycrate_mobile import NAS
def handle_nas_pdu(pdu, dl, regen = False):
log.debug("Processing %s NAS PDU: %s" % ("Downlink" if dl else "Uplink", pdu.encode('hex')))
log.debug("Processing %s NAS PDU: %s" % ("Downlink" if dl else "Uplink", pdu.hex()))
(msg, code) = NAS.parse_NASLTE_MT(pdu) if dl else NAS.parse_NASLTE_MO(pdu)
if code:
log.error("Failed to parse NAS payload")
@ -54,7 +54,7 @@ def handle_s1ap_imsi(imsi):
return '\x29\x26\x24' + '\x00' * 5
def handle_s1ap_tmsi(tmsi):
log.info("Cleaning TMSI: %s" % tmsi.encode('hex'))
log.info("Cleaning TMSI: %s" % tmsi.hex())
return tmsi # NOTE: for now, keep TMSI unchanged
def handle_s1ap_imeisv(imeisv):