aboutsummaryrefslogtreecommitdiffstats
path: root/src/gb/gprs_ns.c
AgeCommit message (Collapse)AuthorFilesLines
2023-02-28doxygen: fix various typos in commands \param and \returnsVadim Yanitskiy1-1/+1
Change-Id: If87cec3739449c6a54e24fb2cb81e746d8244da2
2022-07-22gb/gprs_ns: call osmo_timer_del() unconditionallyVadim Yanitskiy1-4/+2
osmo_timer_del() does check if a timer is active internally. Change-Id: I3fdfcde33bc6f8a88680ad3f1dde2b6ff8846020
2021-07-26cosmetic: gb/gprs_ns.c: fix trailing whitespacePau Espin Pedrol1-2/+2
Change-Id: I842efdb93c9b480d5ab35c78b0bc60697262874a
2021-06-04Use new stat item/ctr getter APIsPau Espin Pedrol1-21/+21
Generated with spatch: """ @@ expression E1, E2; @@ - &E2->ctr[E1] + rate_ctr_group_get_ctr(E2, E1) """ """ @@ expression E1, E2, E3; @@ - E2->items[E1] + osmo_stat_item_group_get_item(E2, E1) """ Change-Id: I41297a8df68e28dfc6016330ac82b0ed5dd0ebc1
2021-04-29gprs_ns: Fix another DSCP vs. TOS mistake in old NS codeHarald Welte1-9/+4
DSCP is a 6-bit value stored in the upper 8 bit of what was used to be known as TOS. Let's use the newly introduced OSMO_SOCK_F_DSCP() to prevent having to worry about this in higher level code. Change-Id: I6b9848fd0752d99d3df5346313618d5847d64fb8 Related: OS#5136
2020-07-28gprs_ns: fix typo in commentAlexander Couzens1-1/+1
Change-Id: Ie9d8decea18542cb0e1641dcb5fca5e4850910eb
2020-06-08NS: replace use of gprs_nsvc_create() with gprs_nsvc_crate2()Harald Welte1-10/+4
Change-Id: I2b10e1707b0976b685d1c14016481d5565888150
2020-06-08NS: Optionally disable NS-{RESET,BLOCK,UNBLOCK} when using UDP/IPHarald Welte1-4/+13
3GPP TS 48.016 is quite clear in that no NS-{RESET,BLOCK,UNBLOCK} procedures shall be used over an IP based transport. They are only for use in Frame Relay based transport. However, as libosmogb was first developed against ip.access nanoBTS, and their Gb implementation mandates those procedures, we unconditionally implemented those procedures back then. Let's give the user the option of disabling this behavior to become more spec compliant (and interoperate with more other vendors out there). Change-Id: Ic4eba1b4dcbeac00f5879db295e0a9f1a50f71d8
2020-03-04gb: Print signalling and data weights on NS-VC creation.Alexander Chemeris1-1/+2
Change-Id: Ieebec5487f5d995a453d15bc024931299d5cf5bf
2020-03-04gb: Fix typos in gprs_ns.c commentsAlexander Chemeris1-2/+2
Change-Id: I24605c8616015b5f7d45297afc65d6a93d2edbaf
2019-12-01gprs_ns_instantiate(): propagate errors from gprs_sns_init() to callerHarald Welte1-2/+7
Change-Id: I71f347a2f0376716e5f83d33a7931eb8a99aad77
2019-06-04make all library-internal static buffers thread-localHarald Welte1-1/+1
We have a number of library-internal static global buffers which are mainly used for various stringification functions. This worked as all of the related Osmocom programs were strictly single-threaded. Let's make those buffers at least thread-local. This way every thread gets their own set of buffers, and it's safe for multiple threads to execute the same functions once. They're of course still not re-entrant. If you need re-entrancy, you will need to use the _c() or _buf() suffix version of those functions and work with your own (stack or heap) buffers. Change-Id: I50eb2436a7c1261d79a9d2955584dce92780ca07
2019-05-10NS: log address:port on errorMax1-2/+2
Change-Id: If2dc533a6dc150254f5d44b672f04bb728e7e927
2019-05-08deal with rate_ctr_group_alloc() returning NULLHarald Welte1-0/+4
Change-Id: I47d6623b9eca704e3c2537cfb5799a4c0749a7bc Related: #3701
2019-04-10Add _c versions of functions that otherwise return static buffersHarald Welte1-0/+8
We have a habit of returning static buffers from some functions, particularly when generating some kind of string values. This is convenient in terms of memory management, but it comes at the expense of not being thread-safe, and not allowing for two calls of the related function within one printf() statement. Let's introduce _c suffix versions of those functions where the caller passes in a talloc context from which the output buffer shall be allocated. Change-Id: I8481c19b68ff67cfa22abb93c405ebcfcb0ab19b
2019-04-03Add _buf() functions to bypass static string buffersHarald Welte1-6/+10
We have a number of static buffers in use in libosmo*. This means the related functions are not usable in a thread-safe way. While we so far don't have many multi-threaded programs in the osmocom universe, the static buffers also prevent us from calling the same e.g. string-ify function twice within a single printf() call. Let's make sure there's an alternative function in all those cases, where the user can pass in a caller-allocated buffer + size, and make the 'classic' function with the static buffer a wrapper around that _buf() variant. Change-Id: Ibf85f79e93244f53b2684ff6f1095c5b41203e05
2019-03-21select: Rename BSC_FD_* constants to OSMO_FD_*Harald Welte1-2/+2
The naming of these constants dates back to when the code was private within OpenBSC. Everything else was renamed (bsc_fd -> osmo_fd) at the time, but somehow the BSC_FD_* defines have been missed at the time. Keep compatibility #defines around, but allow us to migrate the applications to a less confusing naming meanwhile. Change-Id: Ifae33ed61a7cf0ae54ad487399e7dd2489986436
2019-03-16gprs_ns: Don't use initial IP/port for anything but SNSHarald Welte1-2/+55
Section 6.2.1 of 3GPP TS 48.016 states: > A pre-configured endpoint shall not be used for NSE data or signalling > traffic (with the exception of Size and Configuration procedures) unless > it is configured by the SGSN using the auto-configuration procedures. However, in the current SNS implementation, the initial IP/Port over which we perform the SNS-SIZE + SNS-CONFIG are treated as one of the normal NS-VCs. Specifically, we also perform the NS-ALIVE procedure on it, which is clearly wrong. Let's explicitly create the "initial" NS-VC with data and signalling weight of 0, and ensure we never start the alive timer or send any non-SNS PDUs on this connection as long as SNS was not used to change either of the two weights to non-zero. While at it, also safeguard against processing any incoming non-SNS messages on such a all-zero-weight connection. Change-Id: I16a91a07e5914d123b2ea2f8413b94e7cd518628 Closes: OS#3844
2019-03-16gprs_ns.c: Update comment: IP SNS has recently been implementedHarald Welte1-1/+0
Change-Id: I8b98621a582a23d0483a5340b4aca7e0bc096e6d
2019-02-26NS: Add support for GPRS NS IP Sub-Network-Service (SNS)Harald Welte1-16/+237
The NS implementation part of the Gb implementation libosmogb so far implemented a rather classic dialect of Gb, with lots of heritage to FR (Frame Relay) transports. At least since Release 6 of the NS specification, there's an IP Sub-Network Service (SNS), which * permits for dynamic configuration of IP endpoints and their NS-VCs * abandons the concept of a NSVCI on IP transport * forbids the use of RESET/BLOCK/UNBLOCK procedures on IP transport This commit introduces BSS-side IP-SNS support to libosmogb in a minimally invasive way. It adds a corresponding SNS FSM to each NS instance, and implements the new SIZE/CONFIG/ADD/DELETE/CHANGE_WEIGHT procedures very closely aligned with the spec. In order to use the SNS flavor (rather than the classic one), a BSS implementation should use gprs_ns_nsip_connect_sns() instead of the existing gprs_ns_nsip_connect(). This implementation comes with a set of TTCN-3 tests in PCU_Tests_RAW_SNS.ttcn, see Change-ID I0fe3d4579960bab0494c294ec7ab8032feed4fb2 of osmo-ttcn3-hacks.git Closes: OS#3372 Closes: OS#3617 Change-Id: I84786c3b43a8ae34ef3b3ba84b33c90042d234ea
2019-02-26NS: Factor out gprs_nsvc_start_test() and use itHarald Welte1-5/+10
This function performs sending a NS-ALIVE PDU and starting Tns-Test, let's use it in all places where we used to do that. As part of this, also fix a bug where the sendto() return value (number of bytes sent) would actually propagate up all the way to gprs_ns_rx_reset() return value, which in turn affects the test results on stdout. Change-Id: I4d303117f77fabb74bbb91887b9914a81c2a084a
2019-02-26gprs_ns: Add code for SNS-SIZE and SNS-CONFIG encodingHarald Welte1-2/+178
Modern NS specifications contain a SNS (Sub Network Service) for negotiating IP/port/weight parameters of NS-over-IP links dynamically. This patch adds message encoding routines for SNS-CONFIG, SNS-SIZE and their respective acknowledgements. Related: OS#3372 Change-Id: I5c47e1c3c10deb89a7470ee2c03adfc174accc93
2019-02-23NS: Add missing NS Cause stringsHarald Welte1-0/+7
When I added the definitions for the IP-SNS in commit f030b210e8c13314d361a6b721a0cbcc72935219 back in 2010, I forgot to update the string definitions in ns_cause_str[]. Let's fix that Change-Id: I419ccc482d99b01263a60aede83dacd2d9de56ab
2019-02-19gprs_ns: Add missing NSVCI IE to NS-BLOCK-ACK messageHarald Welte1-1/+29
According to Section 9.2.4 of 3GPP TS 48.016, the NS-BLOCK-ACK PDU has a mandatory NSVCI IE which we so far were missing. Change-Id: Ie7205e99d57f1e42d941f1be2460d8c9f46aadfe Closes: OS#3808
2019-02-19gprs_ns.c: cosmetic whitespace fixesHarald Welte1-2/+2
Change-Id: Ic19f65bdc5527ad5a69d0a92320ce5f672bf4d2b
2019-02-19gprs_ns: Use gprs_ns_tx_alive() instead of gprs_ns_tx_simple()Harald Welte1-2/+2
If we use gprs_ns_tx_alive() we will get logging for free. Change-Id: I53d410d13540d389096c40425e1fa2eb7460b16b
2018-11-20document unblock-ack vs. signalling in gprs_ns_process_msg()Stefan Sperling1-0/+6
Since commit 797558ea1768e464f9559c5f7a4f3f4285c5de25 we send the NS_UNBLOCK_ACK message before dispatching the NS_UNBLOCK signal, instead of afterwards. Add comments which explain the intended order of events. Suggested-by: Pau Related: OS#2388 Change-Id: I4b93853c952a97302f8afc14f462f22c3e487564
2018-11-19send NS_POUT_UNBLOCK_ACK before signalling S_NS_UNBLOCKStefan Sperling1-1/+3
In gprs_ns_process_msg(), we were dispatching the S_NS_UNBLOCK signal before sending out the NS_POUT_UNBLOCK_ACK message. Signal handlers might send messages to the other side, assuming that NS is now unblocked. However, since such messages will arrive before the UNBLOCK_ACK message the receiver might discard them. This problem has been observed with our TTCN3 BSSGP_Emulation as a peer to osmo-pcu. This patch makes TTCN3 PCU TC_paging() test pass regardless of whether the test or osmo-pcu is started first. Before this patch, this test would only pass if the test was started before osmo-pcu. A remaining problem is that the test does not yet keep passing reliably unless osmo-pcu is restarted between test runs. Change-Id: I3af54a14bb6bcfa167c9a9d9f67835e7f5b9f1bb Related: OS#2890 Related: OS#2388
2018-10-10fix error handling gprs_ns_nsip_listen()Stefan Sperling1-1/+4
If we cannot bind the listening socket, reset related fields in the osmo fd structure to NULL again. Otherwise our caller might eventually try to use an uninitialized osmo fd. Change-Id: Ia953b2eff54cac0bd980944291f75db14df09a34 Related: OS#3643
2018-08-20use __FILE__, not __BASE_FILE__Neels Hofmeyr1-2/+2
The intention was to use the file's basename, but __BASE_FILE__ means "the root file that is being parsed and contains #include statements". If we had a function using __BASE_FILE__ and that was defined in an #included file, __BASE_FILE__ would indicate the first file where the #include is, and not the file where the function is defined. __BASE_FILE__ works for us because we don't ever include function definitions that log something, so __BASE_FILE__ always coincides with __FILE__ for our logging; but still __BASE_FILE__ is semantically the wrong constant. Related: OS#2740 Change-Id: Ibc1d3746f1876ac42d6b1faf0e5f83bd2283cdcc
2018-06-14Add function gprs_nsvc_state_appendDaniel Willmann1-0/+22
A common function to append the nsvc state from osmo-sgsn or osmo-gbproxy Change-Id: I7f0eaff7329ab98cad792d30b20ab053007aab85
2017-11-13Fix/Update copyright notices; Add SPDX annotationHarald Welte1-1/+4
Let's fix some erroneous/accidential references to wrong license, update copyright information where applicable and introduce a SPDX-License-Identifier to all files. Change-Id: I39af26c6aaaf5c926966391f6565fc5936be21af
2017-10-24GPRS: constify NS printing routine parametersMax1-1/+1
Change-Id: I549ab7c26ac1489e01f281594bafe44b0681dc83
2017-10-24Convert lib-internal rate_ctr from '.' separator to ':' separatorHarald Welte1-7/+7
The rate_ctr.c code would do this mangling automatically, but let's avoid using this from new versions of our code for simplicity/explicitness. Change-Id: I24a556f447cfac25efb6e83cac2d0c2972d98fe3
2017-10-24GPRS: clarify ip/frgre union useMax1-3/+15
* add comment about underlying assumption that structs in ip/frgre union members in gprs_nsvc struct have the same memory layout * remove such assumption from gprs_ns_ll_str() * use gprs_ns_ll_str() for NSE dump Change-Id: Idcb912b7b3f7460fd2b058e16650c0bde8f757ee
2017-10-24GPRS: wrap NS state assignment in macroMax1-14/+35
This enables logging for every state transition which makes NS troubleshooting easier. Change-Id: I5d6eaef0432d9be810bf93d07e40787b9ca59142 Related: SYS#3610
2017-10-24gb: optionally allow nsip packets only from a specific hostPhilipp Maier1-3/+25
When listening for nsip connections is enabled, then every remote host may send packets. This is useful for an SGSN that serves multiple PCUs, but contraproductive for a PCU that awaits packets from a single SGSN. Add struct members remote_ip, and remote_port to struct gprs_ns_inst, when set, then the listening end uses connect() to ensure that only the expected host may send packets. Related: OS#2401 Change-Id: Ifeb201d9006eec275a46708007ff342cdfc14e45
2017-10-23GPRS: log NS socketMax1-0/+1
Let's log NS UDP socket creation similar to the way we log it for telnet and ctrl interfaces. Change-Id: Ic9d0f94ab2c1bb33f67cd4f1c9236b64108c0bb6
2017-06-23doxygen: unify use of \file across the boardNeels Hofmeyr1-28/+26
Considering the various styles and implications found in the sources, edit scores of files to follow the same API doc guidelines around the doxygen grouping and the \file tag. Many files now show a short description in the generated API doc that was so far only available as C comment. The guidelines and reasoning behind it is documented at https://osmocom.org/projects/cellular-infrastructure/wiki/Guidelines_for_API_documentation In some instances, remove file comments and add to the corresponding group instead, to be shared among several files (e.g. bitvec). Change-Id: Ifa70e77e90462b5eb2b0457c70fd25275910c72b
2017-06-23doxygen: enable AUTOBRIEF, drop \briefNeels Hofmeyr1-19/+19
Especially for short descriptions, it is annoying to have to type \brief for every single API doc. Drop all \brief and enable the AUTOBRIEF feature of doxygen, which always takes the first sentence of an API doc as the brief description. Change-Id: I11a8a821b065a128108641a2a63fb5a2b1916e87
2017-06-12update/extend doxygen documentationHarald Welte1-1/+1
It's a pity that even with this patch we still are fare away from having the whole API documented. However, at least we have a more solid foundation. Updates not only extend the documentation, but also make sure it is rendered properly in the doxygen HTML. Change-Id: I1344bd1a6869fb00de7c1899a8db93bba9bafce3
2017-05-24Add human-readable names for signal_nsMax1-0/+10
Change-Id: Id664355eb8305fb287e4dae0800fb20dc2f9b8cd Related: SYS#3610
2017-05-15libosmogb: Convert to use new endian conversion helpersHarald Welte1-15/+16
Change-Id: I5ed17702cd9487e1cab6bae39802aa11fb6a37b0
2017-05-09timer: add osmo_timer_setup()Pablo Neira Ayuso1-2/+1
Add a new function timer function to set up the timer, similar to what we have in the Linux kernel. This patch also converts existing opencoded timer setup in the libosmocore tree as initial client of this new function. This patch implicitly removes function callback passed by reference that defeat compile time type validation. Compile-tested only, but I ran make check that reports success when testing timer infrastructure. Change-Id: I2fa49972ecaab3748b25168b26d92034e9145666
2017-05-09gprs: add value strings for NS PDU typeMax1-2/+26
Add value strings for Service Control PDUs according to 3GPP TS 48.016 ยง9 and use them for logging. Change-Id: I0ea3a45f35d68619d4cfa9735ef77abd9f9f0d58 Related: SYS#3610
2017-04-23fix spelling in API docu, command reply, logging, descriptionsThorsten Alteholz1-1/+1
sections: ctrl, gb, gsm, vty Change-Id: Iac211b5cd8504da36b699777b95a2448dd7c3e70
2017-02-23logging.h: fixup: shorter names for LOGGING_FILTER_* and LOGGING_CTX_*Neels Hofmeyr1-16/+16
My recent logging patch was merged to master a bit too soon. Accomodate the request for naming that matches the general "LOG" prefix instead of "LOGGING". libosmocore will not be backwards-compatible with the few commits from change-id I5c343630020f4b108099696fd96c2111614c8067 up to this one. This and following commits are backwards compatible with those before that short window. See also: * openbsc change-id Ib2ec5e4884aa90f48051ee2f832af557aa525991 * osmo-pcu change-id I4db4a668f2be07f3d55f848d38d1b490d8a7a685 Change-Id: I424fe3f12ea620338902b2bb8230544bde3f1a93
2017-02-22logging: centrally define ctx and filter indexesNeels Hofmeyr1-16/+16
It is too easy for calling code to use the same filter and context indexes for different filters and structs. For example, openbsc's IMSI filter and libgb's GPRS_BVC filter both fall on index 1 even though there are plenty more indexes to choose from. To alleviate this, have one central definition here, sort of like ports.h does for VTY and CTRL port numbers. Add static asserts to make sure the indexes fit in the available array and bit mask space. Calling code like openbsc.git and osmo-pcu need adjustments and/or should move to using these enum values instead of their local definitions. Taking this opportunity to also prepare for a split of struct gsm_subscriber in openbsc into bsc_subsciber and vlr_subscriber with appropriate separate filter index constants for both subscriber types. Include previous LOG_FILTER_ALL in the LOGGING_FILTER_* enum, and replace its use by (1 << LOGGING_FILTER_ALL). Change-Id: I5c343630020f4b108099696fd96c2111614c8067
2016-09-22add osmo_gettimeofday as a shim around gettimeofdayNeels Hofmeyr1-2/+2
This allows feeding a custom time for unit tests by overriding osmo_gettimeofday. Change-Id: Ic7a81a6eb51f27fe452962b91f2eae2070d87089
2016-04-24Fix unaligned access found by addr. sanitizerMax1-2/+2
gprs_bssgp.c:461:9: runtime error: load of misaligned address 0x62100001a66b for type 'uint32_t', which requires 4 byte alignment gprs_ns.c:937:16: runtime error: load of misaligned address 0x61d00002a97f for type 'uint16_t', which requires 2 byte alignment