Commit Graph

5123 Commits

Author SHA1 Message Date
Neels Hofmeyr d3270a9c05 subscriber conn: add indicator for originating RAN
Add via_ran to gsm_subscriber_connection to indicate whether a conn is coming
in via 2G/GERAN/A-Interface or 3G/UTRAN/Iu-Interface. Prepares for Iu, but
also for libvlr to decide between GSM or UMTS Auth.

Until actual Iu support is merged to master, this indicator will aid VLR unit
testing.

At some point we may also add RAN_GERAN_IU; it's not on the agenda yet, but to
clearly distinguish the names if we want to add it, explicitly name the ones we
have RAN_GERAN_A and RAN_UTRAN_IU.

Change-Id: I93b870522f725170e4265a5543f6b680383d7465
2017-03-02 03:13:02 +01:00
Neels Hofmeyr 5616cdde3a fix: gprs_gmm, gprs_llc_vty: two unterminated value_string arrays
Change-Id: Icc4163ac4f962fe88bbebeb3310a557ba0834e84
2017-03-02 01:48:31 +00:00
Keith Whyte f01bd13ca1 meas_json: fix NEIGH: missing array braces
Make NEIGH an array of Javascript objects, otherwise the JSON is not parseable
when neighbours exist

Change-Id: I42029f40bf357adbb2f3c71cdcbafbc21090e348
2017-03-01 11:48:09 +00:00
Alexander Couzens f480b35893 libmsc/update_db_revision_3(): free memleaking db result
Found by ASAN

Change-Id: I2680c60e26b9876b428d4b75323f884f9ecd95b3
2017-02-28 18:36:35 +00:00
Philipp Maier e0d5caa916 silent_call: remove unfinished fuzzer interface
Remove the fuzzer interface that was partially implemented in
gsm_04_08.c and silent_call.c is causing problems when an
SMS is sent during an active silent call. The reason for this
is that gsm0408_dispatch() in gsm_04_08.c would decide to
rout all uplink traffic to silent_call_rx() in silent_call.c.
silent_call_rx() is a stub function that discards the data.

This patch removes the fuzzer interface code by placing ifdefs
around it, so that it can be re-activated by experimentators.

Change-Id: Id500197d58663b3f4b1756136343670388b0a4bc
2017-02-28 18:28:03 +00:00
Neels Hofmeyr acc6e8323a ctrl_test_runner: speed up more than 10 fold by sleeping less
Similar to a recent patch in osmo-python-tests for VTY based tests, but this is
for the Ctrl tests.

The TestCtrlBase tests gave a constant sleep(2) grace period for the process to
startup. This causes tests to take minutes for no reason at all.

Add code to TestCtrlBase to try and connect right away, retrying up to three
seconds in .1 second intervals. This flies through most tests without any
sleep() at all.

Change-Id: I06569767153838bd9cd3edac001df5f6c567874c
2017-02-28 18:26:49 +00:00
Neels Hofmeyr 534034580c vty test: nat_msc_test: setsockopt REUSE to avoid TIME_WAIT problems
When running the testBSCreload test in close succession, I get a "Connection
refused" error because the socket is still in TIME_WAIT state. Passing the
SO_REUSEADDR flag allows reusing the addr despite a TIME_WAIT socket.

Change-Id: I941851b062999ab4b962430f7b27c19935993e0a
2017-02-28 18:22:06 +00:00
Philipp Maier d015cbd65d XID: resend xid with pdp-ctx-ack messages
If a pdp context is created a xid request is sent right after
the pdp-context-ack message. The sending of the pdp-context-ack
and the xid message is triggered from the GGSN via the GTP
interface.

When the pdp-context-ack message is not received by the MS, it will
send the pdp-context-request again. A lost pdp-context-ack is resent
by the SGSN directly so that the mechanism described  above does
not work for pdp-context-ack resents.

This commit adds code to trigger the sending of xid messages also
for resent pdp-context-ack messages.

Change-Id: Ice66790803154310a61a70a54be76cec539c97a7
2017-02-27 18:07:29 +01:00
Neels Hofmeyr 27355c9c65 SGSN VTY: make missing GSUP server address+port fatal
On 'auth-policy remote', the SGSN requires GSUP server address and port. If it
was missing, the SGSN would print a VTY warning and run anyway. Make this error
more fatal: print an error (flattened a bit) to stderr and abort the program.

Move validation of the GSUP server data presence out of the VTY command itself
and into the config reading function. This way the GSUP server config can be
given anywhere, including below the auth-policy config (was required above).

Don't care about setting the auth-policy to remote with a telnet VTY, because
in that case the GSUP client won't be started anyway.

Change-Id: I4d8db910c32abd8579d3c9b9f0b2cb3a9a6dfe4c
2017-02-27 14:29:41 +00:00
Neels Hofmeyr 058cd573d8 SGSN: Integrate support for UMTS AKA
The general infrastructure for UMTS AKA is already in place:
* GSUP with capability to send us auth_vectors that contain
  either triplets or quintuples
* mm_context that holds such auth_vectors

Add:
* capability to send UMTS AUTN in GMM AUTH REQ
* parse extended UMTS RES
* on auth response, validate expected AKA with vector and received res/sres
* add Auth Failure message to receive resync AUTS token and
  * send to HLR
  * clear out-of-sync auth tuple
  * enter new state for when we're waiting for HLR to resync and send new
    tuples so that the next Auth Request will be handled

Original first half of this patch by: Harald Welte <laforge@gnumonks.org>

Full UMTS AKA procedure including AUTS resync tested to work against OsmoHLR
with R99 USIM and Milenage algorithm.

The sgsn_test.c needs adjustment because we're checking the vector's auth_types
now.

Depends: libosmocore change-ids
         I277fb3d407396dffa5c07a9c5454d87a415d393f
         If943731a78089f0aac3d55245de80596d01314a4
Related: OS#1956
Change-Id: Ie6a0cefba5e4e7f02cc2eaf6ec006ac07d5c1816
2017-02-27 14:29:41 +00:00
Neels Hofmeyr 44468ad531 smpp_test_runner.py: fix socket leak
Each running test would open up another socket without ever closing unused
ones. Close the sockets after each test is done.

Change-Id: I0a42caab3bb8c9c9d04b033e4de9efe0ca8fd2af
2017-02-25 17:04:45 +00:00
Neels Hofmeyr 577a125652 python tests: remove process 'Launch' message, now at osmoutil
Change-Id: Id8eb70ddfdc1d0d9f90aa5343a4ea522042c34ee
2017-02-25 17:04:08 +00:00
Neels Hofmeyr 8b24e9f203 vty_rest_runner.py: remove debug monitoring for TCP sockets
Change-Id: I7361bb0ce5302d00ccb18dc04eeb75ee1f6844a8
2017-02-25 17:04:08 +00:00
Alexander Chemeris c634063ea3 utils: 'meas_json' utility to convert measurement feed into a JSON feed.
Change-Id: I56631969384da245eed8ffc14845c76a5d4de8d4
2017-02-25 05:23:22 +00:00
Neels Hofmeyr 0e5d807297 add struct gprs_subscr, separating gprs from gsm_subscriber
Prepare for replacing gsm_subscriber with vlr_subscriber. vlr_subscriber will
not make sense to be used in gprs, so have a dedicated GPRS subscriber struct.
(Could change if the gprs code were to use libvlr; is currently independent).

Related: OS#1592
Change-Id: Ia8b391ee009c8545763cba04505be3947835120e
2017-02-25 01:25:22 +00:00
Neels Hofmeyr a369e24cb9 cosmetic: rename struct osmo_msc_data to bsc_msc_data
With the OsmoMSC program coming up, the name osmo_msc_data becomes even
more confusing than it already is. Clearly indicate it as libbsc's data of
a remote MSC by prefixing with bsc_.

Also, the Osmocom community has in the meantime agreed to have the osmo_
prefix only in libosmocore, to avoid naming conflicts in case things are
moved there. So while renaming anyway, also drop the osmo_ prefix.

Change-Id: I0dfbcb7d1a579211180f71319982820d8700afab
2017-02-24 21:01:55 +01:00
Neels Hofmeyr a42855f09f cosmetic: rename osmo_msc_data.h to bsc_msc_data.h
With the OsmoMSC program coming up, the name osmo_msc_data becomes even
more confusing than it already is. Clearly indicate it as libbsc's data of
a remote MSC by prefixing with bsc_.

Also, the Osmocom community has in the meantime agreed to have the osmo_
prefix only in libosmocore, to avoid naming conflicts in case things are
moved there. So while renaming anyway, also drop the osmo_ prefix.

Change-Id: I13554563ce9289de126ba0d4cf329bafcda35607
2017-02-24 21:01:55 +01:00
Neels Hofmeyr 9762b4c579 cosmetic: clarify BSC's remote MSC data vs. OsmoMSC
Change-Id: I74dd2b3f935d39b8caa718e2c8a51cc81bddf1b9
2017-02-24 21:01:55 +01:00
Neels Hofmeyr fe291de36b cosmetic: gsm_data.h, README: rename CSCN to MSC
We're discarding the name OsmoCSCN for the benefit of OsmoMSC. But "CSCN" has
already crept into the master branch in two places; apply the rename.

See OS#1958

Change-Id: Ib4274eb3c172ada1fe7f05746740b456370bc93d
2017-02-24 21:01:55 +01:00
Neels Hofmeyr d2b3399c04 vty: fix subscr ref count leak in 'subscriber name' cmd
Change-Id: I3d19518c94a7f302bf108f2ad945983cdc8db0b1
2017-02-24 19:58:07 +00:00
Neels Hofmeyr 40a91b38ec vty_test_runner.py: fix socket leak
Each running test would open up another socket without ever closing unused
ones. Close the sockets after each test is done.

Change-Id: Ie433c8560de54f9a9d05fa07c44bae3126d19b30
2017-02-24 17:54:24 +01:00
Neels Hofmeyr 7a250cc9d9 cosmetic: remove unused scall_signal_data.subscr
Doesn't make sense to switch this to struct vlr_subscr when it isn't used at
all. So let's remove it.

Change-Id: Ifa5901f8bf1aed3981841d24d4ec8d659f3de7a9
2017-02-23 23:44:05 +00:00
Neels Hofmeyr 89a8e722ed logging fixup: shorter names for LOGGING_FILTER_* and LOGGING_CTX_*
In libosmocore, my patch was merged to master a bit too soon. To accomodate the
request for naming that matches the general "LOG" prefix instead of "LOGGING",
a fixup was committed to libosmocore. Adjust for that.

Original patch: change-id I5c343630020f4b108099696fd96c2111614c8067
The fixup: change-id I424fe3f12ea620338902b2bb8230544bde3f1a93

Change-Id: Ib2ec5e4884aa90f48051ee2f832af557aa525991
2017-02-23 18:11:57 +01:00
Neels Hofmeyr 94f49a4f08 debug.h/c: remove unused cruft / cosmetic tweaks
Change-Id: I9601d478763569933bcc46bf4eaaff70a9843be9
2017-02-22 17:28:49 +01:00
Neels Hofmeyr f13b3c968f logging: use central filter and ctx consts from libosmocore
The LCHAN and BTS filter contexts are actually never used, so drop them until
someone adds them properly.

For now use only LOGGING_{FILTER,CTX}_VLR_SUBSCR. Some of these will change to
_BSC_SUBSCR once struct bsc_subscriber is introduced, and later on, struct
gsm_subscriber will be replaced by vlr_subscriber so that the names will match.

Depends: libosmocore change-id I5c343630020f4b108099696fd96c2111614c8067
Change-Id: Ifa82f6a461ad4c0eeddb8a38fb3833460432d16b
2017-02-22 17:24:54 +01:00
Max a66d8cfcb5 Handle DSD from HLR
Handle Delete Subscriber Data GSUP message from HLR to disable Packet
Services for a given IMSI.

Change-Id: I6b9b494fa58bcb95bd550c49f8204f00f8fdf628
Related: OS#1645
2017-02-21 16:24:37 +00:00
Neels Hofmeyr a1613695d1 subscr_update_expire_lu(): fix (obscure) segfault
To be paranoid, catch a NULL subscriber and/or bts in
subscr_update_expire_lu(): print an error log and avoid segfault.
(I'm not sure this would really happen in a normal situation.)

During aggressive testing of Paging timeout, I came across this segfault in
msc_release_connection() when conn->expire_timer_stopped is set but
conn->subscr is NULL, at the subscr dereference after:

        if (conn->expire_timer_stopped)
                subscr_update_expire_lu(conn->subscr, conn->bts);

I brought this situation about by a fabricated Paging fault, i.e. in
gsm48_rx_rr_pag_resp() return 0 and don't call gsm48_handle_paging_resp() at
all. Thus conn->subscr is still NULL when expire_timer_stopped is 1.

When looking at CM Service Request handling, the conn->subscr is set before
setting expire_timer_stopped = 1, which is a saner thing to do. But without my
mad 'return 0', there is in fact no way to have a NULL subscriber there.

It looks like all other code paths already do the same, but it's not that
obvious (e.g. _gsm48_rx_mm_serv_req_sec_cb()). So rather catch this case of
NULL conn->subscr, and while at it catch NULL bts as well.

Change-Id: I430dd952b2b928bea7f8360f1e01bb3cccb0a395
2017-02-19 13:48:31 +00:00
Max 2c16beeb64 Add support for extended SI2q parameters
* add vty command to set E-UTRAN_PRIORITY, THRESH_E-UTRAN_low and
  E-UTRAN_QRXLEVMIN according to 3GPP TS 44.018 Table 10.5.2.33b.1
* remove old command which does not support those parameters

Change-Id: I36dcc79f7b7a02036e74720923d0df1a2a2db504
Fixes: RT#8792
2017-02-19 08:53:57 +00:00
Neels Hofmeyr 87bfed259d remove compiler warning: unused rc in vty_interface_layer3
Change-Id: I3dc94dc4bddc5a887ce196071327a6dddfe5b280
2017-02-18 23:11:04 +01:00
Max b726c2c72b Remove duplicating define
Use GSM_MACBLOCK_LEN consistently throughout abis_rsl.c

Change-Id: I96aec02748a0be0100dee2117f124ff32d5ee3f5
2017-02-09 19:23:38 +01:00
Max 8dc8f23c07 Expand chan allocation logging
Log more data related to channel allocation:
- channel type
- number of paging attempts
- timers fired

Change-Id: Ib417a9c942c17b902dd80ff555cd9da5f91bff48
2017-02-09 19:13:02 +01:00
Max db0e380558 vty: remove ignored logging parameters
Since ce9fec3e896571835ac5bfd2980d6836f2b29f0d libosmocore ignores
parameters to log_vty_command_* functions. Hence parameter of
logging_vty_add_cmds() is ignored too. As we depend on much later
libosmocore version anyway, we can simplify code somewhat by removing
parameters which will be ignored anyway.

Change-Id: I62f752fd88f1d8fefa563648f9864c7c31f87991
2017-02-08 09:37:38 +00:00
Alexander Couzens 5ba6fb3ef4 gprs/sgsn_vty: fix typo in comment
Change-Id: I63225b7ba6d666eddf00b1deb893e79dc9ec842b
2017-02-07 00:41:48 +00:00
Alexander Couzens 1013550218 gprs/sgsn_mm_ctx_alloc(): initialize MM state to IDLE
Previous the state was only set in Iu mode.

Change-Id: I99a6aec1090cad9b9d38d134cc9b34ef292062df
2017-02-07 00:41:32 +00:00
Alexander Couzens 17a29ef311 gprs/gprs_mm: add value_strings for PMM & MM states
Change-Id: I4e34dcd5e48c4dd73d63c6f865298ee7d9c864be
2017-02-07 00:41:32 +00:00
Alexander Couzens 2b5fb8ed66 gprs/sgsn: rename sgsn_mm_ctx_alloc() -> sgsn_mm_ctx_alloc_gb()
Postfix the ran type to clarify the purpose.
Because of the new support of the Iu ran type, there are 2 functions to allocate a mm ctx.
For Iu it's sgsn_mm_ctx_alloc_iu(). For gb it should be named in the same way.

Change-Id: Ic49009e8c20c12308855e1409c09004698c79b95
2017-02-07 00:41:32 +00:00
Alexander Couzens 4f8da6dfd5 gprs/sgsn: rename gprs->mm_state -> gmm_state
GMM is the right term. MM state is already occupied.

Change-Id: I9cfdcf921e4ebd14a5e7ce7489ec4ce5d1f5515f
2017-02-07 00:41:31 +00:00
Neels Hofmeyr bcfee2a0a6 vty tests: more attempts to resolve 'Broken Pipe' error
Change-Id: I4251a24eb7a57a354aa76de711547c3e76ebb846
2017-02-07 00:41:06 +00:00
Max d09b26d487 Attempt to fix nightly builds
The fix introduced in dac5867af5 did not
work because autotools in our OE are too old. Use alternative way to
include custom m4 macros to fix it.

Change-Id: I5fe6d1180c2624cfe1d3673314f6846527a43464
2017-02-07 00:40:02 +00:00
Harald Welte 89837d422e VTY: Print 3G auth tuples, not just 2G auth tuples
Change-Id: I277e4347ee1486a39e6dc4e2363a593f328f9e3b
Related: OS#1592
2017-02-06 15:08:11 +01:00
Neels Hofmeyr 22a735bfd4 gsm_04_08: implement parsing of UMTS Auth responses
Parse the longer UMTS res from the extended Auth Response Parameter IE.
Parse the R99 Authentication Failure and AUTS in case of cause
GSM_REJECT_SYNCH_FAILURE which indicates a SQN re-sync request.

Both still end in 'not implemented' error logs, which are the places where the
upcoming VLR that supports UMTS AKA will integrate.

Depends on recently added constants in libosmocore in
commit 55a43b801385e07a484217925ecf2379b9f54fcf
aka change-id I745061ce8eb88aa23080dadcdbfe2d703c362a30

Change-Id: I4868bbeedc32fa7b8d03b9e3c66db618543d38ec
2017-02-06 15:08:11 +01:00
Philipp Maier e1f8b9244a om2000: add VTY command to delete CON groups
The currently unused function abis_om2000_vty.c:con_group_del()
allows deleting OM 2000 connection groups. This commit adds a
matching VTY command to make use of it.

Change-Id: I39a90b06e19356c536cacd1c923e195dd305ab80
2017-02-03 17:05:14 +01:00
Neels Hofmeyr e02e1e782f Revert "vty tests: more attempts to resolve sporadic 'Broken Pipe' error"
'self' will not be accessible in that context, so this patch isn't
useful.

This reverts commit b39053ad6d.

Change-Id: Ic1a9ba5fdfd7bdc6c5cf0974e8c637ae23b81ece
2017-02-03 05:56:50 +01:00
Neels Hofmeyr d675515bd4 gsm48_tx_mm_auth_req(): support UMTS AUTN
To be able to do R99 UMTS authentication, we need to send along AUTN bytes in
the Authentication Request. Add autn parameter to gsm48_tx_mm_auth_req() and
conditionally append the R99 AUTN TLV to the Authentication Request message.

Change-Id: I0d644559088706aa06b42b9bfe1f8c21ca6fa4da
2017-02-03 05:35:25 +01:00
Neels Hofmeyr ba1468e4c6 vty tests: testBSCreload: ipa_handle_small: ensure rx of 4 bytes
Change-Id: I995b7aba9d0b51b0861a4281dbbca888f36e9e00
2017-02-03 04:48:27 +01:00
Neels Hofmeyr b39053ad6d vty tests: more attempts to resolve sporadic 'Broken Pipe' error
Change-Id: I3d833ddf8c62845fe68d1e5503332541a4a04a2d
2017-02-03 04:17:49 +01:00
Neels Hofmeyr 7d17c3ef61 vty tests: attempt to get at sporadic 'Broken Pipe' error
Add verbose logging as well as three retries around the place that often
fails on our build server with a 'Broken Pipe' error.

Change-Id: I8851b76b2d7b87dd500ae40f47e6bea716ef3fc4
2017-02-02 23:38:46 +00:00
Neels Hofmeyr 35706ddd80 gsm0408_rcv_cc: guard against NULL subscriber
Check conn->subscr against NULL.

gsm0408_rcv_cc() dereferences many conn members without checking presence: the
bts and lchan members may be expected to be NULL in the ongoing MSC split and
3G developments.

But the conn->subscr is initially NULL, so an MS sending a CC message before
something like a LU or CM Service Request will result in a segfault. Prevent
that.

Note: the upcoming VLR will be more restrictive on what messages are processed,
this is a "backport" to the situation on current master.

Change-Id: If067db7cc0dd3210d9eb1da15be6b637795a3ecf
2017-02-03 00:34:02 +01:00
Neels Hofmeyr 26adfd099b compiler warning: bsc_vty: remove two unused vars
Added in recent commit 42def7205b
"Implement VTY configuration to control Early Classmark Sending"

Change-Id: Iaf640fa6e1f234f594fb8dc06f716d3d3e95eb2a
2017-02-02 20:04:56 +00:00
Neels Hofmeyr a5c71bf39a paging.h: use '<>' include, not '""'
Also separate openbsc includes from osmocom/core includes.

Change-Id: I4da0cb32476202d06902531d07faed8004f689f9
2017-02-02 04:26:36 +01:00
Neels Hofmeyr 150abfffbf osmo_bsc_grace.h: use '<>' include, not '""'
Change-Id: I2f22be93d1a5fd6f229b85305a1d2a2cf6a43ce2
2017-02-02 04:26:36 +01:00
Harald Welte 2d02775b91 OM2000: use assoc_so *only* for TS objects
all other objects always use the MO instance.  The existing code
likely is due to copy+paste mistakes.

Change-Id: Ie0a31cd93993da10f31eecf530a5a05773c11eb1
2017-02-01 16:36:11 +00:00
Holger Hans Peter Freyther 725f3f1de0 sgsn: Fix deeply flawed copying logic for PDP context activation
It is one of these changes that should have never worked but did
for a long time. Only recently a corrupted GTP message was seen.
The code in ccd2312d10 tried to
solve the right problem but was deeply flawed.

* Make the code operate on the copied message and not the original
one that is deleted by the underlaying layers on return
* Add an out variable to determine if the msgb should be deleted
and assume that by default it will be deleted.

Change-Id: I564526e7cde2b8a2f0ce900492cd38fc23c176a7
2017-02-01 15:02:54 +00:00
Max dac5867af5 Remove dependency to autoconf-archive
It is generally not a good idea to add more and more external
dependencies unless absolutely needed.  autoconf-archive is a good
example of that, as we need to update all build machines, and older
OpenEmbedded versions do not appear to have (the right?)
autoconf-archive recipe. Provide local copy of necessary m4 files to fix
the build there.

The dependency to autoconf-archive was introduced in Change-Id
Ied9c950dafa65f324cf31298b13b590f56139700

Change-Id: Iacc1958b471ec3fc65307259039e1d496845f528
2017-01-31 19:54:58 +01:00
Philipp Maier 6934a0fa9e gprs: Fix compiler warning about uninitalized cause code
in gprs_gmm.c:gsm48_rx_gmm_ra_upd_req the variable reject_cause
is not initalized, which is ok, since it gets initalized before
the jump into the "rejected" path. However, the compiler still
throws a warning. This commit fixes the problem by preinitalizing
the reject_cause to GMM_CAUSE_PROTO_ERR_UNSPEC

Change-Id: I84cffb631e4cad3d4748512b47e3876208f53727
2017-01-27 22:18:06 +00:00
Minh-Quang Nguyen f188623091 rsl: Fix dropping of LAPDm UA message.
In some cases, when successive mobile originated calls are made, the LAPDm UA
message gets lost because the channel is relased to early. Too overcome the
problem we do not send release indications immediately. Instead a flag will be
set and the message stored and sent on the next TCH-RTS-IND.

This commit adds the required flag and the msg-buffer to struct gsm_lchan.
See also coresponding change in osmo-bts.git:
Change-Id Ie4f70c75f0137b4bd72d579b3a32575bac2fca38

This patch is is a slightly improved/reformatted version of:
95d1f15ad1

Change-Id: I15fc1ef8e9e83f009bde96de9a8e95702cffbce6
2017-01-27 22:17:22 +00:00
Harald Welte 42def7205b Implement VTY configuration to control Early Classmark Sending
The SI3 rest octests contain a flag that indicates if early classmark
sending is allowed in this cell or not.  So far we always set this to
one, now it is configurable using the 'early-classmark-sending' command
at the VTY node.

Change-Id: Ia0b1cc5ab45673f3da70c59ae8917eba343f9862
2017-01-26 15:24:07 +01:00
Harald Welte 6c4382b998 remove unused struct members of 'struct sgsn_pdp_ctx'
There were some members that we neither set nor read, so let's
shrink the struct size and remove those unused members.

Change-Id: I02136e3aa91e58b2afc923c09c8693095497fdd7
2017-01-26 15:24:07 +01:00
Harald Welte 471ac7d99c sgsn: Add GTP information to "show pdp-context"
When displaying the PDP context, it is quite useful to also show IP
address and TEI information about the GTP side of that PDP context.

Change-Id: I56ea530240c15b26729e7a42e539020cb1e233e5
2017-01-26 15:24:07 +01:00
Neels Hofmeyr cc7db18e1a various comment / whitespace tweaks (libmsc, gprs, libcommon-cs)
cosmetic ws in common_cs_vty.c, osmo_msc.c

comment: tiny typo fix in gsm_04_08.c

In comments, drop some unbalanced braces, because simplistic C file harvesters
will break at a single opening brace even if it is in a comment. This is aimed
at the fsm-to-dot.py script in libosmocore/contrib.

Change-Id: I3c1fa53195a1e57d6fe0a6791c346d30ceff1251
2017-01-26 03:19:35 +01:00
Philipp Maier d0ef1ed78c compression: Fix nullpointer deref
When the creation of a new compression entity fails, an error
message is created, this error message contains printf with
a dereferentiation of the compression entity, that is clearly
NULL at that point. This commit corrects that.

Change-Id: I87371ade0ccd6a93b446f2013c1747f486739518
2017-01-25 19:44:54 +00:00
Max f6e51709fc CTRL: remove boilerplate
Use CTRL_CMD_DEFINE_RO(), CTRL_CMD_DEFINE_WO() and
CTRL_CMD_DEFINE_WO_NOVRF() where appropriate to get rid of boilerplate
code.

Change-Id: I5bcea0b4f4b8f535bef2b423f2013b8b4a218b5b
2017-01-25 11:52:45 +00:00
Keith Whyte d32b6d13ed Add VTY command to immediately expire user (set expire_lu to now)
Change-Id: I676c84350a7afc963bc6bb4c46c60e5ac3eee67e
2017-01-23 20:34:58 +00:00
Max e610e700da SI2q: add support for multiple UARFCNs
Support multiple UARFCNs with the same Scrambler Code.

Fixes: RT#7379
Change-Id: If1c32e8b547a28325180faaaddd21f80c37f7337
2017-01-23 12:32:09 +00:00
Max 881064e9b8 Prevent segfault in range encoding
* Explicitly check when ARFCN array split is impossible and return
  gracefully instead of using negative index.
* Separate range encoding into generic function and use it for all
  SI-related things.
* Propagate the error into that function and to its callers.
* Add separate test-case for the segfault previously triggered by this bug.

Change-Id: I3e049ab2d7c1c4d6c791b148f37e10636a8e43e0
Related: RT#7379
2017-01-23 12:32:00 +00:00
Max 47e1781907 bsc_control.py: fix blocking
Previously reading from socket would block if no data were sent by
the server. Use non-blocking read for set and get operations.

Change-Id: I706d54a4a7ceef62683bf9a2fe63fc9ab331c24e
2017-01-23 12:31:45 +00:00
Max a5e369300f Improve OML failure report
* clearly separate report parts
* use textual representation for failure cause if possible

Change-Id: I7a98a77011463021d0edd6ecfab1680e211f7e16
Related: OS#1615
2017-01-23 12:16:05 +00:00
Neels Hofmeyr 93bafb611a cosmetic: use osmo_strlcpy() everywhere
Shorten some code and make obvious to the reader that the string copy is done
in a safe way.

Change-Id: I900726cf06d34128db22a3d3d911ee0d1423b1bd
2017-01-23 11:59:01 +00:00
Neels Hofmeyr 59504dc80f fix strncpy() invocation in vty_interface_layer3.c and 3 tests
Use osmo_strlcpy() to fix unsafe invocation of strncpy(), which potentially
left the result unterminated.

Change-Id: I1a119b1760a3e3262538b4b012d476fdce505482
2017-01-23 11:59:01 +00:00
Max f5e74b5988 Print subcriber when skipping auth
Change-Id: I6ae6720afc04cc3c92ceff86e5b2a5a29494aeb1
2017-01-23 11:56:44 +00:00
Neels Hofmeyr b7f41d554b undup: gtphub_test: use libosmocore's llist_count()
Depends on libosmocore Change-Id Ic49adc7a346f5722bf624d7d3b4a735e4220ae15

Change-Id: I67bc1889c064596a2f3e93cc0354b11c720b0225
2017-01-23 11:53:27 +00:00
Max 34f012639d Turn some compiler warnings into errors
Re-apply the reverted commit 98bc7fa50d, this
time with a clear error message in case autoconf-archive is not installed.

Change-Id: I631bde22e79ec0318eb9c8114db5861a1d635816
Tweaked-by: Neels Hofmeyr <nhofmeyr@sysmocom.de>
2017-01-21 01:44:26 +01:00
Neels Hofmeyr 04db87a89f gprs subscr: fix: intended strcmp(), but is strcpy()
The code checked 'if (strcpy(..) != 0)' which is always true and thus always
copied twice -- luckily we want to copy anyway and so this is not an actual
functional failure.

We could correct to strcmp, but instead of iterating to compare, we might as
well copy right away.

Change-Id: I0ea035bd478f7022ed65e9e84d8aaf5e423309b7
2017-01-15 18:10:47 +00:00
Max 3d07aef800 Log expected SRES on GPRS AUTH REJECT
Change-Id: I19b0001650979bf7f1832f04f9fd5a26beb577d0
2017-01-13 19:32:22 +01:00
Neels Hofmeyr 98bc7fa50d Revert "Turn some warnings into errors"
This introduces a failure with ./configure on my machine:

  ../configure: line 6612: syntax error near unexpected token `-Werror=implicit,'
  ../configure: line 6612: `AX_CHECK_COMPILE_FLAG(-Werror=implicit, CFLAGS="$CFLAGS -Werror=implicit")'
  Makefile:420: recipe for target 'config.status' failed
  make[1]: *** [config.status] Error 2

Installing autoconf-archive did not fix the error.
So even though jenkins seems to accept this, I cannot build with this patch.

Let's find out how to do this in a way that all systems can still build
and then re-apply this patch.

This reverts commit fd161ccce8.

Change-Id: I2b368500b07f233882ef854eca1fa21f6df39e29
2017-01-13 02:51:22 +00:00
Max fd161ccce8 Turn some warnings into errors
Make warnings (when available) related to common memory-related issues
into errors to harden the source and decrease chance of errors.

Change-Id: Ied9c950dafa65f324cf31298b13b590f56139700
2017-01-11 19:51:33 +01:00
Max 34be86b93c Cosmetic fixes around SI generation
* add missing spaces after comma and minus
* prevent useless recursion calls
* mark static functions as such
* name and explicitly use enum for ARFCN range

Change-Id: If5b717445c8b24668bad0e78fd5bb51f66c4d18e
2017-01-06 11:37:52 +00:00
Neels Hofmeyr fa9abaca26 fix 'osmo-nitb --version' segfault
Call vty_init() before handle_options() to make sure the host.app_info is
populated before --version potentially tries to print it.

The segfault was introduced by 2c05f75bbf in a
recent MSC-split merge.

Change-Id: Ice91256d72b9eabd52709352ba6cc6a42af2921b
2016-12-31 18:25:36 +01:00
Keith Whyte 80abe522e2 Pass actual smpp_avail_status through to smpp in alert_all_esme()
Change-Id: I4b00d8821c1688ca0c990b6042607f4ded0f80e3
2016-12-24 17:12:34 +00:00
Philipp Maier 532480a705 cosmetic: Rename phone to ms
The term "phone" is incorrect. Rename phone to "MS" (mobile station)
in the comments and log output of gprs_llc.c

Change-Id: I322d3d99452502da7555cc2af6bc8a192ca3c9c5
2016-12-23 11:19:15 +01:00
Philipp Maier db142dc59d sndcp: Allow empty SNDCP-XID indications
In some rare cases the modem might send a xid indication that does
not contain anything except the version number field. The sgsn
ignors such SNDCP-XID indications by stripping the entire field
from the response. We found a modem in the wild that started to
act problematic when the empty SNDCP-XID was missing in the
response. This patch changes the XID negotiation behaviour in
a way that if a modem should send empty SNDCP-XID indications,
the reply will also contain an empty SNDCP-XID indication. Apart
from that the SNDCP-XID version number is now parsed and echoed
in the response. This ensures that we always reply with the version
number that the modem expects. (The version was 0 in all cases we
observed so far)

Change-Id: I097a770cb4907418f53e620a051ebb8cd110c5f2
Related: OS#1794
2016-12-23 11:19:15 +01:00
Harald Welte a191dcd8f0 bsc_vty: Fix missing break statements in switch()
Change-Id: Ifd48e8d56c845603d320748144b4d7c3c24022a0
Fixes: Coverity CID 135188
Fixes: Coverity CID 135190
2016-12-22 14:07:43 +00:00
Neels Hofmeyr b42dc43e28 use new OSMO_VALUE_STRING
libosmocore change-id I857af45ae602bb9a647ba26cf8b0d1b23403b54c adds
OSMO_VALUE_STRING to compose value_string arrays with the exact enum names as
entries. Use instead of identical local macros in two places.

Change-Id: I1b44d2a3f293785a01d6a587c78f9e0cbeec70c3
2016-12-21 14:02:07 +00:00
Neels Hofmeyr 9fdb4e5f2f gitignore: gsup_test_client binary
gsup_test_client was added in 4f8e34b226 and
moved to libcommon in 2c1f8c8ceb, both of
which forgot to adjust the .gitignore.

Change-Id: Idd0d29a2f5c5b9b038103c955e0027d9ee9fee73
2016-12-21 14:30:30 +01:00
Max 549ebc7d6c Improve GPRS logging
* log xid type as string instead of int
* log packet encryption status, algorithm and IOV-UI in debug mode
* print encryption parameters when dumping llme via vty
* log key propagation from MM to LLC

Related: OS#1794
Change-Id: I30c38fdeb0b88bb39bdb9928851300bc79e6aec6
2016-12-21 10:27:24 +00:00
Neels Hofmeyr 6903848029 build: remove obsolete $LIBCRYPT in two places
It should be $LIBCRYPTO_LIBS if at all.

Change-Id: I191dfe0901a10a25dffa3bbfdb9ea319fcebe254
2016-12-21 10:26:15 +00:00
Neels Hofmeyr b735390284 build: osmo-nitb: fix missing LIBCRYPTO_FLAGS
Change-Id: I6268d0b8782ee03b42ab8bbda7aa9650c26e11ad
2016-12-21 10:26:15 +00:00
Ruben Undheim 59d57da1e5 Fix some typos in stdout output
Change-Id: I0dbb438f3bfbaf9744717cbeec31ceefdd679ee9
Related: OS#1694
2016-12-20 17:39:55 +01:00
Max 0c32685898 bsc_control.py: remove unused -i option
This option only served to demonstrate possibility of manually selecting
<id> field in CTRL protocol. Since the transition to generic ipa module
this is no longer exposed so the option became a no-op. Correspondingly
there's no need to explicitly initialize the RNG - the Ctrl class
handles random <id> generation internally.

Change-Id: I10cc7c069354cced2bba84fe67c69c28b8596ded
2016-12-19 08:57:43 +00:00
Neels Hofmeyr ea619f1704 gtphub: fix possible NULL deref: don't print NULL tunnel
Fixes: coverity CID#158302
Change-Id: Ic500a3eb0c49393c7962a20e61eb57fd467208d3
2016-12-18 16:58:41 +00:00
Neels Hofmeyr ecdfd6d097 fix: missing terminator in two value_string arrays
iu_event_type_names[] and auth_action_names[] lacked a { 0, NULL }.

Change-Id: I2e3f271b887e711c8139fbaa32410c16e7fe9921
2016-12-16 14:19:19 +01:00
Neels Hofmeyr 37f9252361 oap_client: make use of OAP optional: disable for NULL config
When passing a NULL config to osmo_oap_client_init(), set OAP to disabled
state. Along with the previous fix that ensures message rejection in the
disabled state, this makes use of OAP in the GSUP client optional.

oap_client_test: expect null config to set state to disabled.

Related: OS#1592
Change-Id: Ie4d622fcfd24cb7d89d19f93e4b2571d8fadd1a3
2016-12-13 14:54:02 +00:00
Neels Hofmeyr 2fa74faf92 oap_client: reject all messages in disabled/uninitialized state
Fixes the bug indicated in oap_client_test.c: adjust to actually expect the
proper behavior.

Also adjust for modified return value for message rejection. Instead of -1,
just expect < 0.

Adjust experr for new error messages.

Related: OS#1592
Change-Id: I16165d228653e8a2689f9df94b77b470c06480c6
2016-12-13 14:54:02 +00:00
Neels Hofmeyr 3cbc052101 oap_client_test: show bug: disabled state does not reject message
There is a hole in OAP where a disabled OAP still accepts at least a
Registration Reject message, after which it will do things it shouldn't. Show
this by expecting the bugs, to be adjusted with the upcoming fix.

Related: OS#1592
Change-Id: I4a5fde308b876946fea2571ea1a550f0cc7ee136
2016-12-13 14:54:02 +00:00
Neels Hofmeyr 73ed45599b oap_client: move logging to DLOAP logging category
Use libosmocore's DLOAP logging category for OAP.

oap_client_test.c: make sure DLOAP is in DEBUG level to not lose any logging
messages from experr.

Todo: we're using a "Library" logging category, which is not really what the
library category was intended for. Instead, the OAP client should probably be
given a logging category like DVLR or DGPRS in its initialization API.

Related: OS#1592
Change-Id: Ic765c19381b0d983da90a5d8aee9cd17e31cf34a
2016-12-13 14:54:02 +00:00
Neels Hofmeyr 2e109f08c0 oap_client_test: print test descr to stderr, check stderr
Related: OS#1592
Change-Id: If1696c8e7bfa696b250f7eac24f08f85f8f492a2
2016-12-13 14:54:02 +00:00
Neels Hofmeyr 28786bb209 oap_test.c: rename to avoid clash with libosmocore oap_test.c
Rename to oap_client_test.c, which is also a more accurate name.

Related: OS#1592
Change-Id: I3ca333141a15940df07a1ae77a30bc54885db41f
2016-12-13 14:54:02 +00:00
Neels Hofmeyr 2c1f8c8ceb move grps_gsup_client.c to libcommon/gsup_client.c
This is in preparation for libvlr.

Related: OS#1592
Change-Id: I9ad7dc7f17f3b033c779de9ae8bc120655502fce
2016-12-13 14:54:02 +00:00
Neels Hofmeyr 3d6b9f4fe9 move gprs/oap.c to libcommon/oap_client.c
This is in preparation for libvlr.

Related: OS#1592
Change-Id: Ib526df6d9de55a1e59a379d5e2c8541ed0ef67e3
2016-12-13 14:54:01 +00:00
Neels Hofmeyr 11ecc9320c rename oap.h to oap_client.h
Related: OS#1592
Change-Id: I05bd65ff81b0f70f68217b2e0a9466e160bdbdec
2016-12-13 14:54:01 +00:00
Neels Hofmeyr 49012f14dd oap: rename public API from oap_ to oap_client_
Mainly to differentiate the OAP messaging API (osmo_oap_ in libosmocore) from
the OAP client.

This is in preparation for moving the oap client to libcommon, which is in turn
preparation for libvlr. Add the osmo_ prefix, as all public Osmocom API should
have. We also have OAP messages code in libosmocore, so clarify by naming this
osmo_oap_client, and by also renaming the oap_test to oap_client_test. This
reshuffling will allow an easy move of OAP to libosmocore if we should want to
do that. A number of patches will follow up on this.

Related: OS#1592
Change-Id: Id447d2bebc026a375567654adafa5f82439ea7e1
2016-12-13 14:54:01 +00:00
Harald Welte 736474ce45 move OAP messages implementations to libosmocore
This corresponds to change-id If5099e60681a215e798b6675f21813f26769c253 in
libosmocore, which is now required to build openbsc.

Related: OS#1592
Change-Id: I2f06aaa6eb54eafa860cfed8e72e41d82ff1c4cf
2016-12-13 14:54:01 +00:00
Neels Hofmeyr ef022783c3 gsup client, gsup_test_client: move logging to DLGSUP category
Use the DLGSUP logging category for GSUP.

Bump the required version of libosmocore to 0.9.5 to benefit from the DLGSUP
logging category fix in core/logging.[hc].
(Id974c7be158e4d60421a98110f5c807aefd31119)

Todo: we're using a "Library" logging category, which is not really what the
library category was intended for. Instead, the GSUP client should probably be
given a logging category like DVLR or DGPRS in its initialization API.

Related: OS#1592
Change-Id: Id3938267fa062e1a997d3704cd678874306f86ee
2016-12-13 14:54:01 +00:00
Neels Hofmeyr eaaee92db5 rename gprs_gsup_client.h to gsup_client.h
This is in preparation for moving gsup to libcommon, which is in turn
preparation for libvlr.

Related: OS#1592
Change-Id: I9c95d00f1a9420887a44c938b1d0ee3e20586f4c
2016-12-13 14:54:01 +00:00
Neels Hofmeyr 814fef04b0 gprs_gsup_client*: remove the gprs_ prefix
Make sure everything is named gsup_client_ / GSUP_CLIENT_.

Rename static gsup_client_send() to client_send() to avoid clash with public
gprs_gsup_client_send() being renamed to gsup_client_send().

This is in preparation for moving gsup to libcommon, which is in turn
preparation for libvlr. libvlr and osmo-sgsn will use the same GSUP client
code. A number of patches will follow up on this, also for the the OAP client.

Related: OS#1592
Change-Id: I57433973b1c4f6cc1e12e7b1c96b5f719f418b51
2016-12-13 14:54:01 +00:00
Neels Hofmeyr 3df5d53a04 comments: gsup client: rename to Generic, adjust copyright and authors
Related: OS#1592
Change-Id: I2c5d145e05aa4afd43ef1341d22563448f1c3577
2016-12-13 14:54:01 +00:00
Harald Welte 4f8e34b226 add gsup_test_client program
Related: OS#1592
Change-Id: Iafd844393dd90b899f84ed61c875c1eb533436d7
2016-12-13 14:54:01 +00:00
Neels Hofmeyr 08586c68db build: bump required libosmocore, libosmogsm to 0.9.4, for GSUP
GSUP was added to libosmocore in 0.9.4. We're using it here, so make up for a
previously missing bump.

(BTW: I'm pretty sure that other dependencies are also in dire need of a bump,
but leaving that for another patch)

Change-Id: I4f245a7d78d0889b37084c52478372bddb8289d6
2016-12-13 14:54:00 +00:00
Max bd33f54444 bsc_control.py: use ipa.py module
Simplify code by using Ctrl implementation from ipa.py

Change-Id: I25fd7cd4b42126354b72abd60a3837be5d13e159
2016-12-13 14:47:32 +01:00
Max 82caa3e9b7 bsc_control.py: style corrections
* replace some tabs indent with spaces
* add comment to make sure no new tabs are used for indentation by emacs
* remove unnecessary parenthesis

Change-Id: Ib79fd4317d40ee4fd87b090b9faf8ebaf4bfca64
2016-12-13 14:47:32 +01:00
Max 688231331b Add twisted-based IPA multiplex
Add sample applications using twisted framework for IPA and CTRL
multiplex.

Change-Id: I07559df420b7fe8418f3412f45acd9a375e43bc5
Related: SYS#3028
2016-12-13 14:47:32 +01:00
Max 3e6768937e Use IPA module for vty tests
Replace hackish ipa_send_* routines with proper implementation from IPA
module thus making it part of extended tests.

Change-Id: If13ed7fd243ce3aeef505d2e8468e221aa62f79e
2016-12-13 14:47:32 +01:00
Neels Hofmeyr d53e9b51b6 Revert "Support Deactivate PDP Context Request from network"
This reverts commit 1611df5226.

This is due to a segfault introduced to the asan build only. See:
http://lists.osmocom.org/pipermail/openbsc/2016-December/009966.html
 Subject: new sanitizer breakage: SIGSEGV in sgsn_create_pdp_ctx()
 Date: Tue Dec 13 12:08:32 UTC 2016

Change-Id: Ic926c0e6778947b516994822e3a21d4fde25bb02
2016-12-13 12:42:45 +00:00
Max c3b94f92c5 Add IPA multiplex
Add base class and derived Ctrl class implementing ctrl-specific
routines.

Change-Id: I41e37ec143183e422c0b31af95d183bd84f0c328
Related: SYS#3028
2016-12-13 10:52:23 +00:00
Pravin Kumarvel 1611df5226 Support Deactivate PDP Context Request from network
Enable Deactivate PDP context based on the IMSI of the subscriber.
When there are PDP contexts present for a MM context,
PDP context will be deactivated along with GMM Detach(MM context deletion).
If there are no PDP present, MM context will be deleted to avoid
further PDP context request from the MS.
Test cases is added to check this functionality.

Change-Id: Ia0a41aa2218ec2fda4ea17a37c8cc55cba63dd13
2016-12-12 17:20:39 +05:30
Harald Welte b8e8d0a402 channel_mode_from_lchan(): Add missing break statement
GSM48_CMODE_DATA_6k0 was not properly terminated and thus resulted in a
bug.

Change-Id: I4000f06d0b49c4afb0446beddd150521c4ba3cf0
Fixes: Coverity CID 148207
2016-12-09 16:26:23 +00:00
Harald Welte c59e28fa5e gsm0408_test.c: Don't pass negative value to strerror()
Change-Id: I4fcf24ec1bc974a3189486d2372b9713d7fdab70
Fixes: Coverity CID 135192
2016-12-09 15:36:58 +00:00
Harald Welte 1cd50585e9 cfg_bts_si2quater_neigh_add(): Don't call strerror() on negative value
Change-Id: I1300eede3f22df812b7e83902327ce4cde21aa35
Fixes: Coverity CID 135185
2016-12-09 15:35:31 +00:00
Harald Welte 4a7d0e79cc mgcp_protocol: Ensure we don't call strtok_r with NULL data
Change-Id: I1dce4df6a49fe95db592b0598194e3a8b8b1b994
Fixes: Coverity CID 135181
2016-12-09 15:35:31 +00:00
Harald Welte 2327cede9c bsc_ctrl: Ensure we don't pass NULL string into strtok_r()
Change-Id: I03bea132377c0136b55b6fdad99a5d92da12e692
Fixes: Coverity CID 135180
2016-12-09 15:35:31 +00:00
Harald Welte 8d35965f24 abisip-find: check bsc_fd_register() result
Change-Id: I72d713725d287d32ec90506099751aeb9b15ef15
Fixes: Coverity CID 70462
2016-12-09 15:35:30 +00:00
Harald Welte c346f87371 sgsn_test: Fix missing = in == type check
Change-Id: I696a7d25d2f4d19922e05a7e83c4aeec5c44fb07
Fixes: Coverity CID 135156
2016-12-09 15:35:30 +00:00
Neels Hofmeyr 8825c69409 Fix TCH/F_PDCH: no need to check ts subslots for PDCH
For TCH/F_PDCH in PDCH mode, directly return the lchan to use, in order to
switch it to TCH/F. To check the pchan type in chan_alloc.c, make ts_pchan()
public in gsm_data_shared.h.

Commit c3f72f63af broke TCH/F_PDCH, as a fallout
of setting the GSM_PCHAN_PDCH subslots number to 0. This is sane and correct,
but the chan_alloc code failed to see a ts as available if it has no subslots.

Explanation:

_lc_find_trx() checks each timeslot. For normal, static TCH timeslots we
determine the number of logical subslots contained and check whether one of
them is free. For dynamic TS, we can do the same when in TCH mode, but when in
PDCH mode, we already know that it is available for immediate switchover for
voice and hence can return it right away. TCH/F_TCH/H_PDCH already has a
special check for that. TCH/F_PDCH doesn't, but this worked for TCH/F_PDCH as
long as ts_subslots() returned 1 for PDCH: the for-loop at the bottom of
_lc_find_trx() checked one subslot, which succeeded on an lchan in PDCH mode,
since PDCH lchans are always marked type == NONE and state == NONE. Now we more
accurately acknowledge that a PDCH timeslot has zero subslots and that a
dynamic timeslot in PDCH mode can always be switched to voice immediately,
without checking lchan type or state.

So, above mentioned commit set PDCH to zero subslots, and the for-loop to check
the (zero) subslots never ran and hence never returned the lchan. This fix adds
a special condition for TCH/F_PDCH in PDCH mode, same as TCH/F_TCH/H_PDCH.

(Todo: ts_pchan() can probably be used in other places as well to remove some
code dup. Leaving that for another patch.)

Fixes: OS#1868
Change-Id: I5d555d018a5bcb8d948e54059d32ec4c9b3070d0
2016-12-09 12:13:03 +00:00
Neels Hofmeyr e14f4b93f2 cosmetic: chan_alloc: use switch instead of if-cascade
Preparing cosmetically for a subsequent commit which will add another pchan
kind to be checked, rather use a "switch (pchan) {}". Also reverse one if()
branch to "early-exit" style.

Change-Id: Ie5eb0fa859c4f225616095dc56d52ce0f2dc8bdc
2016-12-09 12:13:02 +00:00
Max 2440f49a72 Replace duplicated code with macro call
Use already defined GSM48_LEN2PLEN for computing SI length.

Change-Id: I2020417119c844b886f89e34dbfd75e716743dc4
2016-12-09 12:06:27 +00:00
Neels Hofmeyr ec16c16193 lchan release in error state: SACCH deact only for SACCH pchans
This is useful particularly in case where we deactivate PDCHs
which don't have a SACCH associated.  The existin code would
always attempt to deactivate a SACCH even in those cases, leading
to the BTS responsding with related error messages.

Change-Id: Iaf46782329b38ba8f3d438e6c75c2d467b852734
2016-12-09 11:35:41 +00:00
Philipp Maier f788d93382 LLC: Fixup element order in LLC-XID
When the LLC-XID request is constructed the order of the elements
in the TLV structure is reversed. This is in theory not a problem,
but differs from what we know from our practical experience. This
commit fixes the problem.

Change-Id: I1d71c947350d3c5a85ff36b71c1b8f036071d162
2016-12-05 18:56:51 +00:00
Neels Hofmeyr 2b9c53408f abis_om2k: fix typo that declared non-existent struct gsm_bts_trx_s
The typo was recently committed in 80ccb95267,
"OM2000: Fix missing dynamic TCH initialization"

Change-Id: I8e3eec8cf63494962fa31d85a0ec9db9a9e5df46
2016-12-02 12:09:41 +00:00
Neels Hofmeyr ce090f890b gsm_subscriber_connection: mark BSC specific items
This is intended to prepare for splitting gsm_subscriber_connection into BSC
and MSC specific structs, to make the splitting patch more readable.

Change-Id: Ib9666225fb9bfec2cf1e364343560571869fe6a7
2016-12-02 12:09:17 +00:00
Neels Hofmeyr 50669bebdb osmo-nitb: exit when MNCC socket init failed
Change-Id: Icef97bb5da9840b810fe6f4b4da6abd4baa66915
2016-12-02 12:09:17 +00:00
Neels Hofmeyr 42eb0141d7 split subscr_con_allocate()/_free() in bsc_ and msc_
Rename current subscr_con_allocate() and subscr_con_free to bsc_*,
and add two separate msc_subscr_con_allocate() and _free().
The msc_subscr_con_free() ignores all lchan members.

In libbsc use bsc_*, in libmsc use msc_*.

Change-Id: I3cf7c7cafdf4672ec7b26058bba8a77159855257
Future: there will be distinct subscr conns for libbsc and libmsc.
2016-12-02 12:09:17 +00:00
Neels Hofmeyr 640b794de0 move to libcommon-cs: net timezone VTY config
Leave the timezone VTY output in libbsc's config_write_net(), until the BSC/MSC
separation of struct gsm_network is completed.

Change-Id: I9712b2e07b4f1ab8d2e4ad40a8d771e98ed25b20
2016-12-02 12:09:17 +00:00
Neels Hofmeyr 7398395cc0 Move timezone settings up to network level
Time zone used to be configurable per-BTS. In the upcoming MSC-split, no BTS
structures will be available on the MSC level. To simplify, drop the ability to
manage several time zones in a core network and place the time zone config on
the network VTY level, i.e. in gsm_network. If we are going to re-add fine
grained time zone settings, it should probably be tied to the LAC.

Adjust time zone VTY config code (to be moved to libcommon-cs in subsequent commit).

Adjust time zone Ctrl Interface code.

Change-Id: I69848887d92990f3d6f969be80f6ef91f6bdbbe8
2016-12-02 12:09:17 +00:00
Neels Hofmeyr 1a60644eb2 reinvent connection_for_subscr() and move to libmsc
Implement connection_for_subscr() from a completely different angle: instead of
looking up lchans in bts structs, look up the subscriber in the global list of
gsm_subscriber_connection. static lchan_find() is thus obsoleted.

All callers of connection_for_subscr() live in libmsc, so move to libmsc.

The move and edit are done in a single commit since the old and new
implementation have nothing in common.

Future: osmo-cscn will use this, without bts being present.

Remove implementation of connection_for_subscr() from channel_test.c -- it is
possible that the abort() in there was intended for a regression test, but
actually it seems the implementation was merely added for linking reasons, and
the abort() added to guard against the NULL return value: no comment nor the
commit log indicate that the abort() is test critical; the addition was the
only change in channel_test.c for that commit; at the same time a
connection_for_subscr() call was added in libmsc.

Change-Id: I5e0ba0ecf1726ebd540800f4e98fdfc937c904ff
2016-12-02 12:09:17 +00:00
Neels Hofmeyr ea11bf8095 bsc vty: rename show_net_cmd to bsc_show_net_cmd
Future: there will be an MSC-land show-net-cmd, so rename to something with
bsc in its name.

Change-Id: Ifb86698cd57a09f03b935b6d3fcea87eff4cd397
2016-12-02 12:09:16 +00:00
Neels Hofmeyr 06d39fdb72 move to libcommon-cs: network VTY that isn't BSC-specific
Keep only BSC specific bits of the 'network' VTY node in bsc_vty.c, move more
general VTY commands to common_cs_vty.c.

Add arg to common_cs_vty_init() to pass a config_write_net() function. Pass a libbsc
specific config_write_net() function.

Future: upcoming omso-cscn will re-use the VTY bits moved to libcommon-cs and pass a
different config_write_net() function.

Change-Id: I871b7b32a0c56fdce983e409cf244ec487d24e71
2016-12-02 12:09:16 +00:00
Neels Hofmeyr b90eabfb46 move to libcommon-cs: global vty gsm_network pointer
Move gsmnet_from_vty() and the bsc_gsmnet global to common_cs_vty.c.

Rename bsc_gsmnet to vty_global_gsm_network and make it static to common_cs_vty.c, to
clearly mark the global variable for VTY use only.

Introduce common_cs_vty_init() to set vty_global_gsm_network.

Change-Id: I26c5c47de08f899b896813d09612d5cb2f8e42d6
2016-12-02 12:09:16 +00:00
Neels Hofmeyr 2c05f75bbf global gsm_network: move allocation further up
Now that bsc_network_alloc() is separate, move it to before the VTY init (a
subsequent patch will pass the gsm_network instance as a parameter to
vty_init()).

bsc_hack.c: drop the comment that says about the VTY init: "This needs to
precede handle_options()" -- it is not accurate. Actually move the
handle_options() above both vty_init() and the bsc_network_alloc() calls, to be
able to decide which mncc callback to pass to bsc_network_alloc. It would make
sense to set this later on, but that would require further refactoring of the
bsc_network_init() and gsm_network_init() signatures, so not in this patch.

Change-Id: Ie6a7037e703b5a2d08ceeb20d35f197aaddc9d1b
2016-12-02 12:09:15 +00:00
Neels Hofmeyr e235441f73 split bsc_bootstrap_network() in alloc and config
For patch clarity, keep some code dup to be removed in a subsequent patch. In
the same sense don't change the fact that mncc_sock_init()'s return value is
ignored.

The global gsm_network instance 'bsc_gsmnet' is basically only used by the VTY,
and a future patch will "hide" that global in a vty .c file. In a nutshell, I
want to

- first allocate a gsm_network,
- then initialize the VTY passing the gsm_network pointer,
- and then read the config file using the initialized VTY.

So far, bsc_bootstrap_network() allocates the gsm_network and reads the config
file right away, which only works by sharing the extern bsc_gsmnet pointer,
which I would like to uncouple.

Change-Id: I480a09a31a79766ad07b627dd5238b7e37f3be7a
2016-12-02 12:09:15 +00:00
Neels Hofmeyr 6a366055dd tests: drop unused libmsc, unneeded duplicate libbsc linking
Because of libcommon-cs, tests/gsm0408,subscr,trau no longer need libmsc.

Change-Id: I9073eba41a1cd3136ed7a9def6fe8aaf282eaa18
2016-12-02 12:09:15 +00:00
Neels Hofmeyr 05667a0aff sms_next_rp_msg_ref(): use direct pointer to next_rp_ref counter
libbsc and libmsc will have separate subscriber connection structs. Hence don't
rely on gsm_subscriber_connection, but work on a direct pointer to the counter
for the next RP reference.

The only very thin function in gsm_04_11_helper.c thus becomes obsolete: drop
the entire file.

Change-Id: I2a2e9ba6a981a385d1f8f07acbe03536ffed0072
2016-12-02 12:09:15 +00:00
Neels Hofmeyr ac1f1436e9 factor out & introduce struct gsm_encr, in common_cs.h
Factor out encryption info from struct gsm_lchan as struct gsm_encr, placed in
common_cs.h.

Change-Id: I94015fb9dd511c37c1e3058a0963c780b3f700ac
Future: this will be used by libmsc's subscriber connection, for osmo-cscn.
2016-12-02 12:09:15 +00:00
Neels Hofmeyr 43273c63de factor out gen of USSD notify and release complete to libosmocore
Both libmsc and libbsc will need distinct gsm0480_send_ussdNotify() and
gsm0480_send_releaseComplete() functions, since there will be distinct
subscriber connection structs.

Rename to msc_send_ussd_notify() and msc_send_ussd_release_complete(), and add
the same in libbsc with bsc_ prefix in new file gsm_04_80_utils.c.

In preparation of this patch, the message generation part of these functions
has been added to libosmocore as gsm0480_create_ussd_notify() and
gsm0480_create_ussd_release_complete(). Use these.

Adjust all libmsc and libbsc callers according to use the msc_* or bsc_*
implementation, respectively.

Change-Id: I33a84e3c28576ced91d2ea24103123431f551173
2016-12-02 12:09:15 +00:00
Neels Hofmeyr eb52aad198 IuPS: properly update ra_id on GMM Attach Request
For new MM contexts, the ra_id was correctly obtained from the ue_ctx, but in
case an MM ctx is re-used and the ra_id changed, the new ra_id was not copied
to the MM context; instead, the ra_id was overwritten with uninitialized data.

Always initialize the local ra_id variable from the ue_ctx->ra_id for Iu
connections; it is used further below to update the ctx->ra_id.

For the case of a brand new Iu MM ctx, the ctx->ra_id then gets initialized a
second time. We could technically drop the init in sgsn_mm_ctx_alloc_iu(), but
it doesn't hurt either way.

Fixes: CID#57936
Change-Id: Ia06458758362e76925690b1757d8ced95e9609e4
2016-11-28 12:09:06 +01:00
Philipp Maier 143a274051 sndcp: fixup for coverity scan defect CID 149097
Coverity scan detects a Null pointer deref (FORWARD_NULL) in
gprs_sndcp_comp.c: 67 in gprs_sndcp_comp_create().

The reason for this is that gprs_sndcp_dcomp_init() and also
gprs_sndcp_pcomp_init() rely on the comp_entity->algo algo
flag. If the program logic is correct a null pointer deref
should never occur.

This commit adds OSMO_ASSERT() statements to ensure a null
pointer deref is catched if if the ...comp_init() functions
are used with incorrect parameters.

Change-Id: I7748f06d1739a697edad5100a031e5aa1ef11ed1
2016-11-27 18:27:57 +00:00
Harald Welte 487436138e bsc_msc.c: Check setsockopt() return value
Change-Id: I79a8fe9c025772e51560503504f517485b0ace34
Fixes: Coverity CID 57644
2016-11-26 17:10:29 +01:00
Harald Welte be67050a36 abis_nm: ceck fseek() return code in is_last_line()
Change-Id: I8ed4e703625c9da959e0938cd1eb3f0c73a2d4d0
Fixes: Coverity CID 57643
2016-11-26 17:10:29 +01:00
Harald Welte 3c165d02bb ipaccess-proxy: Check setsockopt() return value
Change-Id: I34b082907b6f0b25fe2779f3a1f0a642a9002664
Fixes: Coverity CID 57642
2016-11-26 17:10:29 +01:00
Harald Welte 54f44ec585 ipaccess-config: Handle setsockopt return value
Change-Id: I8c2082f9a9c865cc663ad2abb63ee0f70914dabe
Fixes: Coverity CID 57640
2016-11-26 17:10:29 +01:00
Harald Welte 18712f0bd1 Fix possible non-null-terminated buffer
Change-Id: I22100c260856991b9a836135b3650e5b8c5449ca
Fixes: Coverity CID 57623
2016-11-26 17:10:29 +01:00