aboutsummaryrefslogtreecommitdiffstats
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2017-11-17ss7_vty: Fix out-of-bounds access in 'as' cmdPau Espin Pedrol1-1/+1
Change-Id: I180d2ecbb266d9baf2a96017bab20760bb42812e
2017-11-13Add SPDX-License-Identifier + missing copyright statementsHarald Welte21-0/+60
Change-Id: I113232bbeaa7a835871df7f9b883ba573d8a2534
2017-11-12ipa: Automatically create / destroy route on IPA connect/disconnectHarald Welte1-0/+33
From the STP point of view: In order to be able to route messages back to an IPA client, we need to create a route at the time we have successfully identified the AS for this client based on the name presented in the IPA CCM ACK "name" field. Once the IPA client is destroyed, the route must be deleted again. With this commit present, we can have an IPA client (such as osmo-bsc-sccplite) connect to OsmoSTP and exchange BSS[M]AP with an M3UA-speaking osmo-msc. Basically, the STP reaches the point where it can translate between IPA-style SCCPlite and proper M3UA/SUA on the other side. Change-Id: I901f06c5d0f2eae60f8d931215ed65190330ce66
2017-11-12ipa: Patch DPC/OPC information into SCCP Calling/Called Party AddressHarald Welte1-15/+92
When we receive a SCCPlite message from an IPA peer, it may simply contain a SSN number but no point codes. Similarly to creating a fake MTP routing label from override DPC and routing key OPC, we can also add that point code information to the SCCP header. This way the rest of the SS7 network can handle the message and route it accordingly. Change-Id: I4a2ff063e3c060641b3fd181a1cd600da3ec568b
2017-11-12initialize msg->l2h in sccp_msgb_alloc()Harald Welte1-2/+7
Change-Id: I5fb11075593696b110bfd3e0541e3aa790029903
2017-11-10ipa: Fix endianness of pseud-M3UA headerHarald Welte1-6/+7
Change-Id: I70b420fc2105bb6e486adecf9285fed2fb471f73
2017-11-09ipa: Fix setting of OPC/DPC based on routing-context + overrideHarald Welte1-0/+2
As IPA is a transport layer underneath SCCP, and we don't have MTP-level OPC and DPC fields in it, we are using the "point-code override dpc" feature for setting the pseudo-M3UA DPC on incoming Rx packets, and we use the PC from the routing context as pseudo-M3UA OPC. However, we were so far only storing this in the M3UA data header, and not in the xua->mtp.{opc,dpc} members, which are consulted during the routing decisions. Change-Id: I5e2244620cd48f848382eb595ce59c6212069788
2017-11-09vty: Make sure 'point-code override dpc' is saved with correct indentHarald Welte1-1/+1
Change-Id: I4c42ee71eff4ee6aad8dce4156809adb041811a6
2017-11-09xua: Write 'local-ip' only if non-NULLHarald Welte1-1/+2
Avoid writing 'local-ip (null)' to the config file Change-Id: Ie49f21afd6b29b8e4a3b16f3f18764fea856d196
2017-11-08sccp vty: be fatal for addressbook entry errorsNeels Hofmeyr1-5/+6
So far, the config would log an error upon config parsing, and then continue to use defaults, which is super easy to miss. On errors, return CMD_ERR_INCOMPLETE to abort the program in a config parsing error. Be fatal for re-using an already defined addressbook entry in another cs7 instance, and for having a too long addressbook entry name. Though it is mixing in cosmetic changes, add "Error:" to the output and arrange the erratic name to the end of the message, as is customary for error messages. Related: osmo-bsc Ia4e58902a2d3757b266cf35ac89f256cfb8f0eec Change-Id: I2f71b9c4dd30f919d2054da81283dd7035f44f60
2017-11-08add osmo_sccp_inst_addr_name(), a variant of osmo_sccp_addr_name()Neels Hofmeyr1-0/+7
It can be cumbersome to derive the ss7 instance needed to pass to sccp_addr_name(), because struct osmo_sccp_instance is opaque and only available in sccp_internal.h, within libosmo-sccp. Add osmo_sccp_inst_addr_name() which derives the ss7 instance from the internal knowledge of the osmo_sccp_instance struct. This can save calls to osmo_ss7_instance_find() just to do some logging of an sccp address. Naming: first I thought to pick osmo_sccp_addr_name2(), but for some of the string composing functions, adding a 2 already means that it is identical but using a second static buffer (to be used twice within the same printf). Change-Id: I70ec5c8b42682a23f11a5820431c7e34e225709b
2017-11-01vty: skip installing cmds now always installed by defaultNeels Hofmeyr1-7/+0
vty_install_default() and install_default() will soon be deprecated. Depends: I5021c64a787b63314e0f2f1cba0b8fc7bff4f09b Change-Id: I185aa3a11cb63c893ed80f326f852bde95217321
2017-10-27implement unit tests for osmo_sccp_addr_{parse,encode}()Harald Welte1-0/+1
The recent bug with chopped-off point codes in SCCP Address handling has shown that this code could need proper test cases. This patch adds a testsuite for SCCP address encoding and decoding. Related: OS#2441 Change-Id: I612352736ab33462ca0dd97798a2c437eadccb86
2017-10-27osmo_sccp_addr_encode(): Catch some more errors and log themHarald Welte1-0/+10
Log errors in case the user provides global title indicators or nature-of-address indicators that exceed the permitted value range Change-Id: I493b7810bdc58e448f496565ded36f9dce2c1226
2017-10-27osmo_sccp_addr_encode(): Fix truncation of point codesHarald Welte1-1/+1
In osmo_sccp_addr_encode(), we accidentially truncated all point codes to 10 bits, where in reality we should have truncated them to 14 bits: One 'f' was missing in the bit-mask. Closes: OS#2441 Change-Id: Iad67b674b5b5fd41996aa898a131e98900842dd8
2017-10-27osmo_sccp_addr_encode(): Check for more erroneous situationsHarald Welte1-1/+16
... and bail out + log an error. Change-Id: I2a419343e55edad39c59e763d11046c5a439444d
2017-10-04Makefile.am: Link libosmo-sigtran against libvtyHarald Welte1-2/+4
libosmo-sigtran is using symbols from libosmo-vty, so make sure that we explicitly link against libosmo-vty to ensure the dependency shows up in `ldd` of the library. Change-Id: I4d96612a0df5a1232ed8fe280c5d592f462ef7b1
2017-09-14simple client: prevent overwriting asp settingsPhilipp Maier1-13/+28
If the user does not create an AS, but creates an ASP with a name that is equal to the default name, then the simple client detects that and trys to use this ASP. However, unfortunately it then overwrites the settings of the ASP with the default settings. If the detected ASP is not created by the simple client, use it, but preseve the settings of that ASP. Change-Id: I53d73059f804c3bbea6cb43dc73ad49a753b3b15
2017-09-11vty: add 'asp' / 'local-ip' commandNeels Hofmeyr1-0/+13
We can set the ASP's remote IP (i.e. where to reach osmo-stp), but so far the only way to specify the local IP address to bind to can only be set from C code (e.g. the simple client). Allow setting the local address via VTY. For example, this is desired for the osmo-gsm-tester, to not use arbitrary IP addresses. Change-Id: I3f71897dfacafcf3126e51894d6ca756b02dcd7d
2017-09-03sccp_sap.h: Fix SSN for BSSAP and BSSAP-LEHarald Welte1-2/+3
* BSSAP is 254 on both MSC and BSC side: Add missing define * BSSAP-LE (LCS Extension) has 250/251, adjust name to add -LE suffix Change-Id: Iccec75cfc0cf16bd717a9bd4606d1e772c332ccc
2017-08-28cosmetic: aggressively set vty->index to NULL in osmo_ss7_vty_go_parent()Neels Hofmeyr1-0/+2
Change-Id: I579482f679cd43edfbe796a5806ef360335f1c55
2017-08-24sccp: again fix handling of default IP addresses in osmo_sccp_simple_client()Philipp Maier1-4/+2
The previous fix (I312caf9d54cedb02034e4ef88fdd2e6ad9ca1c34) caused the default addresses to be discarded. Actually talloc_strdup() the default addresses to use them if not NULL. Change-Id: Ic8563ab272d5256a1b8ceefd5fee37da61e1bd26
2017-08-23osmo_ss7_vty: fix 'as' / 'routing-key' commandNeels Hofmeyr1-31/+58
The VTY definition for this command is flawed and breaks osmo-msc VTY tests. The small problem is a stray '}' in the definition, the bigger problem is that square brackets indicating optional arguments must not enclose more than one argument. Split up the command in several separate definitions with si arg, with ssn arg, with both, and with neither. If si and/or ssn are not passed, set them to zero. See https://lists.osmocom.org/pipermail/openbsc/2017-August/011026.html "optional vty items are stricter than expected" Change-Id: Idc68bfae5457960a9eae5d9648586d6ce719ad68
2017-08-22vty: fix doc for 'xua rkm routing-key-allocation'Neels Hofmeyr1-1/+2
A doc element is missing, which fails the VTY tests in osmo-msc at Change-Id I5ae4e05ee7c57cad341ea5e86af37c1f6b0ffa77. Change-Id: I16aa74244ed5332bdc1fddd538e17b86f62ec3b2
2017-08-15Fix SCCP client crash on xUA server (STP) disconnectHarald Welte1-1/+0
When the server (STP) disappears from a live SCCP client, then the xUA default layer manager receives LM_E_SCTP_DISC_IND, which is traversing retart_asp(). In there, we first terminate the current instance of the layer manager FSM, and then re-initialize the ASP to use the default layer manager using osmo_ss7_asp_use_default_lm(). However, osmo_ss7_asp_use_default_lm() uses the presence of an asp->lm_priv pointer as a sign that the old layer manager is still running and attempts to terminate it - despite being terminated just before in restart_as(). So let's simply remove the termination from restart_asp(), and leave it to osmo_ss7_asp_use_default_lm(). Fixes: OS#2402 Change-Id: I062d3af17539de864b56d079fe9b8d76ad99cf1e
2017-08-15vty: fix (null) string in vty configPhilipp Maier1-1/+2
The asp->cfg.remote.host is allowed to be NULL in cases where the localhost is used. Check if asp->cfg.remote.host is NULL when writing the config file and omit it when it is set to NULL. Change-Id: I18f79cc4d4f1db8f2858e8e95098c5821d50594f
2017-08-11sccp: fixup for osmo_sccp_get_ss7()Philipp Maier1-1/+6
osmo_sccp_get_ss7() has the risk of a nullpointer dereference, when sccp is NULL. Return NULL when the sccp instance is NULL. Add doxygen comment Change-Id: I84d484e4441fd37443fff8c67e17df8fb15d5b2e
2017-08-11sccp: function to get sccp instance from sccp userPhilipp Maier1-0/+10
It is currently impossible to find out which SCCP instance handles a particular user. Introduce function to lookup the SCCP instance from a given SCCP user. Change-Id: I9562c4f1d00e2ebb3252c5dea598b643aa393719
2017-08-11sccp: add doxgen comments for osmo_sccp_simple_client()Philipp Maier1-0/+32
Some of the functons in sccp_user.c have already doygen comments on them. Add doxygen comments for the simple client functions as well Change-Id: I9143bdc54d729f9f50e69fe38cd1798e065f2497
2017-08-11sccp: check for valid point code in osmo_sccp_simple_client()Philipp Maier1-6/+10
The point-code is not checked in the beginning, only the ASP checks the point code at a very late stage and fails in case an invalid point-code is detected. Remove the check in the ASP creation. Add a new check after the SS7 initalization that checks the point-code. If none is set, the default point-code will be used. Change-Id: I334d90e769bd9952f67c51b12a945f22bd268fa8
2017-08-11sccp: fix handling of default IP addresses in osmo_sccp_simple_client()Philipp Maier1-4/+4
When the default IP addresses (remote or local) the respective struct value should be set to NULL. Fix wrong ?:-notation. Change-Id: I312caf9d54cedb02034e4ef88fdd2e6ad9ca1c34
2017-08-10sccp: prefix default parameters of osmo_sccp_simple_client()Philipp Maier1-20/+27
The simple client takes certain parameters (pc, ip and port numbers) which serve as a fallback default in case the user did not configure any suitable parameters via the VTY. Prefix all default variables with default_ to make the purpose clear to the API user Change-Id: Id9e697e8b198e4f58a79e59aaf2e649e84a3eb63
2017-08-09safer osmo_sccp_make_addr_pc_ssn(): clear all valuesNeels Hofmeyr1-4/+6
Make sure that all values of the resulting sccp_addr are cleared to obtain a clean PC+SSN address. Before this, gt and ip remained unset/random, e.g. in osmo_sccp_tx_unitdata_ranap() Change-Id: I37395169d364050e45e99793c495a9848a4f8601
2017-08-09vty: hide SG commands when running as ASPPhilipp Maier1-5/+13
The SG (signal gateway) requires an extra set of VTY commands in order to be fully configurable. These VTY commands do not make sense in a situation where libosmo-sccp is used to implement an ASP (application server process). Detect in which role libosmo-sccp is used by which of the VTY initalization functions are called: osmo_ss7_vty_init_asp() ==> ASP osmo_ss7_vty_init_sg() ==> SG Prevent writing back of SG specific configuration when in running as ASP. Only write back the full parameter set when running as SG. Change-Id: I707bcd790f4c6d0f618e41163b51d2179ea3aeaf
2017-08-09sccp: fix creating of the default route in simple clientPhilipp Maier1-3/+7
The simple client (osmo_sccp_simple_client_on_ss7_id() and osmo_sccp_simple_client) does not create a default route if the user has already created an AS via VTY. Check the presence of a default route independently of the AS. If no default route exists, create one. Change-Id: I7516fa5509bade4ba10e9d8eaa3e46cfe3696b3a
2017-08-09cosmetic: ws in logNeels Hofmeyr1-1/+1
Change-Id: If5a56ec170d4e91ce070f6fa9c9cfe5bbc121186
2017-08-09sccp_helpers: check buf len in append_to_buf()Neels Hofmeyr1-18/+21
Change-Id: I2e6d656871f952be8e719573fedf2154832841d7
2017-08-09sccp-addr vty: set RI to SSN_PC when setting a point-codeNeels Hofmeyr1-0/+2
Change-Id: I75c67d289693f1c2a049ac61cf2b2097d6e5687d
2017-08-09fix osmo_sccp_addr_dump(): actually print RINeels Hofmeyr1-1/+1
Adjust xua_test accordingly. Change-Id: I93e0aa706867e7b1de7f7a6071e3c8af89772af0
2017-08-09add osmo_sccp_addr_name() and three value_string[]sNeels Hofmeyr2-0/+71
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-09introduce OSMO_SCCP_RI_NONE to indicate unset RINeels Hofmeyr1-0/+5
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-09constify ss7_instance arg of osmo_ss7_pointcode_print()Neels Hofmeyr1-3/+3
Change-Id: I8c6b7188d004033e75e9c41f4a65c418d13a79c5
2017-08-09consistency: use OSMO_SS7_PC_INVALID for osmo_sccp_userNeels Hofmeyr4-21/+16
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-09ensure valid primary_pc in osmo_ss7_instanceNeels Hofmeyr5-6/+19
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-09add OSMO_SS7_PC_INVALID, add osmo_ss7_pc_is_valid()Neels Hofmeyr1-3/+9
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-09sccp: add function to check sccp addressesPhilipp Maier1-0/+42
In order to catch invalid CS7 configurations, It is necessary to check if sccp addresses contain plausible address data. Change-Id: Ic6245288b0171eae10aa708403c1ddb584c92f38
2017-08-07osmo_ss7_vty_init: ensure a talloc ctx is set by userNeels Hofmeyr1-10/+7
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-07add osmo_sccp_addr_set_ssn()Neels Hofmeyr1-0/+6
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-01sccp: derive local address from given sccp instancePhilipp Maier1-0/+22
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-07-31sccp: fix possible nullpointer derefInstallation Owner1-2/+4
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