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
Attention is currently required from: laforge, pespin.
Hello Jenkins Builder, laforge,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/libosmocore/+/35276?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: socket: Introduce API osmo_sock_sctp_get_peer_addr_info()
......................................................................
socket: Introduce API osmo_sock_sctp_get_peer_addr_info()
This is a convenience helper to reetrieve the whole set of remote
addresses and call getsockopt() on them, making it easy for users to
analyse the full set of remote addresses of a socket simply providing an
fd.
Related: SYS#6636
Change-Id: I3e1c84526b006baff435bbbca49dc6cf7d201cf5
---
M TODO-RELEASE
M include/osmocom/core/socket.h
M src/core/libosmocore.map
M src/core/socket.c
4 files changed, 97 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/76/35276/2
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35276?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I3e1c84526b006baff435bbbca49dc6cf7d201cf5
Gerrit-Change-Number: 35276
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newpatchset
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/35276?usp=email )
Change subject: socket: Introduce API osmo_sock_sctp_get_peer_addr_info()
......................................................................
socket: Introduce API osmo_sock_sctp_get_peer_addr_info()
This is a convenience helper to reetrieve the whole set of remote
addresses and call getsockopt() on them, making it easy for users to
analyse the full set of remote addresses of a socket simply providing an
fd.
Related: SYS#6636
Change-Id: I3e1c84526b006baff435bbbca49dc6cf7d201cf5
---
M TODO-RELEASE
M include/osmocom/core/socket.h
M src/core/socket.c
3 files changed, 121 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/76/35276/1
diff --git a/TODO-RELEASE b/TODO-RELEASE
index 316c0ec..9f5240f 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -9,6 +9,7 @@
#library what description / commit summary line
core ADD osmo_sock_multiaddr_{add,del}_local_addr()
core ADD osmo_sock_multiaddr_get_ip_and_port(), osmo_multiaddr_ip_and_port_snprintf(), osmo_sock_multiaddr_get_name_buf()
+core ADD osmo_sock_sctp_get_peer_addr_info()
core ADD gsmtap_inst_fd2() core, DEPRECATE gsmtap_inst_fd()
isdn ABI change add states and flags for external T200 handling
gsm ABI change add T200 timer states to lapdm_datalink
diff --git a/include/osmocom/core/socket.h b/include/osmocom/core/socket.h
index dd14556..cd9547a 100644
--- a/include/osmocom/core/socket.h
+++ b/include/osmocom/core/socket.h
@@ -211,5 +211,7 @@
int osmo_sock_set_dscp(int fd, uint8_t dscp);
int osmo_sock_set_priority(int fd, int prio);
+int osmo_sock_sctp_get_peer_addr_info(int fd, struct sctp_paddrinfo *pinfo, size_t *pinfo_cnt);
+
#endif /* (!EMBEDDED) */
/*! @} */
diff --git a/src/core/socket.c b/src/core/socket.c
index c600732..70b1885 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -2653,6 +2653,109 @@
return setsockopt(fd, SOL_SOCKET, SO_PRIORITY, &prio, sizeof(prio));
}
+/*! Get multiple IP addresses and/or port number on socket in separate string buffers
+ * \param[in] fd file descriptor of socket.
+ * \param[out] ip_proto IPPROTO of the socket, eg: IPPROTO_SCTP.
+ * \param[out] ip Pointer to memory holding consecutive buffers of size ip_len.
+ * \param[out] ip_cnt length ip array pointer. on return it contains the number of addresses found.
+ * \param[in] ip_len length of each of the string buffer in the the ip array.
+ * \param[out] port number (will be filled in when not NULL).
+ * \param[in] port_len length of the port buffer.
+ * \param[in] local (true) or remote (false) name will get looked at.
+ * \returns 0 on success; negative otherwise.
+ *
+ * Upon return, ip_cnt can be set to a higher value than the one set by the
+ * caller. This can be used by the caller to find out the required array length
+ * and then obtaining by calling the function twice. Only up to ip_cnt addresses
+ * are filed in, as per the value provided by the caller.
+ *
+ * Usage example retrieving all (up to OSMO_SOCK_MAX_ADDRS, 32) bound IP addresses and bound port:
+ * char hostbuf[OSMO_SOCK_MAX_ADDRS][INET6_ADDRSTRLEN];
+ * size_t num_hostbuf = ARRAY_SIZE(hostbuf);
+ * char portbuf[6];
+ * rc = osmo_sock_multiaddr_get_ip_and_port(fd, IPPROTO_SCTP, &hostbuf[0][0], &num_hostbuf,
+ * sizeof(hostbuf[0]), portbuf, sizeof(portbuf), true);
+ * if (rc < 0)
+ * goto error;
+ * if (num_hostbuf > ARRAY_SIZE(hostbuf))
+ * goto not_enough_buffers;
+ */
+
+/*! Fill in array of struct sctp_paddrinfo with each of the remote addresses of an SCTP socket
+ * \param[in] fd file descriptor of SCTP socket
+ * \param[out] pinfo Pointer to memory holding an array of struct sctp_paddrinfo (pinfo_cnt length).
+ * \param[out] pinfo_cnt length of pinfo array (in elements). On return it contains the number of addresses found.
+ * \returns 0 on success; negative otherwise
+ *
+ * Upon return, pinfo_cnt can be set to a higher value than the one set by the
+ * caller. This can be used by the caller to find out the required array length
+ * and then obtaining by calling the function twice. Only up to pinfo_cnt addresses
+ * are filled in, as per the value provided by the caller.
+ *
+ * Usage example retrieving struct sctp_paddringo for all (up to OSMO_SOCK_MAX_ADDRS, 32) remote IP addresses:
+ * struct sctp_paddrinfo pinfo[OSMO_SOCK_MAX_ADDRS];
+ * size_t pinfo_cnt = ARRAY_SIZE(pinfo);
+ * rc = osmo_sock_sctp_get_peer_addr_info(fd, &pinfo[0], &num_hostbuf, pinfo_cnt);
+ * if (rc < 0)
+ * goto error;
+ * if (pinfo_cnt > ARRAY_SIZE(hostbuf))
+ * goto not_enough_buffers;
+ */
+int osmo_sock_sctp_get_peer_addr_info(int fd, struct sctp_paddrinfo *pinfo, size_t *pinfo_cnt)
+{
+ struct sockaddr *addrs = NULL;
+ unsigned int n_addrs, i;
+ void *addr_buf;
+ int rc;
+ socklen_t optlen;
+
+ rc = sctp_getpaddrs(fd, 0, &addrs);
+
+ if (rc < 0)
+ return rc;
+ if (rc == 0)
+ return -ENOTCONN;
+
+ n_addrs = rc;
+ addr_buf = (void *)addrs;
+ for (i = 0; i < n_addrs; i++) {
+ struct sockaddr *sa_addr = (struct sockaddr *)addr_buf;
+ size_t addrlen;
+
+ switch (sa_addr->sa_family) {
+ case AF_INET:
+ addrlen = sizeof(struct sockaddr_in);
+ break;
+ case AF_INET6:
+ addrlen = sizeof(struct sockaddr_in6);
+ break;
+ default:
+ rc = -EINVAL;
+ goto free_addrs_ret;
+ }
+
+ if (i >= *pinfo_cnt) {
+ addr_buf += addrlen;
+ continue;
+ }
+
+ memset(&pinfo[i], 0, sizeof(pinfo[0]));
+ memcpy(&pinfo[i].spinfo_address, sa_addr, addrlen);
+ optlen = sizeof(pinfo[0]);
+ rc = getsockopt(fd, SOL_SCTP, SCTP_GET_PEER_ADDR_INFO, &pinfo[i], &optlen);
+ if (rc < 0)
+ goto free_addrs_ret;
+
+ addr_buf += addrlen;
+ }
+
+ *pinfo_cnt = n_addrs;
+ rc = 0;
+free_addrs_ret:
+ sctp_freepaddrs(addrs);
+ return rc;
+}
+
#endif /* HAVE_SYS_SOCKET_H */
/*! @} */
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35276?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I3e1c84526b006baff435bbbca49dc6cf7d201cf5
Gerrit-Change-Number: 35276
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange
Attention is currently required from: fixeria, pespin.
osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-ci/+/35267?usp=email )
Change subject: coverity: add job to check for failed uploads
......................................................................
Patch Set 3:
(1 comment)
File coverity/badge_status.sh:
https://gerrit.osmocom.org/c/osmo-ci/+/35267/comment/1d4f10db_0ab91880
PS2, Line 11: wget --no-verbose -O "$BADGE" "https://scan.coverity.com/projects/7523/badge.svg"
> some small documentation on how this script accomplished its aim (downloading an svg image containg […]
Done. also updated the script to check for "passed" now that I know how the svg looks like when it did not fail :)
--
To view, visit https://gerrit.osmocom.org/c/osmo-ci/+/35267?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: Ideabcb30f9f8f365acff2de7751eb74a2762a7a6
Gerrit-Change-Number: 35267
Gerrit-PatchSet: 3
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 08 Dec 2023 13:54:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: comment
Attention is currently required from: fixeria, osmith.
Hello Jenkins Builder, fixeria,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/osmo-ci/+/35267?usp=email
to look at the new patch set (#3).
The following approvals got outdated and were removed:
Code-Review+1 by fixeria, Verified+1 by Jenkins Builder
Change subject: coverity: add job to check for failed uploads
......................................................................
coverity: add job to check for failed uploads
Related: SYS#6685
Change-Id: Ideabcb30f9f8f365acff2de7751eb74a2762a7a6
---
A coverity/badge_status.sh
M jobs/README.adoc
A jobs/coverity-status.yml
3 files changed, 85 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/67/35267/3
--
To view, visit https://gerrit.osmocom.org/c/osmo-ci/+/35267?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: Ideabcb30f9f8f365acff2de7751eb74a2762a7a6
Gerrit-Change-Number: 35267
Gerrit-PatchSet: 3
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: osmith <osmith(a)sysmocom.de>
Gerrit-Attention: fixeria <vyanitskiy(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 (#2).
The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder
Change subject: vty: show cs7 instance asp: Allow printing only a specific asp by name
......................................................................
vty: show cs7 instance asp: Allow printing only a specific asp by name
Change-Id: I08426272069ce5f3c8403b08dcaf686547bee336
---
M src/osmo_ss7_vty.c
M tests/vty/ss7_asp_test.vty
2 files changed, 60 insertions(+), 30 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/75/35275/2
--
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: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-MessageType: newpatchset
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/35274?usp=email )
Change subject: vty: show cs7 instance asp: Print loc and rem addr retrieved from socket
......................................................................
vty: show cs7 instance asp: Print loc and rem addr retrieved from socket
Until now, we were in general printing the list of remote addresses that
were stored in config, because we didn't have an easy way to retrieve
the addresses from the socket. Since recently some libosmocore APIs make
that easy, so use them now.
If the socket is not yet created, then log the addrress list from the config.
Furthermore, take the chance to print now both local and remote
addresses.
Related: SYS#6636
Change-Id: I607e4c2dd37f07bf1c07c88681918184e92202ea
---
M src/osmo_ss7_asp.c
M src/osmo_ss7_vty.c
M src/ss7_internal.h
M tests/vty/ss7_asp_test.vty
4 files changed, 104 insertions(+), 46 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/74/35274/1
diff --git a/src/osmo_ss7_asp.c b/src/osmo_ss7_asp.c
index 55e5a29..f867ce5 100644
--- a/src/osmo_ss7_asp.c
+++ b/src/osmo_ss7_asp.c
@@ -1134,3 +1134,19 @@
{
return asp->cfg.proto;
}
+
+/*! \brief Get the fd of a given ASP
+ * \param[in] asp The ASP for which the fd is requested
+ * \returns The fd of the ASP if acailable, negative otherwise
+ */
+int ss7_asp_get_fd(const struct osmo_ss7_asp *asp)
+{
+ if (asp->cfg.is_server) {
+ if (asp->server)
+ return osmo_stream_srv_get_fd(asp->server);
+ } else {
+ if (asp->client)
+ return osmo_stream_cli_get_fd(asp->client);
+ }
+ return -1;
+}
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 35f0dda..91a1eb7 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -1133,13 +1133,39 @@
return buf;
}
+/* Similar to osmo_sock_multiaddr_get_name_buf(), but aimed at listening sockets (only local part): */
+static char *get_sockname_buf(char *buf, size_t buf_len, int fd, int proto, bool local)
+{
+ char hostbuf[OSMO_SOCK_MAX_ADDRS][INET6_ADDRSTRLEN];
+ size_t num_hostbuf = ARRAY_SIZE(hostbuf);
+ char portbuf[6];
+ struct osmo_strbuf sb = { .buf = buf, .len = buf_len };
+ bool need_more_bufs;
+ int rc;
+
+ rc = osmo_sock_multiaddr_get_ip_and_port(fd, proto, &hostbuf[0][0],
+ &num_hostbuf, sizeof(hostbuf[0]),
+ portbuf, sizeof(portbuf), local);
+ if (rc < 0)
+ return NULL;
+
+ need_more_bufs = num_hostbuf > ARRAY_SIZE(hostbuf);
+ if (need_more_bufs)
+ num_hostbuf = ARRAY_SIZE(hostbuf);
+ OSMO_STRBUF_APPEND(sb, osmo_multiaddr_ip_and_port_snprintf,
+ &hostbuf[0][0], num_hostbuf, sizeof(hostbuf[0]), portbuf);
+ if (need_more_bufs)
+ OSMO_STRBUF_PRINTF(sb, "<need-more-bufs!>");
+
+ return buf;
+}
+
DEFUN(show_cs7_asp, show_cs7_asp_cmd,
"show cs7 instance <0-15> asp",
SHOW_STR CS7_STR INST_STR INST_STR "Application Server Process (ASP)\n")
{
struct osmo_ss7_instance *inst;
struct osmo_ss7_asp *asp;
- char buf[512];
char as_buf[64];
int id = atoi(argv[0]);
@@ -1149,28 +1175,32 @@
return CMD_WARNING;
}
- vty_out(vty, " Current Primary Link%s", VTY_NEWLINE);
- vty_out(vty, "ASP Name AS Name State Type Role SCTP Role Remote Addresses%s", VTY_NEWLINE);
- vty_out(vty, "------------ ------------ ------------- ---- ---- --------- -----------------------%s", VTY_NEWLINE);
+ vty_out(vty, "ASP Name AS Name State Type Role SCTP Role Local Addresses Remote Addresses%s", VTY_NEWLINE);
+ vty_out(vty, "------------ ------------ ------------- ---- ---- --------- ----------------------- -----------------------%s", VTY_NEWLINE);
llist_for_each_entry(asp, &inst->asp_list, list) {
- if (asp->cfg.proto == OSMO_SS7_ASP_PROT_IPA && asp->cfg.remote.port == 0 && asp->server) {
- int fd = osmo_stream_srv_get_fd(asp->server);
- char hostbuf[64];
- char portbuf[16];
- osmo_sock_get_ip_and_port(fd, hostbuf, sizeof(hostbuf),
- portbuf, sizeof(portbuf), false);
- snprintf(buf, sizeof(buf), "%s:%s", hostbuf, portbuf);
- } else
- osmo_ss7_asp_peer_snprintf(buf, sizeof(buf), &asp->cfg.remote);
- vty_out(vty, "%-12s %-12s %-13s %-4s %-4s %-9s %-23s%s",
+ char buf_loc[OSMO_SOCK_MAX_ADDRS * INET6_ADDRSTRLEN + OSMO_SOCK_MAX_ADDRS + 2 + 6 + 1];
+ char buf_rem[sizeof(buf_loc)];
+ int fd = ss7_asp_get_fd(asp);
+ if (fd > 0) {
+ int proto = ss7_asp_proto_to_ip_proto(asp->cfg.proto);
+ if (!get_sockname_buf(buf_loc, sizeof(buf_loc), fd, proto, true))
+ OSMO_STRLCPY_ARRAY(buf_loc, "<sockname-error>");
+ if (!get_sockname_buf(buf_rem, sizeof(buf_rem), fd, proto, false))
+ OSMO_STRLCPY_ARRAY(buf_rem, "<sockname-error>");
+ } else {
+ osmo_ss7_asp_peer_snprintf(buf_loc, sizeof(buf_loc), &asp->cfg.local);
+ osmo_ss7_asp_peer_snprintf(buf_rem, sizeof(buf_rem), &asp->cfg.remote);
+ }
+
+ vty_out(vty, "%-12s %-12s %-13s %-4s %-4s %-9s %-23s %-23s%s",
asp->cfg.name,
as_list_for_asp(asp, as_buf, sizeof(as_buf)),
asp->fi? osmo_fsm_inst_state_name(asp->fi) : "uninitialized",
get_value_string(osmo_ss7_asp_protocol_vals, asp->cfg.proto),
osmo_str_tolower(get_value_string(osmo_ss7_asp_role_names, asp->cfg.role)),
asp->cfg.is_server ? "server" : "client",
- buf,
+ buf_loc, buf_rem,
VTY_NEWLINE);
}
return CMD_SUCCESS;
diff --git a/src/ss7_internal.h b/src/ss7_internal.h
index e2d78d8..fd01ca4 100644
--- a/src/ss7_internal.h
+++ b/src/ss7_internal.h
@@ -19,6 +19,7 @@
enum osmo_ss7_asp_protocol proto);
bool ss7_asp_set_default_peer_hosts(struct osmo_ss7_asp *asp);
bool ss7_asp_is_started(const struct osmo_ss7_asp *asp);
+int ss7_asp_get_fd(const struct osmo_ss7_asp *asp);
struct osmo_ss7_asp *ss7_asp_find_by_socket_addr(int fd);
int ss7_asp_proto_to_ip_proto(enum osmo_ss7_asp_protocol proto);
diff --git a/tests/vty/ss7_asp_test.vty b/tests/vty/ss7_asp_test.vty
index 73a13b5..a767552 100644
--- a/tests/vty/ss7_asp_test.vty
+++ b/tests/vty/ss7_asp_test.vty
@@ -256,27 +256,24 @@
ss7_asp_vty_test(config-cs7-asp)# remote-ip 127.0.0.200
ss7_asp_vty_test(config-cs7-asp)# local-ip 127.0.0.100
ss7_asp_vty_test(config-cs7-asp)# do show cs7 instance 0 asp
- Current Primary Link
-ASP Name AS Name State Type Role SCTP Role Remote Addresses
------------- ------------ ------------- ---- ---- --------- -----------------------
-my-asp ? uninitialized m3ua sg server 127.0.0.200:12345
+ASP Name AS Name State Type Role SCTP Role Local Addresses Remote Addresses
+------------ ------------ ------------- ---- ---- --------- ----------------------- -----------------------
+my-asp ? uninitialized m3ua sg server 127.0.0.100:54321 127.0.0.200:12345
ss7_asp_vty_test(config-cs7-asp)# remote-ip 127.0.0.201
ss7_asp_vty_test(config-cs7-asp)# local-ip 127.0.0.101
ss7_asp_vty_test(config-cs7-asp)# do show cs7 instance 0 asp
- Current Primary Link
-ASP Name AS Name State Type Role SCTP Role Remote Addresses
------------- ------------ ------------- ---- ---- --------- -----------------------
-my-asp ? uninitialized m3ua sg server (127.0.0.200|127.0.0.201):12345
+ASP Name AS Name State Type Role SCTP Role Local Addresses Remote Addresses
+------------ ------------ ------------- ---- ---- --------- ----------------------- -----------------------
+my-asp ? uninitialized m3ua sg server (127.0.0.100|127.0.0.101):54321 (127.0.0.200|127.0.0.201):12345
ss7_asp_vty_test(config-cs7-asp)# ! Mark as primary:
ss7_asp_vty_test(config-cs7-asp)# remote-ip 127.0.0.201 primary
ss7_asp_vty_test(config-cs7-asp)# ! 'local-ip 127.0.0.101 primary' cannot be tested here since output may be different based on sysctl available
ss7_asp_vty_test(config-cs7-asp)# local-ip 127.0.0.101
...
ss7_asp_vty_test(config-cs7-asp)# do show cs7 instance 0 asp
- Current Primary Link
-ASP Name AS Name State Type Role SCTP Role Remote Addresses
------------- ------------ ------------- ---- ---- --------- -----------------------
-my-asp ? uninitialized m3ua sg server (127.0.0.200|127.0.0.201*):12345
+ASP Name AS Name State Type Role SCTP Role Local Addresses Remote Addresses
+------------ ------------ ------------- ---- ---- --------- ----------------------- -----------------------
+my-asp ? uninitialized m3ua sg server (127.0.0.100|127.0.0.101):54321 (127.0.0.200|127.0.0.201*):12345
ss7_asp_vty_test(config-cs7-asp)# show running-config
...
local-ip 127.0.0.100
@@ -289,10 +286,9 @@
ss7_asp_vty_test(config-cs7-asp)# remote-ip 127.0.0.201
ss7_asp_vty_test(config-cs7-asp)# local-ip 127.0.0.101
ss7_asp_vty_test(config-cs7-asp)# do show cs7 instance 0 asp
- Current Primary Link
-ASP Name AS Name State Type Role SCTP Role Remote Addresses
------------- ------------ ------------- ---- ---- --------- -----------------------
-my-asp ? uninitialized m3ua sg server (127.0.0.200|127.0.0.201):12345
+ASP Name AS Name State Type Role SCTP Role Local Addresses Remote Addresses
+------------ ------------ ------------- ---- ---- --------- ----------------------- -----------------------
+my-asp ? uninitialized m3ua sg server (127.0.0.100|127.0.0.101):54321 (127.0.0.200|127.0.0.201):12345
ss7_asp_vty_test(config-cs7-asp)# show running-config
...
local-ip 127.0.0.100
@@ -361,26 +357,23 @@
ss7_asp_vty_test(config-cs7-as)# routing-key 0 3.2.1
ss7_asp_vty_test(config-cs7-as)# do show cs7 instance 0 asp
- Current Primary Link
-ASP Name AS Name State Type Role SCTP Role Remote Addresses
------------- ------------ ------------- ---- ---- --------- -----------------------
-my-asp my-ass ASP_DOWN m3ua sg server (127.0.0.200|127.0.0.201):12345
+ASP Name AS Name State Type Role SCTP Role Local Addresses Remote Addresses
+------------ ------------ ------------- ---- ---- --------- ----------------------- -----------------------
+my-asp my-ass ASP_DOWN m3ua sg server (127.0.0.100|127.0.0.101):54321 (127.0.0.200|127.0.0.201):12345
ss7_asp_vty_test(config-cs7-as)# exit
ss7_asp_vty_test(config-cs7)# do show cs7 instance 0 asp
- Current Primary Link
-ASP Name AS Name State Type Role SCTP Role Remote Addresses
------------- ------------ ------------- ---- ---- --------- -----------------------
-my-asp my-ass ASP_DOWN m3ua sg server (127.0.0.200|127.0.0.201):12345
+ASP Name AS Name State Type Role SCTP Role Local Addresses Remote Addresses
+------------ ------------ ------------- ---- ---- --------- ----------------------- -----------------------
+my-asp my-ass ASP_DOWN m3ua sg server (127.0.0.100|127.0.0.101):54321 (127.0.0.200|127.0.0.201):12345
ss7_asp_vty_test(config-cs7)# exit
ss7_asp_vty_test(config)# do show cs7 instance 0 asp
- Current Primary Link
-ASP Name AS Name State Type Role SCTP Role Remote Addresses
------------- ------------ ------------- ---- ---- --------- -----------------------
-my-asp my-ass ASP_DOWN m3ua sg server (127.0.0.200|127.0.0.201):12345
+ASP Name AS Name State Type Role SCTP Role Local Addresses Remote Addresses
+------------ ------------ ------------- ---- ---- --------- ----------------------- -----------------------
+my-asp my-ass ASP_DOWN m3ua sg server (127.0.0.100|127.0.0.101):54321 (127.0.0.200|127.0.0.201):12345
ss7_asp_vty_test(config)# do show cs7 instance 0 as all
Routing Routing Key Cic Cic Traffic
@@ -423,9 +416,8 @@
ss7_asp_vty_test(config-cs7)# no asp my-asp
ss7_asp_vty_test(config-cs7)# do show cs7 instance 0 asp
- Current Primary Link
-ASP Name AS Name State Type Role SCTP Role Remote Addresses
------------- ------------ ------------- ---- ---- --------- -----------------------
+ASP Name AS Name State Type Role SCTP Role Local Addresses Remote Addresses
+------------ ------------ ------------- ---- ---- --------- ----------------------- -----------------------
ss7_asp_vty_test(config-cs7)# do show cs7 instance 0 as all
Routing Routing Key Cic Cic Traffic
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/35274?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: I607e4c2dd37f07bf1c07c88681918184e92202ea
Gerrit-Change-Number: 35274
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange
osmith has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ci/+/35269?usp=email )
(
1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: coverity: readlink /opt/coverity/current
......................................................................
coverity: readlink /opt/coverity/current
Show where the symlink points at the start of the job, so we can see
which coverity version is currently installed.
Related: SYS#6685
Change-Id: If4a7c71759a6eb436eb47024565f169c6134e2e2
---
M coverity/jenkins.sh
1 file changed, 15 insertions(+), 0 deletions(-)
Approvals:
pespin: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
osmith: Verified
diff --git a/coverity/jenkins.sh b/coverity/jenkins.sh
index dfe3067..b33ae86 100755
--- a/coverity/jenkins.sh
+++ b/coverity/jenkins.sh
@@ -3,6 +3,8 @@
set -e -x
+readlink /opt/coverity/current
+
export PATH=$PATH:/opt/coverity/current/bin
base_dir="$HOME/osmo-ci/coverity"
--
To view, visit https://gerrit.osmocom.org/c/osmo-ci/+/35269?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: If4a7c71759a6eb436eb47024565f169c6134e2e2
Gerrit-Change-Number: 35269
Gerrit-PatchSet: 2
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged