Skip to content

Commit

Permalink
qualcomm: remove GSMTAP extension for device timestamp
Browse files Browse the repository at this point in the history
In a preparation work for GSMTAPv3, Wireshark will check the GSMTAP
version field strictly [1]. Reverting back to GSMTAPv2 for Qualcomm DIAG
items to avoid decoding errors on the future version of Wireshark.

[1] https://gitlab.com/wireshark/wireshark/-/merge_requests/14623
  • Loading branch information
shp committed Apr 18, 2024
1 parent d83b5cd commit c704fef
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 28 deletions.
6 changes: 3 additions & 3 deletions src/scat/parsers/qualcomm/diaggsmlogparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def parse_gsm_rr(self, pkt_header, pkt_body, args):
# SACCH DL/Measurement Information: Short PD format

gsmtap_hdr = util.create_gsmtap_header(
version = 3,
version = 2,
payload_type = util.gsmtap_type.UM,
arfcn = arfcn,
sub_type = channel_type,
Expand Down Expand Up @@ -327,7 +327,7 @@ def parse_gprs_mac(self, pkt_header, pkt_body, args):
ts_usec = pkt_ts.microsecond

gsmtap_hdr = util.create_gsmtap_header(
version = 3,
version = 2,
payload_type = payload_type,
arfcn = arfcn,
sub_type = channel_type,
Expand Down Expand Up @@ -355,7 +355,7 @@ def parse_gprs_ota(self, pkt_header, pkt_body, args):
ts_usec = pkt_ts.microsecond

gsmtap_hdr = util.create_gsmtap_header(
version = 3,
version = 2,
payload_type = util.gsmtap_type.ABIS,
arfcn = arfcn,
device_sec = ts_sec,
Expand Down
10 changes: 5 additions & 5 deletions src/scat/parsers/qualcomm/diagltelogparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def parse_lte_ml1_cell_info(self, pkt_header, pkt_body, args):
ts_usec = pkt_ts.microsecond

gsmtap_hdr = util.create_gsmtap_header(
version = 3,
version = 2,
payload_type = util.gsmtap_type.LTE_RRC,
arfcn = item.earfcn,
sub_type = util.gsmtap_lte_rrc_types.BCCH_BCH,
Expand Down Expand Up @@ -508,7 +508,7 @@ def parse_lte_mac_rach_response(self, pkt_header, pkt_body, args):
util.mac_lte_tags.MAC_LTE_PAYLOAD_TAG)

gsmtap_hdr = util.create_gsmtap_header(
version = 3,
version = 2,
payload_type = util.gsmtap_type.LTE_MAC,
arfcn = 0,
device_sec = ts_sec,
Expand Down Expand Up @@ -568,7 +568,7 @@ def create_lte_mac_gsmtap_packet(self, pkt_ts, is_downlink, header, body):
util.mac_lte_tags.MAC_LTE_PAYLOAD_TAG)

gsmtap_hdr = util.create_gsmtap_header(
version = 3,
version = 2,
payload_type = util.gsmtap_type.LTE_MAC,
arfcn = 0,
device_sec = ts_sec,
Expand Down Expand Up @@ -1302,7 +1302,7 @@ def parse_lte_rrc(self, pkt_header, pkt_body, args):
gsmtap_subtype = rrc_subtype_map[item.pdu_num]

gsmtap_hdr = util.create_gsmtap_header(
version = 3,
version = 2,
payload_type = util.gsmtap_type.LTE_RRC,
arfcn = item.earfcn,
frame_number = sfn,
Expand Down Expand Up @@ -1335,7 +1335,7 @@ def parse_lte_nas(self, pkt_header, pkt_body, args, plain = False):
ts_usec = pkt_ts.microsecond

gsmtap_hdr = util.create_gsmtap_header(
version = 3,
version = 2,
payload_type = util.gsmtap_type.LTE_NAS,
arfcn = 0,
sub_type = 0 if plain else 1,
Expand Down
2 changes: 1 addition & 1 deletion src/scat/parsers/qualcomm/diagumtslogparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def parse_umts_ue_ota(self, pkt_header, pkt_body, args):
# msg_hdr[1] == L3 message length
# Rest of content: L3 message
gsmtap_hdr = util.create_gsmtap_header(
version = 3,
version = 2,
payload_type = util.gsmtap_type.ABIS,
arfcn = 0,
device_sec = ts_sec,
Expand Down
2 changes: 1 addition & 1 deletion src/scat/parsers/qualcomm/diagwcdmalogparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def parse_wcdma_rrc(self, pkt_header, pkt_body, args):
ts_usec = pkt_ts.microsecond

gsmtap_hdr = util.create_gsmtap_header(
version = 3,
version = 2,
payload_type = util.gsmtap_type.UMTS_RRC,
arfcn = arfcn,
sub_type = subtype,
Expand Down
21 changes: 3 additions & 18 deletions src/scat/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ def parse_sdm_ts(ts_upper_32bits, ts_lower_16bits):

if ts_s == 0:
return datetime.datetime.now()

try:
date = datetime.datetime.fromtimestamp(ts_s, tz=datetime.timezone.utc)
except OverflowError:
date = datetime.datetime.now()

return date

# Definition copied from libosmocore's include/osmocom/core/gsmtap.h
Expand Down Expand Up @@ -269,7 +269,6 @@ def create_gsmtap_header(version = 2, payload_type = 0, timeslot = 0,
device_sec = 0, device_usec = 0):

gsmtap_v2_hdr_def = '!BBBBHBBLBBBB'
gsmtap_v3_hdr_def = '!BBBBHBBLBBBBQL'
gsmtap_hdr = b''

# Sanity check - Wireshark GSMTAP dissector accepts only 14 bits of ARFCN
Expand All @@ -296,21 +295,7 @@ def create_gsmtap_header(version = 2, payload_type = 0, timeslot = 0,
0 # Reserved
)
elif version == 3:
gsmtap_hdr = struct.pack(gsmtap_v3_hdr_def,
3, # Version
7, # Header Length
payload_type, # Type
timeslot, # GSM Timeslot
arfcn, # ARFCN
signal_dbm, # Signal dBm
snr_db, # SNR dB
frame_number, # Frame Number
sub_type, # Subtype
antenna_nr, # Antenna Number
sub_slot, # Subslot
0, # Reserved
device_sec,
device_usec)
assert False, "New GSMTAPv3 is WIP"
else:
assert (version == 2) or (version == 3), "GSMTAP version should be either 2 or 3"

Expand Down

0 comments on commit c704fef

Please sign in to comment.