Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/scat/parsers/qualcomm/diagltelogparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,10 +690,14 @@ def parse_lte_mac_subpkt_v1_ul_transport_block(self, pkt_header, subpkt_hdr, sub
subpkt_pos = 1
for j in range(n_samples):
if subpkt_hdr.version == 0x01:
if subpkt_pos + 12 > len(subpkt_body):
break
subpkt_mac_ul_tb = subpkt_mac_ul_tb_struct._make(struct.unpack('<BBHHBHBBB', subpkt_body[subpkt_pos:subpkt_pos+12]))
mac_hdr = subpkt_body[subpkt_pos+12:subpkt_pos+12+subpkt_mac_ul_tb.header_len]
subpkt_pos += (12 + subpkt_mac_ul_tb.header_len)
elif subpkt_hdr.version == 0x02 or subpkt_hdr.version == 0x03 or subpkt_hdr.version == 0x05 or subpkt_hdr.version == 0x08:
if subpkt_pos + 14 > len(subpkt_body):
break
subpkt_mac_ul_tb = subpkt_mac_ul_tb_struct_v2._make(struct.unpack('<BBBBHHBHBBB', subpkt_body[subpkt_pos:subpkt_pos+14]))
mac_hdr = subpkt_body[subpkt_pos+14:subpkt_pos+14+subpkt_mac_ul_tb.header_len]
subpkt_pos += (14 + subpkt_mac_ul_tb.header_len)
Expand Down Expand Up @@ -759,6 +763,8 @@ def parse_lte_mac_subpkt_v49(self, pkt_header, pkt_body: bytes, args: dict, is_d
if pkt_version == 0x31:
pos += (19 * 28)
for i in range(num_tb):
if pos + 16 > len(pkt_body):
break
subpkt_tb = subpkt_tb_common_info._make(struct.unpack('<LLL B B H', pkt_body[pos:pos+16]))
pos += 16

Expand All @@ -774,6 +780,8 @@ def parse_lte_mac_subpkt_v49(self, pkt_header, pkt_body: bytes, args: dict, is_d
mac_hdr_len = var3_bits[0:12].uint

for j in range(subpkt_tb.num_sdu):
if pos + 3 > len(pkt_body):
break
mac_common_info_bits = bitstring.Bits(pkt_body[pos:pos+3][::-1])
is_mce = mac_common_info_bits[0:1].uint
lcid = mac_common_info_bits[1:7].uint
Expand Down Expand Up @@ -831,6 +839,8 @@ def parse_lte_mac_subpkt_v49(self, pkt_header, pkt_body: bytes, args: dict, is_d
for k in range(num_pdcp_grp):
has_more = 1
while has_more == 1:
if pos + 4 > len(pkt_body):
break
pdcp_grp_bits = bitstring.Bits(pkt_body[pos:pos+4][::-1])
has_more = pdcp_grp_bits[0:1].uint
pos += 4
Expand Down
3 changes: 3 additions & 0 deletions src/scat/writers/pcapwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def __enter__(self):
return self

def write_pkt(self, sock_content: bytes, port: int, radio_id: int=0, ts: datetime.datetime = datetime.datetime.now()) -> None:
max_payload = 65535 - 8 - 20 # max UDP payload fitting in IPv4
if len(sock_content) > max_payload:
return
pcap_hdr = struct.pack('<LLLL',
int(ts.timestamp()) % 4294967296,
ts.microsecond,
Expand Down