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/+/34347?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: stream: Introduce API to set several transport parameters
......................................................................
stream: Introduce API to set several transport parameters
This will allow extending capabilitites to set different parameters at
the lower layers as we need them.
This commit changes the behavior of osmo_stream_{cli,srv_link}: It now
doesn't enable by default SCTP AUTH/ASCONF features using setsockopt. It
is left up to the user of the API (libosmo-sccp in this case) to set it.
Since this unilateral use of setsockopt() has only been added recently
and we didn't release yet, it's fine changing it. libosmo-sccp will be
changed to unconditionally set its using setsockopt. It is left up to
the user of the API (libosmo-sccp in this case) to set it.
Related: SYS#6501
Related: SYS#6558
Change-Id: I2607c1c926a625986cd851adc65dd8b4de83d6ab
---
M TODO-RELEASE
M include/osmocom/netif/stream.h
M src/stream_cli.c
M src/stream_srv.c
4 files changed, 107 insertions(+), 34 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/47/34347/2
--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/34347?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: I2607c1c926a625986cd851adc65dd8b4de83d6ab
Gerrit-Change-Number: 34347
Gerrit-PatchSet: 2
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/osmo-mgw/+/34350?usp=email
to look at the new patch set (#2).
Change subject: mgcp_client_fsm: explain member param in struct mgcp_conn_peer better
......................................................................
mgcp_client_fsm: explain member param in struct mgcp_conn_peer better
The struct member param specifies additional codec parameters. Let's
improve its explaination.
Change-Id: Iea4dc1e72fccaa464ce503fae88b5d8a867b1d19
Related: OS#6171
---
M include/osmocom/mgcp_client/mgcp_client_fsm.h
1 file changed, 15 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/50/34350/2
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/34350?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: Iea4dc1e72fccaa464ce503fae88b5d8a867b1d19
Gerrit-Change-Number: 34350
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-MessageType: newpatchset
Attention is currently required from: dexter.
Hello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/osmo-mgw/+/34349?usp=email
to look at the new patch set (#2).
Change subject: mgcp_client_fsm: allow the same codec multiple times in ptmap
......................................................................
mgcp_client_fsm: allow the same codec multiple times in ptmap
Ih struct mgcp_conn_peer, the API user is supposed to fill in the codecs
he which to used and optionally a payload type map (ptmap) that is used
to assign a user defined payload type number for each codec (in case
ptmap is not used, than the IANA/3GPP assigned payload type numbers
apply).
Unfortunately ptmap works like a simple lookup table. When a payload
type is looked up for a specific codec, then the lookup table is
searched for the codec and the payload type of the first entry that is
found is returned. This works fine as long as the same codec is not
apparing twice, which different payload type numbers.
What seems to be a corner case on the first look turns out to be a
common case with AMR, where a bandwith-efficient mode and an
octet-aligned mode may be specified. Then we need to specify AMR twice,
but with different payload type numbers in ptmap.
So, let's equip the function that does the mapping (map_pt_to_codec)
with a memory, so that it can checkmark entries it has already mapped.
This will allow us to put the same codec type multiple times in ptmap
and as long as the order in ptmap matches the order used in codecs the
mapping will be consistent.
Related: OS#6171
Change-Id: Ie13ce59d3165936a16e16588b4d58f0ce7e0ae67
---
M include/osmocom/mgcp_client/mgcp_client.h
M include/osmocom/mgcp_client/mgcp_client_fsm.h
M src/libosmo-mgcp-client/mgcp_client.c
M tests/mgcp_client/mgcp_client_test.c
M tests/mgcp_client/mgcp_client_test.ok
5 files changed, 113 insertions(+), 8 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/49/34349/2
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/34349?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: Ie13ce59d3165936a16e16588b4d58f0ce7e0ae67
Gerrit-Change-Number: 34349
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-MessageType: newpatchset
Attention is currently required from: dexter.
Hello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/osmo-mgw/+/34351?usp=email
to look at the new patch set (#2).
Change subject: mgcp_client_fsm: fix inconsistent API (param_present, param).
......................................................................
mgcp_client_fsm: fix inconsistent API (param_present, param).
The struct struct mgcp_conn_peer in mgcp_client_fsm.h (and the struct
struct mgcp_msg in mgcp_client.h) use a problematic way to hold
information about codec parameters: Using the struct member param, the
user can set options for AMR (octet-aligned/bandwith-efficient). This is
done using the struct mgcp_codec_param, which is also not very well
thought out. Since we can only set the parameters for AMR exactly once, it
is not possible to set different parameters when AMR occurs multiple times
in codecs.
Since what we would have needed is an array of struct mgcp_codec_param,
where we can set the parameters for each codec we use indvidually. So
let's depreacate the use of param/param_present and add a new struct
member codec_params/codec_params_present, where codec_params is an
array. Let's also re-define mgcp_codec_params as mgcp_codec_params2, and
use a union so that we can add params for other codecs than AMR in the
future.
Unfortunately mgcp_codec_params is also used in osmo-mgw, we should
migrate each occurrence of mgcp_codec_param to mgcp_codec_param2 there
too, but this should be done in a follow up patch.
Related: OS#6171
Change-Id: I50d737f3f3d45e4004c64101700a471fe75b3436
---
M TODO-RELEASE
M include/osmocom/mgcp/mgcp_common.h
M include/osmocom/mgcp_client/mgcp_client.h
M include/osmocom/mgcp_client/mgcp_client_fsm.h
M src/libosmo-mgcp-client/mgcp_client.c
M src/libosmo-mgcp-client/mgcp_client_fsm.c
6 files changed, 85 insertions(+), 8 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/51/34351/2
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/34351?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I50d737f3f3d45e4004c64101700a471fe75b3436
Gerrit-Change-Number: 34351
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-MessageType: newpatchset
Jenkins Builder has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/34351?usp=email )
Change subject: mgcp_client_fsm: fix inconsistent API (param_present, param).
......................................................................
Patch Set 1:
(6 comments)
File TODO-RELEASE:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-10920):
https://gerrit.osmocom.org/c/osmo-mgw/+/34351/comment/6ce9e944_f5261c4c
PS1, Line 31: mgcp NEW API add struct struct mgcp_codec_param2, depreacte struct mgcp_codec_param
'depreacte' may be misspelled - perhaps 'deprecate'?
File include/osmocom/mgcp_client/mgcp_client.h:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-10920):
https://gerrit.osmocom.org/c/osmo-mgw/+/34351/comment/6c6dadf3_718abc03
PS1, Line 139: bool param_present; /* Depreacted, please use codecs_param_present */
'Depreacted' may be misspelled - perhaps 'Deprecated'?
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-10920):
https://gerrit.osmocom.org/c/osmo-mgw/+/34351/comment/5263e471_ab5d3b44
PS1, Line 140: struct mgcp_codec_param param; /* Depreacted, please use codecs_param */
'Depreacted' may be misspelled - perhaps 'Deprecated'?
File src/libosmo-mgcp-client/mgcp_client.c:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-10920):
https://gerrit.osmocom.org/c/osmo-mgw/+/34351/comment/4a87a0e7_786dde1a
PS1, Line 1376: LOGPMGW(mgcp, LOGL_DEBUG, "using depreacted struct member mgcp_msg->param, please use mgcp_msg->codecs_param!\n");
'depreacted' may be misspelled - perhaps 'deprecated'?
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-10920):
https://gerrit.osmocom.org/c/osmo-mgw/+/34351/comment/61467063_e7d09f41
PS1, Line 1393: if (mgcp_msg->codecs[i] != CODEC_AMR_8000_1 && mgcp_msg->codecs[i] != CODEC_AMRWB_16000_1)
suspect code indent for conditional statements (24, 35)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-10920):
https://gerrit.osmocom.org/c/osmo-mgw/+/34351/comment/79366499_46d24275
PS1, Line 1394: continue;
Statements should start on a tabstop
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/34351?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I50d737f3f3d45e4004c64101700a471fe75b3436
Gerrit-Change-Number: 34351
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-CC: Jenkins Builder
Gerrit-Comment-Date: Fri, 08 Sep 2023 14:59:15 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Jenkins Builder has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/34349?usp=email )
Change subject: mgcp_client_fsm: allow the same codec multiple times in ptmap
......................................................................
Patch Set 1:
(1 comment)
File src/libosmo-mgcp-client/mgcp_client.c:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-10918):
https://gerrit.osmocom.org/c/osmo-mgw/+/34349/comment/e9c71ac2_c1d2a0c7
PS1, Line 179: skip:
labels should not be indented
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/34349?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: Ie13ce59d3165936a16e16588b4d58f0ce7e0ae67
Gerrit-Change-Number: 34349
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-CC: Jenkins Builder
Gerrit-Comment-Date: Fri, 08 Sep 2023 14:59:12 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/34352?usp=email )
Change subject: asp,xua_srv: Use new osmo_stream API to request sockopt SCTP AUTH/ASCONF SUPPORTED
......................................................................
asp,xua_srv: Use new osmo_stream API to request sockopt SCTP AUTH/ASCONF SUPPORTED
Support to enable AUTH/ASCONF in the SCTP socket was added recently in
libosmocore and libosmo-netif, in order to support the Peer Primary
Address features used by the libosmo-sccp code.
The code to request the AUTH/ASCONF support through setsockopt() was
internally applied transparently by lisbosmo-netif's osmo_stream. This
is not 100% disarable since other users of the library may not need/want
that behavior.
As a result, libosmo-netif's osmo_stream no longer enables the SCTP
AUTH/ASCONF support by default, but it must be enabled through
the new osmo_stream_{cli,srv_link}_set_param() API.
This change in behavior of the API/implementation can be done because
all these new features are pretty new and no release of
libosmocore/libosmo-netif/libosmo-sccp has been released yet.
Related: SYS#6501
Related: SYS#6558
Depends: libosmo-netif.git Change-Id I2607c1c926a625986cd851adc65dd8b4de83d6ab
Change-Id: I16c97fc148792aa3e39b7414899660990c39dfff
---
M TODO-RELEASE
M src/osmo_ss7_asp.c
M src/osmo_ss7_xua_srv.c
3 files changed, 39 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/52/34352/1
diff --git a/TODO-RELEASE b/TODO-RELEASE
index 306eed9..172a1f9 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -11,5 +11,5 @@
libosmo-netif > 1.3.0 uses osmo_stream_*_set_name()
libosmo-sccp add API osmo_ss7_asp_get_name(), osmo_ss7_asp_get_proto()
osmo_sccp_simple_client_on_ss7_id() behavior change: ASPs asp-clnt-* defined through VTY must explicitly configure "role" and "sctp-role"
-libosmo-netif > 1.3.0 flag OSMO_STREAM_SCTP_MSG_FLAGS_NOTIFICATION set by osmo_stream_cli_recv()
+libosmo-netif > 1.3.0 osmo_stream_srv_link_set_param(), osmo_stream_srv_link_set_param()
libosmo-sccp add API osmo_ss7_asp_peer_init(), osmo_ss7_asp_peer_set_hosts2(), osmo_ss7_asp_peer_add_host2()
diff --git a/src/osmo_ss7_asp.c b/src/osmo_ss7_asp.c
index c282730..ab01abd 100644
--- a/src/osmo_ss7_asp.c
+++ b/src/osmo_ss7_asp.c
@@ -722,6 +722,7 @@
{
int rc;
char bufloc[512], bufrem[512];
+ uint8_t byte;
OSMO_ASSERT(ss7_initialized);
osmo_ss7_asp_peer_snprintf(bufloc, sizeof(bufloc), &asp->cfg.local);
@@ -758,6 +759,10 @@
else
osmo_stream_cli_set_read_cb(asp->client, xua_cli_read_cb);
osmo_stream_cli_set_data(asp->client, asp);
+ byte = 1; /*AUTH is needed by ASCONF. enable, don't abort socket creation if AUTH can't be enabled */
+ osmo_stream_cli_set_param(asp->client, OSMO_STREAM_CLI_PAR_SCTP_SOCKOPT_AUTH_SUPPORTED, &byte, sizeof(byte));
+ byte = 1; /* enable, don't abort socket creation if ASCONF can't be enabled */
+ osmo_stream_cli_set_param(asp->client, OSMO_STREAM_CLI_PAR_SCTP_SOCKOPT_ASCONF_SUPPORTED, &byte, sizeof(byte));
rc = osmo_stream_cli_open(asp->client);
if (rc < 0) {
LOGPASP(asp, DLSS7, LOGL_ERROR, "Unable to open stream"
diff --git a/src/osmo_ss7_xua_srv.c b/src/osmo_ss7_xua_srv.c
index 04ae893..826c5ce 100644
--- a/src/osmo_ss7_xua_srv.c
+++ b/src/osmo_ss7_xua_srv.c
@@ -181,6 +181,7 @@
uint16_t local_port, const char *local_host)
{
struct osmo_xua_server *oxs = talloc_zero(inst, struct osmo_xua_server);
+ uint8_t byte;
OSMO_ASSERT(ss7_initialized);
if (!oxs)
@@ -205,6 +206,11 @@
osmo_ss7_xua_server_set_local_host(oxs, local_host);
+ byte = 1; /*AUTH is needed by ASCONF. enable, don't abort socket creation if AUTH can't be enabled */
+ osmo_stream_srv_link_set_param(oxs->server, OSMO_STREAM_SRV_LINK_PAR_SCTP_SOCKOPT_AUTH_SUPPORTED, &byte, sizeof(byte));
+ byte = 1; /* enable, don't abort socket creation if ASCONF can't be enabled */
+ osmo_stream_srv_link_set_param(oxs->server, OSMO_STREAM_SRV_LINK_PAR_SCTP_SOCKOPT_ASCONF_SUPPORTED, &byte, sizeof(byte));
+
LOGP(DLSS7, LOGL_INFO, "Created %s server on %s:%" PRIu16 "\n",
get_value_string(osmo_ss7_asp_protocol_vals, proto), local_host, local_port);
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/34352?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: I16c97fc148792aa3e39b7414899660990c39dfff
Gerrit-Change-Number: 34352
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/34349?usp=email )
Change subject: mgcp_client_fsm: allow the same codec multiple times in ptmap
......................................................................
mgcp_client_fsm: allow the same codec multiple times in ptmap
Ih struct mgcp_conn_peer, the API user is supposed to fill in the codecs
he which to used and optionally a payload type map (ptmap) that is used
to assign a user defined payload type number for each codec (in case
ptmap is not used, than the IANA/3GPP assigned payload type numbers
apply).
Unfortunately ptmap works like a simple lookup table. When a payload
type is looked up for a specific codec, then the lookup table is
searched for the codec and the payload type of the first entry that is
found is returned. This works fine as long as the same codec is not
apparing twice, which different payload type numbers.
What seems to be a corner case on the first look turns out to be a
common case with AMR, where a bandwith-efficient mode and an
octet-aligned mode may be specified. Then we need to specify AMR twice,
but with different payload type numbers in ptmap.
So, let's equip the function that does the mapping (map_pt_to_codec)
with a memory, so that it can checkmark entries it has already mapped.
This will allow us to put the same codec type multiple times in ptmap
and as long as the order in ptmap matches the order used in codecs the
mapping will be consistent.
Related: OS#5723
Change-Id: Ie13ce59d3165936a16e16588b4d58f0ce7e0ae67
---
M include/osmocom/mgcp_client/mgcp_client.h
M include/osmocom/mgcp_client/mgcp_client_fsm.h
M src/libosmo-mgcp-client/mgcp_client.c
M tests/mgcp_client/mgcp_client_test.c
M tests/mgcp_client/mgcp_client_test.ok
5 files changed, 113 insertions(+), 8 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/49/34349/1
diff --git a/include/osmocom/mgcp_client/mgcp_client.h b/include/osmocom/mgcp_client/mgcp_client.h
index 9a0611a..4e54bbe 100644
--- a/include/osmocom/mgcp_client/mgcp_client.h
+++ b/include/osmocom/mgcp_client/mgcp_client.h
@@ -183,7 +183,9 @@
enum mgcp_codecs map_str_to_codec(const char *str);
unsigned int map_codec_to_pt(const struct ptmap *ptmap, unsigned int ptmap_len,
- enum mgcp_codecs codec);
+ enum mgcp_codecs codec) __attribute__((__deprecated__));
+unsigned int map_codec_to_pt2(bool *ptmap_used, const struct ptmap *ptmap,
+ unsigned int ptmap_len, enum mgcp_codecs codec);
enum mgcp_codecs map_pt_to_codec(struct ptmap *ptmap, unsigned int ptmap_len,
unsigned int pt);
diff --git a/include/osmocom/mgcp_client/mgcp_client_fsm.h b/include/osmocom/mgcp_client/mgcp_client_fsm.h
index ade4f49..0a5b8d5 100644
--- a/include/osmocom/mgcp_client/mgcp_client_fsm.h
+++ b/include/osmocom/mgcp_client/mgcp_client_fsm.h
@@ -35,8 +35,9 @@
/*! Number of codecs in RTP codec list (optional) */
unsigned int codecs_len;
- /*! RTP payload type map (optional, only needed when payload types are
- * used that differ from what IANA/3GPP defines) */
+ /*! RTP payload type map. This array may be used to assign a user defined payload type number to the codecs (see
+ * codecs array above). In case the same codec type (enum mgcp_codecs) is appearing multiple times in codecs.
+ * Then the order in ptmap must match the order in codecs. */
struct ptmap ptmap[MGCP_MAX_CODECS];
/*! RTP payload type map length (optional, only needed when payload
diff --git a/src/libosmo-mgcp-client/mgcp_client.c b/src/libosmo-mgcp-client/mgcp_client.c
index 5df4560..ee65706 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -138,6 +138,20 @@
unsigned int map_codec_to_pt(const struct ptmap *ptmap, unsigned int ptmap_len,
enum mgcp_codecs codec)
{
+ return map_codec_to_pt2(NULL, ptmap, ptmap_len, codec);
+}
+
+/*! Map a codec to a payload type (but not the same entry twice).
+ * \ptmap[inout] ptmap_used array of length ptmap_len to checkmark ptmap
+ * entries which are already used. Must be initialized with
+ * zeros before use. (optional, may be NULL).
+ * \ptmap[in] payload pointer to payload type map with specified payload types.
+ * \ptmap[in] ptmap_len length of the payload type map.
+ * \ptmap[in] codec the codec for which the payload type should be looked up.
+ * \returns assigned payload type */
+unsigned int map_codec_to_pt2(bool *ptmap_used, const struct ptmap *ptmap,
+ unsigned int ptmap_len, enum mgcp_codecs codec)
+{
unsigned int i;
/*! Note: If the payload type map is empty or the codec is not found
@@ -153,8 +167,16 @@
for (i = 0; i < ptmap_len; i++) {
/* Skip illegal map entries */
- if (check_ptmap(ptmap) == 0 && ptmap->codec == codec)
+ if (check_ptmap(ptmap) == 0 && ptmap->codec == codec) {
+ if (ptmap_used) {
+ if (ptmap_used[i])
+ goto skip;
+ else
+ ptmap_used[i] = true;
+ }
return ptmap->pt;
+ }
+ skip:
ptmap++;
}
@@ -179,7 +201,7 @@
* the mapping is also ignored and a 1:1 mapping is performed
* instead. */
- /* See also note in map_codec_to_pt() */
+ /* See also note in map_codec_to_pt2() */
if (pt < 96 || pt > 127)
return pt;
@@ -1280,6 +1302,10 @@
const char *codec;
unsigned int pt;
+ /* We may use statically allocated memory here since we intend to work only on mgcp_msg->ptmap arrays, which
+ * have a fixed length of MGCP_MAX_CODECS */
+ bool ptmap_used[MGCP_MAX_CODECS];
+
#define MSGB_PRINTF_OR_RET(FMT, ARGS...) do { \
if (msgb_printf(msg, FMT, ##ARGS) != 0) { \
LOGPMGW(mgcp, LOGL_ERROR, "Message buffer too small, can not generate MGCP message (SDP)\n"); \
@@ -1335,8 +1361,9 @@
MSGB_PRINTF_OR_RET("t=0 0\r\n");
MSGB_PRINTF_OR_RET("m=audio %u RTP/AVP", mgcp_msg->audio_port);
+ memset(ptmap_used, 0, sizeof(ptmap_used));
for (i = 0; i < mgcp_msg->codecs_len; i++) {
- pt = map_codec_to_pt(mgcp_msg->ptmap, mgcp_msg->ptmap_len, mgcp_msg->codecs[i]);
+ pt = map_codec_to_pt2(ptmap_used, mgcp_msg->ptmap, mgcp_msg->ptmap_len, mgcp_msg->codecs[i]);
MSGB_PRINTF_OR_RET(" %u", pt);
}
@@ -1344,11 +1371,12 @@
/* Add optional codec parameters (fmtp) */
if (mgcp_msg->param_present) {
+ memset(ptmap_used, 0, sizeof(ptmap_used));
for (i = 0; i < mgcp_msg->codecs_len; i++) {
/* The following is only applicable for AMR */
if (mgcp_msg->codecs[i] != CODEC_AMR_8000_1 && mgcp_msg->codecs[i] != CODEC_AMRWB_16000_1)
continue;
- pt = map_codec_to_pt(mgcp_msg->ptmap, mgcp_msg->ptmap_len, mgcp_msg->codecs[i]);
+ pt = map_codec_to_pt2(ptmap_used, mgcp_msg->ptmap, mgcp_msg->ptmap_len, mgcp_msg->codecs[i]);
if (mgcp_msg->param.amr_octet_aligned_present && mgcp_msg->param.amr_octet_aligned)
MSGB_PRINTF_OR_RET("a=fmtp:%u octet-align=1\r\n", pt);
else if (mgcp_msg->param.amr_octet_aligned_present && !mgcp_msg->param.amr_octet_aligned)
@@ -1356,8 +1384,9 @@
}
}
+ memset(ptmap_used, 0, sizeof(ptmap_used));
for (i = 0; i < mgcp_msg->codecs_len; i++) {
- pt = map_codec_to_pt(mgcp_msg->ptmap, mgcp_msg->ptmap_len, mgcp_msg->codecs[i]);
+ pt = map_codec_to_pt2(ptmap_used, mgcp_msg->ptmap, mgcp_msg->ptmap_len, mgcp_msg->codecs[i]);
/* Note: Only dynamic payload type from the range 96-127
* require to be explained further via rtpmap. All others
diff --git a/tests/mgcp_client/mgcp_client_test.c b/tests/mgcp_client/mgcp_client_test.c
index 37c5f6c..13bd879 100644
--- a/tests/mgcp_client/mgcp_client_test.c
+++ b/tests/mgcp_client/mgcp_client_test.c
@@ -624,6 +624,34 @@
printf("\n");
}
+static void test_map_codec_to_pt2_and_map_pt_to_codec(void)
+{
+ struct ptmap ptmap[10];
+ bool ptmap_used[10] = { 0 };
+ unsigned int ptmap_len;
+ unsigned int i;
+
+ ptmap[0].codec = CODEC_GSMEFR_8000_1;
+ ptmap[0].pt = 96;
+ ptmap[1].codec = CODEC_GSMHR_8000_1;
+ ptmap[1].pt = 97;
+ ptmap[2].codec = CODEC_AMR_8000_1;
+ ptmap[2].pt = 98;
+ ptmap[3].codec = CODEC_AMRWB_16000_1;
+ ptmap[3].pt = 99;
+ /* This would not work with map_codec_to_pt() as we already have an entry with CODEC_AMR_8000_1 in the list. */
+ ptmap[4].codec = CODEC_AMR_8000_1;
+ ptmap[4].pt = 100;
+ ptmap_len = 5;
+
+ /* Mappings that are covered by the table */
+ for (i = 0; i < ptmap_len; i++)
+ printf(" %u => %u\n", ptmap[i].codec, map_codec_to_pt2(ptmap_used, ptmap, ptmap_len, ptmap[i].codec));
+ for (i = 0; i < ptmap_len; i++)
+ printf(" %u <= %u\n", ptmap[i].pt, map_pt_to_codec(ptmap, ptmap_len, ptmap[i].pt));
+ printf("\n");
+}
+
void test_mgcp_client_e1_epname(void)
{
char *epname;
@@ -703,6 +731,7 @@
test_mgcp_client_cancel();
test_sdp_section_start();
test_map_codec_to_pt_and_map_pt_to_codec();
+ test_map_codec_to_pt2_and_map_pt_to_codec();
test_map_pt_to_codec();
test_mgcp_client_e1_epname();
diff --git a/tests/mgcp_client/mgcp_client_test.ok b/tests/mgcp_client/mgcp_client_test.ok
index 039fbd9..dcbb6fc 100644
--- a/tests/mgcp_client/mgcp_client_test.ok
+++ b/tests/mgcp_client/mgcp_client_test.ok
@@ -210,6 +210,17 @@
2 <= 2
100 <= 100
+ 110 => 96
+ 111 => 97
+ 112 => 98
+ 113 => 99
+ 112 => 100
+ 96 <= 110
+ 97 <= 111
+ 98 <= 112
+ 99 <= 113
+ 100 <= 112
+
ds/e1-1/s-15/su64-0@mgw
ds/e1-2/s-14/su32-0@mgw
ds/e1-3/s-13/su32-4@mgw
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/34349?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: Ie13ce59d3165936a16e16588b4d58f0ce7e0ae67
Gerrit-Change-Number: 34349
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-MessageType: newchange
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/34351?usp=email )
Change subject: mgcp_client_fsm: fix inconsistent API (param_present, param).
......................................................................
mgcp_client_fsm: fix inconsistent API (param_present, param).
The struct struct mgcp_conn_peer in mgcp_client_fsm.h (and the struct
struct mgcp_msg in mgcp_client.h) use a problematic way to hold
information about codec parameters: Using the struct member param, the
user can set options for AMR (octet-aligned/bandwith-efficient). This is
done using the struct mgcp_codec_param, which is also not very well
thought out. Since we can only set the parameters for AMR exactly once, it
is not possible to set different parameters when AMR occurs multiple times
in codecs.
Since what we would have needed is an array of struct mgcp_codec_param,
where we can set the parameters for each codec we use indvidually. So
let's depreacate the use of param/param_present and add a new struct
member codec_params/codec_params_present, where codec_params is an
array. Let's also re-define mgcp_codec_params as mgcp_codec_params2, and
use a union so that we can add params for other codecs than AMR in the
future.
Unfortunately mgcp_codec_params is also used in osmo-mgw, we should
migrate each occurrence of mgcp_codec_param to mgcp_codec_param2 there
too, but this should be done in a follow up patch.
Related: OS#5723
Change-Id: I50d737f3f3d45e4004c64101700a471fe75b3436
---
M TODO-RELEASE
M include/osmocom/mgcp/mgcp_common.h
M include/osmocom/mgcp_client/mgcp_client.h
M include/osmocom/mgcp_client/mgcp_client_fsm.h
M src/libosmo-mgcp-client/mgcp_client.c
M src/libosmo-mgcp-client/mgcp_client_fsm.c
6 files changed, 85 insertions(+), 8 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/51/34351/1
diff --git a/TODO-RELEASE b/TODO-RELEASE
index 69b38a9..582ec1b 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -25,4 +25,7 @@
#
#library what description / commit summary line
libosmo-mgcp-client NEW API mgcp_client_conf_alloc()
-libosmo-mgcp-client DEPRECATED mgcp_client_conf_init()
\ No newline at end of file
+libosmo-mgcp-client DEPRECATED mgcp_client_conf_init()
+libosmo-mgcp-client NEW API struct mgcp_conn_peer, added member, codecs_param_present and param
+libosmo-mgcp-client NEW API struct struct mgcp_msg, added member, codecs_param_present and param
+mgcp NEW API add struct struct mgcp_codec_param2, depreacte struct mgcp_codec_param
diff --git a/include/osmocom/mgcp/mgcp_common.h b/include/osmocom/mgcp/mgcp_common.h
index 7de45f9..ed90fad 100644
--- a/include/osmocom/mgcp/mgcp_common.h
+++ b/include/osmocom/mgcp/mgcp_common.h
@@ -59,12 +59,21 @@
MGCP_X_OSMO_IGN_CALLID = 1,
};
-/* Codec parameters (communicated via SDP/fmtp) */
+/* Deprecated: Codec parameters (communicated via SDP/fmtp) */
struct mgcp_codec_param {
bool amr_octet_aligned_present;
bool amr_octet_aligned;
};
+/* Codec parameters (communicated via SDP/fmtp) */
+struct mgcp_codec_param2 {
+ union {
+ struct {
+ bool octet_aligned;
+ } amr;
+ };
+};
+
/* Ensure that the msg->l2h is NUL terminated. */
static inline int mgcp_msg_terminate_nul(struct msgb *msg)
{
diff --git a/include/osmocom/mgcp_client/mgcp_client.h b/include/osmocom/mgcp_client/mgcp_client.h
index 4e54bbe..0757ce0 100644
--- a/include/osmocom/mgcp_client/mgcp_client.h
+++ b/include/osmocom/mgcp_client/mgcp_client.h
@@ -136,8 +136,10 @@
uint32_t x_osmo_ign;
bool x_osmo_osmux_use;
int x_osmo_osmux_cid; /* -1 is wildcard */
- bool param_present;
- struct mgcp_codec_param param;
+ bool param_present; /* Depreacted, please use codecs_param_present */
+ struct mgcp_codec_param param; /* Depreacted, please use codecs_param */
+ bool codecs_param_present; /* See also mgcp_client_fsm.h, struct mgcp_conn_peer */
+ struct mgcp_codec_param2 codecs_param[MGCP_MAX_CODECS]; /* See also mgcp_client_fsm.h, struct mgcp_conn_peer */
};
struct mgcp_client_conf *mgcp_client_conf_alloc(void *ctx);
diff --git a/include/osmocom/mgcp_client/mgcp_client_fsm.h b/include/osmocom/mgcp_client/mgcp_client_fsm.h
index 245e0a7..3e9a497 100644
--- a/include/osmocom/mgcp_client/mgcp_client_fsm.h
+++ b/include/osmocom/mgcp_client/mgcp_client_fsm.h
@@ -58,10 +58,16 @@
* address is set. If != MGCP_CONN_NONE, force this conn mode. */
enum mgcp_connection_mode conn_mode;
- /*! Global codec params. In case the codec requires additional format parameters (fmtp), those cann be set
- * here, see also mgcp_common.h. The format parameters will be applied on all codecs where applicable. */
+ /*! (deprecated, use codecs_param) Global codec params. In case the codec requires additional format parameters
+ * (fmtp), those cann be set here, see also mgcp_common.h. The format parameters will be applied on all codecs
+ * where applicable. */
bool param_present;
struct mgcp_codec_param param;
+
+ /* In case the codec requires additional format parameters (fmtp), those can be set here for each codec
+ * individually, see also mgcp_common.h. The index in codecs_param[] must match index as in codecs[]. */
+ bool codecs_param_present;
+ struct mgcp_codec_param2 codecs_param[MGCP_MAX_CODECS];
};
struct osmo_fsm_inst *mgcp_conn_create(struct mgcp_client *mgcp, struct osmo_fsm_inst *parent_fi, uint32_t parent_term_evt,
diff --git a/src/libosmo-mgcp-client/mgcp_client.c b/src/libosmo-mgcp-client/mgcp_client.c
index ee65706..21963ab 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -1370,7 +1370,10 @@
MSGB_PRINTF_OR_RET("\r\n");
/* Add optional codec parameters (fmtp) */
+ /* Never use mgcp_msg->param (deprecated) together mgcp_msg->param_present->codecs_param! */
+ OSMO_ASSERT(mgcp_msg->param_present != mgcp_msg->codecs_param_present);
if (mgcp_msg->param_present) {
+ LOGPMGW(mgcp, LOGL_DEBUG, "using depreacted struct member mgcp_msg->param, please use mgcp_msg->codecs_param!\n");
memset(ptmap_used, 0, sizeof(ptmap_used));
for (i = 0; i < mgcp_msg->codecs_len; i++) {
/* The following is only applicable for AMR */
@@ -1383,6 +1386,19 @@
MSGB_PRINTF_OR_RET("a=fmtp:%u octet-align=0\r\n", pt);
}
}
+ if (mgcp_msg->codecs_param_present) {
+ memset(ptmap_used, 0, sizeof(ptmap_used));
+ for (i = 0; i < mgcp_msg->codecs_len; i++) {
+ /* The following is only applicable for AMR */
+ if (mgcp_msg->codecs[i] != CODEC_AMR_8000_1 && mgcp_msg->codecs[i] != CODEC_AMRWB_16000_1)
+ continue;
+ pt = map_codec_to_pt2(ptmap_used, mgcp_msg->ptmap, mgcp_msg->ptmap_len, mgcp_msg->codecs[i]);
+ if (mgcp_msg->codecs_param[i].amr.octet_aligned)
+ MSGB_PRINTF_OR_RET("a=fmtp:%u octet-align=1\r\n", pt);
+ else
+ MSGB_PRINTF_OR_RET("a=fmtp:%u octet-align=0\r\n", pt);
+ }
+ }
memset(ptmap_used, 0, sizeof(ptmap_used));
for (i = 0; i < mgcp_msg->codecs_len; i++) {
diff --git a/src/libosmo-mgcp-client/mgcp_client_fsm.c b/src/libosmo-mgcp-client/mgcp_client_fsm.c
index 660f0ad..1d50b3f 100644
--- a/src/libosmo-mgcp-client/mgcp_client_fsm.c
+++ b/src/libosmo-mgcp-client/mgcp_client_fsm.c
@@ -107,6 +107,9 @@
static void make_crcx_msg(struct mgcp_msg *mgcp_msg, struct mgcp_conn_peer *info)
{
+ /* Never use info->param (deprecated) together with info->codecs_param! */
+ OSMO_ASSERT(info->param_present != info->codecs_param_present);
+
*mgcp_msg = (struct mgcp_msg) {
.verb = MGCP_VERB_CRCX,
.presence = (MGCP_MSG_PRESENCE_ENDPOINT | MGCP_MSG_PRESENCE_CALL_ID
@@ -116,12 +119,14 @@
.ptime = info->ptime,
.codecs_len = info->codecs_len,
.ptmap_len = info->ptmap_len,
- .param_present = info->param_present
+ .param_present = info->param_present,
+ .codecs_param_present = info->codecs_param_present
};
osmo_strlcpy(mgcp_msg->endpoint, info->endpoint, MGCP_ENDPOINT_MAXLEN);
memcpy(mgcp_msg->codecs, info->codecs, sizeof(mgcp_msg->codecs));
memcpy(mgcp_msg->ptmap, info->ptmap, sizeof(mgcp_msg->ptmap));
memcpy(&mgcp_msg->param, &info->param, sizeof(mgcp_msg->param));
+ memcpy(&mgcp_msg->codecs_param, &info->codecs_param, sizeof(mgcp_msg->codecs_param));
if (info->x_osmo_ign) {
mgcp_msg->x_osmo_ign = info->x_osmo_ign;
@@ -153,6 +158,9 @@
{
struct mgcp_msg mgcp_msg;
+ /* Never use mgcp_ctx->conn_peer_local->param (deprecated) together with mgcp_ctx->conn_peer_local->codecs_param! */
+ OSMO_ASSERT(mgcp_ctx->conn_peer_local.param_present != mgcp_ctx->conn_peer_local.codecs_param_present);
+
mgcp_msg = (struct mgcp_msg) {
.verb = MGCP_VERB_MDCX,
.presence = (MGCP_MSG_PRESENCE_ENDPOINT | MGCP_MSG_PRESENCE_CALL_ID | MGCP_MSG_PRESENCE_CONN_ID |
@@ -165,12 +173,14 @@
.ptime = mgcp_ctx->conn_peer_local.ptime,
.codecs_len = mgcp_ctx->conn_peer_local.codecs_len,
.ptmap_len = mgcp_ctx->conn_peer_local.ptmap_len,
- .param_present = mgcp_ctx->conn_peer_local.param_present
+ .param_present = mgcp_ctx->conn_peer_local.param_present,
+ .codecs_param_present = mgcp_ctx->conn_peer_local.codecs_param_present
};
osmo_strlcpy(mgcp_msg.endpoint, mgcp_ctx->conn_peer_remote.endpoint, MGCP_ENDPOINT_MAXLEN);
memcpy(mgcp_msg.codecs, mgcp_ctx->conn_peer_local.codecs, sizeof(mgcp_msg.codecs));
memcpy(mgcp_msg.ptmap, mgcp_ctx->conn_peer_local.ptmap, sizeof(mgcp_msg.ptmap));
memcpy(&mgcp_msg.param, &mgcp_ctx->conn_peer_local.param, sizeof(mgcp_ctx->conn_peer_local.param));
+ memcpy(&mgcp_msg.codecs_param, &mgcp_ctx->conn_peer_local.codecs_param, sizeof(mgcp_ctx->conn_peer_local.codecs_param));
set_conn_mode(&mgcp_msg, &mgcp_ctx->conn_peer_local);
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/34351?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I50d737f3f3d45e4004c64101700a471fe75b3436
Gerrit-Change-Number: 34351
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-MessageType: newchange