Commit Graph

121 Commits

Author SHA1 Message Date
Harald Welte ca88edb0fd xua_srv_conn_cb(): Print sctp_recvmsg flags (line in xua_cli_conn_cb())
Change-Id: I91920c6ad665abc791a1dbf386d52cf0aece9133
2017-04-10 11:48:35 +02:00
Harald Welte 48b15e921d xua_cli_conn_cb: Print flags as hex, not decimal.
Change-Id: Idcf861cfdc6c14d7d3bafbf2e243da5db6e2f3e6
2017-04-10 11:48:35 +02:00
Harald Welte 6144da9be8 xua_as_fsm: Include routing context (if configured) in NTFY message
Change-Id: I15e8bf5cee194f9924d0eab9cff0e7c25daa6dde
2017-04-10 11:48:35 +02:00
Harald Welte 55674b8d69 xua_asp_fsm: Always return BEAT-ACK for BEAT, including BEAT DATA IE
The RFCs say we *must* always respond to the optional heartbeat message,
and we must return a verbatim copy of the heartbeat data IE.

This was discovered (and fix validated) using m3ua-sgp-asptm-v-011 of
Michael Tuexen's m3ua-testtool.

Change-Id: I836e0940a8dbb0f55ddf132202a5f0d51473b82d
2017-04-10 11:48:35 +02:00
Harald Welte d11fa298c5 m3ua: Include RC IE of AS in Tx; validate RC IE on Rx
Change-Id: I7db36a23185f82d8d68e318afe89ec5127c40333
2017-04-10 11:48:35 +02:00
Harald Welte 30d4c71b40 add converter functions between osmo_ss7 and m3ua traffic mode types
Change-Id: I6cc9530d7d2812cbc8feb6e9db51902865ebfe83
2017-04-10 11:48:35 +02:00
Harald Welte c9c11b6cfd sccp: add osmo_sccp_user_{get,set}_priv() API function
As 'struct osmo_sccp_user' is private, we need this accessor functions
for the SCCP User so it can set and get the 'priv' data.

Change-Id: Ia68a36dc18a7d754d63ae29c86d68e495b5c4134
2017-04-10 11:48:34 +02:00
Harald Welte 4881c5c169 xua: Remove library-internal DXUA log subsystem
We don't really need those thre log messages, and we can thus do away
with the library-internal log-subsystem of DXUA.  The rest of
libosmo-sigtran uses the new globa DL... subsystems anyway

Change-Id: Iea0d3db34a3674a9c6422b174a879bfdaa25786f
2017-04-10 11:48:34 +02:00
Harald Welte d40b9f842b SUA: Port to new osmo_ss7 and SCCP code
If we use the infrastructure provided by osmo_ss7 on the lower layer and
the SCCP SCRC, SCLC and SCOC code on the upper side, not much of the
original sua.c code remains.  It looks much like the M3UA code now.

Change-Id: I193b74f58aa70c443ae17e78b5604246d6bc3f71
2017-04-10 11:48:34 +02:00
Harald Welte c5204966bf sccp_sap license header was missing
Change-Id: I442634ca74d9c4cd386726a9d6b933a12f45afc5
2017-04-10 11:48:34 +02:00
Harald Welte ee350893cf Add new SCCP implementation
This is an implementation of SCCP as specified in ITO-T Q.71x,
particularly the SCRC (routing), SCLC (Connectionless) and SCOC
(Connection Oriented) portions.  the elaborate state machines of
SCOC are implemented using osmo_fsm, with one state machine for each
connection.

Interfaces to the top (user application) are the SCCP-USER-SAP and on
the bottom (network) side the MTP-USER-SAP as provided by osmo_ss7.

Contrary to a straight-forward implementation, the code internally
always uses a SUA representation of all messages (in struct xua_msg).
This enables us to have one common implementation of all related state
machines and use them for both SUA and SCCP.  If used with real SCCP
wire format, all messages are translated from SCCP to SUA on ingress and
translated from SUA to SCCP on egress.  As SUA is a super-set of SCCP,
this can be done "lossless".

Change-Id: I916e895d9a4914b05483fe12ab5251f206d10dee
2017-04-10 11:48:34 +02:00
Harald Welte e937532ae9 Add SCCP <-> SUA message transcoding routines
Change-Id: I8151a9b08a0b0ca97b9c73105ad4548512ce3be8
2017-04-10 11:48:34 +02:00
Harald Welte cd13b68e67 sua.c: Replace sua_msgb_alloc() with new sccp_msgb_alloc()
Change-Id: I7067a85dcc5dda66f4b17b0fe08da8cb3efe79ef
2017-04-10 11:48:34 +02:00
Harald Welte dd59a11667 sua: Extend address parsing with GT, RI and IPv4 support
Change-Id: I186df77cbdbedfe1a60b855be3626b6766f4681c
2017-04-10 11:48:23 +02:00
Harald Welte 1471dc9764 sua: Make use of xua_msg_dialect
We fill in the data structures of a xua_msg_dialect and make use of it
for generic mandatory IE checking and messageheader printing.

Change-Id: I966103f30b9be247ba6905ba8e06b87654d9981a
2017-04-10 10:41:16 +02:00
Harald Welte 2d3a709527 Add new 'osmo_ss7' SS7 core code with M3UA, ASP/AS FSM, ...
This is what aims to be a rather complete/proper implementation of the
SIGTRAN + SS7 protocol suite.  It has proper abstraction between the
layers with primitives, finite state machines for things like the AS and
ASP state machines, support for point code routing, etc.

What's not implemented at this point:
* re-integration of pre-existing SUA (pending)
* actual MTP2 and physical E1/T1 link support
* different trafic modes like broadcast/fail-over/load-balance

Change-Id: I375eb80f01acc013094851d91d1d3333ebc12bc7
2017-04-10 10:41:16 +02:00
Harald Welte c96db7fa58 xua_msg: Add support for msg_event_maps
msg_event_maps facilitate the mapping from a xUA message (class + type)
to an integer event.  This is useful when passing xUA messages to a
osmo_fsm.

Change-Id: Iee1c7fc2bf64219ebb71a0dbe6fd210749332413
2017-04-10 10:41:16 +02:00
Harald Welte d75e8967ef License headers: Should always have been GPLv2-or-later
libosmo-sigtran is GPLv2-or-later, there were some files that
accidentially had an AGPLv3 license header, which was a copy+paste
mistake at that time.

Change-Id: I67dfd0ae6157afafd3873a3baaa4c6107c04ddfd
2017-04-10 10:41:16 +02:00
Harald Welte 654bed7d5e xua_msg: Add support for encoding IPv4 addr in osmo_sccp_addr
Change-Id: I956f069ce4cea78cb0db0470265ca8365093c0e5
2017-04-10 10:41:16 +02:00
Harald Welte b929e4e3e8 xua_msg: Add support for encoding Global Title in osmo_sccp_addr
Change-Id: I4668fd0fba2e1be1ec37e75eeee85ed476320d14
2017-04-10 10:41:16 +02:00
Harald Welte 6023bcae16 xua_msg: Add concept of xua_msg_class and xua_msg_dialect
A xua_msg_class repreents one xUA message class (like M3UA XFER
or SUA CL).  A dialect is then something like SUA or M3UA, each
consisting of as many as 256 message classes.  Each class contains
value_strings of the individual messages, as well as constraint
information on mandatory IEs for each message.

Change-Id: Ib538aca295b7b50132bc814b2d7b56cbe5d65bfc
2017-04-10 10:41:16 +02:00
Harald Welte 58768015ed xua_msg: Add xua_msg_free_tag() and xua_msg_copy_part()
... also, mark input to xua_msg_find_tag as 'const' pointer.

Change-Id: I083634db9c3606bcff87700f253054a38a20816d
2017-04-10 10:41:16 +02:00
Harald Welte eddeeff310 Add xua_msg_part_get_u32() to get U32 value from xua_msg_part
Sometimes one already has the xua_msg_part and thus can avoid the
lookup that's done by xua_msg_get_u32().

Change-Id: Ie11c35f9528313d0b35786a361d853addd17364f
2017-02-13 15:09:17 +01:00
Harald Welte 0ebde0c42d sccp_helpers: Add osmo_sccp_{addr,gt}_dump() functions
They stringify a global title or SCCP address for human consumption

Change-Id: I630308aa4519c6e9a260419d37a376aac6a1ce28
2017-02-13 15:09:17 +01:00
Harald Welte 0dd089f17d Move xua_msg_add_sccp_addr() to xua_msg.h and export it
Change-Id: I07fa00dd71d8ecdf1542734598fab8ecad5a7b53
2017-02-13 15:09:17 +01:00
Harald Welte 222cd10c2f xua_msg: Make DXUA available to other XUA code
Change-Id: Ie5b6492ead2c523de3969134291b2c3f434f92a2
2017-02-13 15:09:17 +01:00
Harald Welte 1c43cc2918 migrate some generic XUA helpers from sua.c to xua_msg.c
Change-Id: I59e55d21a05b5d770c120da4c17220d5f21d44bd
2017-02-13 15:09:12 +01:00
Neels Hofmeyr e734655afb sccp_helpers: add convenience function for RANAP unitdata
Change-Id: Ie96d78512b8e3907753272d75471b882365968c4
2017-02-13 13:58:09 +00:00
Neels Hofmeyr 199b97652b sccp_helpers: add osmo_ prefix to all functions
Change-Id: I839c976f3ac722b955da18216de3df2eaa4c5af3
2017-02-13 13:58:01 +00:00
Neels Hofmeyr 81f63035ee sccp_helpers: adjust .h include and copyright
Change-Id: Id2d9a6c3e9b0928d245580895c78aa7355627adc
2017-02-13 13:57:53 +00:00
Neels Hofmeyr c07796dc3b sccp_helpers.h/.c: fix: apply rename of osmo_sua_link to osmo_sccp_link
Change-Id: If8b09bb05297ebf663b4a04d3cc094a6a8087f53
2017-02-13 13:57:44 +00:00
Neels Hofmeyr 86cfe9b3b4 Add sccp_helpers.[hc] moved from osmo-iuh, 1:1 at first
Move here unchanged first, so we're able to see the modifications in diffs.
Pending changes will follow in subsequent patches.

Moved from osmo-iuh 3da8608b6ad014fc74536dbb49019704fd425b8c, which was before
the rename of osmo_sua_link and osmo_sua_user to osmo_sccp_link and
osmo_sccp_user, so this will not compile.

Change-Id: Iae0c58c5f1eb00a685de70add0d5257e4316c6d5
2017-02-13 13:57:29 +00:00
Harald Welte 0c72c1c0d3 Start to log + handle SCTP notifications
Change-Id: Ie00c4fc65c66e55262e2db084826084dcaf34b91
2017-01-27 22:14:27 +00:00
Neels Hofmeyr 1f94c07ed2 fix: use proper disconnect prim param type
For the N-DISCONNECT prim, parse CREF, RLC and RLSD from the proper parameter
struct type: osmo_scu_disconn_param instead of osmo_scu_connect_param.

Before this, the conn_id ended up in the wrong place and the other side always
received a zero conn_id.

Tested only for the RLSD case, which fixes Iu-Release message evaluation for
all except the very first SUA conn received by the CN components.

In all three cases, set:

* param->responding_addr to conn->called_addr.
* param->originator to OSMO_SCCP_ORIG_UNDEFINED.

Change-Id: I446f2fe57cc3b7c52723f3ab82836513a5d37752
2017-01-27 09:59:31 +01:00
Neels Hofmeyr 6075f6ad51 cosmetic: sua.c: comments
Add some human readable names.

Change-Id: If4aa15aae8b03c764a45b866a751eb3fbabebec1
2017-01-27 09:59:31 +01:00
Neels Hofmeyr eddf138666 parse SCCP src+dst addresses
In order to receive a Paging command with a valid RANAP SSN, decode the SCCP
source and destination address IEs. This is used by hnbgw to forward a Paging
from CN to RNC.

This may be done more generally as soon as more IEs need parsing of their sub
parts. For now, iterate the higher level IE's data chunk and obtain the address
sub part IEs without storing sub part locations.

Change-Id: I03d0c2a9003fda59c5b88c8738df009c30fbc11c
2017-01-27 09:59:31 +01:00
Neels Hofmeyr b79a61de9a remove two compiler warnings for unused variables
Change-Id: I173dc67050d907f9b09b99265af9dee9d142ace3
2017-01-27 09:59:31 +01:00
Neels Hofmeyr db3a4bb5a5 SUA COIT: send dest ref nr, not dest addr
See RFC 3868 3.3.11
https://tools.ietf.org/html/rfc3868#section-3.3.11

Change-Id: I083384876d4a8d7fa9c03409fbdc9e00e3c8f416
2017-01-27 09:59:30 +01:00
Harald Welte b5f0d1c9bc sua: Ensure that a SUA client will continuously try to reconnect
Change-Id: Ic05a2b78e29e4ede214a3395430ef54bacd84e60
2017-01-27 09:59:30 +01:00
Harald Welte 32a1d54279 sua: call conn_disconnect() in sua_disconnect_req()
disconnect is not a class3/4 operation. We simply generate + send the
DISCONNECT.ind message to the remote side and drop all local state about the
connection.

Change-Id: I4e336f9dfd4ebd0122cd9e5a70db3d05e9dc1764
2017-01-27 09:59:30 +01:00
Harald Welte edfab6fdf5 sua: Fix typo in log message
Change-Id: I13bb0e2f4ec688fefd9b98d6d2389562e2a2dad7
2017-01-27 09:59:30 +01:00
Harald Welte 452b87285b allow user to give private data to osmo_sua_user_create()
... which can be resolved from the primitive call back prim_cb() by
calling osmo_sccp_link_get_user_priv().

Change-Id: If4c0f96f0621fb2adf4c78dc5994d3398431d92f
2017-01-27 09:59:06 +01:00
Neels Hofmeyr 26bcc0b9c4 fix NULL deref: sua_accept_cb: missing error-return
When server creation failed, besides closing the fd also return an error,
instead of continuing to use the NULL srv.

Change-Id: Iabfae7e5a880d10e4050da4945200ce9b848e577
Fixes: coverity CID#57684
2016-12-12 10:59:20 +00:00
Neels Hofmeyr 8fab8413bf NULL safety: sccp_create_sccp_addr: copy only non-NULL sock->gti
presumably, sock->gti_len is always zero when sock->gti is NULL, but ensure
with a check and make coverity scan happy.

Change-Id: I6cf195a3fbda1d9eacbbaec9a0e7f5b4c154f428
Fixes: coverity CID#57683
2016-12-11 21:24:59 +01:00
Harald Welte dfb4d91892 sua: Remove unused 'cur' variables
There are some compiler warnings about other unused variables which we
rather keep as a reminder that the SUA code is partially incomplete and
should be finished at some day.

Change-Id: I42b76351f1bbdfb7fe339d5fad98c5a065822a45
2016-11-11 15:40:06 +01:00
Neels Hofmeyr 03ad002c28 cosmetic: rename osmo_sua_link and osmo_sua_user to osmo_sccp_*
hwelte requested this change for the addition of libiu in openbsc. In a
conversation we came to the conclusion that a rename of these two opaque
structs would suffice.

This is the "upstream" rename and will require adaptation of:

* the sysmocom/iu branch in this repository
* the iu related branches in openbsc.git
* the hnbgw and dummy_cn code in osmo-iuh.git

See https://gerrit.osmocom.org/#/c/192/2/openbsc/src/libiu/iu.c@57

Change-Id: Icbf64dd96f8e0e27695df73d1144519b88360b94
2016-07-06 15:55:02 +02:00
Neels Hofmeyr e076bf2107 fix log msg typo, x5
Change-Id: I00ff99ef14d62d3b353fe69762ae49f374938f94
Reviewed-on: https://gerrit.osmocom.org/265
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-06-14 22:19:11 +00:00
Neels Hofmeyr 1a698a537d clarify fixme comment, x7
The fixme is about an actual message sent back, not about the error log.

Change-Id: I6de8fb202c7beb025232e9b97605e9f46778506a
Reviewed-on: https://gerrit.osmocom.org/228
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-06-14 10:36:23 +00:00
Ruben Undheim 5a1abeb02a Fix for big-endian architectures 2016-02-12 21:18:27 +01:00
Alexander Huemer 7438165b6c fix build if depenedencies are in distinct directories 2015-12-24 16:13:16 +01:00