laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/35282?usp=email )
Change subject: bertlv_parse_len: Fix input data is smaller than num length octets
......................................................................
bertlv_parse_len: Fix input data is smaller than num length octets
This can happen if there's a file with invalid encoding on the card,
such as a tag followed by all-ff. Let's gracefully ignore it and
return zero bytes as response.
Change-Id: Ic44557368a6034dbf4bb021ab23a57927c22def0
---
M pySim/utils.py
1 file changed, 15 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/82/35282/1
diff --git a/pySim/utils.py b/pySim/utils.py
index 44800fb..23b26f9 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -314,6 +314,8 @@
else:
num_len_oct = binary[0] & 0x7f
length = 0
+ if len(binary) < num_len_oct + 1:
+ return (0, b'')
for i in range(1, 1+num_len_oct):
length <<= 8
length |= binary[i]
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35282?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ic44557368a6034dbf4bb021ab23a57927c22def0
Gerrit-Change-Number: 35282
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange
Attention is currently required from: pespin.
Hello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/libosmo-netif/+/35280?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Verified-1 by Jenkins Builder
Change subject: netif: sctp.h: Introduce value_string for enum sctp_spinfo_state
......................................................................
netif: sctp.h: Introduce value_string for enum sctp_spinfo_state
This can be used by apps retrieving struct sctp_paddrinfo through
getsockopt(SCTP_GET_PEER_ADDR_INFO).
The relevant field is spinfo_state: osmo_sctp_spinfo_state_str(pinfo.spinfo_state);
Related: SYS#6636
Change-Id: I78a0bd8279a04f4011c7273e0f542981308e482f
---
M include/osmocom/netif/sctp.h
M src/sctp.c
2 files changed, 29 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/80/35280/2
--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/35280?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I78a0bd8279a04f4011c7273e0f542981308e482f
Gerrit-Change-Number: 35280
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newpatchset
Attention is currently required from: pespin.
Hello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/libosmo-sccp/+/35253?usp=email
to look at the new patch set (#3).
The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder
Change subject: vty: show cs7 instance asp: Swap columns SCTP Role and Remote Address list
......................................................................
vty: show cs7 instance asp: Swap columns SCTP Role and Remote Address list
The Remote Address is by far the potentially largest column, as well as
the one with more variable length, so move it to the end for better formatting.
Change-Id: I4854219f8898266ae47b9117ef79dbad30a5b0fd
---
M TODO-RELEASE
M src/osmo_ss7_vty.c
M tests/vty/ss7_asp_test.vty
3 files changed, 49 insertions(+), 37 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/53/35253/3
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/35253?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: I4854219f8898266ae47b9117ef79dbad30a5b0fd
Gerrit-Change-Number: 35253
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newpatchset
Hello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/libosmo-sccp/+/35275?usp=email
to look at the new patch set (#3).
The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder
Change subject: vty: Introduce cmd 'show cs7 instance asp name ASP_NAME'
......................................................................
vty: Introduce cmd 'show cs7 instance asp name ASP_NAME'
Allow printing only a specific asp by name. Useful when user is only
interested in a uniqe ASP and there's lots of them configured.
Related: SYS#6636
Change-Id: I08426272069ce5f3c8403b08dcaf686547bee336
---
M src/osmo_ss7_vty.c
M tests/vty/ss7_asp_test.vty
2 files changed, 84 insertions(+), 30 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/75/35275/3
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/35275?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: I08426272069ce5f3c8403b08dcaf686547bee336
Gerrit-Change-Number: 35275
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-MessageType: newpatchset
Attention is currently required from: laforge.
Hello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/pysim/+/35279?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Verified-1 by Jenkins Builder
Change subject: move {enc,dec}_addr_tlv functions from pySim.util to pySim.legacy.util
......................................................................
move {enc,dec}_addr_tlv functions from pySim.util to pySim.legacy.util
In the previous commit we've stopped using those functions from modern
pySim-shell code. Hence, the only remaining user is the legacy tools,
so we can move the code to the legacy module.
Change-Id: I6f18ccb36fc33bc204c01f9ece135676510e67ec
---
M pySim/legacy/cards.py
M pySim/legacy/utils.py
M pySim/utils.py
3 files changed, 135 insertions(+), 123 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/79/35279/2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35279?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I6f18ccb36fc33bc204c01f9ece135676510e67ec
Gerrit-Change-Number: 35279
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newpatchset
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/35279?usp=email )
Change subject: move {enc,dec}_addr_tlv functions from pySim.util to pySim.legacy.util
......................................................................
move {enc,dec}_addr_tlv functions from pySim.util to pySim.legacy.util
In the previous commit we've stopped using those functions from modern
pySim-shell code. Hence, the only remaining user is the legacy tools,
so we can move the code to the legacy module.
Change-Id: I6f18ccb36fc33bc204c01f9ece135676510e67ec
---
M pySim/legacy/cards.py
M pySim/legacy/utils.py
M pySim/utils.py
3 files changed, 93 insertions(+), 81 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/79/35279/1
diff --git a/pySim/legacy/cards.py b/pySim/legacy/cards.py
index 496ce78..9d1e2c1 100644
--- a/pySim/legacy/cards.py
+++ b/pySim/legacy/cards.py
@@ -8,11 +8,10 @@
from pySim.cards import SimCardBase, UiccCardBase
from pySim.utils import dec_iccid, enc_iccid, dec_imsi, enc_imsi, dec_msisdn, enc_msisdn
-from pySim.utils import dec_addr_tlv, enc_addr_tlv
from pySim.utils import enc_plmn, get_addr_type
from pySim.utils import is_hex, h2b, b2h, h2s, s2h, lpad, rpad
from pySim.legacy.utils import enc_ePDGSelection, format_xplmn_w_act, format_xplmn, dec_st, enc_st
-from pySim.legacy.utils import format_ePDGSelection
+from pySim.legacy.utils import format_ePDGSelection, dec_addr_tlv, enc_addr_tlv
from pySim.legacy.ts_51_011 import EF, DF
from pySim.legacy.ts_31_102 import EF_USIM_ADF_map
from pySim.legacy.ts_31_103 import EF_ISIM_ADF_map
diff --git a/pySim/legacy/utils.py b/pySim/legacy/utils.py
index 1b6b5d1..d79253b 100644
--- a/pySim/legacy/utils.py
+++ b/pySim/legacy/utils.py
@@ -210,3 +210,82 @@
res['epdg_priority'] = epdg_priority_str
res['epdg_fqdn_format'] = epdg_fqdn_format_str == '00' and 'Operator Identifier FQDN' or 'Location based FQDN'
return res
+
+
+def dec_addr_tlv(hexstr):
+ """
+ Decode hex string to get EF.P-CSCF Address or EF.ePDGId or EF.ePDGIdEm.
+ See 3GPP TS 31.102 version 13.4.0 Release 13, section 4.2.8, 4.2.102 and 4.2.104.
+ """
+
+ # Convert from hex str to int bytes list
+ addr_tlv_bytes = h2i(hexstr)
+
+ # Get list of tuples containing parsed TLVs
+ tlvs = TLV_parser(addr_tlv_bytes)
+
+ for tlv in tlvs:
+ # tlv = (T, L, [V])
+ # T = Tag
+ # L = Length
+ # [V] = List of value
+
+ # Invalid Tag value scenario
+ if tlv[0] != 0x80:
+ continue
+
+ # Empty field - Zero length
+ if tlv[1] == 0:
+ continue
+
+ # Uninitialized field
+ if all([v == 0xff for v in tlv[2]]):
+ continue
+
+ # First byte in the value has the address type
+ addr_type = tlv[2][0]
+ # TODO: Support parsing of IPv6
+ # Address Type: 0x00 (FQDN), 0x01 (IPv4), 0x02 (IPv6), other (Reserved)
+ if addr_type == 0x00: # FQDN
+ # Skip address tye byte i.e. first byte in value list
+ content = tlv[2][1:]
+ return (i2s(content), '00')
+
+ elif addr_type == 0x01: # IPv4
+ # Skip address tye byte i.e. first byte in value list
+ # Skip the unused byte in Octect 4 after address type byte as per 3GPP TS 31.102
+ ipv4 = tlv[2][2:]
+ content = '.'.join(str(x) for x in ipv4)
+ return (content, '01')
+ else:
+ raise ValueError("Invalid address type")
+
+ return (None, None)
+
+
+def enc_addr_tlv(addr, addr_type='00'):
+ """
+ Encode address TLV object used in EF.P-CSCF Address, EF.ePDGId and EF.ePDGIdEm.
+ See 3GPP TS 31.102 version 13.4.0 Release 13, section 4.2.8, 4.2.102 and 4.2.104.
+
+ Default values:
+ - addr_type: 00 - FQDN format of Address
+ """
+
+ s = ""
+
+ # TODO: Encoding of IPv6 address
+ if addr_type == '00': # FQDN
+ hex_str = s2h(addr)
+ s += '80' + ('%02x' % ((len(hex_str)//2)+1)) + '00' + hex_str
+ elif addr_type == '01': # IPv4
+ ipv4_list = addr.split('.')
+ ipv4_str = ""
+ for i in ipv4_list:
+ ipv4_str += ('%02x' % (int(i)))
+
+ # Unused bytes shall be set to 'ff'. i.e 4th Octet after Address Type is not used
+ # IPv4 Address is in octet 5 to octet 8 of the TLV data object
+ s += '80' + ('%02x' % ((len(ipv4_str)//2)+2)) + '01' + 'ff' + ipv4_str
+
+ return s
diff --git a/pySim/utils.py b/pySim/utils.py
index 44800fb..3b9731d 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -751,85 +751,6 @@
return ret
-def dec_addr_tlv(hexstr):
- """
- Decode hex string to get EF.P-CSCF Address or EF.ePDGId or EF.ePDGIdEm.
- See 3GPP TS 31.102 version 13.4.0 Release 13, section 4.2.8, 4.2.102 and 4.2.104.
- """
-
- # Convert from hex str to int bytes list
- addr_tlv_bytes = h2i(hexstr)
-
- # Get list of tuples containing parsed TLVs
- tlvs = TLV_parser(addr_tlv_bytes)
-
- for tlv in tlvs:
- # tlv = (T, L, [V])
- # T = Tag
- # L = Length
- # [V] = List of value
-
- # Invalid Tag value scenario
- if tlv[0] != 0x80:
- continue
-
- # Empty field - Zero length
- if tlv[1] == 0:
- continue
-
- # Uninitialized field
- if all([v == 0xff for v in tlv[2]]):
- continue
-
- # First byte in the value has the address type
- addr_type = tlv[2][0]
- # TODO: Support parsing of IPv6
- # Address Type: 0x00 (FQDN), 0x01 (IPv4), 0x02 (IPv6), other (Reserved)
- if addr_type == 0x00: # FQDN
- # Skip address tye byte i.e. first byte in value list
- content = tlv[2][1:]
- return (i2s(content), '00')
-
- elif addr_type == 0x01: # IPv4
- # Skip address tye byte i.e. first byte in value list
- # Skip the unused byte in Octect 4 after address type byte as per 3GPP TS 31.102
- ipv4 = tlv[2][2:]
- content = '.'.join(str(x) for x in ipv4)
- return (content, '01')
- else:
- raise ValueError("Invalid address type")
-
- return (None, None)
-
-
-def enc_addr_tlv(addr, addr_type='00'):
- """
- Encode address TLV object used in EF.P-CSCF Address, EF.ePDGId and EF.ePDGIdEm.
- See 3GPP TS 31.102 version 13.4.0 Release 13, section 4.2.8, 4.2.102 and 4.2.104.
-
- Default values:
- - addr_type: 00 - FQDN format of Address
- """
-
- s = ""
-
- # TODO: Encoding of IPv6 address
- if addr_type == '00': # FQDN
- hex_str = s2h(addr)
- s += '80' + ('%02x' % ((len(hex_str)//2)+1)) + '00' + hex_str
- elif addr_type == '01': # IPv4
- ipv4_list = addr.split('.')
- ipv4_str = ""
- for i in ipv4_list:
- ipv4_str += ('%02x' % (int(i)))
-
- # Unused bytes shall be set to 'ff'. i.e 4th Octet after Address Type is not used
- # IPv4 Address is in octet 5 to octet 8 of the TLV data object
- s += '80' + ('%02x' % ((len(ipv4_str)//2)+2)) + '01' + 'ff' + ipv4_str
-
- return s
-
-
def is_hex(string: str, minlen: int = 2, maxlen: Optional[int] = None) -> bool:
"""
Check if a string is a valid hexstring
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35279?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I6f18ccb36fc33bc204c01f9ece135676510e67ec
Gerrit-Change-Number: 35279
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange