summaryrefslogtreecommitdiffstats
path: root/include/osmocom/sigtran/sccp_sap.h
AgeCommit message (Collapse)AuthorFilesLines
2019-04-12add osmo_sccp_addr_cmp(), osmo_sccp_addr_ri_cmp()Neels Hofmeyr1-0/+3
osmo-msc identifies its BSC and RNC peers by SCCP address, and compares those by memcmp(), which is not really accurate. Rather provide a meaningful osmo_sccp_addr_cmp() API to determine whether SCCP addresses are identical. Go for a full cmp that would also allow sorting. Change-Id: Ie9e2add7bbfae651c04e230d62e37cebeb91b0f5
2019-04-12add caller-owns-msgb variant osmo_sccp_user_sap_down_nofree()Neels Hofmeyr1-0/+1
Add osmo_sccp_user_sap_down_nofree(), which is identical to osmo_sccp_user_sap_down(), but doesn't imply a msgb_free(). To implement that, sccp_sclc_user_sap_down_nofree() with the same msgb semantics is required. Rationale: Avoiding msgb leaks is easiest if the caller retains ownership of the msgb. Take this hypothetical chain where leaks are obviously avoided: void send() { msg = msgb_alloc(); dispatch(msg); msgb_free(msg); } void dispatch(msg) { osmo_fsm_inst_dispatch(fi, msg); } void fi_on_event(fi, data) { if (socket_is_ok) socket_write((struct msgb*)data); } void socket_write(msgb) { if (!ok1) return; if (ok2) { if (!ok3) return; write(sock, msg->data); } } However, if the caller passes ownership down to the msgb consumer, things become nightmarishly complex: void send() { msg = msgb_alloc(); rc = dispatch(msg); /* dispatching event failed? */ if (rc) msgb_free(msg); } int dispatch(msg) { if (osmo_fsm_inst_dispatch(fi, msg)) return -1; if (something_else()) return -1; // <-- double free! } void fi_on_event(fi, data) { if (socket_is_ok) { socket_write((struct msgb*)data); else /* socket didn't consume? */ msgb_free(data); } int socket_write(msgb) { if (!ok1) return -1; // <-- leak! if (ok2) { if (!ok3) goto out; write(sock, msg->data); } out: msgb_free(msg); return -2; } If any link in this call chain fails to be aware of the importance to return a failed RC or to free a msgb if the chain is broken, or to not return a failed RC if the msgb is consumed, we have a hidden msgb leak or double free. This is the case with osmo_sccp_user_sap_down(). In new osmo-msc, passing data through various FSM instances, there is high potential for leak/double-free bugs. A very large brain is required to track down every msgb path. osmo_sccp_user_sap_down_nofree() makes this problem trivial to solve even for humans. Change-Id: Ic818efa78b90f727e1a94c18b60d9a306644f340
2017-12-24add osmo_sccp_user_name()Neels Hofmeyr1-0/+2
There is a naming dilemma: though the osmo_ prefix is now reserved for libosmocore, all surrounding API already has the osmo_ prefix. This will be used by osmo-hnbgw's VTY 'show cnlink' command. Change-Id: Ib7abf69cfcf4c56273223054b280458451e6c2f6
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-11sccp: fixup for osmo_sccp_get_ss7()Philipp Maier1-1/+1
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/+1
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-09add osmo_sccp_addr_name() and three value_string[]sNeels Hofmeyr1-0/+13
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/+1
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-09sccp: add function to check sccp addressesPhilipp Maier1-0/+2
In order to catch invalid CS7 configurations, It is necessary to check if sccp addresses contain plausible address data. Change-Id: Ic6245288b0171eae10aa708403c1ddb584c92f38
2017-08-01sccp: derive local address from given sccp instancePhilipp Maier1-0/+4
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-20sccp: global addressbook search + api fixPhilipp Maier1-4/+4
The sccp-addressbook only allows defining addresses for a specific ss7 instance. It is not possible to use an sscp-address, that is defined in the one ss7 instance in another ss7 instance. Add a second global list where all sscp-addresses are added, regardless on which instance they are defined. Fixup the search functions so that they always search the global list. Change the API, so that the address data is written to a destination pointer. This protects the stored address from unintentional changes. Also return the ss7 instance, where the address is associated with. Change-Id: I5acc1e5abc3b3081149a9f476038e4e53d23b763
2017-06-21sccp: add addressbook functionality for sccp addressesPhilipp Maier1-0/+6
SCCP addresses are defined through a number of compoinents, not just an IP-Address, there is also point code, ssn and more. To simplify and unify the handling of such objects, this patch introduces an addressbook functionality. The user can set up multiple addresses per ss7 instance and give them names. Later that name can be used to reference the address at a later point in the config. This means that the usage of sccp-addresses from the programmers point of view boils down to a VTY function that reads the string name of a previously defined address. The programmer can then use the API to get a pointer to the SCCP address struct and use it normally. For this feature, two additional VTY nodes are necessary, this commit depends libosmocore change: Change-Id I42aa29c0cccc97f284b85801c5329b015b189640 Change-Id: I068ed7f7d113dab88424a9d47bab7fc703bb7942
2017-04-14SCCP: Add VTY interface for SCCPHarald Welte1-0/+2
Change-Id: I100daaa947dbab6a4528c4e9fbd0d30790288f63
2017-04-10Add osmo_sccp_get_ss7() accessor functionHarald Welte1-0/+1
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-10sccp: add osmo_sccp_user_{get,set}_priv() API functionHarald Welte1-0/+2
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-10Add new SCCP implementationHarald Welte1-0/+20
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-10License headers: Should always have been GPLv2-or-laterHarald Welte1-5/+5
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-10sccp_sap: Add support for N-NOTICE.indicationHarald Welte1-0/+10
Change-Id: I6656889b4333e9909cf1c60c24dfc754281547b4
2017-04-10sccp_sap: Add routing indication (RI) to osmo_sccp_addrHarald Welte1-0/+1
Change-Id: I4dd23150f4c588b6430c22fc0cb66635994ceea9
2017-04-10sccp_sap: Use zero-terminated string for GT digits in osmo_sccp_addrHarald Welte1-2/+1
This is more natural to most application code, so simply go for ASCII string with NUL-termination rather than an array with explicit length. Change-Id: I6312208cdfa83184be41157a473c96e9120c63db
2017-01-27cosmetic: add comments for GT, PC, SSN to help noobs finding their wayNeels Hofmeyr1-3/+3
Change-Id: I8f47f855c2718f4922b36229a388fa719c628bf6
2016-07-07fix struct member typo: repsonding_addr in osmo_scu_disconn_paramNeels Hofmeyr1-1/+1
By accident, I already fixed this typo in osmo-iuh, breaking the build. Instead of reverting there, fix it here. Change-Id: I4076fb37c0d94be7adff46e76465884a61c54c9a
2016-04-16Add more OSMO_SCCP_SSN_ definesHarald Welte1-0/+16
hopefully we should now know all that we ever expect to need.
2016-04-16Fix RANAP SSN: it's 142, not 143Neels Hofmeyr1-1/+1
143 is actually the SSN for RNSAP. Wireshark displayed a RNSAP message type and malformed packet warning until I fixed this to 142. Now I get the proper RANAP and id-Paging reported. There has been a reallocation for RANAP and RNSAP SSNs, though the old SSN for RANAP is apparently 32 (seen in a pcap from a real 3G network). When I send 32 instead of 142, wireshark also decodes the message as valid RANAP.
2015-12-25Add missing OSMO_SCCP_SSN_RANAP for RANAP SSNHarald Welte1-0/+1
2015-12-23Properly define SCCP_SAP_USER without random magic numberHarald Welte1-3/+1
2015-12-22Import SUA (SCCP User Adaptation) and SCCP User SAPHarald Welte1-0/+199
... this code originates from the osmo-iuh repository, but is now part of a new shared libosmo-sigtran.so library generated in this repository.