The recent bug with chopped-off point codes in SCCP Address handling
has shown that this code could need proper test cases. This patch
adds a testsuite for SCCP address encoding and decoding.
Related: OS#2441
Change-Id: I612352736ab33462ca0dd97798a2c437eadccb86
Log errors in case the user provides global title indicators or
nature-of-address indicators that exceed the permitted value range
Change-Id: I493b7810bdc58e448f496565ded36f9dce2c1226
In osmo_sccp_addr_encode(), we accidentially truncated all point
codes to 10 bits, where in reality we should have truncated them to
14 bits: One 'f' was missing in the bit-mask.
Closes: OS#2441
Change-Id: Iad67b674b5b5fd41996aa898a131e98900842dd8
Since the NI is in bits DC, not BA, it needs to be shifted by 6, not 4, to end
up in the two most significant bits. Also, NI is two bits wide, hence & 0x3.
(The m3ua.c side of this is already correct.)
See ITU-T Recommendation Q.704 (07/96), 14.2 "Service information octet".
Before this patch, NI was always sent as 00 == International regardless of the
VTY configuration.
This patch was verified to work by a wireshark trace of osmo-bsc connecting to
osmo-msc, showing the NI decoded as configured by an osmo-bsc.cfg file in the
BSSMAP Reset message MTP 3 / Protocol data.
Change-Id: I7bb4eb6518a1e0d74313bda776d2a6acd0b02e1b
Make sure doxygen generates library documentation by default (can be
disabled at compile time).
Change-Id: I2bf7438bcdde19dc88b9bc14c8ad9c8f49099f8a
Related: OS#2572
libosmo-sigtran is using symbols from libosmo-vty, so make sure that
we explicitly link against libosmo-vty to ensure the dependency shows
up in `ldd` of the library.
Change-Id: I4d96612a0df5a1232ed8fe280c5d592f462ef7b1
If the user does not create an AS, but creates an ASP with a name
that is equal to the default name, then the simple client detects
that and trys to use this ASP. However, unfortunately it then
overwrites the settings of the ASP with the default settings.
If the detected ASP is not created by the simple client, use it,
but preseve the settings of that ASP.
Change-Id: I53d73059f804c3bbea6cb43dc73ad49a753b3b15
We can set the ASP's remote IP (i.e. where to reach osmo-stp), but so far the
only way to specify the local IP address to bind to can only be set from C code
(e.g. the simple client). Allow setting the local address via VTY.
For example, this is desired for the osmo-gsm-tester, to not use arbitrary IP
addresses.
Change-Id: I3f71897dfacafcf3126e51894d6ca756b02dcd7d
* BSSAP is 254 on both MSC and BSC side: Add missing define
* BSSAP-LE (LCS Extension) has 250/251, adjust name to add -LE suffix
Change-Id: Iccec75cfc0cf16bd717a9bd4606d1e772c332ccc
In commit eed8c1bfae we introduced
some singal handling code for (among others) SIGINT and SIGTERM.
This code causes the process to hang rather than terminate, as it
only dispatches a signal that nobody handles yet in libosmo-sccp.
Until a proper implementation is made, let's terminate the process
as expected.
Change-Id: Iff79c8ac0b347660333912c9258073a013ea799b
The previous fix (I312caf9d54cedb02034e4ef88fdd2e6ad9ca1c34) caused the default
addresses to be discarded. Actually talloc_strdup() the default addresses to
use them if not NULL.
Change-Id: Ic8563ab272d5256a1b8ceefd5fee37da61e1bd26
The VTY definition for this command is flawed and breaks osmo-msc VTY tests.
The small problem is a stray '}' in the definition, the bigger problem is that
square brackets indicating optional arguments must not enclose more than one
argument.
Split up the command in several separate definitions with si arg, with ssn arg,
with both, and with neither.
If si and/or ssn are not passed, set them to zero.
See https://lists.osmocom.org/pipermail/openbsc/2017-August/011026.html
"optional vty items are stricter than expected"
Change-Id: Idc68bfae5457960a9eae5d9648586d6ce719ad68
A doc element is missing, which fails the VTY tests in osmo-msc at Change-Id
I5ae4e05ee7c57cad341ea5e86af37c1f6b0ffa77.
Change-Id: I16aa74244ed5332bdc1fddd538e17b86f62ec3b2
When the server (STP) disappears from a live SCCP client,
then the xUA default layer manager receives LM_E_SCTP_DISC_IND,
which is traversing retart_asp(). In there, we first terminate
the current instance of the layer manager FSM, and then re-initialize
the ASP to use the default layer manager using
osmo_ss7_asp_use_default_lm().
However, osmo_ss7_asp_use_default_lm() uses the presence of an
asp->lm_priv pointer as a sign that the old layer manager is still
running and attempts to terminate it - despite being terminated
just before in restart_as().
So let's simply remove the termination from restart_asp(), and
leave it to osmo_ss7_asp_use_default_lm().
Fixes: OS#2402
Change-Id: I062d3af17539de864b56d079fe9b8d76ad99cf1e
The asp->cfg.remote.host is allowed to be NULL in cases where the
localhost is used.
Check if asp->cfg.remote.host is NULL when writing the config file
and omit it when it is set to NULL.
Change-Id: I18f79cc4d4f1db8f2858e8e95098c5821d50594f
osmo_sccp_get_ss7() has the risk of a nullpointer dereference, when
sccp is NULL.
Return NULL when the sccp instance is NULL.
Add doxygen comment
Change-Id: I84d484e4441fd37443fff8c67e17df8fb15d5b2e
It is currently impossible to find out which SCCP instance handles
a particular user.
Introduce function to lookup the SCCP instance from a given SCCP
user.
Change-Id: I9562c4f1d00e2ebb3252c5dea598b643aa393719
osmo_sccp_addr_name() is not listed in any header file.
Add osmo_sccp_addr_name() to sccp_helpers.h in order to make
it available.
Change-Id: I092dd55948faeeff78f28f7d50c5b84b9e69ef24
Some of the functons in sccp_user.c have already
doygen comments on them.
Add doxygen comments for the simple client functions as well
Change-Id: I9143bdc54d729f9f50e69fe38cd1798e065f2497
The point-code is not checked in the beginning, only the ASP
checks the point code at a very late stage and fails in case
an invalid point-code is detected.
Remove the check in the ASP creation.
Add a new check after the SS7 initalization that checks the
point-code. If none is set, the default point-code will be
used.
Change-Id: I334d90e769bd9952f67c51b12a945f22bd268fa8
When the default IP addresses (remote or local) the respective
struct value should be set to NULL.
Fix wrong ?:-notation.
Change-Id: I312caf9d54cedb02034e4ef88fdd2e6ad9ca1c34
The simple client takes certain parameters (pc, ip and port
numbers) which serve as a fallback default in case the user
did not configure any suitable parameters via the VTY.
Prefix all default variables with default_ to make the
purpose clear to the API user
Change-Id: Id9e697e8b198e4f58a79e59aaf2e649e84a3eb63
Make sure that all values of the resulting sccp_addr are cleared to obtain a
clean PC+SSN address. Before this, gt and ip remained unset/random, e.g. in
osmo_sccp_tx_unitdata_ranap()
Change-Id: I37395169d364050e45e99793c495a9848a4f8601
The SG (signal gateway) requires an extra set of VTY commands in
order to be fully configurable. These VTY commands do not make
sense in a situation where libosmo-sccp is used to implement an
ASP (application server process).
Detect in which role libosmo-sccp is used by which of the VTY
initalization functions are called:
osmo_ss7_vty_init_asp() ==> ASP
osmo_ss7_vty_init_sg() ==> SG
Prevent writing back of SG specific configuration when in
running as ASP. Only write back the full parameter set when
running as SG.
Change-Id: I707bcd790f4c6d0f618e41163b51d2179ea3aeaf
The simple client (osmo_sccp_simple_client_on_ss7_id() and
osmo_sccp_simple_client) does not create a default route if
the user has already created an AS via VTY.
Check the presence of a default route independently of the
AS. If no default route exists, create one.
Change-Id: I7516fa5509bade4ba10e9d8eaa3e46cfe3696b3a
osmo_sccp_addr_dump() just prints the raw values. In osmo_sccp_addr_name(), use
osmo_ss7_pointcode_print() and newly added RI, SSN and GT value_string[] to
print more human readable log output.
Change-Id: Ie1aedd7894acd69ddc887cd65a8a0df4b888838c
Allows to automatically set an RI in future change
I75c67d289693f1c2a049ac61cf2b2097d6e5687d
"sccp-addr vty: set RI to SSN_PC when setting a point-code"
Change-Id: I6e2f31b023b08cba2f2ee8234e6108efcaca41c0
A previous patch added ss7_instance primary_pc validity checks by means of
OSMO_SS7_PC_INVALID. To be consistent, also adjust sccp_user accordingly.
(see I7f0f0c89b7335d9da24161bfac8234be214ca00c)
Remove the osmo_sccp_user's pc_valid field, replaced by pc=OSMO_SS7_PC_INVALID.
Adjust all code paths.
Simplify some log printing, using the fact that osmo_ss7_pointcode_print() now
outputs "(no PC)" for unset point codes.
Change-Id: I8684c9b559712072c772012890bbf7efa7c8eb35
Initialize osmo_ss7_instance.cfg.primary_pc = OSMO_SS7_PC_INVALID.
Adjust all code paths using primary_pc to ensure it is indeed valid.
Rationale:
It looks like we are going to use the primary point-code of an SS7 instance to
derive a local SCCP address, e.g. for osmo-bsc and osmo-hnbgw.
cs7-instance 1
point-code 1.2.3 ! sets osmo_ss7_instance.primary_pc = 1.2.3
sccp-address msc
point-code 0.0.1
routing-indicator PC
hnb
iucs
remote-addr msc ! derives cs7 instance 1 and local pc 1.2.3
If 'point-code 1.2.3' is omitted, this becomes '0.0.0' without the user
noticing, and this happens for each client that omits it. I would like to barf
when no local PC is set.
Change-Id: I7f0f0c89b7335d9da24161bfac8234be214ca00c
Introduce OSMO_SS7_PC_INVALID to mark an unset point code.
Add static osmo_ss7_pc_is_valid() (name matches schema of
osmo_ss7_pc_is_local()).
In osmo_ss7_pointcode_print(), return "(no PC)" if !osmo_ss7_pc_is_valid(), for
convenient printing of any PC state.
Subsequent patches will use this for
osmo_ss7_instance (I7f0f0c89b7335d9da24161bfac8234be214ca00c)
as well as osmo_sccp_user (I8684c9b559712072c772012890bbf7efa7c8eb35).
Rationale:
Currently, in osmo_ss7_vty.c we had "if (inst->cfg.primary_pc)" suggesting 0 is
invalid, but in struct osmo_sccp_user we have flag pc_valid suggesting 0 is
indeed valid. All known point code formats are <= 24bit, so we can easily use
0xffffffff as indicator for an unset PC, which removes the need to remember to
set a second field for validity and keeps the structs nice and lean.
Change-Id: Ib5715bf03a4de7713a7a809dfd821c700255ba8c
In order to catch invalid CS7 configurations, It is necessary
to check if sccp addresses contain plausible address data.
Change-Id: Ic6245288b0171eae10aa708403c1ddb584c92f38
Drop the separate osmo_ss7_set_vty_alloc_ctx() because we are likely to forget
calling it. Instead, incorporate into osmo_ss7_vty_init_*() with a new ctx arg,
and set the static context var in vty_init_shared().
Change-Id: Id4e7f47979001f7856b0b3665c9e94982e75e490
The most important parts of an SCCP address are the routing
indicator and the pointcode. The latter one is always available
via the SS7 instance, so a basic local address can be derived
from there.
Add function osmo_sccp_local_addr_by_instance() to derive a basic
local SCCP address from a given SCCP instance
Change-Id: I371dc9132871aad3d8321ea13cf9fd69d76eff8f
check input parameters local_ip and remote_ip of the function
osmo_sccp_simple_client_on_ss7_id() before using them with
talloc_strdup()
Change-Id: I1a5dd1ea3167513bf9e7ae153f83e1ae3136c905
It is possible to add two (or more) different
sccp-addresses under the same name, when the
addresses are defined in different cs7 instances.
Add a check to make sure an address name is not
used multiple times
Change-Id: I63227cd87bc24f7d9ac995430b869f0393818335
The function seems osmo_ss7_asp_use_default_lm() does not guard
against an asp->lm_priv FSM instance already existing. If this
function is called a second time, it will overwrite asp->lm_priv,
causing the original fsm instance to leaked.
Check if asp->lm_priv already exists and terminate (free) the
FSM if present.
Change-Id: I4ad435c042a435c4e641c6e5c53b91265dd23d40
The osmo_sccp_simple_client_on_ss7_id and osmo_sccp_simple_client
are not entirely configurable via VTY commands. The relation to
the VTY is implicit. The user may set up instance objects via
VTY (cs7/ss7, AS, ASP), which are then automatically created on
startup.
Each cs7 instance gets its own ID via the VTY configuration. When
osmo_sccp_simple_client_on_ss7_id() is called with the cs7 instance
id. (for osmo_sccp_simple_client() the ID will be hardcoded to 1),
the function automatically checks if the CS7 instance is present,
if not it will create one automatically using the caller supplied
parameters as a defult. If a CS7 instance is present, the function
checks for the presence of an AS and an ASP. These objects are
present, they will be used. If not, new objects will be created.
Both functions must not be called if an SCCP instance is already
present. Since there can only be one SCCP instance per CS7 instance,
this is an error condition.
Add additional logic that checks to detect an already existing, valid
configuration. If no or an insufficient configuration is detected,
use the caller supplied parameters as default configuration.
Change-Id: I293f3526ce6182dca74a169a23449dbc7af57c7c
The sccp-addressbook only allows defining addresses for a specific
ss7 instance. It is not possible to use an sscp-address, that is
defined in the one ss7 instance in another ss7 instance.
Add a second global list where all sscp-addresses are added,
regardless on which instance they are defined.
Fixup the search functions so that they always search the global
list.
Change the API, so that the address data is written to a
destination pointer. This protects the stored address from
unintentional changes. Also return the ss7 instance, where the
address is associated with.
Change-Id: I5acc1e5abc3b3081149a9f476038e4e53d23b763