Commit Graph

549 Commits

Author SHA1 Message Date
Harald Welte 982c0ce337 sccp_scoc: don't pass variable as argument if we know it's NULL
xua will always be NULL in one particular switch case of
scoc_fsm_conn_pend_out(), so let's use NULL directly rather than obscure
it though a variable that might be understood as this being non-NULL in
some cases.

Change-Id: Id6dc56442441489aefc706bcebc49197ca3dae1e
Fixes: coverity CID#166934
2017-04-27 12:17:20 +02:00
Harald Welte b30b011e34 m3ua_decode_notify(): Ensure status_ie is valid before using it
Change-Id: I3cdd0fbdffcbeeb68dbc979385de045220ea0b0c
Fixes: coverity CID#166939
2017-04-27 12:11:24 +02:00
Harald Welte 6fa1933178 sclc_rx_cldr(): Don't try to dereference user data_ie without check
While the SUA / SCCP2SUA code is ensuring that mandatory information
elements such as the user data IE in a CLD$ message, we might still have
current or future callers of sclc_rx_cldr() that don't comply with that.
So let's make sure data_ie is valid before dereferencing it.

Change-Id: I7c1010b0ac82ee0b7bd5e2c7413899695eae0070
Fixes: coverity CID#166940
2017-04-27 12:09:29 +02:00
Harald Welte 023d4f962b m3ua_to_xfer_ind(): don't use data_ie without checking it exists
Change-Id: I5f7551e49c1b4ea417bee3516da1b2ece5ee0699
Fixes: coverity CID#166941
2017-04-27 12:06:23 +02:00
Harald Welte 36a0ca83ab sclc_rx_cldt(): Don't try to dereference user data_ie without check
While the SUA / SCCP2SUA code is ensuring that mandatory information
elements such as the user data IE in a CLDT message, we might still have
current or future callers of sclc_rx_cldt() that don't comply with that.
So let's make sure data_ie is valid before dereferencing it.

Change-Id: Ia102f6c4cd5c6c3f823cb219635c42b9a87765f8
Fixes: coverity CID#166942
2017-04-27 12:02:47 +02:00
Harald Welte 14bdce0743 ss7_test: Fix '=' that should have been '=='
Change-Id: I1be4529c73992cb342a62aa19ba79be25e982620
Fixes: coverity CID#166944
2017-04-27 11:53:53 +02:00
Harald Welte 8a1f5a72db scu_gen_encode_and_send(): Fix NULL pointer deref
We were using the 'xua' pointer before checkin if it actually is valid

Change-Id: I5cd3250afc0b787b78683cd8ab6b2512e0d5c69e
Fixes: coverity CID#166945
2017-04-27 11:52:43 +02:00
Harald Welte 48c72f1f5c deliver_to_mtp_user(): Fix null pointer dereference
We had used + derefernced the 'prim' pointer before checking its
validity.

Change-Id: I0ca5026091e91926924b297f9342bda5f9fd38c9
Fixes: coverity CID#166946
2017-04-27 11:50:51 +02:00
Harald Welte 4c880a02f4 osmo_sccp_user_sap_down(): Avoid uninitialized pointer deref
When receiving an unknown primitive, we end up de-referencing an
unassigned/uninitialized pointer for 'conn'.  Let's properly catch that
case and print an error message.

Change-Id: Id1f5f293ea9bce8601d45164be670a7062d91802
Fixes: coverity CID#166947
2017-04-27 11:48:15 +02:00
Harald Welte 48c720bffc sccp_user: Add missing 'break' statement
The missing break statement leads to an unintended fall-through which in
turn prints a wrong ERROR message.

Change-Id: I6618fa247b889d4162118278cd05dee85cf21899
Fixes: coverity CID#166948
2017-04-27 11:43:53 +02:00
Harald Welte bf849e4bf0 sccp2sua: Avoid array overruns in sccp_is_{mandatory,optional}()
Change-Id: Ied76c21e20332514c2ad364eea5fc17e24a3f4c6
Fixes: coverity CID#166943, CID#166980
2017-04-27 10:55:03 +02:00
Harald Welte 7c56ab30c9 xua_rkm: Fix handling of RK Registration with multiple Routing Keys
RKM permits multiple routing key IEs to be inside a single Routing Key
Registration message.  We were trying to handle this, but the counter we
used as array index into the 'newly_assigned_as' array was actually
always kept at zero.

Change-Id: I08a962d2f242cefb67fb2dc93818c1ed532e8990
Fixes: coverity CID#166991
2017-04-27 10:45:09 +02:00
Harald Welte 17927de2ad ss7_test: Avoid possible NULL pointer dereference in test case
Change-Id: If2a7b2c988d06e8bbd2a63f3a5ceeb403bfb34ed
Fixes: coverity CID#166992
2017-04-27 10:29:13 +02:00
Harald Welte 68e9aaa32d xua_default_lm_fsm: Missing printf() argument
Change-Id: I03c30a0d1e03ff56df80bdd1e8a7846142b6f79c
Fixes: coverity CID#166993
2017-04-27 10:27:35 +02:00
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 65daa7f064 stp: Install VTY commands for FSM introspection
Change-Id: I4ee881715e874eaed3cca6ac42db21260123306a
2017-04-27 10:12:56 +02:00
Max 37c53749f0 Fix debian builds
Add missing libosmogsm dependency.

Change-Id: I6e5cf393ffe81c582966ca0e9479e6deeffa9280
Fixes: OS#2182
2017-04-25 13:40:12 +02:00
Harald Welte 57d0449d4e IPA: Override/Set point codes
As an IPA SCCPlite message arrives without any MTP routing label, we
simply construct one artificially for all inbound IPA/SCCPlite packets:

* we set the SPC to the point-code of the routing key of the AS
  (as this is the PC we route to this IPA/SCCPlite client anyway)
* we set the DPC to a point-code from a new vty config command
  "point-code override dpc"

Change-Id: Id556398e1ded3e613cfde7ea8b71aff7a414ff90
2017-04-18 10:08:25 +00:00
Harald Welte 529adc67c4 osmo_ss7: Allocate message buffers with headroom
The use of m3ua_msgb_alloc() from generic code is a bit ugly, but I
really don't want to introduce yet another msgb_alloc wrapper.

Change-Id: Ic6dc9a1e7bbed2e1f73395bd18b727fa7892e25b
2017-04-18 10:08:25 +00:00
Harald Welte 6a77241cb1 osmo_ss7: make sure to re-set all state on client disconnect
When we disconnect a client, make sure that we always go through
xua_cli_close_and_reconnect(), which will make sure to notify the ASP
FSM using XUA_ASP_E_SCTP_COMM_DOWN_IND.

Change-Id: I6859b8549c8cbbe2e8279da0ede562387a066d04
2017-04-18 10:08:25 +00: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 afc3b85613 SUA: Our SUA implementation needs an SCCP instance in ss7_instance
So when we create a xua_server for SUA, we must make sure to create that
associated SCCP instance, if it doesn't already exist.  End-user
programs probably normally call this during their initialization anyway,
but in something like OsmoSTP, we need to auto-create it.

Change-Id: Ib575763dbd00f5bd7bfbf48f227a8f5ef9528e2a
2017-04-17 10:45:20 +02:00
Harald Welte 6548d1b9c4 SUA: Make sure to reject unknown CO message types
Found using sua-sgp-mtr-i-04 from Michael Tuexen's sua-testtool.

Change-Id: Iec5c8deb6cc48a1269fd85243c1350bafd1dd815
2017-04-17 10:33:10 +02:00
Harald Welte 161cd0dcd7 SUA: Reject unknown Connectionless Message Types
This was found by sua-sgp-mtr-i-03 of Michael Tuexen's sua-testtool.

Change-Id: I09e96a26d9f9398de07ab46cdc5af10b2ea5acc0
2017-04-17 10:26:59 +02: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 c36be1c06a xua_as_fsm: We might change to AS_INACTIVE after T(r) expiry
Depending on whether or not any ASP is INACTIVE, we need to go to
AS_INACTIVE or AS_DOWN after T(r) expiry in the xua_as_fsm.

Found by m3ua-testtool testcase m3ua-sgp-aspsm-o-003

Change-Id: Iad6b176a5c95a28fbd5ba437696c2e6e160bdb00
2017-04-17 00:24:41 +02:00
Harald Welte 3a57553145 introduce new osmo_ss7_asp_disconnect() function
Higher-layer code shouldn't have to worry between client and server
difference.  It just wants to close the underlying connection for a
given ASP - which it now can by means of osmo_ss7_asp_disconnect().

Change-Id: I36b089abd281b8edac8830fda2d8e57cc06cd0a7
2017-04-15 23:01:13 +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 f7abfe1bb1 osmo_ss7: avoid crash during disconnect after unknown ASP
Change-Id: Ib201f9f480f25ede0f26d4918007ff22fea28824
2017-04-15 23:01:13 +02:00
Harald Welte 3a09645ca6 m3ua: Generalize + Export function to generate MTP-TRANSFER xua_msg
Change-Id: If82956317ec703341514ad81057eceb3d0714f47
2017-04-15 23:01:13 +02:00
Harald Welte 5012416b7e osmo_ss7: Fix protocol of dynamically allocated ASPs
When dynamically allocating ASPs, we used the hardcoded M3UA protocol,
which is of course wrong in case of SUA or other protocols.  Let's use
the xua_server's configured protocol for the created ASPs.

Change-Id: I07832cbaf1ca42f0c7df399e4f96599034b72816
2017-04-15 23:01:13 +02:00
Harald Welte 58f225b2f0 osmo_ss7: Clean up all ASPs established via xua_server upon destroy
When we destroy a xua_server, we would like to close and destroy any
ASPs that were established via that xua_server.   In order to do so, we
need to add a list of ASPs to the xua_server, which we can iterate.

Change-Id: Iff3ed099b817e54e563b70d9ab40f63af63cc2fb
2017-04-15 23:01:09 +02:00
Harald Welte 05ad104c58 get rid of global osmo_ss7_xua_servers variable
By moving this variable into the SS7 instance, we avoid one more global
variable, and we also fix a bug where the xua servers would be saved
multiple times (once per instance).

Change-Id: Icbab59d773f23cc8514cbeb6e21e25ca35dd337f
2017-04-14 22:48:46 +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 d282c4cc47 osmo_ss7_vty: Print AS and ASP state names during 'show'
Change-Id: I6a06d93d6e6c0386676742d6d19f5483a46d7fba
2017-04-14 21:51:04 +02:00
Harald Welte 47c2a97c6d ss7_vty: don't re-define xUA dialect strings
If we add more xUA variants/protocols, we want to avoid having to touch
too many parts of the code with copy+pasted strings.

Change-Id: I085b884d98fb4c45ac15910a8ebf82b91e861fd4
2017-04-14 20:40:00 +02:00
Harald Welte 04dee2f9e1 m3ua_example: Add SS7 and SCCP VTY
Change-Id: Id03d2f94d22445ada01917356a5ec5a8e4fa3fca
2017-04-14 20:25:50 +02:00
Harald Welte c031536808 SCCP: Add VTY interface for SCCP
Change-Id: I100daaa947dbab6a4528c4e9fbd0d30790288f63
2017-04-14 20:25:50 +02:00
Harald Welte f5a030fac8 sccp_scoc: Memorize if a connection is incoming or outbound
This is not really needed by the state machines internally, so we have
to artificially add it to the sccp_connection.  We don't use it yet, but
upcoming code for VTY introspection of SCCP connections will be able to
use it.

Change-Id: Ic3c85152665abfb613e197b098c97392d16d16bf
2017-04-14 20:25:50 +02:00
Harald Welte f06c7f559a osmo_ss7_vty: Don't save dynamically generated AS / ASP
If RKM has dynamically generated some AS definitions on the fly, or if
we accepted auto-creation of ASPs on SCTP connect time, then we don't
wnat to save such objects during vty config file store.

Change-Id: I9d0b0b61737a30b9d6e76cecbe42ec071bcddeeb
2017-04-14 20:25:50 +02:00
Harald Welte 975a2c81e0 osmo-stp: Add command line options and daemonize functionality
Change-Id: I267fbe2e5c774960f0b63cfdd9f60df121b4934d
2017-04-14 17:11:21 +02:00
Harald Welte bc4257867b osmo-stp: Remove hack to always enable debug logging
... and rather use the config file based logging configuration, like
other osmocom programs, too.

Change-Id: I7e0fb869bd778d8c276dc8afd16ecd7f1965b74a
2017-04-14 17:11:21 +02:00
Harald Welte acb914d54b stp: Add copyright notice
Change-Id: I4e074f570eac2e6a0a761f9f5f9c35fa4afa0315
2017-04-14 17:11:21 +02:00
Harald Welte 8cf687b2dc Add exampel osmo-stp configuration file
Change-Id: I45a04dc808e5a419bf5d68eb28c48cbec352b318
2017-04-14 17:11:21 +02:00
Harald Welte fa049a4914 osmo_ss7_vty: Fix config file writing for xUA listeners
We so far generated un-parseable config files..

Change-Id: Iff6940ef6f52739b6f30a152487038cb0220da43
2017-04-14 17:11:21 +02:00
Harald Welte e7589d107c osmo_ss7_vty: Introduce xUA listener accept-asp-connections command
Using this command one can specify if ASP connections should be refused
if there's no matching configuration, or whether ASPs should simply be
create on-demand.

Change-Id: Ic93b99047fb566cdb25a2f4139ebef54849dece9
2017-04-14 17:11:21 +02:00
Harald Welte 146bb5cebd Don't overwrite existing data in osmo_ss7_instance_find_or_create()
If we actually found an instance for the specified ID, return it fast
and don't (re)initialize all linked list heads, etc.

Change-Id: I91b6aabdb873ed8dd103918ee5e40b7ad3946735
2017-04-14 17:11:21 +02:00
Harald Welte 993da0b4c2 osmo_ss7_vty: Add 'description' command for SS7 instances
This allows the user to add some description to each SS7 instance

Change-Id: Ia5d22f2f70ec12dd13151f949bb45b5fdab42fc5
2017-04-14 17:11:21 +02:00
Harald Welte 246266c939 osmo_ss7_vty: Add Command to permit (or disallow) dynamc routing key allocation
This feature has been introduced in
8dec5a8ec5, but so far hasn't been exposed
to the VTY yet.

Change-Id: I7355522bacbad1072feb5484b865dfd1be50a64d
2017-04-14 17:11:21 +02:00
Harald Welte f9aa940105 osmo_ss7_vty: Add 'show cs7 instance <0-15> users' command
This will list which Service Indicators have bound local users (like SCCP)

Change-Id: Ibb21810e2ebe520e07cfdda3a0c62172b152015e
2017-04-14 17:11:21 +02:00