aboutsummaryrefslogtreecommitdiffstats
path: root/src/gsm/lapd_core.c
AgeCommit message (Collapse)AuthorFilesLines
2017-03-29Fix LAPD UA message buffer memory leak.Jean-Francois Dionne1-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
2017-03-15lapd_core: Use 'struct value_string' for LAPD state namesHarald Welte1-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
2017-02-07lapd_core: Fix MDL-ERROR ind after RELEASE indPhilipp Maier1-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
2017-02-07lapd_core: fix program flowPhilipp Maier1-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
2017-02-03lapd_core: Improve debug outputPhilipp Maier1-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
2017-01-13Fix compilation warnings: missing includes: gsm0411_utils.c, lapd_core.c, ↵Max1-0/+1
oap_test.c Change-Id: Id524327b3f44e22e3aa44c5e8e4965b084cb326a
2017-01-10LAPD: improve loggingMax1-4/+6
Log error cause and state names in case of SABM errors. Change-Id: I2c7fa276e03f8b14ba41cc1fb6e19d0aae77d127
2016-08-01lapd_core: Fix crash in lapd_dl_flush_hist()Harald Welte1-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
2016-07-03lapd_dl_flush_hist(): Don't flush a non-existant historyHarald Welte1-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
2015-12-21some comments / fixed typosNeels Hofmeyr1-1/+1
2014-03-26gsm/lapdm: Prevent LAPD tx_queue from filling up in polling modeDaniel Willmann1-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.
2014-03-16lapd: Improve log message and mention the SAPI the dl is onHolger Hans Peter Freyther1-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.
2014-02-09lapd: Use the right struct for the talloc_zero_array callHolger Hans Peter Freyther1-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.
2013-08-09lapd: Remove the double NULL check idiom with msgb_freeHolger Hans Peter Freyther1-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."
2013-07-10LAPD: Free resume/re-establishment msgb if it carries no contentAndreas Eversberg1-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.
2013-07-06LAPDm: Fix re-establishment of datalinkAndreas Eversberg1-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
2013-06-18lapd_core: msgb_trim() the L2 padding from ESTABLISH.ind0.6.1Harald Welte1-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.
2013-05-08lapd: Set the tx_hist to NULL after freeing itHolger Hans Peter Freyther1-0/+1
Make detecting use after free of the tx_hist easy and set the variable to NULL after talloc_free has been freed.
2013-04-06Fix: LAPDm contention resoltion must acknowledge subsequent SABMAndreas Eversberg1-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).
2013-02-15misc: Doxygen tweaks: fixed some typos and minor errorsKaterina Barone-Adesi1-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.
2012-11-26lapd: Use LOGL_ERROR for messgaes that are wrong in the given contextHolger Hans Peter Freyther1-14/+14
Log message that are either too big or have the C/R bit set as error.
2012-11-22misc: Use static const struct for LAPD and AbisHolger Hans Peter Freyther1-1/+1
2012-03-16lapd: Remove unused variable t200_start in lapd_acknowledge.Holger Hans Peter Freyther1-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]
2012-01-12lapd: Warn if someone attempts to send an empty messageHolger Hans Peter Freyther1-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.
2012-01-12lapd: Mention the L3 size of the payload being sentHolger Hans Peter Freyther1-1/+2
2012-01-10libosmocore/lapd: Fixed handling of sequence errors at lapd_core.cAndreas.Eversberg1-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>
2011-11-20gsm/lapd_core: Make sure rc is initialize in lapd_rx_uSylvain Munaut1-1/+1
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12lapd: Fixed possible double free buf in lapd_core.cAndreas Eversberg1-2/+3
Written-by: Andreas Eversberg <jolly@eversberg.eu> Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-10-10LAPD: Moved timer handling into seperate functionsAndreas Eversberg1-72/+87
2011-10-10Split of LAPDm into a core part and a GSM specific partroot1-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)