Commit Graph

549 Commits

Author SHA1 Message Date
Neels Hofmeyr 603e065f43 add osmo_sccp_addr_name() and three value_string[]s
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
2017-08-09 13:54:44 +02:00
Neels Hofmeyr c881c49127 introduce OSMO_SCCP_RI_NONE to indicate unset RI
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
2017-08-09 13:54:44 +02:00
Neels Hofmeyr 775ac6f6b1 constify ss7_instance arg of osmo_ss7_pointcode_print()
Change-Id: I8c6b7188d004033e75e9c41f4a65c418d13a79c5
2017-08-09 13:54:44 +02:00
Neels Hofmeyr a212398f7c consistency: use OSMO_SS7_PC_INVALID for osmo_sccp_user
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
2017-08-09 13:54:44 +02:00
Neels Hofmeyr b352ca030d ensure valid primary_pc in osmo_ss7_instance
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
2017-08-09 13:54:44 +02:00
Neels Hofmeyr b711e14504 add OSMO_SS7_PC_INVALID, add osmo_ss7_pc_is_valid()
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
2017-08-09 13:53:26 +02:00
Philipp Maier 81a029a4e4 sccp: add function to check sccp addresses
In order to catch invalid CS7 configurations, It is necessary
to check if sccp addresses contain plausible address data.

Change-Id: Ic6245288b0171eae10aa708403c1ddb584c92f38
2017-08-09 09:53:35 +00:00
Neels Hofmeyr 41b6803fd5 osmo_ss7_vty_init: ensure a talloc ctx is set by user
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
2017-08-07 16:04:39 +02:00
Neels Hofmeyr 473048d0d2 add osmo_sccp_addr_set_ssn()
Will be used by e.g. osmo-hnbgw to add an SSN to addresses obtained from the
sccp address book.

Change-Id: I85b46269dbe7909e52873ace3f720f6292a4516c
2017-08-07 16:04:39 +02:00
Philipp Maier 882f340b6c sccp: derive local address from given sccp instance
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
2017-08-01 11:08:05 +00:00
Installation Owner 738756984f sccp: fix possible nullpointer deref
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
2017-07-31 11:56:03 +02:00
Philipp Maier b06c887cf0 sccp: ensure addressbook entry names are unique
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
2017-07-26 15:14:49 +00:00
Philipp Maier dcb360a9db xua: fix possible memory leak in seems osmo_ss7_asp_use_default_lm()
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
2017-07-22 09:08:13 +00:00
Philipp Maier dae7491c14 sccp: make simple client configurable via VTY
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
2017-07-22 09:08:13 +00:00
Philipp Maier 9fc351de69 sccp: global addressbook search + api fix
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
2017-07-20 12:38:37 +02:00
Philipp Maier 2b74a5fdc0 cosmetic: remove comment
The vty command string already says it all, remove the comment entirely.

Change-Id: I8ecad584a1bc9b97693b199abd1ec2e5f6ce156d
2017-07-20 10:40:31 +02:00
Philipp Maier 6823dd9f44 vty: make addressbook available for _sg and _asp
The installation of the vty commands for the sccp addressbook is
currently located in osmo_ss7_vty_init_sg(), which is normally
only used in signalling gateway applications. An ASP would lack
the addressbook functionality.

Make SCCP addressbook available for both SG and ASP

Change-Id: Ib49ab623055e9ada7f95e0163ba7e33c5f6f99cb
2017-07-19 12:08:18 +00:00
Harald Welte e29888ab69 jenkins.sh: Proper error message if local environment isn't set up
Change-Id: I79c2302365824d9c8783dadfa378c8eaa07e2ee7
2017-07-10 15:01:03 +02:00
Pau Espin f356131808 contrib: Enable -Werror by default
Change-Id: I16a8ca7f0bfabeed6a9b58cda5e60bd58889f74d
2017-07-08 10:46:31 +00:00
Pau Espin eebbec23a5 sccp_scoc: Fix compilation warning and leave a pragma message
Following warning was being printed:
warning: statement will never be executed [-Wswitch-unreachable]

The code in there seems not to be finished, so better leave the code and a
pragma message to get notified when we compile.

Change-Id: I4e2c482803954c984cb6792b11b4ea0fe674e269
2017-07-08 10:46:31 +00:00
Pau Espin 698045d205 sccp_scoc: Fix trailing whitespace
Change-Id: Ia93bb7d59e4e2c31b693e2c3424d34386762d02e
2017-07-08 10:46:31 +00:00
Pau Espin d59ed0b3b4 configure.ac: Fix C(PP)FLAGS for BSD build
Issue first found in libosmocore. It seems the BSD build doesn't use
bash which means using += to append to a variable doesn't work
correctly.

Change-Id: I33f6b9de4990de0c4d3a6fc0bd7df632094e79ac
2017-07-08 10:46:31 +00:00
Philipp Maier 4f30f785c8 vty: Check returncode of osmo_ss7_pointcode_parse()
The result of osmo_ss7_pointcode_parse() is currently not
checked. This means that -EINVAL could end up as value
in the pointcode configuration.

Check the return code of osmo_ss7_pointcode_parse() and
exit the VTY command with CMD_WARNING if the returned
pointcode is < 0

Change-Id: Iae6d92b1d135063dfd0a26bc23a89802cb3b1a78
2017-07-07 10:11:35 +02:00
Philipp Maier cbb7b79e19 simple-client/server: be able to decide on which ss7 instance to bind
osmo_sccp_simple_client() and osmo_sccp_simple_server() are binding
on the ss7 instance with the id 1 by default. If the instance does
not exist, it is created automatically.

Allow choosing the ss7 instance by supplying the id number as
function parameter. Add two new functions:

osmo_sccp_simple_client_on_ss7_id()
osmo_sccp_simple_server_on_ss7_id()

Change-Id: I62e608253212415bddbb4c7dcf5d3b5e79c8d28e
2017-07-05 13:41:28 +02:00
Neels Hofmeyr 4313bdfa20 sccp_helpers.h: remove duplicate declaration of osmo_sccp_make_addr_pc_ssn()
Change-Id: Ifbb03de3df3b9bac86fb97dfc8e81e99fc172292
2017-06-29 19:56:31 +02:00
Neels Hofmeyr 6df7a4a6ee fix compiler warning: xua_test: hexdump pointer type
Was recently introduced by a70b4599f6.

Change-Id: Iab5529f6919fd22902a8b39e8a52079f08deb851
2017-06-29 17:52:08 +00:00
Neels Hofmeyr 81c0bcab06 Revert "SCOC: When sending a CORE/CR, SUA SRC_ADDR == CallingPartyAddress"
This reverts commit 5527df78ad.

I tried some time to figure out what other changes are needed to make this
commit work and fix a confusion, until I noticed:

The commit's *log message* is correct that SRC == calling, but the *patch*
modifies callED addr to be the SRC, which is wrong. So reverting this commit is
indeed the correct way to fix our addresses.

Change-Id: Ic76aacc81f87f8885fe04121aead5c79a761ef07
2017-06-27 21:25:03 +00:00
Neels Hofmeyr 38d2aabd4a sccp_user.c: add missing error logging
Change-Id: I98e400e297f8fa83037a8e74a936e4ecc137099c
2017-06-25 22:35:05 +02:00
Neels Hofmeyr c5b26c9959 gen_mtp_transfer_req_xua(): add addr to error log for missing DPC
Change-Id: Icfd45bcbecc440b94893db2aca537a162f210abd
2017-06-25 22:35:05 +02:00
Neels Hofmeyr 3468d5dce4 add/tweak various logging to help figure out complex routing
Add function osmo_ss7_point_code_print2() to be able to print two point codes
in the same log message.

Change signatures of two static functions to aid logging:
add invalid ref arg to sccp_scoc_rx_inval_src_ref(),
pass conn instead of inst to sccp_scoc_rx_inval_opc().

Change-Id: Ia3243606d6cad7721f7da7f6caba2caa90ae2bbd
2017-06-25 22:35:01 +02:00
Neels Hofmeyr 4e015f6664 cosmetic: drop second ';;'
Change-Id: I861b87e485d94f17e4b4a800c8da865f98633c92
2017-06-23 14:21:14 +00:00
Neels Hofmeyr a70b4599f6 fix sanitize make check: xua_test: initialize gt_out.
The sanitize build fails because gt_out is not initialized to zero, but is
later mem-compared to a zero-initialized struct.

Zero-initialize gt_out.

Also print in the test output both byte dumps. It helped to figure out the test
failure and might as well stay.

Change-Id: Ice8ee9c2a6bde4924f3ae6d95aa9268ebef9f070
2017-06-23 03:21:24 +02:00
Philipp Maier 4248838327 ss7: Fix compilation error (warning)
In osmo_ss7_route_create() as is only initalized if lset can not
be initalized. If lset can be initalized, as will not be used so
everything is fine. However, the compiler complains that as may
not be initalized. Initalizing as to NULL solves the problem.

Change-Id: Ibcb3ebf9aaa7717cb553242517abce1499bc9c2a
2017-06-22 22:47:45 +00:00
Neels Hofmeyr fa3215618b Revert "configure.ac: Use -Werror in C(PP)FLAGS"
As discussed in chat, -Werror should not be enabled by default.
Instead it should be added in our jenkins build scripts.

This reverts commit fc252ca384.

Change-Id: I92955c2f74f9a5c40e80028459100cf5e79a537b
2017-06-22 21:35:12 +00:00
Holger Hans Peter Freyther 483bf42f45 sccp: Fix a classic typo of mine
Change-Id: Ie1194406d9d9c62a513fac35ffa458957809a0e3
2017-06-22 06:46:32 +00:00
Pau Espin fc252ca384 configure.ac: Use -Werror in C(PP)FLAGS
Change-Id: Ia753a3080ef54ac248dacce5cd692fdd38f7649a
2017-06-22 06:23:04 +00:00
Pau Espin e32bff4ef4 configure.ac: Use -Wall in C(PP)FLAGS
Change-Id: I1e49427b8267bbdb05d0121971a56359dbecd690
2017-06-22 06:23:04 +00:00
Pau Espin 19c5c07525 xua_test.c: remove useless keyword in struct declaration
Fixes following warning:
warning: useless storage class specifier in empty declaratio

Change-Id: I5cea7b6ec2cc755ad8cec69b771f6e3b297e607d
2017-06-22 06:23:04 +00:00
Pau Espin 2abc1d5c7f stp_main.c: Add missing header
stp_main uses osmo_fsm_vty_add_cmds which is defined in /osmocom/vty/misc.h

Fixes 'implicit declaration of function' compilation warning.

Change-Id: I3cc9543fcb908eeb172d36fa472a19b01bf52c46
2017-06-22 06:23:04 +00:00
Pau Espin ad7fbd9b4d xua_internal.h: Add missing functions required by xua_test
Change-Id: Ic97de20c567bf67c513a45060e1e96e4b67b2311
2017-06-22 06:23:04 +00:00
Pau Espin f04e2f31ea sccp_test_vty: Fix compilation warning: Unused variable
Instead of removing the variable, leave it there with unused attribute
set because it is an example and gives extra information to potential
readers of the function (it provides you with the actual type of void* _scu).

Change-Id: Id5fddf261a7a75ee1d6e9aff0734065ebf8551ab
2017-06-22 06:23:04 +00:00
Pau Espin b1510a1122 sccp_scrc: Fix warning: uneeded constant evaulation
translate function is always present in the same file, thus we can
remove this check.

Fixes following warning:
warning: the address of ‘translate’ will always evaluate as ‘true’ [-Waddress]
    if (translate &&

As requested by Harald, leave a comment there stating that there are some
checks missing and yet to be implemented. The translate function check
was used for this purpose.

Change-Id: I48a711f3a43496e2c0c637f34f56784f765938c4
2017-06-22 06:23:04 +00:00
Philipp Maier 34cb3c16a5 sccp: add addressbook functionality for sccp addresses
SCCP addresses are defined through a number of compoinents, not
just an IP-Address, there is also point code, ssn and more. To
simplify and unify the handling of such objects, this patch
introduces an addressbook functionality. The user can set up
multiple addresses per ss7 instance and give them names. Later
that name can be used to reference the address at a later point
in the config. This means that the usage of sccp-addresses from
the programmers point of view boils down to a VTY function that
reads the string name of a previously defined address. The
programmer can then use the API to get a pointer to the SCCP
address struct and use it normally.

For this feature, two additional VTY nodes are necessary,
this commit depends libosmocore change:
Change-Id I42aa29c0cccc97f284b85801c5329b015b189640

Change-Id: I068ed7f7d113dab88424a9d47bab7fc703bb7942
2017-06-21 18:02:05 +02:00
Philipp Maier 144f5912eb cosmetic: Fix typo in sccp_types.h
change
SCCP_RETURN_CAUSE_SEGMENTATION_FAOLURE

to
SCCP_RETURN_CAUSE_SEGMENTATION_FAILURE

Change-Id: I34f767234f677307bb04891b40f03109901c0f1b
2017-06-18 08:46:23 +00:00
Philipp Maier b781b371fc cosmetic: fix typo in osmo_ss7_vty.c VTY doc
Change-Id: I931ccf6f765d4fe916ea94bde704314561e4537c
2017-06-18 02:03:25 +00:00
Harald Welte 4c9041b9d3 stp: Add test scripts for executing m3ua-testtool and sua-testtool
You will need to have
* GNU/Linux with support for [network] namespaces
* the 'unshare' command line tool
* m3ua-testtool and sua-testtool repositories
  from git.osmocom.org/nplab installed adjacent to libosmo-sccp
* their requirements, i.e.
** guile
** guile-sctp from https://github.com/nplab/guile-sctp

When those are installed, you can do things like

(cd contrib/test && ./run-in-ns.sh test-m3ua.sh)
(cd contrib/test && ./run-in-ns.sh test-sua.sh)

to execute the test suite.

Change-Id: Ic36eafbb9868b2ec9ae2173f8d1b651b976ccf88
2017-05-14 22:59:33 +02:00
Harald Welte 872c6b2a8e SUA-to-SCCP: Fix use of Called/Calling vs. Src/Dest Address
SUA uses different semantics (source / destination) address, while SCCP
uses Calling/CalledParty. This leads to some confusion.  At least in the
CR/CORE and CREF/COREF case, the CallingParty equals the SRC_ADDR.

Change-Id: I1c641aac7b53c6de7c4e369aaf3004523bd85936
2017-05-04 09:07:21 +02:00
Harald Welte 5527df78ad SCOC: When sending a CORE/CR, SUA SRC_ADDR == CallingPartyAddress
SUA uses different semantics (source / destination) address, while SCCP
uses Calling/CalledParty. This leads to some confusion.  At least in the
CR/CORE case, the CallingParty equals the SRC_ADDR.

Change-Id: I5a3c27b112148dd539f092cce7618b4f62fde73c
2017-05-04 09:07:21 +02:00
Harald Welte b354652502 osmo_sccp_addr_parse() Fix point code integer precision handling
"(cur[1] << 8) & 0x3f" is always 0 regardless of the values of its
operands.

Change-Id: Ie47e632f4bca490baf4282dc5d55ee55ca7f1ae8
Fixes: coverity CID#166932
2017-04-27 12:31:01 +02:00
Harald Welte fa3325fb8b osmo_ss7_user_unregister(): Don't dereference NULL user
The 'user' argument to osmo_ss7_user_unregister() can be NULL, so let's
make sure we don't dereference it.

Change-Id: Ia34b181dcbcb179b2639e2f405364cc952069842
Fixes: coverity CID#166933
2017-04-27 12:24:38 +02:00