Commit Graph

210 Commits

Author SHA1 Message Date
Harald Welte fb82880905 osmo_ss7: destroy any ASPs allocated dynamically at accept() time
When we accept SCTP connections from clients for whose IP/port we have
no matching local configurations, and it is permitted by local
configuration, we dynamically allocate osmo_ss7_asp's in this case.
Make sure to properly destroy them at the time the SCTP connection is
lost.

Change-Id: I07d69a0cd52a049a7a4bb0d996e95d39fee9a106
2017-04-11 23:27:05 +02:00
Harald Welte bba8fe8166 osmo_ss7: Make sure to start server-side ASP FSM for dynamically created ASPs
Change-Id: I5dd079158a8c6b176a94dc251748924ef3e9c937
2017-04-11 23:27:05 +02:00
Harald Welte 2c2ae5997c osmo_ss7: When destroying an AS or a linkset, delete all routes
When we destroy a linkset, it make sense to remove all associated routes
pointing to the linkset, as they would point to nowhere anyway.

Change-Id: I393400bc758c28997e16bc78e3142719b6a61be8
2017-04-11 23:27:05 +02:00
Harald Welte 8af8d643de osmo_ss7: Fix memory leak with sock_name on clients at re-connect time
We cannot use osmo_talloc_replace_string() together with
osmo_sock_get_name(), as the latter already creates a dynamically
allocated string, and the former will then make a copy of that
allocation.

Change-Id: I6798221ccb3c70186c1c51dd34b7823fefd6df58
2017-04-11 23:27:05 +02:00
Harald Welte ed18c11de9 osmo_ss7: Generate M-SCTP_RESTART.ind towards Layer Manager
The M3UA RFC defines this primitive to the layer manager, but we so far
didn't generate it.  Let's inform the Layer Manager about such events,
in case it wants to take appropriate action.

Change-Id: I4e4e86f9b9d8ef4639c835878749ce8d8cc76f7c
2017-04-11 23:27:05 +02:00
Harald Welte 1978e3a320 osmo_ss7: Instruct libosmo-netif to use {TCP,SCTP}_NODELAY on all sockets
If we don't do this, we get some nasty packet delays, which are
sufficient enough to trigger re-transmissions of an M3UA ASP-UP packet
even over loopback/localhost on an otherwise unloaded system.

Change-Id: I6aa4eb421ecb483d3da1b0ce3aa6511d161c3750
2017-04-11 23:27:05 +02:00
Harald Welte b650dd9d77 osmo_ss7: Use proper string name for dynamically-created ASP
Change-Id: Id346002c79ba2aba2183ebd46bead372a727316d
2017-04-11 23:27:05 +02:00
Harald Welte 5181c5fe1b osmo_ss7: Send M-SCTP_RELEASE.ind for close of xUA client or server socket
Change-Id: I31e7de136545279a75a5faca0927d3dbf11ff46d
2017-04-11 23:26:58 +02:00
Harald Welte b5e569ee67 xua: Add value_string for routing key [de]registration results
Change-Id: If8f0a0ad0837810388cfe65a7b571b6ce4df33e3
2017-04-11 21:45:25 +02:00
Harald Welte 4012ea51a5 SCRC: Print NOTICE log message if we attempt to use (missing) GT routing
Change-Id: I4dc954cc3f10860dea518f95e53f72c6a9a3de95
2017-04-11 21:45:25 +02:00
Harald Welte dff8f995ef SCCP SCOC: Ensure user primitive msgb->l2h always poinst to tail
In case there is no user data in a CONNECT.conf primitive (or other CO
primitives), we must make sure that msgb->l2h = msgb->tail so that the
SCCP User can use msgb_l2len(msg) == 0 as indicator to verify if user
data is present or not.

Change-Id: Ie512fe063391e3a634097f555b9b0089d2981de9
2017-04-11 21:45:25 +02:00
Harald Welte 996dcf3ba6 Fix for SCCP CC without user data
When sending messages like CC (or SUA COAK) without user data, we must
make sure to not include the optional data part - as opposed to
including one with zero length.

Change-Id: If91edb526cbcd792ec5ebcb4518cf848feb69391
2017-04-11 09:42:09 +02:00
Harald Welte 17df5953ff xUA: Fix endianness handling of PPID and STREAM_ID
In their infinite wisdom, the inventors of SCTP designed an API (the
sockets API described in RFC6458), where some members are in host byte
order (like the stream identifier), while other members are in network
byte order (like the PPID).

Let's handle this properly (we assumed both are network byte order), and
also use 16-bit htons/ntohs fo the PPID, rather than htonl/ntohl.

Change-Id: I51c87314ef9ba6415e7e89980699ab07e787ed5d
2017-04-10 17:52:30 +02:00
Harald Welte 9ecb11bd6d Allow clients to specify local IP/port
Change-Id: Ief7ce8181442fd0f51c34cf598269ed3a6beacea
2017-04-10 11:48:36 +02:00
Harald Welte 0be0a4e035 m3ua: cosmetic clanup. We can simply return the M3UA errror code
Change-Id: I6ed04a4f78e618938484aeab62dbcfb3f310998d
2017-04-10 11:48:36 +02:00
Harald Welte 63c6cb27a6 M3UA: Reject Message Class XFER / Type != DATA
This was discovered (and fix validated) using m3ua-sgp-mtr-i-003 of
Michael Tuexen's m3ua-testtol.

Change-Id: I7498f606b031f5a6dfb538d9900c744da6aed36f
2017-04-10 11:48:36 +02:00
Harald Welte 1710c7e71f M3UA: Ensure XFER messages are not sent on stream 0
According to the RFC, Stream ID 0 MUST not be used for XFER/DATA
messages.

This was discovered (and fix validated) using m3ua-sgp-mtr-v-003-alternate
of Michale Tuexen's m3ua-testtool.

Change-Id: I80b941426b5106e091bd1becff0ae97958aff97c
2017-04-10 11:48:36 +02:00
Harald Welte 440771f18a M3UA: Properly reject invalid/unknown routing context
This was discovered (and fix validated) using m3ua-sgp-asptm-i-005 of
Michael Tuexne's m3ua-testtool.

Change-Id: I217ae287e22371e36dda0f87a7737b62fb1bf2d6
2017-04-10 11:48:35 +02:00
Harald Welte 312fd7e4b9 M3UA: Handle opportunistic ASPIA in INACTIVE state
This was discovered (and fix validated) using m3ua-sgp-asptm-o-003
of Michale Tuexen's m3ua-testtool.

Change-Id: If231072655170fe52dae738882dd63b1d0a60cf9
2017-04-10 11:48:35 +02:00
Harald Welte fbb2bddce6 M3UA: Send opportunistic ASPACT-ACK to ASPACT-REQ in ACTIVE state
This was discovered (and fix validated) using m3ua-sgp-asptm-o-001 of
Michael Tuexen's m3ua-testtool.

Change-Id: I6d254f7a33856e036329aa717a9c03efb1f1289d
2017-04-10 11:48:35 +02:00
Harald Welte 2cef54f4cc M3UA: Send "Unexpected Message" when receiving ASP_UP-ACK in ACTIVE
Change-Id: Ibcda68b7acb02bf1580a832baff06ff21cbac713
2017-04-10 11:48:35 +02:00
Harald Welte 6f8c84b27e M3UA: Make sure to reject unsupported traffic mode types
This was discovered (and fix validated) using m3ua-sgp-asptm-i-004 of
Michael Tuexen's m3ua-testtool.

Change-Id: I76c01189b75ff3084cd4d3944314ec9b9f811dbf
2017-04-10 11:48:35 +02:00
Harald Welte f21eaabe24 M3UA: Respond with "Unexpected Message" if ASPTM is received too soon
This was discovered (and fix validated) using m3ua-sgp-aspsm-i-003
of Michale Tuexen's m3ua-testtool.

Change-Id: I8b63e7b5e39a7ef8dd66bf014110a04f5f3dc2a2
2017-04-10 11:48:35 +02:00
Harald Welte dde5fda513 osmo_sccp_make_addr_pc_ssn(): Set routing indicator
When we crate a sccp address with PC+SSN, we should also set the routing
indicator accordingly (OSMO_SCCP_RI_SSN_PC).

Change-Id: Ie179df7158624520e90093da063c57f1e3efa0bd
2017-04-10 11:48:35 +02:00
Harald Welte 632ab5a359 osmo_ss7: Fix msgb memory leaks in error paths (asp not connected)
Change-Id: I031d90348ea243ac5dbdde14365528f3ec8e3709
2017-04-10 11:48:35 +02:00
Harald Welte 72f12f7543 m3ua: Remove inbound routing context before routing
After verifying the routing context of an incoming M3UA message, remove
the routing context before passing into MTP routing.  In the forwarding
case, we might want to set a new routing context on the outbound link,
and we don't want the routing context IE to show up twice.

Change-Id: I7a534cb1da275369c70766c059aaae8157ce6833
2017-04-10 11:48:35 +02:00
Harald Welte ac00448f19 osmo_ss7: default point-code format for parsing/printing without ss7_instance
osmo_ss7_pointcode_print() osmo_ss7_pointcode_parse() etc. now support
passing a NULL ss7-instance which will lead to application of the
default ITU 3.8.3 point code format.

Change-Id: Ifb739e92e31eaaa0343dc57c9af8c9164d00175f
2017-04-10 11:48:35 +02:00
Harald Welte e2d1cc8b0e send M-SCTP_ESTABLISH.ind to Layer Manager
Change-Id: I2904f8ebd97036690ba8a9525b31354c0252123b
2017-04-10 11:48:35 +02:00
Harald Welte 082dc7f170 move layer_manager from xua_asp_fsm priv to osmo_ss7_asp
... this way it is publicly accessible/reachable

Change-Id: I00ec1689bfb068b9067d893fdba14d12d59f73f0
2017-04-10 11:48:35 +02:00
Harald Welte d36571a776 xua: report N-ERROR and N-NOTIFY primitives to layer manager
Change-Id: I5c2060f0397d2bf510b085a5bb07e7ab176f2742
2017-04-10 11:48:35 +02:00
Harald Welte 02e7530671 xua: move notfiy parameters from xua_internal to sigtran_sap and rename them
Change-Id: I295b9d6755a4bb52a817d2791a302bdd9fc775dd
2017-04-10 11:48:35 +02:00
Harald Welte 3e463a3862 M3UA: RKM DEREG-REQ should contain routing context, not routing key
The mandatory IE checking is requiring the wrong IE

Change-Id: I73ecd163e2143341687ee4bca15a0bc69719c594
2017-04-10 11:48:35 +02:00
Harald Welte 4e818c3cfd Add M3UA RKM (routing key management) support, SGW side only
Change-Id: I9b1cf438a42519c0fe2f555c1672fafa499122a1
2017-04-10 11:48:35 +02:00
Harald Welte a5b5dac5b3 osmo_ss7: Add support for dynamic ASP registration
if osmo_xua_server.cfg.accept_dyn_reg is set, then ASPs are permitted
to connect without having a pre-configured matching ASP definition in
the vty.  This helps particularly in cases where RKM is used for
dynamica registration of a RC (and hence AS).

Change-Id: Ie48898202acbdbfe144fdd5851dfedbb554b11aa
2017-04-10 11:48:35 +02:00
Harald Welte a40df808d5 Add osmo_ss7_find_free_rctx() function to get unused rctx
Change-Id: I0186e25a1b3a325c6b0e3f50ef1590c4de6dbef6
2017-04-10 11:48:35 +02:00
Harald Welte 1e25c3a0ac xua_msg: Add xua_from_nested() helper function for nested IEs
... and add a test case to ensure it continues to work.

Change-Id: Iee434886598b528d23ddce0490dcc782e0f5d6ae
2017-04-10 11:48:35 +02:00
Harald Welte 9aee15c23d osmo_ss7: Fix segfault when routing MTP-TRANSFER.req to ASP without sctp connection
Change-Id: I142a11b09672864b54b927b8334b1975c8cd6022
2017-04-10 11:48:35 +02:00
Harald Welte 30c2b89925 Add osmo_sccp_get_ss7() accessor function
as 'struct osmo_sccp_instance' is opaque to the user application, it is
useful to have an accessor function that resolves the ss7 instance used
by the SCCP instance.

Change-Id: I8057a6d69584239b9781c5cece42066293ea1dd6
2017-04-10 11:48:35 +02:00
Harald Welte c860f9a41e sigtran: fix various memory leaks (msgb and xua_msg)
The general rule for 'struct xua_msg' is now that it is free'd by the
function that also allocates it in the first place.  Any downstream
consumer of the xua_msg may interpret it, but not hold any references or
free() it.

Change-Id: I708505d129da5824c69b31a13a9c93201929bada
2017-04-10 11:48:35 +02:00
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
Harald Welte ec86dcdc2f sccp.c: Fix compiler warnings about size_t / %u 2015-12-22 23:24:27 +01:00
Harald Welte bf49cc1c00 Import SUA (SCCP User Adaptation) and SCCP User SAP
... this code originates from the osmo-iuh repository, but is now part
of a new shared libosmo-sigtran.so library generated in this repository.
2015-12-22 23:03:41 +01:00
Holger Hans Peter Freyther a9c411ec8c sccp: Allow to specify the context of the incoming message
At the time a SCCP CREF is sent there is no context anymore
and the user of the API might not know where to return the
message to. Allow to specify the incoming context and use it
on the way out.

There are no more callers of _send_msg which passes a NULL
connection and a NULL context.
2015-06-15 09:40:43 +02:00
Holger Hans Peter Freyther 7046633c02 xua: Generalize the m2ua_msg and call it xua_msg
Generalize, this requires various API modifications
but that is the most sane path forward.
2015-03-23 12:28:06 +01:00
Holger Hans Peter Freyther 4d244d3c31 XUA: Move m2ua headers to sigtran, create xua_types.h and m3ua_types.h
Begin with type definitions for m3ua
2015-03-23 11:06:51 +01:00
Alexander Huemer 7925409b35 Makefile.am: Use AM_CPPFLAGS
Since automake 1.13 INCLUDES is depricates and causes a warning
2013-06-12 07:56:31 +02:00
Holger Hans Peter Freyther b01178898f sccp: Create sccp_create_cr and use it in the connection creation
The data is optional in the in the CR msg so we have to check if the
msgb is NULL or not.
2013-04-10 16:17:14 +02:00
Holger Hans Peter Freyther 0b0dda7e4b misc: Use a unsigned result for the sizeof sizes
Avoid comparing unsigned/signed values with the msgb. In practice
our messages are way lower than this would would matter though.
2013-04-10 16:17:13 +02:00
Holger Hans Peter Freyther 84406e2779 sccp: Make sccp_write take an additional local context
For connection less data there is no way to pass a per context
data for outgoing data, add one.
2011-06-04 16:55:50 +02:00
Harald Welte d35a3079df namespace: use osmo_static_assert() instead of static_assert() 2011-05-08 09:43:49 +02:00
Harald Welte 2d97000f98 Update include paths with libosmocore 0.2.0 2011-03-23 18:30:22 +01:00