aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bsc/osmo_bsc_bssap.c
AgeCommit message (Collapse)AuthorFilesLines
2020-07-18Move struct gsm_bts: gsm_data.* => bts.*Pau Espin Pedrol1-0/+1
Place all code related to the object into the related file. Having all the data model in one file made sense in early stage of development to make progress quickly, but nowadays it hurts more than helps, due to constantly growing size and more and more bits being added to the model, gaining in complexity. Currently, having lots of different objects mixed up in gsm_data.h is a hole of despair, where nobody can make any sense were to properly put new stuff in, ending up with functions related to same object in different files or with wrong prefixes, declarations of non-existing functions, etc. because people cannot make up their mind on strict relation to objects in the data model. Splitting them in files really helps finding code operating on a specific object and helping with logically splitting in the future. Change-Id: I00c15f5285b5c1a0109279b7ab192d5467a04ece
2020-07-16RR Channel Release: pass Cause code from BSSMAP Clear to the BTSNeels Hofmeyr1-4/+12
In lchan.release, add 'cause_rr', and set RR Channel Release message's cause value to lchan.release.cause_rr. In lchan_release(), do not set lchan.release.rsl_error_cause to the RR cause value, these are unrelated. Store in new lchan.release.cause_rr instead. The rsl_error_cause is apparently only used for logging, except for one place in lchan_fsm_wait_activ_ack() that compares it to RSL_ERR_RCH_ALR_ACTV_ALLOC, so there should not be a functional difference by this fix. Propagate the BSSMAP Clear Command cause to the RR Channel Release: Add struct gscon_clear_cmd_data as event data for GSCON_EV_A_CLEAR_CMD -- so far it sent the is_csfb flag, add the gsm0808_cause; invoking the event happens in bssmap_handle_clear_cmd(). Adjust event handling in gscon_fsm_allstate(); there, pass the cause to gscon_release_lchans(). In gscon_release_lchans(), pass the cause to gscon_release_lchan(), and then lchan_release(), which sets the new lchan.release.cause_rr to the passed cause value. As soon as the lchan FSM enters the proper state, it calls gsm48_send_rr_release(). There, set the cause value in the encoded message to lchan.release.cause_rr. Interworking with osmo-msc: so far, osmo-msc fails to set the Clear Command cause code for normal release, it just passes 0 which amounts to GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE. Before this patch, osmo-bsc always sent GSM48_RR_CAUSE_NORMAL in the RR Channel Release, and after this patch it will receive 0 == GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE from osmo-msc and more accurately translate that to GSM48_RR_CAUSE_PROT_ERROR_UNSPC. This means in practice that we will now see an error cause in RR Channel Release instead of GSM48_RR_CAUSE_NORMAL when working with osmo-msc. For changing osmo-msc to send GSM0808_CAUSE_CALL_CONTROL instead (which translates to GSM48_RR_CAUSE_NORMAL), see OS#4664 and change-id I1347ed72ae7d7ea73a557b866e764819c5ef8c42 (osmo-msc). A test for this is in Ie6c99f28b610a67f2d59ec00b3541940e882251b (osmo-ttcn3-hacks). Related: SYS#4872 Change-Id: I734cc55c501d61bbdadee81a223b26f9df57f959
2020-06-23fix crashes due to OSMO_ASSERT(conn->lchan)Vadim Yanitskiy1-10/+14
Starting from ttcn3-bsc-test-sccplite build #777, it was noticed that osmo-bsc crashes with the following message: Assert failed conn->lchan include/osmocom/bsc/gsm_data.h:1376 The cause of this is a recently merged patch that calls conn_get_bts() during assignment_fsm rate counter dispatch: "Count assignment rates per BTS as well" commit b5ccf09fc4042c7fb1fdaaa6263961c40b32564e Change-Id I0009e51d4caf68e762138d98e2e23d49acc3cc1a The root cause being that the assignment_fsm attempts to count an Assignment event for a BTS after the lchan has already been released and disassociated from the conn. The assertion is found in conn_get_bts(), which is used in various places. In fact, each caller is a potential DoS risk -- though most are in code paths that are guaranteed to have an lchan and bts present, having an OSMO_ASSERT() on the relatively volatile presence of an lchan is not a good idea for osmo-bsc's stability and error resilience. - Change conn_get_bts() to return NULL in the lack of an lchan. - Adjust all callers of conn_get_bts() to gracefully handle a NULL return val. - Same for cgi_for_msc() and callers, closely related. Here is a backtrace: Program received signal SIGABRT pwndbg> bt 0x0000555555be6e52 in conn_get_bts (conn=0x622000057160) at include/osmocom/bsc/gsm_data.h:1376 0x0000555555c1edc8 in assignment_fsm_timer_cb (fi=0x612000060220) at assignment_fsm.c:758 0x00007ffff72b1104 in fsm_tmr_cb (data=0x612000060220) at libosmocore/src/fsm.c:325 0x00007ffff72ab062 in osmo_timers_update () at libosmocore/src/timer.c:257 0x00007ffff72ab5d2 in _osmo_select_main (polling=0) at libosmocore/src/select.c:260 0x00007ffff72abd2f in osmo_select_main_ctx (polling=<optimized out>) at libosmocore/src/select.c:291 0x0000555555e1b81b in main (argc=3, argv=0x7fffffffe1b8) at osmo_bsc_main.c:953 0x00007ffff6752002 in __libc_start_main () from /usr/lib/libc.so.6 0x0000555555b61bbe in _start () In the case of the assignment_fsm counter, we now miss a chance to increase a BTS counter for a failed Assignment, but this is a separate problem. The main point of this patch is that osmo-bsc must not crash. Related: OS#4620, OS#4619 Patch-by: fixeria Tweaked-by: neels Fixes: I0009e51d4caf68e762138d98e2e23d49acc3cc1a Change-Id: Id681dfb0ad654bdb4b71805d1ad4f39a8bf6bbd1
2020-06-16use osmo_mobile_identity API everywhereNeels Hofmeyr1-17/+22
Depends: If4f7be606e54cfa1c59084cf169785b1cbda5cf5 (libosmocore) Change-Id: I71c3b4c65dbfdfa51409e09d4868aea83225338a
2020-05-29flatten: move network->bsc_data->* to network->*Neels Hofmeyr1-1/+1
The separate struct osmo_bsc_data is like another separate struct gsm_network for no reason. It is labeled "per-BSC data". These days, all of this is a single BSC and there will not be different sets of osmo_bsc_data. Drop struct osmo_bsc_data, move its members directly into gsm_network. Some places tested 'if (net->bsc_data)', which is always true. Modify those cases to rather do checks like 'if (net->rf_ctrl)', which are also always true AFAICT, to keep as much unmodified logic as possible in this patch. Change-Id: Ic7ae65e3b36e6e4b279eb01ad594f1226b5929e0
2020-05-29drop all BSC originated USSD notification featuresNeels Hofmeyr1-13/+2
The BSC is the wrong network component to originate USSD messaging, as can be seen in the hacks in the USSD code: for example, the BSC would send a CM Service Accept message as if an MSC had accepted the connection, dispatch a USSD and directly send some RR release message (without proper tear down messaging like the lchan_fsm does these days). This made sense in the osmo-nitb world, but by now we are aiming for solid 3GPP compliance. The BSC shall not originate USSD messages. Deprecate all VTY and CTRL commands related to USSD: VTY [no] bsc-welcome-text [no] bsc-msc-lost-text [no] bsc-grace-text [no] missing-msc-text (the commands with 'no' are ignored, without 'no' lead to an error) CTRL ussd-notify-v1 Drop (already unused) ussd.h. Drop gsm_04_80.h, gsm_04_80_utils.c, and all calling code. Drop "RF grace" notification, where osmo-bsc was able to notify active subscribers that the RF was being turned off. Change-Id: Iaef6f2e01b4dbf2bff0a0bb50d6851f50ae79f6a
2020-05-19bssap: Handle BSSMAP CONFUSION message.Alexander Chemeris1-0/+54
We decode the mesage and print it to the log files at ERROR log level. We also count it in the BSSMAP message counters. There is not much else we could do about it. Depends: If8afd2d096fb66c6c2f255a08fc1129de3d09cec (libosmocore) Change-Id: Ib4cd94f185f751b2384842222678ff671ac413c4
2020-05-16log: Fix "Paging request failed" logging levelAlexander Chemeris1-1/+1
"Paging request failed" message can be logged e.g. when we're already paging this subscriber which means we get hundreds of these messages in a perfectly normal situation. Let's demote this to INFO and adjust the wording. Change-Id: I97214796906ac599338e87b2b4b5465ab6b2447a
2020-05-11stats: Rename BSSMAP Rx message counters to match Tx ones.Alexander Chemeris1-3/+3
Change-Id: I29e42687ac084a60007f0b1ec6ec0a102fb4007f
2020-05-11stats: Add counters for Tx BSSMAP messages.Alexander Chemeris1-0/+8
We already have counters for Rx side, now we also count Tx side. See comments in the msc_ctr_description array implementation for the details. Change-Id: I89a173f6bdd9a3c21233fe01d07ab2ff0442bb10
2020-05-11stats: Only dereference a connection pointer after checking for NULL.Alexander Chemeris1-1/+2
Addresses CID 210261. Change-Id: Ic7e7c92c5b9ff696fa7f4cd0d69451cd22333f71
2020-05-09stats: Add counters for received BSSMAP messages.Alexander Chemeris1-0/+17
Change-Id: I3f08d71b58b4e8d6f61376d85c2051e194aa8e43
2020-05-09Fix indent whitespace and log message.Alexander Chemeris1-5/+5
Change-Id: I985bf8ac4ce6136812692c06b6dc78edc6bde652
2020-02-12bssap: Avoid logging error if no optional Global Call Ref IE receivedPau Espin Pedrol1-11/+15
Also take the chance to simplify related code and print erroneous IE data. Change-Id: I27ee9c6112f96d6839b8b6141888ac8fe377db65
2019-11-13Fix some typosMartin Hauke1-3/+3
Fix typos and common misspellings in code comments and in the manual. Change-Id: I46fc9d424620c77ae9ccf78b58081bd303386d7c
2019-05-19bssap: Parse Osmux CID on BSSAP Assign Req recv and use it in MGCPPau Espin Pedrol1-0/+28
The Osmux CID obtained from the MSC is passed to the co-located BSC MGW to configure the MSC-side MGW conn of a call leg. Depends on: osmo-mgw.git I73b4c62baf39050da81d65553cbea07bc51163de Change-Id: I86e7e13fc7921e3209fb764c0e7797e7ec09b79e
2019-05-19bssap: Detect MSC Osmux support on RESET (ACK) recvPau Espin Pedrol1-0/+23
Related: OS#2551 Depends on: libosmocore I28f83e2e32b9533c99e65ccc1562900ac2aec74e Change-Id: I830e38cc1ffb8b6ebbe299567507160f19beb528
2019-05-05fix inter-BSC-HO-incoming for AoIP (2/2)Neels Hofmeyr1-6/+31
For AoIP, the AoIP Transport Layer Address IE must be included in the Handover Request Acknowledge message, so the MSC can send RTP to the right place. Add this IE for AoIP. Depends: Ia71542ea37d4fd2c9fb9b40357db7aeb111ec576 (libosmocore) Depends: Id617265337f09dfb6ddfe111ef5e578cd3dc9f63 (libosmocore) Change-Id: Ia05e37da125eb6e7b7be9b974b73261bd72de1f4
2019-05-03assignment_fsm: Properly support assigning signalling mode TCH/xSylvain Munaut1-48/+76
To support the 3 possible preferences, the changes needed were: - Replace 'full_rate' bool with a 3 option enum to represent the channels types for signalling - Switch from _pref/_alt to using an array sorted in preference order Originally merged as Change-Id I4c7499c8c866ea3ff7b1327edb3615d003d927d3, reverted because the change broke voice calls. Re-submitting with the fix: don't forget to set conn->assignment.requires_voice_stream. Signed-off-by: Sylvain Munaut <tnt@246tNt.com> Change-Id: I7513d2cbe8b695ba6f031ad11560c63a6535cf2d
2019-04-30move mgw endpoint FSM to osmo-mgw.gitNeels Hofmeyr1-1/+2
osmo-mgw.git also includes fixes of the MGW endpoint FSM, for example I92a9944acc96398acd6649f9c3c5badec5dd6dcc. Depends: I9a3effd38e72841529df6c135c077116981dea36 (osmo-mgw) Change-Id: I03e6b48d9b0a5370310d5f56809259ff7909cf9d
2019-03-27osmo_bsc_bssap: check bssmap length fieldPhilipp Maier1-1/+31
At the moment the length field of the bssmap header is not parsed. Instead the length is computed out of the known header length and the number of bytes received. This is prone to error, lets make sure that extranous data at the end of a message is ignored by parsing the bssmap length correctly. Change-Id: Idef2e783d2377a2ad1f697ea4d26491a32b3e549 Related: OS#3806
2019-03-14Revert "assignment_fsm: Properly support assigning signalling mode TCH/x"Neels Hofmeyr1-76/+48
This commit breaks voice channel assignment. It results in the Assignment Complete sent to the MSC for a voice lchan lacking AoIP Transport Layer Address, Speech Version and Speech Codec. Hence the MSC cannot complete the Assignment for a voice call. Let's revisit this patch, test thoroughly and re-merge later. This reverts commit 4d3a21269b25e7164a94fa8ce3ad67ff80904aee. Reason for revert: <INSERT REASONING HERE> Change-Id: I72aaa03539919e7e85b5b75b133326cec5e68bc9
2019-03-14assignment_fsm: Properly support assigning signalling mode TCH/xSylvain Munaut1-48/+76
To support the 3 possible preferences, the changes needed were: - Replace 'full_rate' bool with a 3 option enum to represent the channels types for signalling - Switch from _pref/_alt to using an array sorted in preference order Change-Id: I4c7499c8c866ea3ff7b1327edb3615d003d927d3 Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2019-02-21assignment_fsm: fix channel allocator preferencesPhilipp Maier1-26/+107
When the MSC allocates a channel through the ASSIGNMENT REQUEST, it may ask for a TCH/H and a TCH/F at the same time and tell which of the two types it prefers. The process of channel allocation currently selects, based on the BTS, MSC and MS capabilites exactly one apropriate codec/rate (e.g. TCH/H) and then tries to allocate it. If that allocation fails, there is no way to try the second choice and the assignment fails. For example: The MSC asks for TCH/F and TCH/H, prefering TCH/F, then the channel allocator will try TCH/F and if it fails (all TCH/F are currently in use), then TCH/H is never tried. Since the BSC currently only trys the first best codec/rate that is supported it also ignores the preference. Lets fix those problems by including the preference information and both possible codec/rate settings into the channel allocation decision. Change-Id: I5239e05c1cfbcb8af28f43373a58fa6c2d216c51 Related: OS#3503
2019-02-05Implement CSFB "Fast Return" Handling at RR RELEASEHarald Welte1-1/+18
When the MSC sends a BSSMAP CLEAR CMD containing a CSFB Indication IE, it lets us know that the to-be-released connection related to a CSFB call. We as the BSC then subsequently should include the "Cell Selection Indicator after release of all TCH and SDCCH" IE in the RR RELEASE message sent to the MS/UE. This IE contains the LTE neighbor cells that we're configured to broadcast in si2quater. That in turn will make sure the MS/UE can return very quickly to the LTE cell. Closes: OS#3777 Change-Id: Ibfbb87e2e16b05032ad1cb91c11fad1b2f76d755 Requires: libosmocore Id4bd7f7543f5b0f4f6f876e283bd065039c37646 Requires: libosmocore I0e101af316438b56d63d43fc2cb16d7caf563d07 Requires: libosmocore I8980a6b6d1973b67a2d9ad411c878d956fb428d1
2018-12-21make sure early lchan act failure resets the lchanNeels Hofmeyr1-1/+1
Fix crash after AMR configuration fails. The crash is due to an assertion that finds a non-NULL conn in the lchan, when re-using an lchan that has failed in AMR configuration earlier on. That is because the AMR config still happens in state UNUSED. DCHAN ERROR lchan(0-0-2-TCH_F_TCH_H_PDCH-0)[0x6120000066a0]{UNUSED}: (type=TCH_F) lchan allocation failed in state UNUSED: Can not generate multirate configuration IE ... DCHAN DEBUG lchan(0-0-2-TCH_F_TCH_H_PDCH-0)[0x6120000066a0]{UNUSED}: (type=TCH_F) After failure handling, already in state UNUSED ... ... DCHAN DEBUG lchan(0-0-2-TCH_F_TCH_H_PDCH-0)[0x6120000066a0]{UNUSED}: Received Event LCHAN_EV_ACTIVATE (lchan_fsm.c:324) Assert failed !lchan->conn ../../../../src/osmo-bsc/src/osmo-bsc/lchan_fsm.c:491 The FSM design idea is that when returning to the UNUSED state, all lchan state is cleared. However, when calling lchan_activate(), a failure may happen still in state UNUSED, so that we don't transition *back* to UNUSED properly. So, first transition out of UNUSED before failures can happen. (Other ways to solve this would be to invoke lchan clearing even if already in UNUSED, but semantically, transitioning first makes more sense.) Upon LCHAN_EV_ACTIVATE, just remember the lchan_activate_info and transition to WAIT_TS_READY, so that on lchan_fail(), we can normally transition back to UNUSED and clear the lchan. Move the initial lchan activation code to lchan_fsm_wait_ts_ready_onenter(). Also, there is a bit of duplication of members of the lchan->activate (lchan state) and the lchan_activate_info (passed to lchan_activate()) structs. The fix for this also removes the dup: Add struct lchan_activate_info as child struct at lchan->activate.info, drop the other lchan->activate members that would dup .info.*. Move struct lchan_activate_info declaration to gsm_data.h. Apply the new '.info' member struct throughout the code. Related: OS#3737 Change-Id: Ide665b10fa3f4583059c55346db8da833959e3cc
2018-12-12bsc: bssap: Set subscr log context during pagingPau Espin Pedrol1-2/+8
Change-Id: I3998a35ff6ea29440882514bbb30cafed66f03fa
2018-12-11bsc: dtap: Set subscr log contextPau Espin Pedrol1-0/+3
Change-Id: I362a7d10f5ca9a95b594f7caafd7ed5b10fd059a
2018-12-01osmo_bsc_bssap.c: fix incorrect link_id assignmentVadim Yanitskiy1-1/+1
Every DTAP message coming from the MSC has a header (see struct dtap_header) that contains message type, length, and link ID. The link ID indicates SAPI and channel type of a given message. In dtap_rcvmsg() we allocate a new message buffer and copy the received message into it. The old message buffer is freed by the caller then. The link ID value parsed from DTAP header is usually being stored in the control buffer of a message buffer (i.e. msgb->cb). Due to a mistake, it was stored in the old (to be freed) message, while the new (to be forwarded) message always had link_id = 0x00! This change resolves the problem with sending SMS during a voice call, when MT signalling goes through FACCH, while MO signalling goes through SACCH. Change-Id: I7675e1ce4436fad836778261ac9d446fa8f81483 Related: OS#3716
2018-11-18LCLS: tighten GCR checkMax1-13/+14
Use stricter checks for received Global Call Reference. Change-Id: I9690e1b2d14e41471413bb35eb22fa6c4c4d67fd Related: OS#2487
2018-10-25cipher mode reject: send proper cause codesOliver Smith1-0/+3
bssmap_handle_cipher_mode() had code paths doing "goto reject" without setting a meaningful cause value. Related: OS#3186 Change-Id: Ia608fa34a6a2d3035a66d05fbc38553ac5186804
2018-10-25cosmetic: fix spec ref for gsm0808_cipher_mode()Oliver Smith1-1/+1
Change-Id: I359caf1dd30f033c0b606040ccf27aa4c5a9d2c6
2018-10-21bssmap_handle_cipher_mode(): Don't sent reject if !connHarald Welte1-1/+1
We can only send a reject response if we have a valid conn. Change-Id: I0ea535f494173ad4996c70dc82d7f69455e4e15e Fixes: Coverity CID#188824
2018-10-05codec_pref: handle S0-S15 in ASSIGNMENT REQUESTPhilipp Maier1-3/+4
Opposed to all other codecs that are common in GSM, AMR requires a codec configuration that is expressed by a bitmask (S0 to S15) in the speech codec list in the ASSIGNMENT REQUEST. Also the BSC acknowledges those configuration in the ASSIGNMENT COMPLETE message. At the moment osmo-bsc ignores all incoming configuration bits. The bits in the ASSIGNMENT COMPLETE speech codec (choosen) field are hardcoded. - Store the configuration bits while parsing the ASSIGNMENT COMPLETE - Create an intersection with the configuration that is actually supported by the BSS - Return the resulting (chosen) configuration bits with the assignment complete message. - Use the (highest of the) agreed codec rates in RSL channel activation. Change-Id: I2d8ded51b3eb4c003fe2da6f2d6f48d001b73737 Related: OS#3529
2018-09-18Implement RR Classmark EnquiryNeels Hofmeyr1-0/+3
If the MSC sends a BSSMAP Classmark Request, send an RR Classmark Enquiry to the MS. (The reverse direction, i.e. sending a BSSMAP Classmark Update back to the MSC, is already implemented.) Related: OS#3043 (A5/3 encryption) Related: osmo-ttcn3-hacks Idaab4d568cf986b4897ba008f6262c839d1592fb Change-Id: If5db638fd6e8d9c2ef9e139e99f0fabe1ef16ddf
2018-09-07inter-BSC HO incoming: send BSSMAP HO Complete directlyNeels Hofmeyr1-1/+1
Before Handover is fully completed, the gscon remains in an INIT state. To send back the BSSMAP Handover Complete message, use osmo_bsc_sigtran_send() directly to not thwart the message due to the gscon state. (The gscon state will change to ACTIVE right after that, once the handover FSM is done.) Change-Id: Ic48ae2bb23565015d5e2ccb56308fad09347b51a
2018-08-29inter-BSC HO: send failure msg directlyNeels Hofmeyr1-1/+1
If inter-BSC HO failed, the conn is by definition not in an active state, and hence it makes no sense to verify the gscon FSM state before sending. Directly call osmo_bsc_sigtran_send(). Change-Id: Ic49c94462041800674fa961c4d19c0c045bfe0c0
2018-08-29log: 'sending BSSMAP HO Request ACK'Neels Hofmeyr1-0/+1
Change-Id: Ie472c32861d9c9ca9ebec0221837030ffd83c73a
2018-08-07GSCON: call api of a_reset.c with msc object directlyPhilipp Maier1-1/+1
The API of a_reset.c is currently called with a pointer to struct reset_ctx. This puts the responsibility of checking the presence of msc->a.reset_fsm to the caller. It would be much more effective if the caller would check if msc->a.reset_fsm before dereferencing it. This also fixes at least one segfault that ocurrs when gscon_timer_cb() is called but no sccp connection is present yet. Therefore the pointer to bsc_msc_data would not be populated. This is now detected by a_reset.c itsself. - minor code cleanups - call a_reset.c functions with msc (struct bsc_msc_data) Change-Id: I0802aaadf0af4e58e41c98999e8c6823838adb61 Related: OS#3447
2018-07-28cosmetic: dissolve bsc_api.cNeels Hofmeyr1-0/+28
gsm0808_page() is just a thin wrapper for rsl_paging_cmd(), the only caller is page_ms() from paging.c. Directly call rsl_paging_cmd() instead. Move gsm0808_cipher_mode() to the only caller in osmo_bsc_bssap.c, make static. Change-Id: Ib7ce026b52d4ba3e53a8b2824e74ea92432c48c5
2018-07-28large refactoring: use FSMs for lchans; add inter-BSC HONeels Hofmeyr1-57/+247
Add FSMs: - timeslot_fsm: handle dynamic timeslots and OML+RSL availability. - lchan_fsm: handle an individual lchan activation, RTP stream and release, signal the appropriate calling FSMs on success, failure, release. - mgw_endpoint_fsm: handle one entire endpoint with several CI. - assignment_fsm: BSSMAP Assignment Request. - handover_fsm: all of intra, inter-MO and inter-MT handover. Above FSMs absorb large parts of the gscon FSM. The gscon FSM was surpassing the maximum amount events (32), and it is more logical to treat assignment, handover and MGW procedures in separate FSMs. - Add logging macros for each FSM type: - LOG_TS() - LOG_LCHAN() - LOG_MGWEP(), LOG_CI() - LOG_ASSIGNMENT() - LOG_HO() These log with the osmo_fsm_inst where present. New style decision: logging without a final newline char is awkward, especially for gsmtap logging and when other logs interleave LOGPC() calls; we have various cases where the final \n goes missing, and also this invokes the log category checking N times instead of once. So I decided to make these macros *always* append a newline, but only if there is no final newline yet. I hope that the compiler optimizes the strlen() of the constant format strings away. Thus I can log with or without typing "\n" and always get an \n termination anyway. General: - replace osmo_timers, state enums and program-wide osmo_signal_dispatch() with dedicated FSM timeouts, states and events. - introduce a common way to handle Tnnn timers: gsm_timers.h/.c: struct T_def. These can be used (with some macro magic) to define a state's timeout once, and not make mistakes for each osmo_fsm_inst_state_chg(). Details: bsc_subscr_conn_fsm.c: - move most states of this FSM to lchan_fsm, assignment_fsm, handover_fsm and mgw_endpoint_fsm. - There is exactly one state for an ongoing Assignment, with all details handled in conn->assignment.fi. The state relies on the assignment_fsm's timeout. - There is one state for an ongoing Handover; except for an incoming Handover from a remote BSS, the gscon remains in ST_INIT until the new lchan and conn are both established. - move bssmap_add_lcls_status() to osmo_bsc_lcls.c abis_rsl.c: - move all dynamic timeslot logic away into timeslot_fsm. Only keep plain send/receive functions in abis_rsl.c - reduce some rsl functions to merely send a message, rename to "_tx_". - rsl_ipacc_mdcx(): add '_tx_' in the name; move parts that change the lchan state out into the lchan_fsm, the lchan->abis_ip.* are now set there prior to invoking this function. - move all timers and error/release handling away into various FSMs. - tweak ipa_smod_s_for_lchan() and ipa_rtp_pt_for_lchan() to not require an lchan passed, but just mode,type that they require. Rename to ipacc_speech_mode*() and ipacc_payload_type(). - add rsl_forward_layer3_info, used for inter-BSC HO MO, to just send the RR message received during BSSMAP Handover Command. - move various logging to LOG_LCHAN() in order to log with the lchan FSM instance. One drawback is that the lchan FSM is limited to one logging category, i.e. this moves some logging from DRR to DRSL. It might actually make sense to combine those categories. - lose LOGP...LOGPC logging cascades: they are bad for gsmtap logging and for performance. - handle_classmark_chg(): change logging, move cm2 len check out of the cm3 condition (I hope that's correct). - gsm48_send_ho_cmd(): split off gsm48_make_ho_cmd() which doesn't send right away, so that during inter-bsc HO we can make an RR Handover Command to send via the MSC to the remote BSS. assignment_fsm.c: - the Chan Mode Modify in case of re-using the same lchan is not implemented yet, because this was also missing in the previous implementation (OS#3357). osmo_bsc_api.c: - simplify bsc_mr_config() and move to lchan_fsm.c, the only caller; rename to lchan_mr_config(). (bsc_mr_config() used to copy the values to mr_bts_lv twice, once by member assignment and then again with a memcpy.) - During handover, we used to copy the MR config from the old lchan. Since we may handover between FR and HR, rather set the MR Config anew every time, so that FR rates are always available on FR lchans, and never on HR lchans. Depends: I03ee7ce840ecfa0b6a33358e7385528aabd4873f (libosmocore), I1f2918418c38918c5ac70acaa51a47adfca12b5e (libosmocore) Change-Id: I82e3f918295daa83274a4cf803f046979f284366
2018-07-28rename gsm_04_08_utils.[hc] to gsm_04_08_rrNeels Hofmeyr1-1/+1
"utils" suggests thin helpers to aid using a proper API, while this .c file actually *is* the proper RR API. Rename from "utils" to "rr". Change-Id: I0ffff63d57f03cb324df8e40e41caea5b55a2c85
2018-07-22codec_pref: check bts codec supportPhilipp Maier1-1/+1
The vty option bts->codec-support allows the user to set the supported codecs per BTS level. However, those values are currently only used to make the handover decision but the logic that handles the BSSMAP ASSIGNMENT REQUEST does not check those flags. - Do not ignore bts->codec-support flags on BSSMAP ASSIGNMENT REQUEST Change-Id: I285234e9c81de74d9fb9907fca2c443b08537435 Closes: OS#3361
2018-07-22codec_pref: move match_codec_pref() to separate c-file and add unit-testPhilipp Maier1-160/+1
At the moment there are three sources that may advertise a list of supported audio codec/rate settings. There is the MS that advertises advertises a speech codec list and the MSC that sends a channel type information element over A and there are also settings in the bsc configuration file that may restrict the codec/rate types that are allowed to use. The function match_codec_pref() looks at all of the three buckets and selects a codec that satisfies all three. This is already a somewhat complicated process, overit is very isolated, so lets give it its own c-file. Due to the lack of unit-tests it is very hard to make changes here so lets add also unit-test to make sure that regressions are catched early. - Put match_codec_pref() and all its helper functions into a separate c-file. - Add a unit test. Change-Id: Iabedfdcec8b99a319f2d57cbea45c5e36c7b6e29 Related: OS#3361
2018-06-05Reject ASSIGNMENT REQ with CIC but no AoIP transp addr in AoIP caseHarald Welte1-8/+25
If we receive a BSSMAP ASSIGNMENT REQ for a speech channel containing only a CIC but no AoIP transport layer address, then that's illegal and must be rejected. In Change-Id If362a0084de452727cd063063dfb645eca2f9beb we re-introduced accepting CIC-only ASSIGNMENT REQ, but we failed to verify that this actually only happens over a SCCPlite A interface. This fixes the BSC_Tests.TC_assignment_cic_only testcase. Change-Id: Ia6e3897edca48b9f838ea69939d9b8be7185abf8
2018-06-02Add initial 3GPP LCLS support to OsmoBSCHarald Welte1-0/+84
This code contains the following code: * receive/parse/interpret LCLS specific BSSMAP IEs and PDUs * osmo_fsm handling the various states and their transitions * call leg correlation (finding the other subscr_conn with same GCR) * communication between the two call-leg LCLS FSMs * detection of supported / unsupported LCLS configurations * display of GCR / LCLS information in "show conns" * switch the media streams locally using MDCX to the MGW Closes: OS#1602 Change-Id: I614fade62834def5cafc94c4d2578cd747a3f9f7
2018-05-25bsc: Don't reject ASSIGNMENT for Audio in IPA/SCCPlite caseHarald Welte1-13/+1
Change-Id: If362a0084de452727cd063063dfb645eca2f9beb
2018-05-25bsc: Add mgcp_port_to_cic() to determine CIC from RTP PortHarald Welte1-13/+0
Also: Move mgcp_timeslot_to_port() next to it, as they are more or less the inverse transformation of each other. Change-Id: Ica908e2bb8fc4e59e0d146b428c93a9efc385688
2018-05-17a_reset: cleanup + remove dead codePhilipp Maier1-1/+1
The function a_reset_free() is not used anywhere at the code. The reason for this is that a BSC instance is never cleared once it is started up. Also the timer number is not according to the spec. - Remove a_reset_free() - Fix timer identification number (T4) - use fi->priv to hold context info - Fix sourcecode formatting Change-Id: I72095d52304c520e383755eee6c889bce492cbd4 Related: OS#3102
2018-05-14log: indicate hr/fr in audio_support_to_gsm88() errorNeels Hofmeyr1-2/+2
Change-Id: Iaaa710d0274fe813d227cb658d82a24db68c4161