Commit Graph

16 Commits

Author SHA1 Message Date
Harald Welte 5112d60ff7 Address some negative integer handling issues
If for some reason we cannot resolve the file descriptor for a given
FSM, we shouldn't attempt to send data through it.

Fixes: coverity CID#167155, CID#167154, CID#167153, CID#167152, CID#167151, CID#167151
Change-Id: I8b1a676b653bcdad21cb7927d549f499950a2b73
2017-04-27 10:21:42 +02:00
Harald Welte 5f0a8df34c Add IPA/SCCPlite support as SIGTRAN alternative
This tries as good as possible to fit the IPA/SCCPlite stacking into the
existing SIGTRAN/SS7 code architecture/model.  To the user, the IPA
protocol looks like yet another protocol on the same level as the choice
between SUA and M3AU.  On the inside, things are obviously quite
different.

We need to handle TCP with IPA framing instead of SCTP for both server
and client.  We also implement an alternative "ASP FSM" for IPA, which
takes care of the CCM handshake (ID_REQ/ID_RESP/ID_ACK/ID_ACK2) for both
client and server mode.

In server mode, we use the 'unit name' as identifier to look up the AS,
similar to how we use a routing context to look up the AS in the xUA
case.

We also have to bypass activating the default layer manager in the
simple client to make sure we don't run into even more complexity.

What's missing right now is some way to manually override/set the point
codes.  As IPA/SCCPlite is missing any routing label, we currently
simply generate one with SPC=0/DPC=0, which will obviously not work in
most configurations.

Change-Id: I9098574cddeba10fcf8f1b6c196a7069a6805c56
2017-04-18 10:08:25 +00:00
Harald Welte 19e30eb1db xua_asp_fsm: Fix ordering of messages to pass M3UA_SGP_ASPSM_O_003
I don't think the order of messages is that important (and specified in
the RFC), but let's do this to make the m3ua-testtool case happy.

Change-Id: I2e150e941a6fcfd203944f5b20bd07c07193f44a
2017-04-17 00:59:07 +02:00
Harald Welte 03eda14b26 Add new ASP event XUA_ASP_E_SCTP_EST_IND
For classic xUA this is not needed, as the server doesn't have to react
to establishment of the SCTP connection.  The client will start with an
ASP_UP_REQ.  However, in upcoming IPA support, the FSM will need to
react on this event.

Change-Id: Ib10914b27f8761ea44a0fdba96c045821223722a
2017-04-15 23:01:13 +02:00
Harald Welte d95958b5fb SUA/M3UA: Implement T(r) recovery timer of Application Server FSM
When an AS goes "down" it first entres a recovery state, in which any
to-be-transmitted messages are enqueued until the timer T(r) expires.

Once the timer expires, the messages are discarded.  If the AS goes
ACTIVE before timer expiration, queued messages are sent.

Change-Id: I22725bf35306299a00c66d7b3637f5e198c26247
2017-04-14 22:48:41 +02:00
Harald Welte ed15c74a01 Add a default layer manager using RKM to register PC with SG
This "default layer manager" can optionally be used by a xUA ASP. It
will handle the xUA Layer Manager (xlm) primitives and use them to
behave as follows:

* bring the ASP into state "INACTIVE"
* see if the SG can match our connection (based on IP address + port
  information) to a statically configured ASP configuration with
  associated AS(s).  If yes, it will send us a NOTIFY message with
  AS-INACTIVE.
* if the above doesn't work, try to dynamically register a routing key
  using RKM for the point code that was locally confiured on the
  ASP/client.   If that works, the SG will now have created ASP and AS
  objects as well as a routing key and be able to serve us, sending the
  NOTIFY with the AS-INACTIVE state.
* After either of the two above, we will attempt to transition into
  ASP-ACTIVE.  The SG should send us an AS-ACTIVE notification in return
* if anything fails, abort and disconnect the SCTP connection, restart
  related FSMs and start from scratch

Change-Id: I78d4623dd213b5c59007a026a6cc3cfe5c04af50
2017-04-13 18:05:13 +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 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 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 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 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