GSUP: include terminating nul in inter-MSC source/destination name

Before, I was testing with osmo-hlr patch
I01a45900e14d41bcd338f50ad85d9fabf2c61405 applied, but that patch is currently
in an abandoned state.

This is the counterpart implemented in osmo-msc: always include the terminating
nul char in the "blob" that is the MSC IPA name.

The dualities in the formats of routing between MSCs is whether to handle it as
a char*, or as a uint8_t* with explicit len (a blob).

In the VTY config to indicate target MSCs for inter-MSC handover, we have
strings. We currently even completely lack a way of configuring any blob-like
data as a VTY config item.

In osmo-hlr, the IPA names used for routing are currently received as a char*
which *includes* the terminating nul char. So in osmo-msc, if we also always
include the nul char, it works.

Instead, we could just send the char* part without the nul char, and apply
above mentioned osmo-hlr patch. That patch would magically match a name that
lacks a nul with a name that includes one. I think it is better to agree on one
format on the GSUP wire now, instead of making assumptions in osmo-hlr on the
format of the source/target names for routing. This format, from the way GSUP
so far transmits the IPA SERNO tag when a client attaches to osmo-hlr, happens
to include the terminating nul char.

Change-Id: I9ca8c9eef104519ed1ea46e2fef46dcdc0d554eb
Neels Hofmeyr 4 years ago
parent c4628a3ad4
commit e27fa15022
  1. 21

@ -68,6 +68,7 @@ struct e_link *e_link_alloc(struct gsup_client_mux *gcm, struct osmo_fsm_inst *m
struct e_link *e;
struct msc_role_common *c = msc_role->priv;
size_t use_len;
/* use msub as talloc parent, so we can move an e_link from msc_t to msc_i when it is established. */
e = talloc_zero(c->msub, struct e_link);
@ -76,13 +77,19 @@ struct e_link *e_link_alloc(struct gsup_client_mux *gcm, struct osmo_fsm_inst *m
e->gcm = gcm;
/* Expecting all code paths to print the remote name according to remote_name_len. To be paranoid, place a nul
* character after the end. */
e->remote_name = talloc_size(e, remote_name_len + 1);
/* FIXME: this is a braindamaged duality of char* and blob, which we can't seem to get rid of easily.
* See also osmo-hlr change I01a45900e14d41bcd338f50ad85d9fabf2c61405 which resolved this on the
* osmo-hlr side, but was abandoned. Not sure which way is the right solution. */
/* To be able to include a terminating NUL character when sending the IPA name, append one if there is none yet.
* Current osmo-hlr needs the terminating NUL to be included. */
use_len = remote_name_len;
if (remote_name[use_len-1] != '\0')
e->remote_name = talloc_size(e, use_len);
memcpy(e->remote_name, remote_name, remote_name_len);
e->remote_name[remote_name_len] = '\0';
e->remote_name_len = remote_name_len;
e->remote_name[use_len-1] = '\0';
e->remote_name_len = use_len;
e_link_assign(e, msc_role);
return e;
@ -123,9 +130,9 @@ int e_prep_gsup_msg(struct e_link *e, struct osmo_gsup_message *gsup_msg)
*gsup_msg = (struct osmo_gsup_message){
.source_name = (const uint8_t*)local_msc_name,
.source_name_len = strlen(local_msc_name),
.source_name_len = strlen(local_msc_name)+1, /* include terminating nul */
.destination_name = (const uint8_t*)e->remote_name,
.destination_name_len = e->remote_name_len,
.destination_name_len = e->remote_name_len, /* the nul here is also included, from e_link_alloc() */
if (vsub)