summaryrefslogtreecommitdiffstats
path: root/src/gsm/lapd_core.c
Commit message (Collapse)AuthorAgeFilesLines
* gsm: lapd_core: Log timeout used upon start of T200Pau Espin Pedrol2019-06-211-1/+2
| | | | | | | | The timeout is calculated dynamically in t200_by_lchan() based on FN advance value estimated by bts_get_avg_fn_advance(), so it's informative to have the final value printed out. Change-Id: Ib50a9c23de881c66c9218833703cc41101e06bfd
* lapd_core: Perform N200 retransmissions, not N200-1Harald Welte2019-06-051-4/+4
| | | | | | | | | | | | | | | During testing with BTS_Tests_LAPDm.TC_t200_n200() it was discovered that the existing LAPD[m] implementation always gave up at N200-1 retransmissions, rather than N200 retransmissions. The first transmission doesn't count, and hence we must have N200 actual re-transmissions. The Error message is then described as "T200 expired N200+1 times", i.e. we start T200 one more time after the last re-transmission and only give up if it expires again (i.e. no ACK received) Change-Id: Ic33854ee61311f73b7db55eeef10280349151097 Related: OS4037
* Log lapd_datalink state on errorsMax2018-01-161-5/+5
| | | | | | | It's not very useful to get just the raw pointer address in case of lapd_datalink receive error. Log it's state in addition. Change-Id: Ie8c5df262312f886f509113f2707e36811df3bd5
* Fix malformed Abis/RSL messages with extra L3 Information fieldPau Espin Pedrol2017-12-101-3/+1
| | | | | | | | | | | | | | | | | Some Abis/RSL messages such as "Release Indication" contained 3 extra bytes from an L3 Information header which should not be there according to specs in GSM 08.58 (section 8.3 "Radio link layer management messages"). Other RSL messages were affected by the same issue, except for "Establish Indication", which had already a workaround in send_rslms_dlsap. This commit fixes the issue in a generic way, removes the "Establish Indication" and fixes the test accounting for the bug, as it otherwise fails after applying the changes. Fixes: OS#1635, OS#2336 Change-Id: Ibb116214e8b1798d65a8b0917150496a3c14f344
* Fix LAPD UA msgb memory leak.Jean-Francois Dionne2017-12-101-0/+3
| | | | Change-Id: Ia4f0606810e00aa6f1779d11893e4acc01976f9a
* cosmetic: Fix trailing whitespacePau Espin Pedrol2017-12-101-6/+6
| | | | Change-Id: I0c7a414789f8ce6516369327430f71164e2cbd94
* Fix/Update copyright notices; Add SPDX annotationHarald Welte2017-11-131-0/+2
| | | | | | | | 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
* lapd_core: Fix crash in lapd_est_req() functionIvan Kluchnikov2017-09-011-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | lapd_est_req() function could be called on uninitialized lapd link (before lapd_dl_init() and after lapd_dl_exit() functions) due to invalid usage on higher levels. In order to prevent using uninitialized lapd link, we should set LAPD_STATE_NULL state for lapd_datalink in lapd_dl_exit() function. So all messages for lapd_datalink in null state will be unhandled by lapd_recv_dlsap() function and lapd_est_req() function will not be called before lapd_dl_init() function where lapd link state is changed to idle. #0 0x00007f46ecd99aa5 in lapd_est_req (dp=<optimized out>, lctx=0x7f46ed80b8b8) at lapd_core.c:1769 #1 0x00007f46ecd9dda8 in rslms_rx_rll_est_req (msg=msg@entry=0x7f46eeab4940, dl=dl@entry=0x7f46ed80b888) at lapdm.c:845 #2 0x00007f46ecd9fc03 in rslms_rx_rll (lc=0x7f46ed80b398, msg=0x7f46eeab4940) at lapdm.c:1157 #3 lapdm_rslms_recvmsg (msg=0x7f46eeab4940, lc=0x7f46ed80b398) at lapdm.c:1223 #4 0x00007f46ed63773d in rsl_rx_rll (msg=<optimized out>, trx=<optimized out>) at rsl.c:2178 #5 down_rsl (trx=<optimized out>, msg=<optimized out>) at rsl.c:2541 #6 0x00007f46ed641529 in sign_link_cb (msg=<optimized out>) at abis.c:169 #7 0x00007f46ec54b111 in ipaccess_bts_read_cb (link=0x7f46eeab4940, msg=0x0) at input/ipaccess.c:807 #8 0x00007f46ec548a8e in ipa_client_read (link=0x7f46ee26ae30) at input/ipa.c:74 #9 ipa_client_fd_cb (ofd=<optimized out>, what=1) at input/ipa.c:137 #10 0x00007f46ecfc726f in osmo_fd_disp_fds (_eset=0x7ffe7a9fcd20, _wset=0x7ffe7a9fcca0, _rset=0x7ffe7a9fcc20) at select.c:167 #11 osmo_select_main (polling=polling@entry=0) at select.c:207 #12 0x00007f46ed63fc25 in bts_main (argc=5, argv=<optimized out>) at main.c:359 #13 0x00007f46ebd76f45 in __libc_start_main (main=0x7f46ed61b120 <main>, argc=5, argv=0x7ffe7a9fcf18, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, #14 0x00007f46ed61b14e in _start () Related: OS#1982 Change-Id: I306dad9b78e3becaef14c5305ec25c312feefe3c
* doxygen: unify use of \file across the boardNeels Hofmeyr2017-06-231-9/+8
| | | | | | | | | | | | | | | | | 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
* doxygen: enable AUTOBRIEF, drop \briefNeels Hofmeyr2017-06-231-2/+2
| | | | | | | | | | 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
* update/extend doxygen documentationHarald Welte2017-06-121-0/+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
* use osmo_{htonl,htons,ntohl,ntohs}() functions all over libosmocoreHarald Welte2017-05-151-1/+0
| | | | | | This gets us one step closer to fixing the embedded build Change-Id: I3fc2639b6ade9ab138766987eceab7ec9498fdc7
* timer: add osmo_timer_setup()Pablo Neira Ayuso2017-05-091-4/+2
| | | | | | | | | | | | | | | 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
* fix spelling in API docu, command reply, logging, descriptionsThorsten Alteholz2017-04-231-1/+1
| | | | | | sections: ctrl, gb, gsm, vty Change-Id: Iac211b5cd8504da36b699777b95a2448dd7c3e70
* Fix LAPD UA message buffer memory leak.Jean-Francois Dionne2017-03-291-5/+5
| | | | | | | | | The state check in lapd_dl_reset causes some buffers never to be released. Using talloc report LAPD UA message buffers are never released after each call and cause a memory leak. Change-Id: I2799b70623f2ec4dbc725eb213e332e98da02a3e
* lapd_core: Use 'struct value_string' for LAPD state namesHarald Welte2017-03-151-28/+33
| | | | | | | | | We don't really use state numbers without bounds check into string tables since March 2010, when value_string became part of libosmocore. It's time to catch up, 7 years later... Change-Id: I1dac7b4cb441a1119cc167112521e8b8aae62e63
* lapd_core: Fix MDL-ERROR ind after RELEASE indPhilipp Maier2017-02-071-4/+4
| | | | | | | | | in lapd_t200_cb() The RELEASE INDICATION is transmitted before the MDL ERROR INIDCATION, this prevents the MDL ERROR INDICATION from being sent because the RELASE INDICATION close to connection eraly. This commit puts the messages into the correct order. Change-Id: Iae74777138fc27828f511e3aa321d1981861f4a5
* lapd_core: fix program flowPhilipp Maier2017-02-071-5/+5
| | | | | | | | | | | | | | | | when the lapd core is in state LAPD_STATE_SABM_SENT, and the retransmission counter exceeds (link down) lapd_t200_cb() will send an RELASE_INDICATION and an MDL_ERROR_INDICATION to L3. This action is done before the state is processed. This seems to be no problem with standard retransmission counts (n200), but may cause timing problems that lead to deadlock states when custom timer configurations are in use. (Ericsson RBS). This commit moves the functions calls for sending the indications mentioned above to the very end of the if branch to relax the timing again. (See lapd_t200_cb()) Change-Id: I1c1beb3701b19744a3ce9946abca7767d20a0b6a
* lapd_core: Improve debug outputPhilipp Maier2017-02-031-144/+190
| | | | | | | | | The debug output of lapd core has no references to the dl objects, since we have multiple links, seeing which action is for which object is impossible. This commit adds pointer references (dl=%p) to each log line. Change-Id: I3024d1cbd58631e2abac4ce5822528e2e6e15fda
* Fix compilation warnings: missing includes: gsm0411_utils.c, lapd_core.c, ↵Max2017-01-131-0/+1
| | | | | | oap_test.c Change-Id: Id524327b3f44e22e3aa44c5e8e4965b084cb326a
* LAPD: improve loggingMax2017-01-101-4/+6
| | | | | | Log error cause and state names in case of SABM errors. Change-Id: I2c7fa276e03f8b14ba41cc1fb6e19d0aae77d127
* lapd_core: Fix crash in lapd_dl_flush_hist()Harald Welte2016-08-011-1/+1
| | | | | | | | When lapd_dl_flush_hist() was called before we actually had started a transmit history from lapd_dl_init(), we woul segfault before this patch. Change-Id: Ifa677c9b335dd2884b4f3e44699d901957a0500b
* lapd_dl_flush_hist(): Don't flush a non-existant historyHarald Welte2016-07-031-0/+3
| | | | | | | | | | | If lapd_dl_flush_hist() is called after lapd_dl_exit(), dl->tx_hist has already been free'd and set to NULL. Check for this before attempting to de-reference a NULL pointer. This bug breaks OpenBSC with any E1 based BTSs using DAHDI. Change-Id: I117ba3445fa5e8097e21c11c5a6337de6ba46c7d Related: OS#1760
* some comments / fixed typosNeels Hofmeyr2015-12-211-1/+1
|
* gsm/lapdm: Prevent LAPD tx_queue from filling up in polling modeDaniel Willmann2014-03-261-0/+6
| | | | | | | If LAPDm receives an I-Frame while there already is an I-Frame in the tx_queue the code generates an additional RR (to acknowledge the received I-Frame). Instead, N(R) of the I-Frame in the tx_queue should be updated to ACK the data.
* lapd: Improve log message and mention the SAPI the dl is onHolger Hans Peter Freyther2014-03-161-2/+2
| | | | | | | When debugging an issue that involves SAPI=0 and SAPI=3 the log file does not have enough context. Add the SAPI to this message so we at least understand which SAPI we are talking about.
* lapd: Use the right struct for the talloc_zero_array callHolger Hans Peter Freyther2014-02-091-2/+2
| | | | | | I saw this while playing with talloc pools and wondered why lapd_core is creating a log_info. Use the right struct for the array.
* lapd: Remove the double NULL check idiom with msgb_freeHolger Hans Peter Freyther2013-08-091-22/+13
| | | | | | | | | | | | | | if (ptr) msgb_free(ptr) extends to: if (ptr) talloc_free(ptr) And according to the talloc documentation a talloc_free(NULL) will not crash: "... Likewise, if "ptr" is NULL, then the function will make no modifications and returns -1."
* LAPD: Free resume/re-establishment msgb if it carries no contentAndreas Eversberg2013-07-101-2/+5
| | | | | | | | | lapdm.c takes the re-establishment message and forwards it to lapd_core.c, so we can assume that msgb is set at primitive. In case there is data in the re-establishment msg, it is moved into send_buffer. In case of no data (0 length), it must be freed. Fixes an issue spotted by Coverity Scan.
* LAPDm: Fix re-establishment of datalinkAndreas Eversberg2013-07-061-5/+14
| | | | | | | | | | If the datalink fails or if handover or assignment to a new channel fails, it is re-establised by sending SABM again. The length of establish message is 0 in this case. The length is used to differentiate between re-establishment and contention resolution, which has to be handled differently. See TS 04.06 Chapter 5.4.2.1
* lapd_core: msgb_trim() the L2 padding from ESTABLISH.indHarald Welte2013-06-181-2/+3
| | | | | | | | When a SABM(E) frame arrives, we have to trim the L2 padding (0x2b for gsm) before handing the data off to L3, just like we do with I frames. Also, we should use mggb_trim() or even msgb_l3trim() instead of manually fiddling with msgb->length and ->tail pointers.
* lapd: Set the tx_hist to NULL after freeing itHolger Hans Peter Freyther2013-05-081-0/+1
| | | | | Make detecting use after free of the tx_hist easy and set the variable to NULL after talloc_free has been freed.
* Fix: LAPDm contention resoltion must acknowledge subsequent SABMAndreas Eversberg2013-04-061-2/+8
| | | | | | | | | After reception of SABM, the network responds with UA and enters the establised multiframe state. If UA is not received by mobile, the SABM is transmitted again, and the network must respond with UA again, unless it is from a different mobile. Add LAPDm collision test (contention resolution on network side).
* misc: Doxygen tweaks: fixed some typos and minor errorsKaterina Barone-Adesi2013-02-151-1/+2
| | | | | Doxygen generates quite a lot of warnings on libosmocore. Some of them are obvious typos - this patch aims to fix such low-hanging fruit.
* lapd: Use LOGL_ERROR for messgaes that are wrong in the given contextHolger Hans Peter Freyther2012-11-261-14/+14
| | | | Log message that are either too big or have the C/R bit set as error.
* misc: Use static const struct for LAPD and AbisHolger Hans Peter Freyther2012-11-221-1/+1
|
* lapd: Remove unused variable t200_start in lapd_acknowledge.Holger Hans Peter Freyther2012-03-161-2/+1
| | | | | lapd_core.c: In function 'lapd_acknowledge': lapd_core.c:710:38: warning: variable 't200_start' set but not used [-Wunused-but-set-variable]
* lapd: Warn if someone attempts to send an empty messageHolger Hans Peter Freyther2012-01-121-0/+7
| | | | | | DATA REQ with a msgb_l3len(msg) == 0 message does not make any sense, log an error and return immediately before attempting to send an empty I frame in lapd_send_i.
* lapd: Mention the L3 size of the payload being sentHolger Hans Peter Freyther2012-01-121-1/+2
|
* libosmocore/lapd: Fixed handling of sequence errors at lapd_core.cAndreas.Eversberg2012-01-101-3/+21
| | | | | | | | | | | | | | | If a sequence error is received, the N(R) variable must still be used to acknowledge previously transmitted frames. If there are two subsequent sequence errors received, ignore it. (Ignore every second subsequent error.) This happens if our reply with the REJ is too slow, so the remote gets a T200 timeout and sends another frame with a sequence error. Test showed that replying with two subsequent REJ messages could the remote L2 process to abort. Replying too slow shouldn't happen, but may happen over serial link between BB and LAPD. Written-by: Andreas.Eversberg <jolly@eversberg.eu> Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
* gsm/lapd_core: Make sure rc is initialize in lapd_rx_uSylvain Munaut2011-11-201-1/+1
| | | | Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
* lapd: Fixed possible double free buf in lapd_core.cAndreas Eversberg2011-11-121-2/+3
| | | | | Written-by: Andreas Eversberg <jolly@eversberg.eu> Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
* LAPD: Moved timer handling into seperate functionsAndreas Eversberg2011-10-101-72/+87
|
* Split of LAPDm into a core part and a GSM specific partroot2011-10-101-0/+2128
Instead of mixing together the GSM layer 1 interface and RSL interface with the implementation of LAPD, the core function of LAPD is now extracted from LAPDm. The core implementation is now in lapd_core.c and lapd_core.h respectively. The lapd_core.c implements exactly one datalink instance for one SAP. The surrounding implementation "lapdm.c" codes/decodes the layer 2 headers and handles multiplexing and datalink instances, as well as translates primitives from/to RSL layer. lapd_core.c can now be used for other LAPD implementations. (ISDN/ABIS)