Compare commits

..

286 Commits

Author SHA1 Message Date
Ivan Kluchnikov
bd6784dbe8 debian: Update changelog to 0.15.1-fw.1 2017-02-15 19:54:56 +03:00
Ivan Klyuchnikov
5788904242 gsup: Update code after rebase to updated gsup implementation 2017-02-07 19:01:13 +03:00
Ivan Kluchnikov
362a757f56 osmo-nitb: Send purge ms to reg-proxy and handle response 2017-02-07 18:59:56 +03:00
Ivan Kluchnikov
444a9b9304 reg-proxy: Implement purge ms forwarding and handling 2017-02-07 18:59:56 +03:00
Ivan Kluchnikov
8d8bedff4c gsm_04_08: Change reject cause for not "attached" subscribers from "destination out of order" to "no user responding" 2017-02-07 18:59:56 +03:00
Ivan Kluchnikov
084a35588f reg-proxy: fix osip transactions releasing procedure
* implement nict_trans_free function for checking list of osip_nict_transactions and releasing transactions in terminated state
* call nict_trans_free function in main loop
* transactions should not be released in message callback functions, so remove osip_transaction_free and osip_message_free from sip_cb_rcv2xx function
2017-02-07 18:59:56 +03:00
Ivan Kluchnikov
03bf40f6a5 reg-proxy: use osip_strdup function, because we should allocate memory for scheme and host values to be used in osip_uri_set_ functions 2017-02-07 18:59:56 +03:00
Ivan Kluchnikov
842e599c5c reg-proxy: we shouldn't free call_id_num and seq_num_str, because they are used in osip_message and will be freed by osip_message_free function 2017-02-07 18:59:56 +03:00
Ivan Kluchnikov
16e9c4a70f reg-proxy: free allocated ipa control messages in ipa_sock_server_cb function 2017-02-07 18:59:56 +03:00
Ivan Kluchnikov
fdee81b35f reg-proxy: free all allocated osip elements, messages and transactions 2017-02-07 18:59:56 +03:00
Ivan Kluchnikov
582242d2f5 gsm_sup: check connection before use it, because it can be already closed 2017-02-07 18:59:56 +03:00
Sergey.Kostanbaev
fb5a18db4b ussd_proxy: fix decoding GSM7 to latin1 2017-02-07 18:59:56 +03:00
Sergey Kostanbaev
8a8703e06c fix incorrect autorebase 2017-02-07 18:59:56 +03:00
Sergey Kostanbaev
d68abba3d0 fixup after rebase 2017-02-07 18:59:55 +03:00
Ivan Kluchnikov
bbd3c7cd46 reg-proxy: Implement handling LU responses without msisdn
If we receive 200 ok response with imsi instead of msisdn in sip contact header, we should send LU response message to osmo-nitb without msisdn.
2017-02-07 18:59:55 +03:00
Ivan Kluchnikov
0a2a92a4f5 gsm_sup: Update subscriber info in database only if msisdn is received in LU response 2017-02-07 18:59:55 +03:00
Ivan Kluchnikov
a52726dae8 msc: Increase value of location update timer to 10 sec
We should increase this timer, because LU procedure can take more than 5 sec, if 'remote' auth policy is used.
2017-02-07 18:59:55 +03:00
Ivan Kluchnikov
8af593e4e4 sms: Route all sms from/to subscribers with extension length = 5 to local smsc 2017-02-07 18:59:55 +03:00
Ivan Kluchnikov
fb11fc1a7a sup: pass subscriber group parameter to subscr_get_by_extension function
Subscriber group parameter should be set for subscriber in subscr_get_by_extension function, because it is used in connection_for_subscr function.
2017-02-07 18:59:55 +03:00
Ivan Kluchnikov
0904c1de19 sms: Use gsm411_rp_hdr structure instead of manual parsing of RP messages 2017-02-07 18:59:55 +03:00
Ivan Kluchnikov
c301ef4ea7 sms: MO RP ACK and RP ERROR should be also forwarded to the sms socket 2017-02-07 18:59:55 +03:00
Ivan Kluchnikov
59dc70462b sms: In case of receiving MO RP-DATA, we should assign RP message reference value to transaction variable 2017-02-07 18:59:55 +03:00
Ivan Kluchnikov
e7dc282b51 sup: Fix RP header offset and RP data length calculations 2017-02-07 18:59:55 +03:00
Ivan Kluchnikov
45fdb6a728 vty: Install sms_destination_cmd element as NITB_NODE 2017-02-07 18:59:55 +03:00
Ivan Kluchnikov
32906636f1 sms: Add functions for forwarding/handling SMS in RP format to/from external application 2017-02-07 18:59:55 +03:00
Ivan Kluchnikov
b314380065 sms: Add new socket for forwarding/receiving SMS in RP format to/from external application 2017-02-07 18:59:55 +03:00
Ivan Kluchnikov
8bb11c90fc trans: Add new parameter message reference for SMS and function for finding transaction by this reference 2017-02-07 18:59:55 +03:00
Sergey Kostanbaev
933de8cb48 send actual message in facility op (not initial) 2017-02-07 18:59:55 +03:00
Kirill Zakharenko
1bcfaa7119 debian: use --enable-ussd-proxy with ./configure 2017-02-07 18:59:55 +03:00
Kirill Zakharenko
6c079bb981 reg-proxy, ussd-proxy: don't use realtime priority 2017-02-07 18:59:55 +03:00
Sergey.Kostanbaev
c572ac8733 add test for registerSS 2017-02-07 18:59:55 +03:00
Sergey.Kostanbaev
53d1a9186c set transaction_id from transaction data 2017-02-07 18:59:55 +03:00
Sergey Kostanbaev
2f749ef103 emulation for SS 2017-02-07 18:59:55 +03:00
Sergey Kostanbaev
17276417ef various bugs in ss reply 2017-02-07 18:59:55 +03:00
Sergey.Kostanbaev
234f6714a7 add generation of src/ussd-proxy/Makefile 2017-02-07 18:59:54 +03:00
Sergey.Kostanbaev
3e7a48c475 add forgotten files 2017-02-07 18:59:54 +03:00
Sergey Kostanbaev
9d53708f58 add forgotten file 2017-02-07 18:59:54 +03:00
Sergey Kostanbaev
da8c96e097 recovery latin1 USSD message, probably bad rebase 2017-02-07 18:59:54 +03:00
Sergey.Kostanbaev
d4839fe14a manual merge SS from sup-ussd-on-master-ss-wip 2017-02-07 18:59:54 +03:00
Ivan Kluchnikov
db0e216845 msc: Implement 'remote-closed' authentication policy
This mode is modified version of 'remote' policy.
Osmo-nitb uses remote subscription data only if the MS is activated in local HLR, otherwise osmo-nitb rejects subscriber.
2017-02-07 18:59:54 +03:00
Ivan Kluchnikov
2d9f39ec43 reg-proxy: Added configuration parameter for setting registration expiry time 2017-02-07 18:59:54 +03:00
Ivan Kluchnikov
e5e251c396 sup: fix handling update location result message
If LUR procedure timed out, we should just skip update location result message.
2017-02-07 18:59:54 +03:00
Sergey Kostanbaev
991691f8df ussd_proxy: add content-type sip tag in bye for 3rd party software workaround 2017-02-07 18:59:54 +03:00
Sergey Kostanbaev
955d8800e5 ussd_proxy: add -x proxy option 2017-02-07 18:59:54 +03:00
Sergey Kostanbaev
9a4936a234 ussd_proxy: add -7 option to force latin1 convertion to gsm 7-bit 2017-02-07 18:59:54 +03:00
Sergey Kostanbaev
012c9203e4 ussd: handle UCS-2 coding 2017-02-07 18:59:54 +03:00
Sergey Kostanbaev
5087f994fd libmsc: set proper length field in ASN.1 format for USSD internals 2017-02-07 18:59:54 +03:00
Sergey Kostanbaev
420e4d445c libmsc: fix no return and use after free 2017-02-07 18:59:54 +03:00
Sergey Kostanbaev
a8f56961be ussd_proxy: handle reject from sup and send BYE to sip 2017-02-07 18:59:54 +03:00
Sergey Kostanbaev
b2679b822e ussd: send reject to sup 2017-02-07 18:59:54 +03:00
Sergey Kostanbaev
0ce3516a47 ussd_proxy: add debug output when session is destroyed 2017-02-07 18:59:54 +03:00
Sergey Kostanbaev
2b5eb8ddb0 libmsc: use message type as an entry point and handle release complete message 2017-02-07 18:59:54 +03:00
Sergey Kostanbaev
fd245fcfa8 ussd_proxy: fix reject after resultLast 2017-02-07 18:59:54 +03:00
Sergey Kostanbaev
9f24671589 ussd_proxy: add -l parameter to set loglevel in sip sofia 2017-02-07 18:59:54 +03:00
Sergey Kostanbaev
acddb2a632 ussd_proxy: remove dead code 2017-02-07 18:59:54 +03:00
Kirill Zakharenko
800369d258 debian: new package for reg-proxy & ussd-proxy 2017-02-07 18:59:54 +03:00
Sergey Kostanbaev
236d81fa0c ussd_proxy: detailed help 2017-02-07 18:59:54 +03:00
Sergey Kostanbaev
8e58f575e7 ussd_proxy: handle multiple USSD sessions 2017-02-07 18:59:53 +03:00
Sergey Kostanbaev
da0864dfde ussd_proxy: handle session timeout 2017-02-07 18:59:53 +03:00
Sergey Kostanbaev
fc969503e1 ussd_proxy: handle error callback 2017-02-07 18:59:53 +03:00
Sergey Kostanbaev
1e4a954c73 ussd_proxy: handle USSD dialogs into sip INFO messages 2017-02-07 18:59:53 +03:00
Sergey Kostanbaev
2f4878a90f ussd_proxy: handle basic errors to release channel 2017-02-07 18:59:53 +03:00
Sergey Kostanbaev
70e6f2ec74 ussd_proxy: properly set To and From SIP headers 2017-02-07 18:59:53 +03:00
Sergey Kostanbaev
be9419881c Add forgotten Makefile 2017-02-07 18:59:53 +03:00
Sergey Kostanbaev
a363aa3fc0 add standalone ussd_proxy utility based on sip sofia 2017-02-07 18:59:53 +03:00
Kirill Zakharenko
9cddaeafd5 debian: added libosip2 to build dependencies 2017-02-07 18:59:53 +03:00
Alexander Chemeris
9fe68b0fbc libmsc: Add a comment to the HLR SUP socket creation. 2017-02-07 18:59:53 +03:00
Alexander Chemeris
1c30463e76 libmsc: Create a separate SUP socket for USSD. 2017-02-07 18:59:53 +03:00
Alexander Chemeris
bcc2567579 libmsc: Fix comment style. 2017-02-07 18:59:53 +03:00
Alexander Chemeris
924292977f libmsc: Remove sup_init() to make SUP socket initialiaton generic. 2017-02-07 18:59:53 +03:00
Alexander Chemeris
a317e334c2 libmsc: Make internal functions 'static' in gsm_sup. 2017-02-07 18:59:53 +03:00
Alexander Chemeris
76c7cec298 libmsc: Whitespace fix in gsm_sup.c, no code changes. 2017-02-07 18:59:53 +03:00
Alexander Chemeris
c70110945a libmsc: Rename sup_client to hlr_sup_client in preparation for multiple SUP clients. 2017-02-07 18:59:53 +03:00
Sergey Kostanbaev
f5fe345dbb USSD MAP external interface over SUP 2017-02-07 18:59:53 +03:00
Ivan Klyuchnikov
07a5b120e9 Revert "ussd: Add band-aid for interrogationSS"
This reverts commit 5085e0bf4c.
2017-02-07 18:59:53 +03:00
Ivan Kluchnikov
dfeabbbff6 reg-proxy: add application which allows translate SUP to SIP and SIP to SUP 2017-02-07 18:59:53 +03:00
Ivan Kluchnikov
1371303689 sup: Fix msisdn decoding 2017-02-07 18:59:53 +03:00
Ivan Kluchnikov
f7cb56572a sup: Change status of waiting_for_remote_accept before checking subscriber 2017-02-07 18:59:53 +03:00
Ivan Kluchnikov
014316f514 nitb: Integrate the SUP client into the osmo-nitb 2017-02-07 18:59:53 +03:00
Ivan Kluchnikov
b96f1912da msc: Implement 'remote' authentication policy
- All location update requests should be send to the remote HLR and accepted.
- Authentication info should be also received from remote HLR.
- SUP is used for sending/handling subscription data to/from remote HLR.
2017-02-07 18:59:52 +03:00
Ivan Kluchnikov
adc681331e sup: Add functions to create/handle SUP messages
- Add functions to send location update request and handle responses.
- Add functions to query auth info and handle responses.
2017-02-07 18:57:31 +03:00
Ivan Kluchnikov
8516d533db debug: Add DSUP debug category for subscriber update protocol 2017-02-07 18:57:31 +03:00
Ivan Kluchnikov
c6e735fd00 debian: Add osmocom-meas-utils package 2017-02-07 18:57:31 +03:00
Ivan Kluchnikov
cc75a7f014 debian: build only osmo-nitb package - enable smpp support - disable the gbproxy test (failing) 2017-02-07 18:57:30 +03:00
Alexander Chemeris
1c33b89886 utils: Support new fields in the v1 of meas_feed in meas_json. 2017-02-07 18:53:38 +03:00
Alexander Chemeris
077e62cded utils: 'meas_json' utility to convert measurement feed into a JSON feed. 2017-02-07 18:53:38 +03:00
Alexander Chemeris
a78396dcb3 libbsc: Update a BTS's SIs when ms_max_power is changed from VTY.
Otherwise you have to restart BTS or at least break the RSL connection
to apply the change.
2017-02-07 18:53:38 +03:00
Alexander Chemeris
e9c81d2581 libmsc: Update 'max_power_red' VTY command.
Changes:
 * Apply change even if the supplied value is odd, just warn that it is rounded.
 * Apply change even if the supplied value is higher than the 24dB maximum
   suggested by the standard, just warn about this.
 * Apply change to the BTS over OML immediately.
2017-02-07 18:53:38 +03: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
48324fed11 vty tests: more attempts to resolve 'Broken Pipe' error (3)
Change-Id: Iea5329b6b92afc4088520d7420953106f04f8e1c
2017-02-07 00:41:16 +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
Holger Hans Peter Freyther
3f940fc9ee debian: Require libgtp-dev after the SO version bump
The ABI of libgtp changed and we require a new library now. Drop
the SO_VERSION from the library name and just depend on libgtp-dev.

Change-Id: Ib301b27e2c08fda827b55820389247e27e5e8fc7
2017-01-30 09:54:22 +00: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
Holger Hans Peter Freyther
76f048a1fd debian: Install header and source file to different directory
osmo-bts consumes the gsm_data_shared.{h,c} files and assumes the
OpenBSC directory layout. Install the files into the specific
sub-directories to make the --with-openbsc=dir option work.

Change-Id: I3da21402dee3d6f1d812b232b0a3f13b8a462d5b
2017-01-24 13:16:10 +00:00
Keith
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
Ruben Undheim
c8fc41c2f6 deb: unbreak nightly builds
Add openbsc-dev with source and header files necessary for osmo-bts builds.

Max's note: extracted from Debian packaging work into separate commit.

Change-Id: I25f8c639d2dc525ca280a7cd09de3ca6358d2568
2017-01-19 13:35:18 +00: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
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
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
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
5fa8b083cc Integrate Debian packaging changes
debian/control:
* restructure to make it easier to incorporate further changes
* update package descriptions
* update project URL

debian/rules:
* use proper hardening syntax
* restructure to make it easier to incorporate further changes
* remove useless comment

debian/compat: update compatibility version

debian/coryright: update to match Debian format

Change-Id: I49cc9239b15dc77d782914ca2547e601d049acdc
Related: OS#1694
2016-12-21 10:31:21 +00: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
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
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
Harald Welte
96df077083 libmsc/db: avoid subscr->name without terminating NULL char
Change-Id: Ic8944ac4c5e940c9d835c52f1701461f274238db
Fixes: Coverity CID 57621
2016-11-26 16:08:38 +00:00
Harald Welte
b0993e61d0 abis_nm: Fix non-null terminated buffer
Unrealistic case (filename of 4096 bytes)

Change-Id: Icf7b835f9edaf66976556fce1e9e0f66aa2010bc
Fixes: Coverity CID 57620
2016-11-26 16:08:38 +00:00
Harald Welte
7b6bae6584 abis_nm: Fix possible not-null-terminated buffer
Unrealistic case with file name of 4096 bytes length.

Change-Id: I503200b879b854cf2dc218d5fe3059a555732d92
Fixes: Coverity CID 57619
2016-11-26 16:08:37 +00:00
Neels Hofmeyr
28f637ec2c move to libcommon-cs: gsm48_create_mm_serv_rej(), gsm48_create_loc_upd_rej()
Used by libbsc, libmsc as well as osmo-bsc and osmo-bsc_nat.

Moving gsm48_create* to libcommon-cs affects linking of osmo-bsc_nat, resulting in
undefined references to gsm48_extract_mi() and gsm48_paging_extract_mi(); fix
that by placing libfilter.a left of libbsc.a upon linker invocation.

Change-Id: I212c2567b56191022b683674c1c4daf842839946
2016-11-24 16:58:31 +01:00
Neels Hofmeyr
e78ae21ff4 move to libcommon-cs: net init 3: actual move
Reincarnate gsm_network_init() as the parts not specific to libbsc.
Move from bsc_network_init() those bits that are not BSC specific (and useful
for upcoming osmo-cscn).

Add libcommon-cs to all linkages that use gsm_network_init().

Note: the only requirement to allow linking gsm_network_init() without libbsc
is to keep the call to gsm_net_update_ctype() out of libcommon-cs. The other items
are kept out of libcommon-cs because it makes sense semantically. But the separation
is not strong in that the BSC specific data members are of course still
omnipresent in struct gsm_network. If bsc_network_init() is not called, these
are not initialized properly -- for now no users of uninitialized members
exist.

So this is just a first step towards a sensible split of the BSC and MSC
gsm_network structs. The long term aim should be to have entirely separate
structs with some common general items.

Change-Id: If06316b97002390dc9a434686750cb96193ea63b
2016-11-24 16:58:31 +01:00
Neels Hofmeyr
2d521a0296 move to libcommon-cs: net init 2: move bsc_network_init decl to new .h
bsc_network_init() is more fit to live in a BSC specific header, move it to new
common_bsc.h. It will probably also absorb the BSC-specific part of gsm_network
in the future.

Adjust header includes across the board. Particularly, fix abis_nm.h by
explicitly including gsm_data.h: it so far relied on other headers to do that,
which now is no longer always given.

Change-Id: I9edfb1e748bb1cb484fadd48b0406f5b3098e89b
2016-11-24 16:58:31 +01:00
Neels Hofmeyr
27681a3407 move to libcommon-cs: net init 1: rename to bsc_network_init
The gsm_network_init() function initializes a whole lot of BSC specific stuff.
Aiming to move some of it to libcommon-cs, first rename it to bsc_network_init().
This will retain the BSC specific stuff when the move is done.

Adjust all callers.

Future: osmo-cscn will call the more generic part and not the BSC specific
part.

Change-Id: I4816ae19374390fc5c64972f7cad2e9ec3d8bcc3
2016-11-24 16:58:31 +01:00
Neels Hofmeyr
402006dfdf define mncc_recv_cb_t to avoid code dup
Put mncc_recv_cb_t in common_cs.h to avoid header include complications: if placing
right above struct gsm_network, one must include gsm_data.h to use
mncc_recv_cb_t as function parameter in a header, which will include
gsm_data_shared.h, which will include common_cs.h (future knowledge). Since I will
need to use mncc_recv_cb_t in common_cs.h, including gsm_data.h from there would
introduce an #include loop. Avoid that and define mncc_recv_cb_t in common_cs.h to
begin with.

Change-Id: I2e64cffa563750ce9f3172ffba6f9cf5b9280e9c
2016-11-24 16:58:30 +01:00
Neels Hofmeyr
c69ee8527c Add empty libcommon-cs
This will gradually soak up code shared by libbsc and libmsc.

Change-Id: If34e2bd38a099d0799238337468d56e0305ab8ae
2016-11-24 16:58:30 +01:00
Pravin Kumarvel
16606c9007 Add support for pdpctx_timer_stop
Timer T3395 starts  at the transmission of Deactivate PDP request using
pdpctx_timer_start  but there was no corresponding stop function.
The timer is stopped when Deactivate PDP Context Accept is received.
This according to 3gpp spec reference 24.008 section 6.1.3.4.2.

Change-Id: I825c0a47d39e784dd1b8251f564609262530a5c6
2016-11-23 12:23:41 +00:00
Holger Hans Peter Freyther
5085e0bf4c ussd: Add band-aid for interrogationSS
This is a speculative change for interrogateSS and by not answering
the request the radio connection would remain open long.

The SS/USSD code is from a time where none of knew much about GSM. We
do not support SS but should reject it. We have checked for an empty
string in the text field to guess if it is a result/release to not send
more information. The right way forward is to decode the ASN1 into the
fields REQUEST/RESULT(last).

Fix an issue and make the code worse. Assume ss_code > 0 to see if this
is a interrogate invoke. The issue is that code 0 is a well defined
value but unlikely to be used.

MAP ASN1 definition:

SS-Code ::= OCTET STRING (SIZE (1))
        -- This type is used to represent the code identifying a single
        -- supplementary service, a group of supplementary services, or
        -- all supplementary services. The services and abbreviations
        -- used are defined in TS 3GPP TS 22.004 [5]. The internal structure is
        -- defined as follows:
        --
        -- bits 87654321: group (bits 8765), and specific service
        -- (bits 4321)

allSS                   SS-Code ::= '00000000'B

Change-Id: Ib0dc4485388f030eb172fe21f5327b7ab94751f5
2016-11-18 19:04:37 +00:00
Pravin Kumarvel
26f6ced05c Correct Logging macro for pdpctx_timer_start
This commit corrects the Logging macro used in pdpctx_timer_start.

Change-Id: Id4e3a7fb934ed82af8096fda9ddd3f4550e05844
2016-11-17 12:19:01 +05:30
Harald Welte
80ccb95267 OM2000: Fix missing dynamic TCH initialization
When OM2000 has confirmed that a TS is started, call dyn_ts_init()
on the timeslot to start the processing for fully dynamic (osmocom
style) TCH/F_TCH/H_PDCH.  This should in turn trigger the activation of
idle timeslots as PDCH until we want to allocate any of them for TCH/F
or TCH/H.

Change-Id: I1a1fd61d6afd85449cacad4bacfb830252dab6b1
2016-11-16 18:20:22 +01:00
Harald Welte
96638d141e OM2000: Add three IEs to TCH activation about which we have no clue
Change-Id: Ie3067606033e894c558659ddf0025d01b8198cf9
2016-11-16 18:20:21 +01:00
Philipp
309425e105 rsl: support for ericssons propritary SI13 format
Ericsson has introduced a propritary format to issue the S13 BCCH
information. Normally the system info type field for SI13 would
be encoded as 0x28. Ericsson encodes that field as 0x02 and ads
a bcch mapping parameter, (IEI=F2) This patch sets the BCCH mapping
to 0x00 (=BCCH Normal) statically (0xF200)

The new constands are added to libosmocore, see commit:
f0f9c8c29daaefbf9cff19177ade4a13ffb2e36c

Change-Id: Ie0900f9b810744172b3090ce1b0ef7b7a1132946
2016-11-16 16:36:17 +00:00
Philipp
38cba5aa79 OM2000: Fixup based on Coverity Scan suggestion
This commit fixes Coverity Scan defect:

CID 151901:  Insecure data handling  (TAINTED_SCALAR)
Passing tainted variable "tag_len" to a tainted sink.

Change-Id: Ic71ed6a3bbb228bc03e95bfc4a6f5fe09cf5a021
2016-11-16 16:35:42 +00:00
Philipp
fb89b9b00b rbs2000: Add missing bts feature definitions
function bts_model_rbs2k_start() in bts_ericsson_rbs2000.c lacks
the feature definition for GPRS and EGPRS.

Change-Id: I777a67862084aa6cca39cfc43f5708e47608b0e6
2016-11-16 16:35:05 +00:00
Max
c04c6ed4af abisip-find: use protocol constant
Use library define instead of directly using hardcoded value.

Change-Id: Ie9b8bc55bf40cf005434f27e205d47ffab959413
2016-11-15 22:35:38 +00:00
Philipp
7d3093506a SNDCP: Fixup based on Coverity Scan suggestion
This commit fixes Coverity Scan defect:

CID 151900:  Null pointer dereferences  (FORWARD_NULL)
Passing null pointer "comp_field->v42bis_params->nsapi"
to "memcpy", which dereferences it.

Change-Id: Iff83e21168a267dd4b4c401ab7c603e029b3ac39
2016-11-15 22:32:20 +00:00
Daniel Willmann
bb42eee113 test/gbproxy: Test for possible memory corruption when link_info is freed
This test is to trigger the use-after free issue in commit bff7b0d80972. If
compiled with address-sanitizer the test will abort without the fix.

Change-Id: I5e8c6626ba43342740f08d699383bdded739079f
Ticket: OW#3049
Sponsored-by: On-Waves ehf
2016-11-15 22:32:03 +00:00
Daniel Willmann
beade314d0 gbproxy: Check whether gbproxy_update_link_state_after() deletes the link_info
In case the link_info is deleted we have to stop handling the stored messages
inside link_info. Not doing so can lead to invalid memory being accessed.

Change-Id: Ieb8503e9e94e7a5ac450ad8aa1713ec4f21cdea5
Ticket: OW#3049
Sponsored-by: On-Waves ehf
2016-11-15 22:32:02 +00:00
Harald Welte
58273f4b88 OM2000: CON MO: Allow larger range for CCP and CI values
it seesm more recent RBS2000 models have much larger CCP and CI value ranges
than those of older models.

Change-Id: Ib116c1fac901b293929fce34223d1fd0af15d2bc
2016-11-13 21:22:33 +01:00
Harald Welte
eae68292bd Support configuration of CON MO Groups/Paths from VTY
The code for supporting the configuration of the OM2000 CON (LAPD
Concentrator) MO was so far incomplete and not used from the OM2000 FSM
initialization.  This patch adds
* VTY commands for configuration of CON Groups and Paths
* The FSM integration to actually configure the CON MO

Change-Id: I56dc1b5e35adef3a2078bcf9536537eb0f454192
2016-11-13 21:22:29 +01:00
Harald Welte
fe7be8ddd0 RBS2000: Ensure the is-connection-list command is only used on RBS2000
... and not on other BTS models.

Change-Id: I8882ca9a9ab974b0bbdcbd5c3bab0eadf4bc0927
2016-11-11 21:20:49 +01:00
Harald Welte
c1efa67c13 RBS2000: Avoid segfault if ts->lapd instance doesn't exist
This happens e.g. with DAHDI driver, when the DAHDI device cannot be
opened.  Let's not prematurely seg-fault early in the RBS2000 signal
handler, but take the proper error handlign for this.

Change-Id: I9223fb1568d3db7e278f07240c4be334c6602a13
2016-11-11 21:20:49 +01:00
Harald Welte
dfe48fdecf bs11_config: remove compiler waring about unused variable
bs11_config.c:78:22: warning: ‘too_fast’ defined but not used [-Wunused-const-variable=]
 static const uint8_t too_fast[] = { 0x12, 0x80, 0x00, 0x00, 0x02, 0x02
};
                      ^~~~~~~~

Change-Id: I1fdb9645128c2dfeb489bf75e89ab0adea919d2b
2016-11-11 15:34:05 +00:00
Harald Welte
af9a9b0b44 talloc_cxt: Fix compiler warning / missing #include
talloc_ctx.c: In function ‘talloc_ctx_init’:
talloc_ctx.c:40:2: warning: implicit declaration of function ‘msgb_talloc_ctx_init’ [-Wimplicit-function-declaration]
  msgb_talloc_ctx_init(ctx_root, 0);
  ^~~~~~~~~~~~~~~~~~~~

Change-Id: Ib8ebc02d5cf0d2b4019473d3750ae7c6f8a32896
2016-11-11 15:52:58 +01:00
Neels Hofmeyr
87ef68eb33 OM2000: disallow ip.access style TCH/F_PDCH pchan type
For TCH/F_PDCH, return an invalid chan comb (0) and print an error message
that hints at the proper pchan type to use instead: TCH/F_TCH/H_PDCH

Change-Id: Ibe0f944573f0a6d1be4bf7cf4986c4b2b3bd6d0d
2016-11-10 17:05:02 +00:00
Neels Hofmeyr
f926f45c4b OM2000: for TS conf of dyn TS, always send TCH/F chan comb
When OM2K sets up the timeslots with the BTS, the dynamic channel state
is not yet resolved to any particular pchan type. Instead of using the
dyn state, always advertise dynamic timeslots as pchan2comb(TCH/F).

In the past, the Ericsson dynamic timeslots were handled as pchan type
TCH/F_PDCH. This is a mistake, as this pchan type is intended for
the ip.access dynamic PDCH way of dynamic channels. In any case, in the
initial state of this pchan type, the timeslot was initialized as
pchan2comb(TCH/F) because the ts->flags do not reflect an active PDCH
yet. In short, this patch does not change the behavior of TCH/F_PDCH
timeslots, only clarifies it.

It would in fact make sense to disallow use of TCH/F_PDCH for OM2K,
but that should probably be a separate patch.

The proper pchan to use for Ericsson dynamic timeslots is
TCH/F_TCH/H_PDCH. These do not use ts->flags, but ts->dyn.* as state,
which first reflects pchan_want == pchan_is == GSM_PCHAN_NONE. Hence
the timeslot was initialized by OM2K as pchan type zero, which is
unknown / invalid. So, instead of using pchan_is, which is not yet
reflecting anything meaningful, always initialize as TCH/F chan comb,
as Ericsson hardware apparently expects it.

Change-Id: If0693f7c5c85977b0e4acbc701ee5d635434d0d1
2016-11-10 17:05:02 +00:00
Neels Hofmeyr
194b4cb4fd fix use after free in bsc_config_free
talloc_free the cfg only after asserting num_bsc count sanity.
This caused a failure in the 'bsc-nat' test with -fsanitize build.

Should fix the Osmocom_Sanitizer build on jenkins.osmocom.org
https://jenkins.osmocom.org/jenkins/job/Osmocom_Sanitizer/

Change-Id: Ic20aacaccffcaa58ccec6d24c884727dc1bc50e6
2016-11-10 03:19:22 +01:00
Philipp
b4ecc1d43b OM2000: Throw error when MO can not be enabled
Throw warning message in case the MO state does not change
to enabled after sendeing an Enable-Request message.

Change-Id: Idfde8d6f71526e8acfea51835732515a4bee858e
2016-11-09 15:43:34 +00:00
Philipp
6bbcfbb78c om2000: added support for ericssons sabm negotiation
This patch adds support for ericssons sambm negotiation.

This patch depends on libosmo-abis commit:
2788c7eacab91cd39d68e316fc8ee87763bbfeb4

Change-Id: I56b1c1cef07a61143fc0e8058480805cddfeff96
2016-11-09 15:43:34 +00:00
Philipp
8136e4b9af OM2000: Add fault report parsing
This patch adds parsing for OM2000 MO fault report map parsing,
the bits in the fault maps are counted out and displayed.

Change-Id: I6e2928f39b09bc08e9ab78bc10bc81e07f7eb55d
2016-11-09 15:43:34 +00:00
Harald Welte
7975ddf0ec RBS2000: re-establish any lost signalling links
Contrary to standard A-bis, in the RBS2000 case the BSC connects
the signalling data links (LAPD) to the BTS.  In case one of them
drop, we need to attempt to re-establish them.

This requires libosmo-abis with Change-Id I07f0f79e0cda09766f357032ffb4e7ad643d448a

Change-Id: I710b5af5d0acbdd3febd314849340f2adb7abd80
2016-11-09 15:43:34 +00:00
root
4579978983 om2000: Add support for querying RBS capabilities
Change-Id: Id1fbaf41286f3651ce8f210eb8da05fb51179c96
2016-11-09 15:43:34 +00:00
Holger Hans Peter Freyther
46edbc4162 lchan: Release channel in case of late activation ack
In case of the sysmoBTS and receiving a channel activation ack on a channel
that was marked as broken, release it again.

Use a normal release without SACCH deactivation and release the rqd_ta data.

Also add a local variable 'ts' to shorten some lines.

The typical situation where this would occur is with high latency between BTS
and BSC (or NITB). If a channel activation ack does not arrive in time, a
channel is marked broken, and never recovers after that. This patch will
release the channel again, which will remove the BROKEN_UNUSABLE state and
makes lchan available again. Reported by Rhizomatica.

However, in case of packet loss, i.e. when the channel activation ack never
arrives at the BSC, this patch does not provide a resolution of the
BROKEN_UNUSABLE state.

On dynamic timeslots: clearing the dyn ts state could possibly happen in
lchan_free() instead of in rsl_rx_chan_act_ack(). That's to be done in a
separate patch, if at all.

Tweaked-By: nhofmeyr
Change-Id: I63dc0deaf15ba7c21e20b1e0c7b85f0437e183ed
2016-11-09 15:43:13 +00:00
Harald Welte
686f4d6a85 SGSN: Use dummy all-zero MSISDN value in PDP Context Act on GTP
The GTP protocol specification requires us to include the MSISDN IE in
all non-secondary PDP context activations. However, when no real HLR is
used (e.g. via GSUP), we do not have the MSISDN information available
and so far simply sent a zero-length MSISDN IE in GTP.  The latter is a
violation of the spec.

So to resolve this, we now send a 15-digit all-zero dummy MSISDN IE, as
described in TS 23.003.

Change-Id: I8d0a5d52d6cd2a00b5dda060bd41d45056dfa84d
2016-11-09 15:42:39 +00:00
Harald Welte
424656e527 OM2000: Fix state machien for CF/TRXC on START Result
When receiving the 'Start Result' message, for CF and TRXC MO
we directly transition to performing the Operational Info.  In that
case, we need to return after sending the Operational Info and skip
the usual processing for the default case below.

Change-Id: I99860d198b337ffe461b240bda20dc10e1b5b2cb
2016-11-09 15:11:36 +01:00
Harald Welte
591e1d7daa WIP: OM2000: Full state machine implementation using osmo_fsm
Our existing OM2000 code for initializing all Managed Objects of a BTS
at startup was never complete.  Rather than trying to fix the old-style
code, introudce a hierarchy of osmo_fsm's reflecting the full protocol
hand-shake and sequence of bringing up the individual MO's.

If this works out well, it mihgt make sense to convert the TS 12.21 OML
code for other BTS models, too.

Change-Id: I3e11b28ba22b8c227e0401e6207fdda5381dda8c
2016-11-08 19:57:50 +00:00
Neels Hofmeyr
b748012d31 bsc_vty: include dyn TS info in vty show lchan
Extend both 'show lchan <bts> <trx> <lchan>' and 'show lchan summary' to
include information on dynamic timeslots.

Have one common function that prints " as foo" or " switching foo -> bar" to
the vty, use it in lchan_dump_full_vty() and lchan_dump_short_vty().

In lchan_dump_short_vty(), split the vty_out call in two in order to interleave
the dyn ts info right after the pchan.

The summary hence looks e.g. like this for osmocom style dyn ts:

    BTS 0, TRX 0, Timeslot 5 TCH/F_TCH/H_PDCH as PDCH, Lchan 0, Type NONE, State ACTIVE - L1 MS Power: 0 dBm RXL-FULL-dl: -110 dBm RXL-FULL-ul: -110 dBm

or

    BTS 0, TRX 0, Timeslot 4 TCH/F_TCH/H_PDCH switching NONE -> PDCH, Lchan 0, Type NONE, State BROKEN UNUSABLE - L1 MS Power: 0 dBm RXL-FULL-dl: -110 dBm RXL-FULL-ul: -110 dBm

Change-Id: I3eb72ac7f0a520a8eefe171b9fb357f149aa3fda
2016-11-03 12:37:03 +00:00
Neels Hofmeyr
350f93e1e4 log: count_codecs(): drop logging of non-TCH lchan types
count_codecs() is called on every chan act ack, also for channels other than
TCH/F and TCH/H. So this logging happens a lot during normal operation but adds
no real information.

Also, RSL would be the wrong logging category for this -- RSL is about the RSL
communications, not whether our internal code tries to count lchan codecs for
the wrong channel types.

Change-Id: Ibdac3bbe48745fe6a1c31d6f87369c9066c0374a
2016-11-02 14:33:48 +01:00
Harald Welte
0c566a444b mncc_builtin: Properly reject DTMF
As per TS 23.014, a GSM MSC must implement mobile-originated DTMF
generation.  We gate the DTMF signalling messages to MNCC, and expect
the external MNCC handler to deal with it.  However, the internal MNCC
handler simply ignored such singalling messages, rather than rejecting
DTMF altogether.

It turns out failure to respond to START DTMF will cause some phones to
behave in interesting ways, particularly with modem
firmware v6.01.00, see https://osmocom.org/issues/1817).  In this case
the phone is not able to release the call as the pending response to the
START DTMF is probably keping a reference or lock of some sort.

Change-Id: I336f0cd0a6396b522d228479a417fd4d606157ac
2016-11-02 09:20:54 +00:00
Philipp
5e5d94cd1b Cosmetic: Add missing switch to usage help
Adds the -p --pcap option to the help text.

Change-Id: I3e763c30ca13bc51c8b72af8a94558c92439f109
2016-11-01 21:56:23 +00:00
Philipp
d37981e8f7 gsm0408: Adding log output for 3g specific RR messages
GSM 04.18, which is the successor of GSM 04.08, describes
additional RR 3g specific message types. This commit adds
log output for those messages. The behaviour is not changed
all affected message types are still forwared to the MSC
as they were before.

See also 3GPP TS 04.18, section 10.4, table 10.4.1

The change requires to update libosmocore as well, see
also commit f48fdb3a108da0dc23d7af4ac021e98e11f07152 in
libosmocore.git for details.

Change-Id: I41f2242fdf59c3eb4b3f8f7f003c17f7e0df01aa
2016-11-01 21:56:22 +00:00
Philipp
b4cb838092 OML: Improve OML attribute handling
the OML attribute tables are hardcoded. To set variable parameters,
the hardcoded data structure (tlv) is patched on byte level during
runtime. This patch replaces this mechanism.

- Replace hardcoded OML attribute tables with dynamically
  generated TLV structures.

- Add unit tests to check if the OML attribute tables are
  generated correctly

- Put OML attribute table generator code in a separate file:
  bts_ipaccess_nanobts_omlattr.c

Change-Id: Ibeb34a84912d6cf695f553a34c69320fca7d08fa
2016-11-01 21:56:22 +00:00
Max
05adbdcb2e Decrease count_codecs logging verbosity
Use channel type name instead of number and log it with DEBUG facility
otherwise it produces lots of irrelevant messages for SDCCH*

Change-Id: I11b04e0cb02bf6ed01f6076cb31a56d8921d735e
2016-11-01 11:51:51 +01:00
Neels Hofmeyr
87c0056480 info log: iu: add line break to and tweak rx RAB Ass Resp log
Change-Id: I50e701493f3951a43506cc37753a30d47f8d601f
2016-10-30 18:28:27 +00:00
Philipp
ae9beda150 sndcp: Fixups for sndcp layer based on coverity-scan suggestions
- missing break in gprs_sndcp_pcomp.c, line 143
- string overflow in slhc_test.c, line 211
- sizeof mismatch in gprs_sndcp_xid.c, line 1369 and 1378
- mismatching signedness in gprs_sndcp_xid.c, line 1377
- needless < 0 comparison in gprs_sndcp_xid.c, line 477
- needless < 0 comparison in gprs_sndcp_xid.c, line 209
- missing returncode check in v42bis_test.c, line 320
- wrong pointer dereferentialization in gprs_sndcp_comp.c, line 73

Change-Id: I4f9adf251f5119e67ffe76baad6f1f996ac8dbad
2016-10-28 13:43:10 +00:00
Max
1b76a03cdd DTX DL: Add FACCH cache
When DL DTX is active and silent period is in progress dtx.cache is
populated by SID UPDATE message which about to be scheduled next. If at
that moment FACCH message arrives (which have higher priority) we have
to send ONSET message to L1 but we can't invalidate cache with SID
UPDATE as it will be used for SID FIRST message to resume silent period
after FACCH transmission is over (provided there were no incoming voice
in between). Hence the necessity for separate buffer to store content of
FACCH message while we're sending ONSET to L1 while keeping SID UPDATE
cached.

Change-Id: I316e81af893b24766bf259baaed7a0be75a11694
Related: OS#1801
2016-10-28 09:25:47 +00:00
Alexander Couzens
8c53c59bfb bsc: count the usage of codec by setting the lchan active
We count the codec when the channel was successful setted up
Using sign_link->trx->bts instead of msg->trx to get the bts.
Add OSMO_ASSERT for bts within count_codecs()

Change-Id: Ib49c7c337980a7d6f189d7a0551ca2e4c3822f45
2016-10-27 10:17:58 +00:00
Max
582e4f6276 Replace magic number with define
Value 4 used as magic number by both OpenBSC and OsmoBTS so it make
sense to add it to shared header. See
ebb483b69a5319e522ba5f713e9cb6f68a814a6a in osmo-bts for details.

Change-Id: I9c6ad68f4c6aa72d39ec7e5a6968b36ec20e79f4
2016-10-18 16:19:33 +02:00
Alexander Couzens
fbd96f55fd fix mistypes, spaces and tabs
Change-Id: I651473f638365bbd333c4c80d223cdd023dd2c51
2016-10-14 12:20:25 +00:00
Neels Hofmeyr
39ae17fb69 msgb ctx: use new msgb_talloc_ctx_init(), don't access talloc_msgb_ctx
Drop extern definitions of talloc_msgb_ctx and use msgb_talloc_ctx_init()
instead.

In sgsn_test.c, use a local variable msgb_ctx to do the talloc report
from the return value of msgb_talloc_ctx_init().

Change-Id: I2f9ace855f0ecbdc9adf5d75bcb1a3d666570de4
2016-10-13 13:14:41 +00:00
Neels Hofmeyr
4c2d4ab5db msgb talloc ctx: initialize in all main() scopes
Add msgb_talloc_ctx_init() call to many main() functions still lacking a
msgb talloc context.

Change-Id: Ib0d6751260659cabf18a7ce80680ba2fb4228ea1
2016-10-13 13:14:41 +00:00
Neels Hofmeyr
e072da9d2e gtphub_test.c: remove unused include of msgb.h
Change-Id: I7a8003a0e0bff803941d7981ffc07cf78c3ae9a9
2016-10-13 13:14:41 +00:00
Neels Hofmeyr
20436c8506 meas_pcap2db.c: remove unused include of msgb.h
Change-Id: I2197432c9482537bd5cf06a6c4fc912607ffab53
2016-10-13 13:14:41 +00:00
Neels Hofmeyr
30f7310a62 bs11_config: initialize bs11 tall ctx, use instead of bsc ctx
Actually initialize tall_bs11cfg_ctx as named const.

Change-Id: I3b42b29cd1a688cb4c9d1d4e44208509d936e4ef
2016-10-13 13:14:41 +00:00
Neels Hofmeyr
3edd0b03d5 ipaccess-config: initialize root talloc ctx with name
tall_ctx_config is defined but remains NULL. Instead initialize as named
const.

Change-Id: Iec708eda2e4f8eb88b9e5bc5f82f6342709760b1
2016-10-13 13:14:41 +00:00
Max
b6591072d8 Log use of incompatible BS-AG-BLKS-RES value
There's "channel-descrption bs-ag-blks-res" vty command which sets
BS-AG-BLKS-RES which might be too high if CCCH is combined with
SDCCHs. Previously proper value was silently enforced. Log this
situation explicitly and add spec reference to the comment.

Change-Id: I53e2b881fc28472d6709f063fb265a4e6a0fffcd
2016-10-13 08:35:24 +00:00
Neels Hofmeyr
f1a56dea7b jenkins.sh: use osmo-build-dep.sh, log test failures
Like in libosmo-abis' jenkins.sh

Change-Id: I4d6ffd5b230dd095650cc2231678b66056a8e4b5
2016-10-12 11:29:22 +00:00
Max
1e646f02f4 DTX DL: use FSM for AMR
- consolidate all DTX-specific things in a separate struct
- rename struct fields to better reflect meaning
- add pointer to DL FSM for AMR
- remove unused flag
- expand buffer to hold cached payload alongside with CMR/CMI

Change-Id: Idac8609faf9b5ced818fde899ccfc6ed0c42e8fd
2016-10-12 11:22:22 +00:00
Neels Hofmeyr
756fb30c8a gsm_trx_name(): don't break if trx is NULL
Just as a general precaution deemed to fit such a convenience function that
lives in libcommon, no actual failure observed.

Change-Id: I8e77fe1abc402469fd037e2fde2f46e2c8114f59
2016-10-10 03:26:36 +02:00
Neels Hofmeyr
a6ba6a370b abis_rsl_rx_dchan(): guard against lchan_lookup() returning NULL
Found this by coincidence, no actual failure case was observed.

lchan_lookup() does have a return NULL code path, so we should not blindly use
its returned pointer.

Change-Id: I34ce126d36420b8194c88c0faa865294334a6658
2016-10-10 03:24:09 +02:00
Neels Hofmeyr
5275c152e5 Revert "bsc: count the usage of codec by setting the lchan active"
This reverts commit 38e9ea3f7f.

Introduced a reproducable segfault, because msg->trx is not actually set/used
in the openbsc code paths.

 Program received signal SIGSEGV, Segmentation fault.
 count_codecs (lchan=0x1, bts=<optimized out>) at ../../../src/libbsc/abis_rsl.c:104
 104                             rate_ctr_inc(&bts->network->bsc_ctrs->ctr[BSC_CTR_CODEC_V1_FR]);
 (gdb) bt
 #0  count_codecs (lchan=0x1, bts=<optimized out>) at ../../../src/libbsc/abis_rsl.c:104
 #1  0x0000000000425661 in abis_rsl_rx_dchan (msg=<optimized out>) at ../../../src/libbsc/abis_rsl.c:1516
 #2  abis_rsl_rcvmsg (msg=0x8143f0) at ../../../src/libbsc/abis_rsl.c:2611
 #3  0x00007ffff71420d0 in handle_ts1_read (bfd=<optimized out>) at ../../src/input/ipaccess.c:271
 #4  ipaccess_fd_cb (bfd=0x815af8, what=1) at ../../src/input/ipaccess.c:386
 #5  0x00007ffff7779b62 in osmo_fd_disp_fds (_eset=0x7fffffffe590, _wset=0x7fffffffe510, _rset=0x7fffffffe490) at ../../src/select.c:149
 #6  osmo_select_main (polling=polling@entry=0) at ../../src/select.c:189
 #7  0x0000000000406fac in main (argc=<optimized out>, argv=0x7fffffffe738) at ../../../src/osmo-nitb/bsc_hack.c:385
2016-10-10 02:33:59 +02:00
Max
2d66bb2099 DTX: add flag for AMR HR P*
Add flag to explicitly track the state of DTX DL for AMR HR whe
SID_FIRST_P1 has been sent to L1 already but no next frame available
yet: this can be followed by SID_FIRST_P2 or SID_FIRST_INH depending on
arrival of voice frame within next 60 ms.

Change-Id: Id28b07b8e83cfe5e84de48a2f124084036580cd4
2016-10-05 05:48:16 +00:00
Max
63c18ca791 DTX: extend SID cache
In addition to RTP payload SID cache got to store CMR/CMI prefix. Extend
the buffer so it can fit in.

Change-Id: Ibd4a63604a82cad3ce65f0752bffefa4b083e1b3
Fixes: Coverity CID#149508
2016-10-05 05:48:11 +00:00
Alexander Couzens
3316397921 gprs/gprs_llc: count UI frames over SAPI in the statistics
Change-Id: I5f38d70e046ce9ca1342e6f862329dc3cded8995
2016-10-04 17:53:21 +02:00
Alexander Couzens
92f552f344 msc: add counters to track call attempts/active/success/failed
active_calls describe all calls in active state.
call.complete Call got terminated by disconnect requested either by MS or MSC.
call.incomplete Call got terminated by any other reason.
call.active Calls reached active state.
Change-Id: I49b93af2e6a0ba16c2fb00b7b83974e8a6a16df3
2016-10-04 01:08:12 +02:00
Alexander Couzens
38e9ea3f7f bsc: count the usage of codec by setting the lchan active
we count the codec when the channel was successful setted up

Change-Id: Ifc8a406a11dce16b9e7f3310841e470545550a2c
2016-10-04 00:55:05 +02:00
Neels Hofmeyr
a8f91df851 configure: check for pkg-config presence
Change-Id: I1484fc8b870df6f0aeef0c13078c66d0cfa97e75
2016-10-01 01:01:53 +02:00
Neels Hofmeyr
b81031292b build: be robust against install-sh files above the root dir
Explicitly set AC_CONFIG_AUX_DIR.

To reproduce the error avoided by this patch:

  rm install-sh        # in case it was already generated.
  touch ../install-sh  # yes, outside this source tree
  autoreconf -fi

This will produce an error like

  ...
  configure.ac:16: error: required file '../ltmain.sh' not found
  configure.ac:5: installing '../missing'
  src/Makefile.am: installing '../depcomp'
  autoreconf: automake failed with exit status: 1

See also automake (vim `which automake`) and look for 'sub locate_aux_dir'.

Change-Id: I3b6d9ad4e5af44c2bdf3844c7bf8e8517bd61d8e
2016-10-01 01:01:53 +02:00
Philipp
ea291e3004 SGSN: Fixing build config
Tests for V.42bis, slhc, llc-xid and sndcp-xid are built and
executed on all build configurations, but are only needed when
the sgsn (gprs) is built. This patch adds conditions check
if the tests mentioned abvove are needed or not.

Change-Id: I6921e6198ea7f99fe5276f91cbc522091853bc4e
2016-09-30 12:42:48 +00:00
Neels Hofmeyr
0867b72055 vty_test_runner.py: fix indents to use spaces, fix vim comment
Most of this file uses four spaces of indenting. Replace all tabs with spaces.

Remove the erratic 'set' from the recently added vim comment at the bottom.

Change-Id: I4273b3314defb1e5b31b509c2ac7d7c6cd6834cf
2016-09-30 12:42:20 +00:00
Neels Hofmeyr
0a45c1e77d vty_test_runner.py: make unittest print all output by default
Add option to TextTestRunner that shows print output on stdout.
It's better to see everything in our jenkins runs and not hide test output.

Change-Id: If4be1ad1c81c9ed4ab9b208b4c6d1e4b2cc8fdd5
2016-09-30 12:42:20 +00:00
Neels Hofmeyr
aba82097b6 log CTRL bind only once
After libosmocore 38d232ee5d2ceb045d9ad6d3a23afcb4972523f7 which outputs
'CTRL at <ip> <port>' from ctrl_interface_setup_dynip(), there's no need to log
the CTRL bind here anymore.

Change-Id: I1a874efe365a1ecf8ec37b058215b95b9a635ec2
2016-09-30 03:12:46 +02:00
249 changed files with 12931 additions and 4820 deletions

View File

@@ -5,64 +5,47 @@ set -ex
base="$PWD"
deps="$base/deps"
inst="$deps/install"
export deps inst
mkdir "$deps" || true
rm -rf "$inst"
build_dep() {
project="$1"
branch="$2"
cfg="$3"
set +x
echo
echo
echo
echo " =============================== $project ==============================="
echo
set -x
if [ -z "$project" ]; then
echo "internal failure"
exit 1
fi
cd "$deps"
rm -rf "$project"
osmo-deps.sh "$project"
cd "$project"
if [ -n "$branch" ]; then
git checkout "$branch"
fi
git rev-parse HEAD
autoreconf --install --force
./configure --prefix="$inst" $cfg
$MAKE $PARALLEL_MAKE install
}
osmo-build-dep.sh libosmocore "" ac_cv_path_DOXYGEN=false
build_dep libosmocore "" ac_cv_path_DOXYGEN=false
# All below builds want this PKG_CONFIG_PATH
export PKG_CONFIG_PATH="$inst/lib/pkgconfig:$PKG_CONFIG_PATH"
export LD_LIBRARY_PATH="$inst/lib"
if [ "x$IU" = "x--enable-iu" ]; then
netif_branch="sysmocom/sctp"
sccp_branch="sysmocom/iu"
fi
build_dep libosmo-abis
build_dep libosmo-netif $netif_branch
build_dep libosmo-sccp $sccp_branch
PARALLEL_MAKE="" build_dep libsmpp34
build_dep openggsn
osmo-build-dep.sh libosmo-abis
osmo-build-dep.sh libosmo-netif $netif_branch
osmo-build-dep.sh libosmo-sccp $sccp_branch
PARALLEL_MAKE="" osmo-build-dep.sh libsmpp34
osmo-build-dep.sh openggsn
if [ "x$IU" = "x--enable-iu" ]; then
build_dep libasn1c
#build_dep asn1c aper-prefix # only needed for make regen in osmo-iuh
build_dep osmo-iuh
osmo-build-dep.sh libasn1c
#osmo-build-dep.sh asn1c aper-prefix # only needed for make regen in osmo-iuh
osmo-build-dep.sh osmo-iuh
fi
set +x
echo
echo
echo
echo " =============================== openbsc ==============================="
echo
set -x
cd "$base"
cd openbsc
autoreconf --install --force
./configure --enable-osmo-bsc --enable-nat $SMPP $MGCP $IU --enable-vty-tests --enable-external-tests
$MAKE $PARALLEL_MAKE
LD_LIBRARY_PATH="$inst/lib" $MAKE check
LD_LIBRARY_PATH="$inst/lib" $MAKE distcheck
LD_LIBRARY_PATH="$inst/lib" $MAKE check \
|| cat-testlogs.sh
LD_LIBRARY_PATH="$inst/lib" $MAKE distcheck \
|| cat-testlogs.sh

6
debian/changelog vendored
View File

@@ -1,3 +1,9 @@
openbsc (0.15.1-fw.1) UNRELEASED; urgency=medium
* New release of openbsc for fairwaves build.
-- Ivan Klyuchnikov <kluchnikovi@gmail.com> Tue, 14 Feb 2017 15:12:30 +0200
openbsc (0.15.1) UNRELEASED; urgency=medium
* Move forward toward a new release.

2
debian/compat vendored
View File

@@ -1 +1 @@
7
9

139
debian/control vendored
View File

@@ -1,121 +1,78 @@
Source: openbsc
Maintainer: Harald Welte <laforge@gnumonks.org>
Section: net
Priority: optional
Maintainer: Harald Welte <laforge@gnumonks.org>
Build-Depends: debhelper (>= 7.0.0~), autotools-dev, pkg-config, libgtp0-dev, libosmocore-dev, libosmo-sccp-dev, libdbi0-dev, dh-autoreconf, libosmo-abis-dev, libosmo-netif-dev, libdbd-sqlite3, libpcap-dev, libssl-dev, libc-ares-dev, libsmpp34-dev
Standards-Version: 3.8.4
Homepage: http://openbsc.osmocom.org/
Build-Depends: debhelper (>= 9),
autotools-dev,
autoconf-archive,
pkg-config,
libosmocore-dev,
libosmo-sccp-dev,
libdbi0-dev,
dh-autoreconf,
libosmo-abis-dev,
libosmo-netif-dev,
libdbd-sqlite3,
libpcap-dev,
libssl-dev,
libc-ares-dev,
libsmpp34-dev,
libosip2-dev,
libsofia-sip-ua-dev
Standards-Version: 3.9.8
Vcs-Git: git://bs11-abis.gnumonks.org/openbsc.git
Vcs-Browser: http://openbsc.osmocom.org/trac/browser
Package: osmocom-bsc
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: GSM Base Station Controller; BSC-only version of OpenBSC. Needs a real MSC!
Classical BSC which requires MSC to operate.
Homepage: https://projects.osmocom.org/projects/openbsc
Package: osmocom-nitb
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, libdbd-sqlite3
Depends: ${shlibs:Depends},
${misc:Depends},
libdbd-sqlite3
Description: GSM Network-in-a-Box, implements BSC, MSC, SMSC, HLR, VLR
All the GSM network components bundled together.
This is the Network-in-a-Box version of OpenBSC. It has all the GSM network
components bundled together. When using osmocom-nitb, there is no need for a
Mobile Switching Center (MSC) which is needed when using osmocom-bsc.
Package: osmocom-ipaccess-utils
Package: osmocom-meas-utils
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Command line utilities for ip.access nanoBTS
Utilities specific for ip.access unit.
Package: osmocom-bs11-utils
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Command line utilities for Siemens BS-11 BTS
Utilities specific for BS-11 unit.
Package: osmocom-sgsn
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Osmocom Serving GPRS Support Node
SGSN implementation.
Package: osmocom-gbproxy
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Osmocom GPRS Gb Interface Proxy
Proxy for Gb interface.
Package: osmocom-bsc-nat
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Osmocom Base Station Controller Network Address Translation
Network address translation for BSC.
Package: osmo-gtphub
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Osmocom GTP Hub
Proxy for comms between multiple SGSNs and GGSNs.
Package: osmocom-bsc-dbg
Architecture: any
Section: debug
Priority: extra
Depends: osmocom-bsc (= ${binary:Version}), ${misc:Depends}
Description: Debug symbols for the OpenBSC BSC
Make debugging possible
Depends: ${shlibs:Depends},
${misc:Depends},
libcdk5,
sqlite3
Description: Measurement utilities for the OpenBSC
Measurement utilities for the OpenBSC.
Package: osmocom-nitb-dbg
Architecture: any
Section: debug
Priority: extra
Depends: osmocom-nitb (= ${binary:Version}), ${misc:Depends}
Depends: osmocom-nitb (= ${binary:Version}),
${misc:Depends}
Description: Debug symbols for the OpenBSC NITB
Make debugging possible
Package: osmocom-ipaccess-utils-dbg
Package: osmocom-meas-utils-dbg
Architecture: any
Section: debug
Priority: extra
Depends: osmocom-ipaccess-utils (= ${binary:Version}), ${misc:Depends}
Description: Debug symbols for the OpenBSC ip.access utils
Depends: osmocom-meas-utils (= ${binary:Version}),
${misc:Depends}
Description: Debug symbols for the OpenBSC measurement utilities
Make debugging possible
Package: osmocom-bs11-utils-dbg
Package: osmocom-proxy
Architecture: any
Section: debug
Priority: extra
Depends: osmocom-bs11-utils (= ${binary:Version}), ${misc:Depends}
Description: Debug symbols for the OpenBSC BS11 utils
Make debugging possible
Depends: ${shlibs:Depends},
${misc:Depends}
Description: GSM Network-in-a-Box, implements BSC, MSC, SMSC, HLR, VLR
reg and ussd proxies
Package: osmocom-sgsn-dbg
Package: osmocom-proxy-dbg
Architecture: any
Section: debug
Priority: extra
Depends: osmocom-sgsn (= ${binary:Version}), ${misc:Depends}
Description: Debug symbols for the OpenBSC Serving GPRS Support Node
Make debugging possible
Package: osmocom-gbproxy-dbg
Architecture: any
Section: debug
Priority: extra
Depends: osmocom-gbproxy (= ${binary:Version}), ${misc:Depends}
Description: Debug symbols for the OpenBSC GPRS GBProxy
Make debugging possible
Package: osmocom-bsc-nat-dbg
Architecture: any
Section: debug
Priority: extra
Depends: osmocom-bsc-nat (= ${binary:Version}), ${misc:Depends}
Description: Debug symbols for the OpenBSC Network Address Translation
Make debugging possible
Package: osmo-gtphub-dbg
Architecture: any
Section: debug
Priority: extra
Depends: osmo-gtphub (= ${binary:Version}), ${misc:Depends}
Description: Debug symbols for Osmocom GTP Hub
Depends: osmocom-nitb (= ${binary:Version}),
${misc:Depends}
Description: Debug symbols for the OpenBSC Proxies
Make debugging possible

158
debian/copyright vendored
View File

@@ -1,47 +1,137 @@
This work was packaged for Debian by:
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: OpenBSC
Source: http://openbsc.osmocom.org/
Harald Welte <laforge@gnumonks.org> on Tue, 24 Aug 2010 10:55:04 +0200
Files: *
Copyright: 2008-2015 Harald Welte <laforge@gnumonks.org>
2008-2015 Holger Hans Peter Freyther <zecke@selfish.org>
2009-2015 On-Waves
2008 Jan Luebbe <jluebbe@debian.org>
2008,2010-2011 Daniel Willmann <daniel@totalueberwachung.de>
2009,2011,2013 Andreas Eversberg <Andreas.Eversberg@versatel.de>
2009,2011 Dieter Spaar <spaar@mirider.augusta.de>
2009 Mike Haben <michael.haben@btinternet.com>
2010 Sylvain Munaut <246tnt@gmail.com>
2012-2013 Pablo Neira Ayuso <pablo@gnumonks.org>
2013-2015 Sysmocom s.f.m.c. GmbH (Jacob Erlbeck)
2014 Alexander Chemeris <Alexander.Chemeris@fairwaves.co>
License: AGPL-3+
Comment: Contributions by Stefan Schmidt <stefan@datenfreihafen.org> as well
It was downloaded from:
Files: wireshark/0001-abis_oml.patch
wireshark/0002-ericsson_rbs2409.patch
wireshark/0003-lucent-hnb.patch
wireshark/0005-rsl-hsl.patch
Copyright: 1998 Gerald Combs <gerald@wireshark.org>
2007,2011 Anders Broman <anders.broman@ericsson.com>
2009 Holger Hans Peter Freyther <zecke@selfish.org>
2009-2011 Harald Welte <laforge@gnumonks.org>
License: GPL-2+
git://bs11-abis.gnumonks.org/openbsc.git
Files: openbsc/include/mISDNif.h
Copyright: 2008 Karsten Keil <kkeil@novell.com>
License: LGPL-2.1
Upstream Authors:
Files: openbsc/src/libmgcp/g711common.h
Copyright: 2009 Abramo Bagnara <abramo@alsa-project.org>
License: GPL-2+
Harald Welte <laforge@gnumonks.org>
Dieter Spaar <spaar@mirider.augusta.de>
Holger Hans Peter Freyther <zecke@selfish.org>
Sylvain Munaut <tnt@246tNt.com>
Daniel Willmann <daniel@totalueberwachung.de>
Jan Luebbe <jluebbe@debian.org>
Mike Haben <michael.haben@btinternet.com>
Andreas Eversberg <Andreas.Eversberg@versatel.de>
Files: openbsc/git-version-gen
Copyright: 2007-2010 Free Software Foundation
License: GPL-3+
Copyright:
Files: openbsc/osmoappdesc.py
openbsc/tests/smpp_test_runner.py
openbsc/tests/ctrl_test_runner.py
openbsc/tests/vty_test_runner.py
Copyright: 2013 Katerina Barone-Adesi <kat.obsc@gmail.com>
2013 Jacob Erlbeck <jerlbeck@sysmocom.de>
2013-2014 Holger Hans Peter Freyther <zecke@selfish.org>
License: GPL-3+
Copyright (C) 2008-2010 Harald Welte <laforge@gnumonks.org>
Copyright (C) 2008-2009 Dieter Spaar <spaar@mirider.augusta.de>
Copyright (C) 2008-2010 Holger Hans Peter Freyther <zecke@selfish.org>
Copyright (C) 2009-2010 Sylvain Munaut <tnt@246tNt.com>
Copyright (C) 2009-2010 On-Waves
Copyright (C) 2008 Daniel Willmann <daniel@totalueberwachung.de>
Copyright (C) 2008 Jan Luebbe <jluebbe@debian.org>
Copyright (C) 2009 by Mike Haben <michael.haben@btinternet.com>
Copyright (C) 2009 Andreas Eversberg <Andreas.Eversberg@versatel.de>
Files: openbsc/src/libbsc/bsc_ctrl_lookup.c
Copyright: 2010-2011 Daniel Willmann <daniel@totalueberwachung.de>
2010-2011 On-Waves
License: GPL-2+
License:
Files: openbsc/src/libmsc/mncc_sock.c
openbsc/src/libmsc/mncc_builtin.c
Copyright: 2008-2010 Harald Welte <laforge@gnumonks.org>
2009 Andreas Eversberg <Andreas.Eversberg@versatel.de>
2012 Holger Hans Peter Freyther <zecke@selfish.org>
License: GPL-2+
GNU General Public License, Version 2 or later
Files: debian/*
Copyright: 2012-2015 Holger Hans Peter Freyther <zecke@selfish.org>
2016 Ruben Undheim <ruben.undheim@gmail.com>
License: GPL-2+
The Debian packaging is:
Copyright (C) 2010 Harald Welte <laforge@gnumonks.org>
License: AGPL-3+
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please chose a license for your packaging work. If the program you package
# uses a mainstream license, using the same license is the safest choice.
# Please avoid to pick license terms that are more restrictive than the
# packaged work, as it may make Debian's contributions unacceptable upstream.
# If you just want it to be GPL version 3, leave the following lines in.
and is licensed under the GPL version 3,
see "/usr/share/common-licenses/GPL-3".
License: GPL-2+
This package is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or (at
your option) any later version.
.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
.
On Debian systems, the complete text of the GNU General Public
License version 2 can be found in "/usr/share/common-licenses/GPL-2".
License: GPL-3+
This package is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.
.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
.
On Debian systems, the complete text of the GNU General Public
License version 3 can be found in "/usr/share/common-licenses/GPL-3".
License: LGPL-2.1
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; version
2.1 of the License.
.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see <http://www.gnu.org/licenses/>.
.
On Debian systems, the complete text of the GNU Lesser General
Public License version 2.1 can be found in
"/usr/share/common-licenses/LGPL-2.1".

3
debian/openbsc-dev.install vendored Normal file
View File

@@ -0,0 +1,3 @@
openbsc/include/openbsc/gsm_data_shared.h usr/src/osmocom/openbsc/openbsc/include/openbsc/
openbsc/include/openbsc/common_cs.h usr/src/osmocom/openbsc/openbsc/include/openbsc/
openbsc/src/libcommon/gsm_data_shared.c usr/src/osmocom/openbsc/openbsc/src/libcommon/

4
debian/osmocom-meas-utils.install vendored Normal file
View File

@@ -0,0 +1,4 @@
/usr/bin/osmo-meas-udp2db
/usr/bin/osmo-meas-pcap2db
/usr/bin/meas_vis
/usr/bin/meas_json

9
debian/osmocom-proxy.install vendored Normal file
View File

@@ -0,0 +1,9 @@
usr/bin/reg-proxy
etc/sv/reg-proxy
etc/service/reg-proxy
etc/reg-proxy.config
usr/bin/ussd-proxy
etc/sv/ussd-proxy
etc/service/ussd-proxy
etc/ussd-proxy.config

26
debian/rules vendored
View File

@@ -1,14 +1,4 @@
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
#
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
#
# Modified to make a template file for a multi-binary package with separated
# build-arch and build-indep targets by Bill Allombert 2001
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
@@ -17,26 +7,20 @@ DEBIAN := $(shell dpkg-parsechangelog | grep ^Version: | cut -d' ' -f2)
DEBVERS := $(shell echo '$(DEBIAN)' | cut -d- -f1)
VERSION := $(shell echo '$(DEBVERS)' | sed -e 's/[+-].*//' -e 's/~//g')
export DEB_BUILD_HARDENING=1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
%:
dh --sourcedirectory=openbsc --with autoreconf $@
dh $@ --sourcedirectory=openbsc --with autoreconf
# This is needed for debian stable (squeeze)
override_dh_autoreconf:
cd openbsc && autoreconf --install --force
override_dh_strip:
dh_strip -posmocom-bsc --dbg-package=osmocom-bsc-dbg
dh_strip -posmocom-nitb --dbg-package=osmocom-nitb-dbg
dh_strip -posmocom-ipaccess-utils --dbg-package=osmocom-ipaccess-utils-dbg
dh_strip -posmocom-bs11-utils --dbg-package=osmocom-bs11-utils-dbg
dh_strip -posmocom-sgsn --dbg-package=osmocom-sgsn-dbg
dh_strip -posmocom-gbproxy --dbg-package=osmocom-gbproxy-dbg
dh_strip -posmocom-bsc-nat --dbg-package=osmocom-bsc-nat-dbg
dh_strip -posmo-gtphub --dbg-package=osmo-gtphub-dbg
dh_strip -posmocom-meas-utils --dbg-package=osmocom-meas-utils-dbg
dh_strip -posmocom-proxy --dbg-package=osmocom-proxy-dbg
override_dh_auto_configure:
echo $(VERSION) > openbsc/.tarball-version
dh_auto_configure --sourcedirectory=openbsc -- --enable-nat --enable-osmo-bsc --enable-smpp
dh_auto_configure --sourcedirectory=openbsc -- --enable-smpp --enable-ussd-proxy

3
etc/reg-proxy.config Normal file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
COMMAND_LINE="-S 172.31.0.16 -s 5040 -D 172.31.0.10 -d 5040"

1
etc/service/reg-proxy Symbolic link
View File

@@ -0,0 +1 @@
../sv/reg-proxy

1
etc/service/ussd-proxy Symbolic link
View File

@@ -0,0 +1 @@
../sv/ussd-proxy/

4
etc/sv/reg-proxy/log/run Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
LOG_FOLDER=/var/log/reg-proxy
mkdir -p $LOG_FOLDER
exec svlogd -tt $LOG_FOLDER

6
etc/sv/reg-proxy/run Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
. /etc/reg-proxy.config
exec 2>&1
echo "reg-proxy restart" | /usr/bin/ts >> /var/log/runsv.log
exec reg-proxy $COMMAND_LINE

4
etc/sv/ussd-proxy/log/run Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
LOG_FOLDER=/var/log/ussd-proxy
mkdir -p $LOG_FOLDER
exec svlogd -tt $LOG_FOLDER

6
etc/sv/ussd-proxy/run Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
. /etc/ussd-proxy.config
exec 2>&1
echo "ussd-proxy restart" | /usr/bin/ts >> /var/log/runsv.log
exec ussd-proxy $COMMAND_LINE

3
etc/ussd-proxy.config Normal file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
COMMAND_LINE="-t sip:172.31.0.6:5060 -u sip:172.31.0.29:5090 -l8"

3
openbsc/.gitignore vendored
View File

@@ -55,7 +55,7 @@ src/gprs/osmo-sgsn
src/gprs/osmo-gbproxy
src/gprs/osmo-gtphub
src/osmo-bsc_nat/osmo-bsc_nat
src/osmo-cscn/osmo-cscn
src/libcommon/gsup_test_client
#tests
tests/testsuite.dir
@@ -86,6 +86,7 @@ tests/xid/xid_test
tests/sndcp_xid/sndcp_xid_test
tests/slhc/slhc_test
tests/v42bis/v42bis_test
tests/nanobts_omlattr/nanobts_omlattr_test
tests/atconfig
tests/atlocal

View File

@@ -1,5 +1,8 @@
AUTOMAKE_OPTIONS = foreign dist-bzip2 1.6
## FIXME: automake >= 1.13 or autoconf >= 2.70 provide better suited AC_CONFIG_MACRO_DIRS for configure.ac
## remove line below when OE toolchain is updated to version which include those
ACLOCAL_AMFLAGS = -I m4
AM_CPPFLAGS = \
$(all_includes) \
-I$(top_srcdir)/include \

View File

@@ -3,6 +3,9 @@ AC_INIT([openbsc],
m4_esyscmd([./git-version-gen .tarball-version]),
[openbsc@lists.osmocom.org])
dnl *This* is the root dir, even if an install-sh exists in ../ or ../../
AC_CONFIG_AUX_DIR([.])
AM_INIT_AUTOMAKE([dist-bzip2])
AC_CONFIG_TESTDIR(tests)
@@ -15,15 +18,27 @@ AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_RANLIB
dnl check for pkg-config (explained in detail in libosmocore/configure.ac)
AC_PATH_PROG(PKG_CONFIG_INSTALLED, pkg-config, no)
if test "x$PKG_CONFIG_INSTALLED" = "xno"; then
AC_MSG_WARN([You need to install pkg-config])
fi
PKG_PROG_PKG_CONFIG([0.20])
dnl check for AX_CHECK_COMPILE_FLAG
m4_ifdef([AX_CHECK_COMPILE_FLAG], [], [
AC_MSG_ERROR([Please install autoconf-archive; re-run 'autoreconf -fi' for it to take effect.])
])
dnl checks for libraries
AC_SEARCH_LIBS([dlopen], [dl dld], [LIBRARY_DL="$LIBS";LIBS=""])
AC_SUBST(LIBRARY_DL)
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.6.4)
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.9.5)
PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.3.0)
PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl)
PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.7.0)
PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.9.5)
PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.2.0)
PKG_CHECK_MODULES(LIBOSMOGB, libosmogb >= 0.6.4)
PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 0.0.1)
@@ -47,7 +62,7 @@ fi
AM_CONDITIONAL(BUILD_BSC, test "x$osmo_ac_build_bsc" = "xyes")
AC_SUBST(osmo_ac_build_bsc)
# Enable/disable smpp support in the cscn?
# Enable/disable smpp support in the nitb?
AC_ARG_ENABLE([smpp], [AS_HELP_STRING([--enable-smpp], [Build the SMPP interface])],
[osmo_ac_build_smpp="$enableval"],[osmo_ac_build_smpp="no"])
if test "$osmo_ac_build_smpp" = "yes" ; then
@@ -130,6 +145,13 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
CFLAGS="$saved_CFLAGS"
AC_SUBST(SYMBOL_VISIBILITY)
AX_CHECK_COMPILE_FLAG([-Werror=implicit], [CFLAGS="$CFLAGS -Werror=implicit"])
AX_CHECK_COMPILE_FLAG([-Werror=maybe-uninitialized], [CFLAGS="$CFLAGS -Werror=maybe-uninitialized"])
AX_CHECK_COMPILE_FLAG([-Werror=memset-transposed-args], [CFLAGS="$CFLAGS -Werror=memset-transposed-args"])
AX_CHECK_COMPILE_FLAG([-Werror=null-dereference], [CFLAGS="$CFLAGS -Werror=null-dereference"])
AX_CHECK_COMPILE_FLAG([-Werror=sizeof-array-argument], [CFLAGS="$CFLAGS -Werror=sizeof-array-argument"])
AX_CHECK_COMPILE_FLAG([-Werror=sizeof-pointer-memaccess], [CFLAGS="$CFLAGS -Werror=sizeof-pointer-memaccess"])
# Coverage build taken from WebKit's configure.in
AC_MSG_CHECKING([whether to enable code coverage support])
AC_ARG_ENABLE(coverage,
@@ -189,6 +211,18 @@ AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
AC_MSG_RESULT([$enable_ext_tests])
AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
# Enable/disable ussd_proxy utility
AC_ARG_ENABLE([ussd_proxy], [AS_HELP_STRING([--enable-ussd-proxy], [Build the USSD MAP SUP to SIP proxy])],
[osmo_ac_build_ussd_proxy="$enableval"],[osmo_ac_build_ussd_proxy="no"])
if test "$osmo_ac_build_ussd_proxy" = "yes" ; then
PKG_CHECK_MODULES(LIBSOFIA_SIP_UA, sofia-sip-ua >= 1.10)
AC_DEFINE(BUILD_USSD_PROXY, 1, [Define if we want to build ussd_proxy])
fi
AM_CONDITIONAL(BUILD_USSD_PROXY, test "x$osmo_ac_build_ussd_proxy" = "xyes")
AC_SUBST(osmo_ac_build_smpp)
dnl Generate the output
AM_CONFIG_HEADER(bscconfig.h)
@@ -204,17 +238,18 @@ AC_OUTPUT(
src/libcommon/Makefile
src/libfilter/Makefile
src/libiu/Makefile
src/libxsc/Makefile
src/osmo-cscn/Makefile
src/libcommon-cs/Makefile
src/osmo-nitb/Makefile
src/osmo-bsc/Makefile
src/osmo-bsc_nat/Makefile
src/osmo-bsc_mgcp/Makefile
src/ipaccess/Makefile
src/utils/Makefile
src/gprs/Makefile
src/reg-proxy/Makefile
src/ussd-proxy/Makefile
tests/Makefile
tests/atlocal
tests/libiudummy/Makefile
tests/gsm0408/Makefile
tests/db/Makefile
tests/channel/Makefile
@@ -236,6 +271,8 @@ AC_OUTPUT(
tests/sndcp_xid/Makefile
tests/slhc/Makefile
tests/v42bis/Makefile
tests/nanobts_omlattr/Makefile
tests/ussd/Makefile
doc/Makefile
doc/examples/Makefile
Makefile)

View File

@@ -1,75 +1,54 @@
#!/usr/bin/python
# -*- mode: python-mode; py-indent-tabs-mode: nil -*-
import sys,os, random
from optparse import OptionParser
from ipa import Ctrl
import socket
import struct
verbose = False
def prefix_ipa_ctrl_header(data):
return struct.pack(">HBB", len(data)+1, 0xee, 0) + data
def ipa_ctrl_header(header):
(plen, ipa_proto, osmo_proto) = struct.unpack(">HBB", header)
return None if (ipa_proto != 0xee or osmo_proto != 0) else plen
def remove_ipa_ctrl_header(data):
if (len(data) < 4):
raise BaseException("Answer too short!")
plen = ipa_ctrl_header(data[:4])
if (None == plen):
raise BaseException("Wrong protocol in answer!")
if (plen + 3 > len(data)):
print "Warning: Wrong payload length (expected %i, got %i)" % (plen, len(data) - 3)
return data[4:plen+3], data[plen+3:]
def connect(host, port):
if verbose:
print "Connecting to host %s:%i" % (host, port)
if verbose:
print "Connecting to host %s:%i" % (host, port)
sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sck.setblocking(1)
sck.connect((host, port))
return sck
def send(sck, data):
if verbose:
print "Sending \"%s\"" %(data)
data = prefix_ipa_ctrl_header(data)
sck.send(data)
def do_set(var, value, op_id, sck):
setmsg = "SET %s %s %s" %(op_id, var, value)
send(sck, setmsg)
def do_get(var, op_id, sck):
getmsg = "GET %s %s" %(op_id, var)
send(sck, getmsg)
sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sck.setblocking(1)
sck.connect((host, port))
return sck
def do_set_get(sck, var, value = None):
r = random.randint(1, sys.maxint)
if (value != None):
s = 'SET_REPLY'
do_set(var, value, r, sck)
else:
s = 'GET_REPLY'
do_get(var, r, sck)
(answer, data) = remove_ipa_ctrl_header(sck.recv(4096))
x = answer.split()
if (s == x[0] and str(r) == x[1] and var == x[2]):
return None if ('SET_REPLY' == s and value != x[3]) else x[3]
return None
(r, c) = Ctrl().cmd(var, value)
sck.send(c)
answer = Ctrl().rem_header(sck.recv(4096))
return (answer,) + Ctrl().verify(answer, r, var, value)
def set_var(sck, var, val):
return do_set_get(sck, var, val)
(a, _, _) = do_set_get(sck, var, val)
return a
def get_var(sck, var):
return do_set_get(sck, var)
(_, _, v) = do_set_get(sck, var)
return v
def _leftovers(sck, fl):
"""
Read outstanding data if any according to flags
"""
try:
data = sck.recv(1024, fl)
except socket.error as (s_errno, strerror):
return False
if len(data) != 0:
tail = data
while True:
(head, tail) = Ctrl().split_combined(tail)
print "Got message:", Ctrl().rem_header(head)
if len(tail) == 0:
break
return True
return False
if __name__ == '__main__':
random.seed()
parser = OptionParser("Usage: %prog [options] var [value]")
parser.add_option("-d", "--host", dest="host",
help="connect to HOST", metavar="HOST")
@@ -79,8 +58,6 @@ if __name__ == '__main__':
dest="cmd_get", help="perform GET operation")
parser.add_option("-s", "--set", action="store_true",
dest="cmd_set", help="perform SET operation")
parser.add_option("-i", "--id", dest="op_id", default=random.randint(1, sys.maxint),
help="set id manually", metavar="ID")
parser.add_option("-v", "--verbose", action="store_true",
dest="verbose", help="be verbose", default=False)
parser.add_option("-m", "--monitor", action="store_true",
@@ -91,40 +68,32 @@ if __name__ == '__main__':
verbose = options.verbose
if options.cmd_set and options.cmd_get:
parser.error("Get and set options are mutually exclusive!")
parser.error("Get and set options are mutually exclusive!")
if not (options.cmd_get or options.cmd_set or options.monitor):
parser.error("One of -m, -g, or -s must be set")
parser.error("One of -m, -g, or -s must be set")
if not (options.host):
parser.error("Destination host and port required!")
parser.error("Destination host and port required!")
sock = connect(options.host, options.port)
if options.cmd_set:
if len(args) < 2:
parser.error("Set requires var and value arguments")
do_set(args[0], ' '.join(args[1:]), options.op_id, sock)
if len(args) < 2:
parser.error("Set requires var and value arguments")
_leftovers(sock, socket.MSG_DONTWAIT)
print "Got message:", set_var(sock, args[0], ' '.join(args[1:]))
if options.cmd_get:
if len(args) != 1:
parser.error("Get requires the var argument")
do_get(args[0], options.op_id, sock)
data = sock.recv(1024)
while (len(data)>0):
(answer, data) = remove_ipa_ctrl_header(data)
print "Got message:", answer
if len(args) != 1:
parser.error("Get requires the var argument")
_leftovers(sock, socket.MSG_DONTWAIT)
(a, _, _) = do_set_get(sock, args[0])
print "Got message:", a
if options.monitor:
while (True):
data = sock.recv(1024)
if len(data) == 0:
print "Connection is gone."
break
while (len(data)>0):
(answer, data) = remove_ipa_ctrl_header(data)
print "Got message:", answer
while True:
if not _leftovers(sock, 0):
print "Connection is gone."
break
sock.close()

278
openbsc/contrib/ipa.py Executable file
View File

@@ -0,0 +1,278 @@
#!/usr/bin/python3
# -*- mode: python-mode; py-indent-tabs-mode: nil -*-
"""
/*
* Copyright (C) 2016 sysmocom s.f.m.c. GmbH
*
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
"""
import struct, random, sys
class IPA(object):
"""
Stateless IPA protocol multiplexer: add/remove/parse (extended) header
"""
version = "0.0.5"
TCP_PORT_OML = 3002
TCP_PORT_RSL = 3003
# OpenBSC extensions: OSMO, MGCP_OLD
PROTO = dict(RSL=0x00, CCM=0xFE, SCCP=0xFD, OML=0xFF, OSMO=0xEE, MGCP_OLD=0xFC)
# ...OML Router Control, GSUP GPRS extension, Osmocom Authn Protocol
EXT = dict(CTRL=0, MGCP=1, LAC=2, SMSC=3, ORC=4, GSUP=5, OAP=6)
# OpenBSC extension: SCCP_OLD
MSGT = dict(PING=0x00, PONG=0x01, ID_GET=0x04, ID_RESP=0x05, ID_ACK=0x06, SCCP_OLD=0xFF)
_IDTAG = dict(SERNR=0, UNITNAME=1, LOCATION=2, TYPE=3, EQUIPVERS=4, SWVERSION=5, IPADDR=6, MACADDR=7, UNIT=8)
CTRL_GET = 'GET'
CTRL_SET = 'SET'
CTRL_REP = 'REPLY'
CTRL_ERR = 'ERR'
CTRL_TRAP = 'TRAP'
def _l(self, d, p):
"""
Reverse dictionary lookup: return key for a given value
"""
if p is None:
return 'UNKNOWN'
return list(d.keys())[list(d.values()).index(p)]
def _tag(self, t, v):
"""
Create TAG as TLV data
"""
return struct.pack(">HB", len(v) + 1, t) + v
def proto(self, p):
"""
Lookup protocol name
"""
return self._l(self.PROTO, p)
def ext(self, p):
"""
Lookup protocol extension name
"""
return self._l(self.EXT, p)
def msgt(self, p):
"""
Lookup message type name
"""
return self._l(self.MSGT, p)
def idtag(self, p):
"""
Lookup ID tag name
"""
return self._l(self._IDTAG, p)
def ext_name(self, proto, exten):
"""
Return proper extension byte name depending on the protocol used
"""
if self.PROTO['CCM'] == proto:
return self.msgt(exten)
if self.PROTO['OSMO'] == proto:
return self.ext(exten)
return None
def add_header(self, data, proto, ext=None):
"""
Add IPA header (with extension if necessary), data must be represented as bytes
"""
if ext is None:
return struct.pack(">HB", len(data) + 1, proto) + data
return struct.pack(">HBB", len(data) + 1, proto, ext) + data
def del_header(self, data):
"""
Strip IPA protocol header correctly removing extension if present
Returns data length, IPA protocol, extension (or None if not defined for a give protocol) and the data without header
"""
if not len(data):
return None, None, None, None
(dlen, proto) = struct.unpack('>HB', data[:3])
if self.PROTO['OSMO'] == proto or self.PROTO['CCM'] == proto: # there's extension which we have to unpack
return struct.unpack('>HBB', data[:4]) + (data[4:], ) # length, protocol, extension, data
return dlen, proto, None, data[3:] # length, protocol, _, data
def split_combined(self, data):
"""
Split the data which contains multiple concatenated IPA messages into tuple (first, rest) where rest contains remaining messages, first is the single IPA message
"""
(length, _, _, _) = self.del_header(data)
return data[:(length + 3)], data[(length + 3):]
def tag_serial(self, data):
"""
Make TAG for serial number
"""
return self._tag(self._IDTAG['SERNR'], data)
def tag_name(self, data):
"""
Make TAG for unit name
"""
return self._tag(self._IDTAG['UNITNAME'], data)
def tag_loc(self, data):
"""
Make TAG for location
"""
return self._tag(self._IDTAG['LOCATION'], data)
def tag_type(self, data):
"""
Make TAG for unit type
"""
return self._tag(self._IDTAG['TYPE'], data)
def tag_equip(self, data):
"""
Make TAG for equipment version
"""
return self._tag(self._IDTAG['EQUIPVERS'], data)
def tag_sw(self, data):
"""
Make TAG for software version
"""
return self._tag(self._IDTAG['SWVERSION'], data)
def tag_ip(self, data):
"""
Make TAG for IP address
"""
return self._tag(self._IDTAG['IPADDR'], data)
def tag_mac(self, data):
"""
Make TAG for MAC address
"""
return self._tag(self._IDTAG['MACADDR'], data)
def tag_unit(self, data):
"""
Make TAG for unit ID
"""
return self._tag(self._IDTAG['UNIT'], data)
def identity(self, unit=b'', mac=b'', location=b'', utype=b'', equip=b'', sw=b'', name=b'', serial=b''):
"""
Make IPA IDENTITY tag list, by default returns empty concatenated bytes of tag list
"""
return self.tag_unit(unit) + self.tag_mac(mac) + self.tag_loc(location) + self.tag_type(utype) + self.tag_equip(equip) + self.tag_sw(sw) + self.tag_name(name) + self.tag_serial(serial)
def ping(self):
"""
Make PING message
"""
return self.add_header(b'', self.PROTO['CCM'], self.MSGT['PING'])
def pong(self):
"""
Make PONG message
"""
return self.add_header(b'', self.PROTO['CCM'], self.MSGT['PONG'])
def id_ack(self):
"""
Make ID_ACK CCM message
"""
return self.add_header(b'', self.PROTO['CCM'], self.MSGT['ID_ACK'])
def id_get(self):
"""
Make ID_GET CCM message
"""
return self.add_header(self.identity(), self.PROTO['CCM'], self.MSGT['ID_GET'])
def id_resp(self, data):
"""
Make ID_RESP CCM message
"""
return self.add_header(data, self.PROTO['CCM'], self.MSGT['ID_RESP'])
class Ctrl(IPA):
"""
Osmocom CTRL protocol implemented on top of IPA multiplexer
"""
def __init__(self):
random.seed()
def add_header(self, data):
"""
Add CTRL header
"""
return super(Ctrl, self).add_header(data.encode('utf-8'), IPA.PROTO['OSMO'], IPA.EXT['CTRL'])
def rem_header(self, data):
"""
Remove CTRL header, check for appropriate protocol and extension
"""
(_, proto, ext, d) = super(Ctrl, self).del_header(data)
if self.PROTO['OSMO'] != proto or self.EXT['CTRL'] != ext:
return None
return d
def parse(self, data, op=None):
"""
Parse Ctrl string returning (var, value) pair
var could be None in case of ERROR message
value could be None in case of GET message
"""
(s, i, v) = data.split(' ', 2)
if s == self.CTRL_ERR:
return None, v
if s == self.CTRL_GET:
return v, None
(s, i, var, val) = data.split(' ', 3)
if s == self.CTRL_TRAP and i != '0':
return None, '%s with non-zero id %s' % (s, i)
if op is not None and i != op:
if s == self.CTRL_GET + '_' + self.CTRL_REP or s == self.CTRL_SET + '_' + self.CTRL_REP:
return None, '%s with unexpected id %s' % (s, i)
return var, val
def trap(self, var, val):
"""
Make TRAP message with given (vak, val) pair
"""
return self.add_header("%s 0 %s %s" % (self.CTRL_TRAP, var, val))
def cmd(self, var, val=None):
"""
Make SET/GET command message: returns (r, m) tuple where r is random operation id and m is assembled message
"""
r = random.randint(1, sys.maxsize)
if val is not None:
return r, self.add_header("%s %s %s %s" % (self.CTRL_SET, r, var, val))
return r, self.add_header("%s %s %s" % (self.CTRL_GET, r, var))
def verify(self, reply, r, var, val=None):
"""
Verify reply to SET/GET command: returns (b, v) tuple where v is True/False verification result and v is the variable value
"""
(k, v) = self.parse(reply)
if k != var or (val is not None and v != val):
return False, v
return True, v
if __name__ == '__main__':
print("IPA multiplexer v%s loaded." % IPA.version)

373
openbsc/contrib/twisted_ipa.py Executable file
View File

@@ -0,0 +1,373 @@
#!/usr/bin/python3
# -*- mode: python-mode; py-indent-tabs-mode: nil -*-
"""
/*
* Copyright (C) 2016 sysmocom s.f.m.c. GmbH
*
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
"""
from ipa import Ctrl, IPA
from twisted.internet.protocol import ReconnectingClientFactory
from twisted.internet import reactor
from twisted.protocols import basic
import argparse
class IPACommon(basic.Int16StringReceiver):
"""
Generic IPA protocol handler: include some routines for simpler subprotocols.
It's not intended as full implementation of all subprotocols, rather common ground and example code.
"""
def dbg(self, line):
"""
Debug print helper
"""
if self.factory.debug:
print(line)
def osmo_CTRL(self, data):
"""
OSMO CTRL protocol
Placeholder, see corresponding derived class
"""
pass
def osmo_MGCP(self, data):
"""
OSMO MGCP extension
"""
self.dbg('OSMO MGCP received %s' % data)
def osmo_LAC(self, data):
"""
OSMO LAC extension
"""
self.dbg('OSMO LAC received %s' % data)
def osmo_SMSC(self, data):
"""
OSMO SMSC extension
"""
self.dbg('OSMO SMSC received %s' % data)
def osmo_ORC(self, data):
"""
OSMO ORC extension
"""
self.dbg('OSMO ORC received %s' % data)
def osmo_GSUP(self, data):
"""
OSMO GSUP extension
"""
self.dbg('OSMO GSUP received %s' % data)
def osmo_OAP(self, data):
"""
OSMO OAP extension
"""
self.dbg('OSMO OAP received %s' % data)
def osmo_UNKNOWN(self, data):
"""
OSMO defaul extension handler
"""
self.dbg('OSMO unknown extension received %s' % data)
def handle_RSL(self, data, proto, extension):
"""
RSL protocol handler
"""
self.dbg('IPA RSL received message with extension %s' % extension)
def handle_CCM(self, data, proto, msgt):
"""
CCM (IPA Connection Management)
Placeholder, see corresponding derived class
"""
pass
def handle_SCCP(self, data, proto, extension):
"""
SCCP protocol handler
"""
self.dbg('IPA SCCP received message with extension %s' % extension)
def handle_OML(self, data, proto, extension):
"""
OML protocol handler
"""
self.dbg('IPA OML received message with extension %s' % extension)
def handle_OSMO(self, data, proto, extension):
"""
Dispatcher point for OSMO subprotocols based on extension name, lambda default should never happen
"""
method = getattr(self, 'osmo_' + IPA().ext(extension), lambda: "extension dispatch failure")
method(data)
def handle_MGCP(self, data, proto, extension):
"""
MGCP protocol handler
"""
self.dbg('IPA MGCP received message with attribute %s' % extension)
def handle_UNKNOWN(self, data, proto, extension):
"""
Default protocol handler
"""
self.dbg('IPA received message for %s (%s) protocol with attribute %s' % (IPA().proto(proto), proto, extension))
def process_chunk(self, data):
"""
Generic message dispatcher for IPA (sub)protocols based on protocol name, lambda default should never happen
"""
(_, proto, extension, content) = IPA().del_header(data)
if content is not None:
self.dbg('IPA received %s::%s [%d/%d] %s' % (IPA().proto(proto), IPA().ext_name(proto, extension), len(data), len(content), content))
method = getattr(self, 'handle_' + IPA().proto(proto), lambda: "protocol dispatch failure")
method(content, proto, extension)
def dataReceived(self, data):
"""
Override for dataReceived from Int16StringReceiver because of inherently incompatible interpretation of length
If default handler is used than we would always get off-by-1 error (Int16StringReceiver use equivalent of l + 2)
"""
if len(data):
(head, tail) = IPA().split_combined(data)
self.process_chunk(head)
self.dataReceived(tail)
def connectionMade(self):
"""
We have to resetDelay() here to drop internal state to default values to make reconnection logic work
Make sure to call this via super() if overriding to keep reconnection logic intact
"""
self.dbg('IPA connection made!')
self.factory.resetDelay()
class CCM(IPACommon):
"""
Implementation of CCM protocol for IPA multiplex
"""
def ack(self):
self.transport.write(IPA().id_ack())
def ping(self):
self.transport.write(IPA().ping())
def pong(self):
self.transport.write(IPA().pong())
def handle_CCM(self, data, proto, msgt):
"""
CCM (IPA Connection Management)
Only basic logic necessary for tests is implemented (ping-pong, id ack etc)
"""
if msgt == IPA.MSGT['ID_GET']:
self.transport.getHandle().sendall(IPA().id_resp(self.factory.ccm_id))
# if we call
# self.transport.write(IPA().id_resp(self.factory.test_id))
# instead, than we would have to also call
# reactor.callLater(1, self.ack)
# instead of self.ack()
# otherwise the writes will be glued together - hence the necessity for ugly hack with 1s timeout
# Note: this still might work depending on the IPA implementation details on the other side
self.ack()
# schedule PING in 4s
reactor.callLater(4, self.ping)
if msgt == IPA.MSGT['PING']:
self.pong()
class CTRL(IPACommon):
"""
Implementation of Osmocom control protocol for IPA multiplex
"""
def ctrl_SET(self, data, op_id, v):
"""
Handle CTRL SET command
"""
self.dbg('CTRL SET [%s] %s' % (op_id, v))
def ctrl_SET_REPLY(self, data, op_id, v):
"""
Handle CTRL SET reply
"""
self.dbg('CTRL SET REPLY [%s] %s' % (op_id, v))
def ctrl_GET(self, data, op_id, v):
"""
Handle CTRL GET command
"""
self.dbg('CTRL GET [%s] %s' % (op_id, v))
def ctrl_GET_REPLY(self, data, op_id, v):
"""
Handle CTRL GET reply
"""
self.dbg('CTRL GET REPLY [%s] %s' % (op_id, v))
def ctrl_TRAP(self, data, op_id, v):
"""
Handle CTRL TRAP command
"""
self.dbg('CTRL TRAP [%s] %s' % (op_id, v))
def ctrl_ERROR(self, data, op_id, v):
"""
Handle CTRL ERROR reply
"""
self.dbg('CTRL ERROR [%s] %s' % (op_id, v))
def osmo_CTRL(self, data):
"""
OSMO CTRL message dispatcher, lambda default should never happen
For basic tests only, appropriate handling routines should be replaced: see CtrlServer for example
"""
self.dbg('OSMO CTRL received %s::%s' % Ctrl().parse(data.decode('utf-8')))
(cmd, op_id, v) = data.decode('utf-8').split(' ', 2)
method = getattr(self, 'ctrl_' + cmd, lambda: "CTRL unknown command")
method(data, op_id, v)
class IPAServer(CCM):
"""
Test implementation of IPA server
Demonstrate CCM opearation by overriding necessary bits from CCM
"""
def connectionMade(self):
"""
Keep reconnection logic working by calling routine from CCM
Initiate CCM upon connection
"""
print('IPA server connection made!')
super(IPAServer, self).connectionMade()
self.transport.write(IPA().id_get())
class CtrlServer(CTRL):
"""
Test implementation of CTRL server
Demonstarte CTRL handling by overriding simpler routines from CTRL
"""
def connectionMade(self):
"""
Keep reconnection logic working by calling routine from CTRL
Send TRAP upon connection
Note: we can't use sendString() because of it's incompatibility with IPA interpretation of length prefix
"""
print('CTRL server connection made!')
super(CtrlServer, self).connectionMade()
self.transport.write(Ctrl().trap('LOL', 'what'))
self.transport.write(Ctrl().trap('rulez', 'XXX'))
def reply(self, r):
self.transport.write(Ctrl().add_header(r))
def ctrl_SET(self, data, op_id, v):
"""
CTRL SET command: always succeed
"""
print('SET [%s] %s' % (op_id, v))
self.reply('SET_REPLY %s %s' % (op_id, v))
def ctrl_GET(self, data, op_id, v):
"""
CTRL GET command: always fail
"""
print('GET [%s] %s' % (op_id, v))
self.reply('ERROR %s No variable found' % op_id)
class IPAFactory(ReconnectingClientFactory):
"""
Generic IPA Client Factory which can be used to store state for various subprotocols and manage connections
Note: so far we do not really need separate Factory for acting as a server due to protocol simplicity
"""
protocol = IPACommon
debug = False
ccm_id = IPA().identity(unit=b'1515/0/1', mac=b'b0:0b:fa:ce:de:ad:be:ef', utype=b'sysmoBTS', name=b'StingRay', location=b'hell', sw=IPA.version.encode('utf-8'))
def __init__(self, proto=None, debug=False, ccm_id=None):
if proto:
self.protocol = proto
if debug:
self.debug = debug
if ccm_id:
self.ccm_id = ccm_id
def clientConnectionFailed(self, connector, reason):
"""
Only necessary for as debugging aid - if we can somehow set parent's class noisy attribute then we can omit this method
"""
if self.debug:
print('IPAFactory connection failed:', reason.getErrorMessage())
ReconnectingClientFactory.clientConnectionFailed(self, connector, reason)
def clientConnectionLost(self, connector, reason):
"""
Only necessary for as debugging aid - if we can somehow set parent's class noisy attribute then we can omit this method
"""
if self.debug:
print('IPAFactory connection lost:', reason.getErrorMessage())
ReconnectingClientFactory.clientConnectionLost(self, connector, reason)
if __name__ == '__main__':
p = argparse.ArgumentParser("Twisted IPA (module v%s) app" % IPA.version)
p.add_argument('-v', '--version', action='version', version='%(prog)s v0.3')
p.add_argument('-p', '--port', type=int, default=4250, help="Port to use for CTRL interface")
p.add_argument('-d', '--host', default='localhost', help="Adress to use for CTRL interface")
cs = p.add_mutually_exclusive_group()
cs.add_argument("-c", "--client", action='store_true', help="asume client role")
cs.add_argument("-s", "--server", action='store_true', help="asume server role")
ic = p.add_mutually_exclusive_group()
ic.add_argument("--ipa", action='store_true', help="use IPA protocol")
ic.add_argument("--ctrl", action='store_true', help="use CTRL protocol")
args = p.parse_args()
test = False
if args.ctrl:
if args.client:
# Start osmo-bsc to receive TRAP messages when osmo-bts-* connects to it
print('CTRL client, connecting to %s:%d' % (args.host, args.port))
reactor.connectTCP(args.host, args.port, IPAFactory(CTRL, debug=True))
test = True
if args.server:
# Use bsc_control.py to issue set/get commands
print('CTRL server, listening on port %d' % args.port)
reactor.listenTCP(args.port, IPAFactory(CtrlServer, debug=True))
test = True
if args.ipa:
if args.client:
# Start osmo-nitb which would initiate A-bis/IP session
print('IPA client, connecting to %s ports %d and %d' % (args.host, IPA.TCP_PORT_OML, IPA.TCP_PORT_RSL))
reactor.connectTCP(args.host, IPA.TCP_PORT_OML, IPAFactory(CCM, debug=True))
reactor.connectTCP(args.host, IPA.TCP_PORT_RSL, IPAFactory(CCM, debug=True))
test = True
if args.server:
# Start osmo-bts-* which would attempt to connect to us
print('IPA server, listening on ports %d and %d' % (IPA.TCP_PORT_OML, IPA.TCP_PORT_RSL))
reactor.listenTCP(IPA.TCP_PORT_RSL, IPAFactory(IPAServer, debug=True))
reactor.listenTCP(IPA.TCP_PORT_OML, IPAFactory(IPAServer, debug=True))
test = True
if test:
reactor.run()
else:
print("Please specify which protocol in which role you'd like to test.")

View File

@@ -1,36 +0,0 @@
!
! OsmoCSCN configuration saved from vty
!
line vty
no login
!
network
network country code 1
mobile network code 1
short name OsmoCSCN
long name OsmoCSCN
auth policy closed
location updating reject cause 13
encryption a5 0
rrlp mode none
mm info 1
handover 0
handover window rxlev averaging 10
handover window rxqual averaging 1
handover window rxlev neighbor averaging 10
handover power budget interval 6
handover power budget hysteresis 3
handover maximum distance 9999
timer t3101 10
timer t3103 0
timer t3105 0
timer t3107 0
timer t3109 4
timer t3111 0
timer t3113 60
timer t3115 0
timer t3117 0
timer t3119 0
timer t3141 0
cscn
subscriber-create-on-demand

View File

@@ -11,7 +11,10 @@ noinst_HEADERS = \
bsc_nat_sccp.h \
bsc_rll.h \
bss.h \
bts_ipaccess_nanobts_omlattr.h \
chan_alloc.h \
common_bsc.h \
common_cs.h \
crc24.h \
ctrl.h \
db.h \
@@ -20,7 +23,6 @@ noinst_HEADERS = \
gb_proxy.h \
gprs_gb_parse.h \
gprs_gmm.h \
gprs_gsup_client.h \
gprs_llc.h \
gprs_llc_xid.h \
gprs_sgsn.h \
@@ -36,26 +38,23 @@ noinst_HEADERS = \
gsm_data.h \
gsm_data_shared.h \
gsm_subscriber.h \
gsup_client.h \
gtphub.h \
handover.h \
handover_decision.h \
ipaccess.h \
iu.h \
iucs.h \
meas_feed.h \
meas_rep.h \
mgcp.h \
mgcp_internal.h \
mgcp_transcode.h \
mgcpgw_client.h \
misdn.h \
mncc.h \
mncc_int.h \
msc_ifaces.h \
nat_rewrite_trie.h \
network_listen.h \
oap.h \
oap_messages.h \
oap_client.h \
openbscdefines.h \
osmo_bsc.h \
osmo_bsc_grace.h \
@@ -84,7 +83,6 @@ noinst_HEADERS = \
vty.h \
v42bis.h \
v42bis_private.h \
xsc.h \
$(NULL)
openbsc_HEADERS = \

View File

@@ -26,6 +26,8 @@
#include <osmocom/gsm/abis_nm.h>
#include <osmocom/gsm/protocol/gsm_12_21.h>
#include <openbsc/gsm_data.h>
struct cell_global_id {
uint16_t mcc;
uint16_t mnc;

View File

@@ -41,13 +41,6 @@ enum om2k_mo_state {
OM2K_MO_S_DISABLED,
};
struct abis_om2k_mo {
uint8_t class;
uint8_t bts;
uint8_t assoc_so;
uint8_t inst;
} __attribute__ ((packed));
/* on-wire format for IS conn group */
struct om2k_is_conn_grp {
uint16_t icp1;
@@ -63,6 +56,39 @@ struct is_conn_group {
uint8_t ci;
};
/* on-wire format for CON Path */
struct om2k_con_path {
uint16_t ccp;
uint8_t ci;
uint8_t tag;
uint8_t tei;
} __attribute__ ((packed));
/* internal data format for CON group */
struct con_group {
/* links list of CON groups in BTS */
struct llist_head list;
struct gsm_bts *bts;
/* CON Group ID */
uint8_t cg;
/* list of CON paths in this group */
struct llist_head paths;
};
/* internal data format for CON path */
struct con_path {
/* links with con_group.paths */
struct llist_head list;
/* CON Connection Point */
uint16_t ccp;
/* Contiguity Index */
uint8_t ci;
/* Tag */
uint8_t tag;
/* TEI */
uint8_t tei;
};
extern const struct abis_om2k_mo om2k_mo_cf;
extern const struct abis_om2k_mo om2k_mo_is;
extern const struct abis_om2k_mo om2k_mo_con;
@@ -84,12 +110,17 @@ int abis_om2k_tx_disable_req(struct gsm_bts *bts, const struct abis_om2k_mo *mo)
int abis_om2k_tx_test_req(struct gsm_bts *bts, const struct abis_om2k_mo *mo);
int abis_om2k_tx_op_info(struct gsm_bts *bts, const struct abis_om2k_mo *mo,
uint8_t operational);
int abis_om2k_tx_cap_req(struct gsm_bts *bts, const struct abis_om2k_mo *mo);
int abis_om2k_tx_is_conf_req(struct gsm_bts *bts);
int abis_om2k_tx_tf_conf_req(struct gsm_bts *bts);
int abis_om2k_tx_rx_conf_req(struct gsm_bts_trx *trx);
int abis_om2k_tx_tx_conf_req(struct gsm_bts_trx *trx);
int abis_om2k_tx_ts_conf_req(struct gsm_bts_trx_ts *ts);
struct osmo_fsm_inst *om2k_bts_fsm_start(struct gsm_bts *bts);
void abis_om2k_bts_init(struct gsm_bts *bts);
void abis_om2k_trx_init(struct gsm_bts_trx *trx);
int abis_om2k_vty_init(void);
struct vty;

View File

@@ -3,7 +3,7 @@
#include <stdint.h>
enum {
enum gsm48_range {
ARFCN_RANGE_INVALID = -1,
ARFCN_RANGE_128 = 127,
ARFCN_RANGE_256 = 255,
@@ -14,8 +14,8 @@ enum {
#define RANGE_ENC_MAX_ARFCNS 29
int range_enc_determine_range(const int *arfcns, int size, int *f0_out);
int range_enc_arfcns(const int rng, const int *arfcns, int sze, int *out, int idx);
int range_enc_find_index(const int rng, const int *arfcns, int size);
int range_enc_arfcns(enum gsm48_range rng, const int *arfcns, int sze, int *out, int idx);
int range_enc_find_index(enum gsm48_range rng, const int *arfcns, int size);
int range_enc_filter_arfcns(int *arfcns, const int sze, const int f0, int *f0_included);
int range_enc_range128(uint8_t *chan_list, int f0, int *w);

View File

@@ -2,6 +2,7 @@
#define _AUTH_H
#include <osmocom/core/utils.h>
#include <openbsc/gsm_data.h>
struct gsm_auth_tuple;
struct gsm_subscriber;
@@ -20,7 +21,8 @@ static inline const char *auth_action_str(enum auth_action a)
return get_value_string(auth_action_names, a);
}
int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple,
int auth_get_tuple_for_subscr(enum gsm_auth_policy auth_policy,
struct gsm_auth_tuple *atuple,
struct gsm_subscriber *subscr, int key_seq);
#endif /* _AUTH_H */

View File

@@ -1,10 +1,10 @@
/* Media Gateway Control Protocol Media Gateway: RFC 3435 */
/* Implementations useful both for the MGCP GW as well as MGCP GW clients */
/* OML attribute table generator for ipaccess nanobts */
/*
* (C) 2016 by sysmocom s.m.f.c. GmbH <info@sysmocom.de>
/* (C) 2016 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* Author: Philipp Maier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
@@ -17,16 +17,16 @@
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <osmocom/core/utils.h>
#include <openbsc/mgcp.h>
#pragma once
const struct value_string mgcp_connection_mode_strs[] = {
{ MGCP_CONN_NONE, "none" },
{ MGCP_CONN_RECV_SEND, "sendrecv" },
{ MGCP_CONN_SEND_ONLY, "sendonly" },
{ MGCP_CONN_RECV_ONLY, "recvonly" },
{ MGCP_CONN_LOOPBACK, "loopback" },
};
#include <stdint.h>
#include <osmocom/core/msgb.h>
struct msgb *nanobts_attr_bts_get(struct gsm_bts *bts);
struct msgb *nanobts_attr_nse_get(struct gsm_bts *bts);
struct msgb *nanobts_attr_cell_get(struct gsm_bts *bts);
struct msgb *nanobts_attr_nscv_get(struct gsm_bts *bts);
struct msgb *nanobts_attr_radio_get(struct gsm_bts *bts,
struct gsm_bts_trx *trx);

View File

@@ -0,0 +1,9 @@
#pragma once
#include <stdint.h>
#include <openbsc/common_cs.h>
struct gsm_network *bsc_network_init(void *ctx,
uint16_t country_code,
uint16_t network_code,
mncc_recv_cb_t mncc_recv);

View File

@@ -22,6 +22,6 @@ struct gsm_network *gsm_network_init(void *ctx,
uint16_t network_code,
mncc_recv_cb_t mncc_recv);
int xsc_vty_init(struct gsm_network *network,
int common_cs_vty_init(struct gsm_network *network,
int (* config_write_net )(struct vty *));
struct gsm_network *gsmnet_from_vty(struct vty *v);

View File

@@ -38,7 +38,8 @@ enum {
DRANAP,
DSUA,
DV42BIS,
DIUCS,
DSUP,
DSS,
Debug_LastEntry,
};

View File

@@ -208,7 +208,7 @@ struct gbproxy_link_info *gbproxy_update_link_state_ul(
struct gbproxy_link_info *gbproxy_update_link_state_dl(
struct gbproxy_peer *peer, time_t now,
struct gprs_gb_parse_context *parse_ctx);
void gbproxy_update_link_state_after(
int gbproxy_update_link_state_after(
struct gbproxy_peer *peer, struct gbproxy_link_info *link_info,
time_t now, struct gprs_gb_parse_context *parse_ctx);
int gbproxy_remove_stale_link_infos(struct gbproxy_peer *peer, time_t now);

View File

@@ -46,6 +46,8 @@ enum gprs_llc_xid_type {
GPRS_LLC_XID_T_RESET = 12,
};
extern const struct value_string gprs_llc_xid_type_names[];
/* TS 04.64 Section 7.1.2 Table 7: LLC layer primitives (GMM/SNDCP/SMS/TOM) */
/* TS 04.65 Section 5.1.2 Table 2: Service primitives used by SNDCP */
enum gprs_llc_primitive {
@@ -270,7 +272,7 @@ void gprs_llme_copy_key(struct sgsn_mm_ctx *mm, struct gprs_llc_llme *llme);
/* parse a GPRS LLC header, also check for invalid frames */
int gprs_llc_hdr_parse(struct gprs_llc_hdr_parsed *ghp,
uint8_t *llc_hdr, int len);
void gprs_llc_hdr_dump(struct gprs_llc_hdr_parsed *gph);
void gprs_llc_hdr_dump(struct gprs_llc_hdr_parsed *gph, struct gprs_llc_lle *lle);
int gprs_llc_fcs(uint8_t *data, unsigned int len);

View File

@@ -36,9 +36,9 @@ enum gprs_pmm_state {
PMM_DETACHED,
PMM_CONNECTED,
PMM_IDLE,
MM_IDLE = PMM_DETACHED,
MM_READY = PMM_CONNECTED,
MM_STANDBY = PMM_IDLE,
MM_IDLE,
MM_READY,
MM_STANDBY,
};
enum gprs_mm_ctr {
@@ -126,7 +126,7 @@ struct sgsn_mm_ctx {
enum sgsn_ran_type ran_type;
char imsi[GSM23003_IMSI_MAX_DIGITS+1];
enum gprs_gmm_state mm_state;
enum gprs_gmm_state gmm_state;
enum gprs_pmm_state pmm_state; /* Iu: page when in PMM-IDLE mode */
uint32_t p_tmsi;
uint32_t p_tmsi_old; /* old P-TMSI before new is confirmed */
@@ -244,7 +244,7 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_by_tlli_and_ptmsi(uint32_t tlli,
const struct gprs_ra_id *raid);
/* Allocate a new SGSN MM context */
struct sgsn_mm_ctx *sgsn_mm_ctx_alloc(uint32_t tlli,
struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_gb(uint32_t tlli,
const struct gprs_ra_id *raid);
struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_iu(void *uectx);
@@ -295,12 +295,7 @@ struct sgsn_pdp_ctx {
//uint32_t qos_profile_req;
//uint32_t qos_profile_neg;
uint8_t radio_prio;
uint32_t tx_npdu_nr;
uint32_t rx_npdu_nr;
uint32_t tx_gtp_snd;
uint32_t rx_gtp_snu;
//uint32_t charging_id;
int reordering_reqd;
struct osmo_timer_list timer;
unsigned int T; /* Txxxx number */

View File

@@ -24,7 +24,7 @@
#include <stdint.h>
#include <osmocom/core/linuxlist.h>
#define CURRENT_SNDCP_VERSION 0 /* See 3GPP TS 44.065, clause 8 */
#define DEFAULT_SNDCP_VERSION 0 /* See 3GPP TS 44.065, clause 8 */
#define MAX_ENTITIES 32 /* 3GPP TS 44.065 reserves 5 bit
* for compression enitity number */
@@ -197,13 +197,15 @@ enum gprs_sndcp_dcomp_v44_dcomp {
/* Transform a list with compression fields into an SNDCP-XID message (dst) */
int gprs_sndcp_compile_xid(uint8_t *dst, unsigned int dst_maxlen,
const struct llist_head *comp_fields);
const struct llist_head *comp_fields, int version);
/* Transform an SNDCP-XID message (src) into a list of SNDCP-XID fields */
struct llist_head *gprs_sndcp_parse_xid(const void *ctx,
const uint8_t * src,
unsigned int src_len,
const struct llist_head *comp_fields_req);
struct llist_head *gprs_sndcp_parse_xid(int *version,
const void *ctx,
const uint8_t *src,
unsigned int src_len,
const struct llist_head
*comp_fields_req);
/* Find out to which compression class the specified comp-field belongs
* (header compression or data compression?) */

View File

@@ -53,7 +53,8 @@ int get_reason_by_chreq(uint8_t ra, int neci);
void gsm_net_update_ctype(struct gsm_network *net);
int gsm48_tx_mm_info(struct gsm_subscriber_connection *conn);
int gsm48_tx_mm_auth_req(struct gsm_subscriber_connection *conn, uint8_t *rand, int key_seq);
int gsm48_tx_mm_auth_req(struct gsm_subscriber_connection *conn, uint8_t *rand,
uint8_t *autn, int key_seq);
int gsm48_tx_mm_auth_rej(struct gsm_subscriber_connection *conn);
int gsm48_tx_mm_serv_ack(struct gsm_subscriber_connection *conn);
int gsm48_tx_mm_serv_rej(struct gsm_subscriber_connection *conn,
@@ -77,8 +78,6 @@ int decode_bcd_number(char *output, int output_len, const uint8_t *bcd_lv,
int send_siemens_mrpci(struct gsm_lchan *lchan, uint8_t *classmark2_lv);
int gsm48_extract_mi(uint8_t *classmark2, int length, char *mi_string, uint8_t *mi_type);
int gsm48_paging_extract_mi(struct gsm48_pag_resp *pag, int length, char *mi_string, uint8_t *mi_type);
/* TODO MSCSPLIT remove gsm48_handle_paging_resp() */
int gsm48_handle_paging_resp(struct gsm_subscriber_connection *conn, struct msgb *msg, struct gsm_subscriber *subscr);
int gsm48_lchan_modify(struct gsm_lchan *lchan, uint8_t lchan_mode);
@@ -95,4 +94,8 @@ void allocate_security_operation(struct gsm_subscriber_connection *conn);
int gsm48_multirate_config(uint8_t *lv, struct amr_multirate_conf *mr, struct amr_mode *modes);
int gsm0408_authorize(struct gsm_subscriber_connection *conn, struct msgb *msg);
int gsm0408_loc_upd_rej(struct gsm_subscriber_connection *conn, uint8_t cause);
void release_loc_updating_req(struct gsm_subscriber_connection *conn, int release);
#endif

View File

@@ -38,5 +38,8 @@ int gsm411_send_sms(struct gsm_subscriber_connection *conn,
struct gsm_sms *sms);
void gsm411_sapi_n_reject(struct gsm_subscriber_connection *conn);
int gsm411_send_rp_msg_subscr(struct gsm_subscriber *subscr,
struct msgb *rp);
uint8_t sms_next_rp_msg_ref(uint8_t *next_rp_ref);
#endif

View File

@@ -7,23 +7,24 @@
struct gsm_subscriber_connection;
int gsm0480_send_ussd_response(struct gsm_subscriber_connection *conn,
const struct msgb *in_msg, const char* response_text,
const struct ussd_request *req);
int gsm0480_send_component(struct gsm_subscriber_connection *conn,
struct msgb *msg,
struct ss_header* reqhdr);
int gsm0480_send_ussd_reject(struct gsm_subscriber_connection *conn,
const struct msgb *msg,
const struct ussd_request *request);
uint8_t invoke_id,
uint8_t transaction_id);
struct msgb *gsm0480_gen_ussdNotify(int level, const char *text);
struct msgb *gsm0480_gen_releaseComplete(void);
struct msgb *gsm0480_compose_ussd_component(struct ss_request* req);
int msc_gsm0480_send_ussdNotify(struct gsm_subscriber_connection *conn,
int level, const char *text);
int msc_gsm0480_send_releaseComplete(struct gsm_subscriber_connection *conn);
/* TODO: move to a bsc_*.h file? */
int bsc_gsm0480_send_ussdNotify(struct gsm_subscriber_connection *conn,
int level, const char *text);
int bsc_gsm0480_send_releaseComplete(struct gsm_subscriber_connection *conn);
int msc_send_ussd_notify(struct gsm_subscriber_connection *conn, int level,
const char *text);
int msc_send_ussd_release_complete(struct gsm_subscriber_connection *conn);
int bsc_send_ussd_notify(struct gsm_subscriber_connection *conn, int level,
const char *text);
int bsc_send_ussd_release_complete(struct gsm_subscriber_connection *conn);
#endif

View File

@@ -14,8 +14,8 @@
#include <osmocom/crypt/auth.h>
#include <openbsc/rest_octets.h>
#include <openbsc/xsc.h>
#include <openbsc/mgcpgw_client.h>
#include <openbsc/common_cs.h>
#include <openbsc/gsup_client.h>
/** annotations for msgb ownership */
#define __uses
@@ -24,7 +24,6 @@
struct mncc_sock_state;
struct gsm_subscriber_group;
struct ue_conn_ctx;
#define OBSC_LINKID_CB(__msgb) (__msgb)->cb[3]
@@ -72,6 +71,7 @@ struct gsm_loc_updating_operation {
struct osmo_timer_list updating_timer;
unsigned int waiting_for_imsi : 1;
unsigned int waiting_for_imei : 1;
unsigned int waiting_for_remote_accept : 1;
unsigned int key_seq : 4;
};
@@ -106,18 +106,6 @@ struct neigh_meas_proc {
uint8_t last_seen_nr;
};
enum interface_type {
IFACE_UNKNOWN = -1,
IFACE_A = 0, /* A-interface for 2G */
IFACE_IU = 1 /* Iu-interface for UMTS aka 3G (IuCS or IuPS) */
};
enum integrity_protection_state {
INTEGRITY_PROTECTION_NONE = 0,
INTEGRITY_PROTECTION_IK = 1,
INTEGRITY_PROTECTION_IK_CK = 2,
};
/* active radio connection of a mobile subscriber */
struct gsm_subscriber_connection {
struct llist_head entry;
@@ -160,21 +148,6 @@ struct gsm_subscriber_connection {
struct osmo_timer_list T10; /* BSC */
struct gsm_lchan *secondary_lchan; /* BSC */
uint16_t lac;
struct gsm_encr encr;
/* 2G or 3G? See enum interface_type */
int via_iface;
/* which Iu-CS connection, if any. */
struct {
struct ue_conn_ctx *ue_ctx;
int integrity_protection;
unsigned int mgcp_rtp_endpoint;
uint16_t mgcp_rtp_port_ue;
uint16_t mgcp_rtp_port_cn;
uint8_t rab_id;
} iu;
};
@@ -198,6 +171,11 @@ enum {
BSC_CTR_CHAN_RLL_ERR,
BSC_CTR_BTS_OML_FAIL,
BSC_CTR_BTS_RSL_FAIL,
BSC_CTR_CODEC_AMR_F,
BSC_CTR_CODEC_AMR_H,
BSC_CTR_CODEC_EFR,
BSC_CTR_CODEC_V1_FR,
BSC_CTR_CODEC_V1_HR,
};
static const struct rate_ctr_desc bsc_ctr_description[] = {
@@ -216,6 +194,11 @@ static const struct rate_ctr_desc bsc_ctr_description[] = {
[BSC_CTR_CHAN_RLL_ERR] = {"chan.rll_err", "Received a RLL failure with T200 cause from BTS."},
[BSC_CTR_BTS_OML_FAIL] = {"bts.oml_fail", "Received a TEI down on a OML link."},
[BSC_CTR_BTS_RSL_FAIL] = {"bts.rsl_fail", "Received a TEI down on a OML link."},
[BSC_CTR_CODEC_AMR_F] = {"bts.codec_amr_f", "Count the usage of AMR/F codec by channel mode requested."},
[BSC_CTR_CODEC_AMR_H] = {"bts.codec_amr_h", "Count the usage of AMR/H codec by channel mode requested."},
[BSC_CTR_CODEC_EFR] = {"bts.codec_efr", "Count the usage of EFR codec by channel mode requested."},
[BSC_CTR_CODEC_V1_FR] = {"bts.codec_fr", "Count the usage of FR codec by channel mode requested."},
[BSC_CTR_CODEC_V1_HR] = {"bts.codec_hr", "Count the usage of HR codec by channel mode requested."},
};
enum {
@@ -223,8 +206,8 @@ enum {
MSC_CTR_LOC_UPDATE_TYPE_NORMAL,
MSC_CTR_LOC_UPDATE_TYPE_PERIODIC,
MSC_CTR_LOC_UPDATE_TYPE_DETACH,
MSC_CTR_LOC_UPDATE_FAILED,
MSC_CTR_LOC_UPDATE_COMPLETED,
MSC_CTR_LOC_UPDATE_RESP_REJECT,
MSC_CTR_LOC_UPDATE_RESP_ACCEPT,
MSC_CTR_SMS_SUBMITTED,
MSC_CTR_SMS_NO_RECEIVER,
MSC_CTR_SMS_DELIVERED,
@@ -235,6 +218,9 @@ enum {
MSC_CTR_CALL_MO_CONNECT_ACK,
MSC_CTR_CALL_MT_SETUP,
MSC_CTR_CALL_MT_CONNECT,
MSC_CTR_CALL_ACTIVE,
MSC_CTR_CALL_COMPLETE,
MSC_CTR_CALL_INCOMPLETE,
};
static const struct rate_ctr_desc msc_ctr_description[] = {
@@ -242,8 +228,8 @@ static const struct rate_ctr_desc msc_ctr_description[] = {
[MSC_CTR_LOC_UPDATE_TYPE_NORMAL] = {"loc_update_type.normal", "Received location update normal requests."},
[MSC_CTR_LOC_UPDATE_TYPE_PERIODIC] = {"loc_update_type.periodic", "Received location update periodic requests."},
[MSC_CTR_LOC_UPDATE_TYPE_DETACH] = {"loc_update_type.detach", "Received location update detach indication."},
[MSC_CTR_LOC_UPDATE_FAILED] = {"loc_update_resp.failed", "Rejected location updates."},
[MSC_CTR_LOC_UPDATE_COMPLETED] = {"loc_update_resp.completed", "Successful location updates."},
[MSC_CTR_LOC_UPDATE_RESP_REJECT] = {"loc_update_resp.reject", "Sent location update reject responses."},
[MSC_CTR_LOC_UPDATE_RESP_ACCEPT] = {"loc_update_resp.accept", "Sent location update accept responses."},
[MSC_CTR_SMS_SUBMITTED] = {"sms.submitted", "Received a RPDU from a MS (MO)."},
[MSC_CTR_SMS_NO_RECEIVER] = {"sms.no_receiver", "Counts SMS which couldn't routed because no receiver found."},
[MSC_CTR_SMS_DELIVERED] = {"sms.delivered", "Global SMS Deliver attempts."},
@@ -255,6 +241,9 @@ static const struct rate_ctr_desc msc_ctr_description[] = {
[MSC_CTR_CALL_MO_CONNECT_ACK] = {"call.mo_connect_ack", "Received a connect ack from MS of a MO call. Call is now succesful connected up."},
[MSC_CTR_CALL_MT_SETUP] = {"call.mt_setup", "Sent setup requests to the MS (MT)."},
[MSC_CTR_CALL_MT_CONNECT] = {"call.mt_connect", "Sent a connect to the MS (MT)."},
[MSC_CTR_CALL_ACTIVE] = {"call.active", "Count total amount of calls that ever reached active state."},
[MSC_CTR_CALL_COMPLETE] = {"call.complete", "Count total amount of calls which got terminated by disconnect req or ind after reaching active state."},
[MSC_CTR_CALL_INCOMPLETE] = {"call.incomplete", "Count total amount of call which got terminated by any other reason after reaching active state."},
};
@@ -279,6 +268,8 @@ enum gsm_auth_policy {
GSM_AUTH_POLICY_ACCEPT_ALL, /* accept everyone, even if not authorized in DB */
GSM_AUTH_POLICY_TOKEN, /* accept first, send token per sms, then revoke authorization */
GSM_AUTH_POLICY_REGEXP, /* accept IMSIs matching given regexp */
GSM_AUTH_POLICY_REMOTE,
GSM_AUTH_POLICY_REMOTE_CLOSED
};
#define GSM_T3101_DEFAULT 10
@@ -294,12 +285,6 @@ struct gsm_tz {
};
struct gsm_network {
/* TODO MSCSPLIT the gsm_network struct is basically a kitchen sink for
* global settings and variables, "madly" mixing BSC and MSC stuff. Split
* this in e.g. struct osmo_bsc and struct osmo_msc, with the things
* these have in common, like country and network code, put in yet
* separate structs and placed as members in osmo_bsc and osmo_msc. */
/* global parameters */
uint16_t country_code;
uint16_t network_code;
@@ -331,7 +316,7 @@ struct gsm_network {
struct rate_ctr_group *bsc_ctrs;
struct rate_ctr_group *msc_ctrs;
struct osmo_counter *active_calls;
/* layer 4 */
struct mncc_sock_state *mncc_state;
@@ -339,6 +324,9 @@ struct gsm_network {
struct llist_head upqueue;
struct llist_head trans_list;
struct bsc_api *bsc_api;
struct gsup_client *hlr_sup_client;
struct gsup_client *ussd_sup_client;
struct gsup_client *sms_client;
unsigned int num_bts;
struct llist_head bts_list;
@@ -400,14 +388,6 @@ struct gsm_network {
* BTS|RNC specific timezone overrides for multi-tz networks in
* OsmoCSCN, this should be tied to the location area code (LAC). */
struct gsm_tz tz;
/* Periodic location update default value */
uint8_t t3212;
struct {
struct mgcpgw_client_conf conf;
struct mgcpgw_client *client;
} mgcpgw;
};
struct osmo_esme;
@@ -458,6 +438,10 @@ extern void talloc_ctx_init(void *ctx_root);
int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type);
/* Get reference to a neighbor cell on a given BCCH ARFCN */
struct gsm_bts *gsm_bts_neighbor(const struct gsm_bts *bts,
uint16_t arfcn, uint8_t bsic);
enum gsm_bts_type parse_btstype(const char *arg);
const char *btstype2str(enum gsm_bts_type type);
struct gsm_bts *gsm_bts_by_lac(struct gsm_network *net, unsigned int lac,
@@ -540,6 +524,7 @@ int bts_gprs_mode_is_compat(struct gsm_bts *bts, enum bts_gprs_mode mode);
int gsm48_ra_id_by_bts(uint8_t *buf, struct gsm_bts *bts);
void gprs_ra_id_by_bts(struct gprs_ra_id *raid, struct gsm_bts *bts);
struct gsm_meas_rep *lchan_next_meas_rep(struct gsm_lchan *lchan);
int gsm_btsmodel_set_feature(struct gsm_bts_model *model, enum gsm_bts_features feat);
int gsm_bts_model_register(struct gsm_bts_model *model);

View File

@@ -24,7 +24,7 @@
#include <osmocom/gsm/lapdm.h>
#endif
#include <openbsc/xsc.h>
#include <openbsc/common_cs.h>
struct osmo_bsc_data;
@@ -48,6 +48,10 @@ enum gsm_chreq_reason_t {
GSM_CHREQ_REASON_OTHER,
};
/* lchans 0..3 are SDCCH in combined channel configuration,
use 4 as magic number for BCCH hack - see osmo-bts-../oml.c:opstart_compl() */
#define CCCH_LCHAN 4
#define TRX_NR_TS 8
#define TS_MAX_LCHAN 8
@@ -102,6 +106,19 @@ struct gsm_abis_mo {
struct gsm_bts *bts;
};
/* Ericsson OM2000 Managed Object */
struct abis_om2k_mo {
uint8_t class;
uint8_t bts;
uint8_t assoc_so;
uint8_t inst;
} __attribute__ ((packed));
struct om2k_mo {
struct abis_om2k_mo addr;
struct osmo_fsm_inst *fsm;
};
#define A38_XOR_MIN_KEY_LEN 12
#define A38_XOR_MAX_KEY_LEN 16
#define A38_COMP128_KEY_LEN 16
@@ -292,18 +309,23 @@ struct gsm_lchan {
struct {
struct amr_multirate_conf amr_mr;
struct {
uint8_t buf[16];
struct osmo_fsm_inst *dl_amr_fsm;
/* TCH cache */
uint8_t cache[20];
/* FACCH cache */
uint8_t facch[GSM_MACBLOCK_LEN];
uint8_t len;
uint32_t fn;
bool is_update;
} last_sid;
/* set for each SID frame to detect talkspurt for codecs without
explicit ONSET event */
bool ul_sid;
/* set for each SID frame to detect talkspurt for codecs
without explicit ONSET event */
bool ul_sid;
/* indicates if DTXd was active during DL measurement
period */
bool dl_active;
} dtx;
uint8_t last_cmr;
uint32_t last_fn;
/* indicates if DTXd was active during DL measurement period */
bool dtxd_active;
} tch;
/* BTS-side ciphering state (rx only, bi-directional, ...) */
uint8_t ciph_state;
@@ -328,6 +350,8 @@ struct gsm_lchan {
uint8_t current;
uint8_t fixed;
} ms_power_ctrl;
struct msgb *pending_rel_ind_msg;
#endif
};
@@ -375,6 +399,12 @@ struct gsm_bts_trx_ts {
/* To which E1 subslot are we connected */
struct gsm_e1_subslot e1_link;
union {
struct {
struct om2k_mo om2k_mo;
} rbs2000;
};
struct gsm_lchan lchan[TS_MAX_LCHAN];
};
@@ -429,6 +459,17 @@ struct gsm_bts_trx {
uint8_t test_nr;
struct rxlev_stats rxlev_stat;
} ipaccess;
struct {
struct {
struct om2k_mo om2k_mo;
} trxc;
struct {
struct om2k_mo om2k_mo;
} rx;
struct {
struct om2k_mo om2k_mo;
} tx;
} rbs2000;
};
struct gsm_bts_trx_ts ts[TRX_NR_TS];
};
@@ -659,17 +700,26 @@ struct gsm_bts {
} bs11;
struct {
struct {
struct om2k_mo om2k_mo;
struct gsm_abis_mo mo;
struct llist_head conn_groups;
} cf;
struct {
struct om2k_mo om2k_mo;
struct gsm_abis_mo mo;
struct llist_head conn_groups;
} is;
struct {
struct om2k_mo om2k_mo;
struct gsm_abis_mo mo;
struct llist_head conn_groups;
} con;
struct {
struct om2k_mo om2k_mo;
struct gsm_abis_mo mo;
} dp;
struct {
struct om2k_mo om2k_mo;
struct gsm_abis_mo mo;
} tf;
} rbs2000;
@@ -755,6 +805,7 @@ struct gsm_bts {
uint16_t scramble_list[MAX_EARFCN_LIST];
} data;
} si_common;
bool early_classmark_allowed;
/* do we use static (user-defined) system information messages? (bitmask) */
uint32_t si_mode_static;
@@ -843,6 +894,7 @@ static inline uint8_t gsm_ts_tsc(const struct gsm_bts_trx_ts *ts)
struct gsm_lchan *rsl_lchan_lookup(struct gsm_bts_trx *trx, uint8_t chan_nr,
int *rc);
enum gsm_phys_chan_config ts_pchan(struct gsm_bts_trx_ts *ts);
uint8_t ts_subslots(struct gsm_bts_trx_ts *ts);
bool ts_is_tch(struct gsm_bts_trx_ts *ts);

View File

@@ -71,7 +71,6 @@ struct gsm_subscriber {
/* pending requests */
int is_paging;
struct osmo_timer_list paging_timeout;
struct llist_head requests;
/* GPRS/SGSN related fields */
@@ -91,20 +90,6 @@ enum gsm_subscriber_update_reason {
GSM_SUBSCRIBER_UPDATE_EQUIPMENT,
};
/*
* Struct for pending channel requests. This is managed in the
* llist_head requests of each subscriber. The reference counting
* should work in such a way that a subscriber with a pending request
* remains in memory.
*/
struct subscr_request {
struct llist_head entry;
/* the callback data */
gsm_cbfn *cbfn;
void *param;
};
struct gsm_subscriber *subscr_get(struct gsm_subscriber *subscr);
struct gsm_subscriber *subscr_put(struct gsm_subscriber *subscr);
struct gsm_subscriber *subscr_create_subscriber(struct gsm_subscriber_group *sgrp,
@@ -119,7 +104,7 @@ struct gsm_subscriber *subscr_get_by_id(struct gsm_subscriber_group *sgrp,
unsigned long long id);
struct gsm_subscriber *subscr_get_or_create(struct gsm_subscriber_group *sgrp,
const char *imsi);
int subscr_update(struct gsm_subscriber *s, uint16_t lac, int reason);
int subscr_update(struct gsm_subscriber *s, struct gsm_bts *bts, int reason);
struct gsm_subscriber *subscr_active_by_tmsi(struct gsm_subscriber_group *sgrp,
uint32_t tmsi);
struct gsm_subscriber *subscr_active_by_imsi(struct gsm_subscriber_group *sgrp,
@@ -130,19 +115,14 @@ char *subscr_name(struct gsm_subscriber *subscr);
int subscr_purge_inactive(struct gsm_subscriber_group *sgrp);
void subscr_update_from_db(struct gsm_subscriber *subscr);
void subscr_expire(struct gsm_subscriber_group *sgrp);
int subscr_update_expire_lu(struct gsm_subscriber *subscr);
bool subscr_authorized_imsi(const struct gsm_network *net, const char *imsi);
bool subscr_authorized(struct gsm_subscriber *subsc);
int subscr_update_expire_lu(struct gsm_subscriber *subscr, struct gsm_bts *bts);
/*
* Paging handling with authentication
*/
struct subscr_request *subscr_request_conn(struct gsm_subscriber *subscr,
gsm_cbfn *cbfn, void *param);
struct subscr_request *subscr_request_channel(struct gsm_subscriber *subscr,
int type, gsm_cbfn *cbfn, void *param);
void subscr_remove_request(struct subscr_request *req);
int subscr_rx_paging_response(struct msgb *msg,
struct gsm_subscriber_connection *conn);
/* internal */
struct gsm_subscriber *subscr_alloc(void);

View File

@@ -0,0 +1,26 @@
#ifndef _GSM_SUP_H
#define _GSM_SUP_H
#include <openbsc/debug.h>
#include <openbsc/gsm_subscriber.h>
#include <osmocom/gsm/gsm0480.h>
#include <osmocom/gsm/protocol/gsm_04_11.h>
#define LOGGSUBSCRP(level, subscr, fmt, args...) \
LOGP(DSUP, level, "SUBSCR(%s) " fmt, \
(subscr) ? (subscr)->imsi : "---", \
## args)
/* Callback for both HLR/auth and USSD SUP sockets */
int sup_read_cb(struct gsup_client *sup_client, struct msgb *msg);
/*
int subscr_query_auth_info(struct gsm_subscriber *subscr);
*/
int subscr_location_update(struct gsm_subscriber *subscr);
int subscr_purge_ms(struct gsm_subscriber *subscr);
int subscr_tx_sms_message(struct gsm_subscriber *subscr,
struct gsm411_rp_hdr *rph);
#endif /* _GSM_SUP_H */

View File

@@ -0,0 +1,14 @@
#ifndef _GSM_USSD_MAP_H
#define _GSM_USSD_MAP_H
#include <openbsc/gsup_client.h>
#include <openbsc/gsm_subscriber.h>
#include <openbsc/gsm_ussd_map_proto.h>
int ussd_map_read_cb(struct gsup_client *sup_client,
struct msgb *msg);
int ussd_map_tx_message(struct gsm_network *net, struct ss_header *req,
const char *extension, uint32_t ref, const uint8_t *component_data);
#endif /* _GSM_USSD_MAP_H */

View File

@@ -0,0 +1,25 @@
#ifndef _GSM_USSD_MAP_PROTO_H
#define _GSM_USSD_MAP_PROTO_H
#include <osmocom/gsm/gsm0480.h>
enum {
FMAP_MSISDN = 0x80
};
int subscr_uss_message(struct msgb *msg,
struct ss_header *req,
const char* extension,
uint32_t ref,
const uint8_t *component_data);
int rx_uss_message_parse(const uint8_t* data,
size_t len,
struct ss_header *ss,
uint32_t *ref,
char* extention,
size_t extention_len);
#endif /* _GSM_USSD_MAP_PROTO_H */

View File

@@ -23,37 +23,39 @@
#include <osmocom/core/timer.h>
#include <openbsc/oap.h>
#include <openbsc/oap_client.h>
#define GPRS_GSUP_RECONNECT_INTERVAL 10
#define GPRS_GSUP_PING_INTERVAL 20
#define GSUP_CLIENT_RECONNECT_INTERVAL 10
#define GSUP_CLIENT_PING_INTERVAL 20
struct msgb;
struct ipa_client_conn;
struct gprs_gsup_client;
struct gsup_client;
/* Expects message in msg->l2h */
typedef int (*gprs_gsup_read_cb_t)(struct gprs_gsup_client *gsupc, struct msgb *msg);
typedef int (*gsup_client_read_cb_t)(struct gsup_client *gsupc,
struct msgb *msg);
struct gprs_gsup_client {
struct ipa_client_conn *link;
gprs_gsup_read_cb_t read_cb;
void *data;
struct gsup_client {
struct ipa_client_conn *link;
gsup_client_read_cb_t read_cb;
void *data;
struct oap_state oap_state;
struct oap_client_state oap_state;
struct osmo_timer_list ping_timer;
struct osmo_timer_list connect_timer;
int is_connected;
int got_ipa_pong;
struct osmo_timer_list ping_timer;
struct osmo_timer_list connect_timer;
int is_connected;
int got_ipa_pong;
struct gsm_network *net;
};
struct gprs_gsup_client *gprs_gsup_client_create(const char *ip_addr,
unsigned int tcp_port,
gprs_gsup_read_cb_t read_cb,
struct oap_config *oap_config);
struct gsup_client *gsup_client_create(const char *ip_addr,
unsigned int tcp_port,
gsup_client_read_cb_t read_cb,
struct oap_client_config *oap_config);
void gprs_gsup_client_destroy(struct gprs_gsup_client *gsupc);
int gprs_gsup_client_send(struct gprs_gsup_client *gsupc, struct msgb *msg);
struct msgb *gprs_gsup_msgb_alloc(void);
void gsup_client_destroy(struct gsup_client *gsupc);
int gsup_client_send(struct gsup_client *gsupc, struct msgb *msg);
struct msgb *gsup_client_msgb_alloc(void);

View File

@@ -58,6 +58,5 @@ int iu_rab_act(struct ue_conn_ctx *ue_ctx, struct msgb *msg);
int iu_rab_deact(struct ue_conn_ctx *ue_ctx, uint8_t rab_id);
int iu_tx_sec_mode_cmd(struct ue_conn_ctx *uectx, struct gsm_auth_tuple *tp,
int send_ck, int new_key);
int iu_tx_common_id(struct ue_conn_ctx *ue_ctx, const char *imsi);
void iu_vty_init(int *asn_debug_p);

View File

@@ -1,7 +0,0 @@
#pragma once
int gsm0408_rcvmsg_iucs(struct gsm_network *network, struct msgb *msg,
uint16_t *lac);
struct gsm_subscriber_connection *subscr_conn_lookup_iu(struct gsm_network *network,
struct ue_conn_ctx *ue);

View File

@@ -170,21 +170,6 @@ enum mgcp_role {
MGCP_BSC_NAT,
};
enum mgcp_connection_mode {
MGCP_CONN_NONE = 0,
MGCP_CONN_RECV_ONLY = 1,
MGCP_CONN_SEND_ONLY = 2,
MGCP_CONN_RECV_SEND = MGCP_CONN_RECV_ONLY | MGCP_CONN_SEND_ONLY,
MGCP_CONN_LOOPBACK = 4 | MGCP_CONN_RECV_SEND,
};
extern const struct value_string mgcp_connection_mode_strs[];
static inline const char *mgcp_cmode_name(enum mgcp_connection_mode mode)
{
return get_value_string(mgcp_connection_mode_strs, mode);
}
struct mgcp_config {
int source_port;
char *local_ip;

View File

@@ -28,6 +28,14 @@
#define CI_UNUSED 0
enum mgcp_connection_mode {
MGCP_CONN_NONE = 0,
MGCP_CONN_RECV_ONLY = 1,
MGCP_CONN_SEND_ONLY = 2,
MGCP_CONN_RECV_SEND = MGCP_CONN_RECV_ONLY | MGCP_CONN_SEND_ONLY,
MGCP_CONN_LOOPBACK = 4 | MGCP_CONN_RECV_SEND,
};
enum mgcp_trunk_type {
MGCP_TRUNK_VIRTUAL,
MGCP_TRUNK_E1,

View File

@@ -1,47 +0,0 @@
#pragma once
#include <stdint.h>
enum mgcp_connection_mode;
struct msgb;
struct mgcpgw_client;
#define MGCPGW_CLIENT_LOCAL_ADDR_DEFAULT "0.0.0.0"
#define MGCPGW_CLIENT_LOCAL_PORT_DEFAULT 0
#define MGCPGW_CLIENT_REMOTE_ADDR_DEFAULT "127.0.0.1"
#define MGCPGW_CLIENT_REMOTE_PORT_DEFAULT 2427
typedef void (* mgcp_rx_cb_t )(struct msgb *msg, void *priv);
struct mgcpgw_client_conf {
const char *local_addr;
int local_port;
const char *remote_addr;
int remote_port;
};
void mgcpgw_client_conf_init(struct mgcpgw_client_conf *conf);
struct mgcpgw_client *mgcpgw_client_init(void *ctx,
struct mgcpgw_client_conf *conf,
mgcp_rx_cb_t rx_cb, void *rx_cb_priv);
const char *mgcpgw_client_remote_addr_str(struct mgcpgw_client *mgcp);
uint16_t mgcpgw_client_remote_port(struct mgcpgw_client *mgcp);
uint32_t mgcpgw_client_remote_addr_n(struct mgcpgw_client *mgcp);
unsigned int mgcpgw_client_next_endpoint(struct mgcpgw_client *client);
int mgcpgw_client_tx_crcx(struct mgcpgw_client *client,
uint16_t rtp_endpoint, unsigned int call_id,
enum mgcp_connection_mode mode);
int mgcpgw_client_tx_mdcx(struct mgcpgw_client *client, uint16_t rtp_endpoint,
const char *rtp_conn_addr, uint16_t rtp_port,
enum mgcp_connection_mode mode);
int mgcpgw_client_tx_str(struct mgcpgw_client *mgcp, const char *fmt, ...);
int mgcpgw_client_tx_buf(struct mgcpgw_client *mgcp, const char *buf, int len);
int mgcpgw_client_tx(struct mgcpgw_client *mgcp, struct msgb *msg);
void mgcpgw_client_vty_init(int node, struct mgcpgw_client_conf *conf);
int mgcpgw_client_config_write(struct vty *vty, const char *indent);

View File

@@ -1,51 +0,0 @@
#pragma once
#include <osmocom/core/msgb.h>
#include <openbsc/gsm_data.h>
/* These are the interfaces of the MSC layer towards (from?) the BSC and RNC,
* i.e. in the direction towards the mobile device (MS aka UE).
*
* 2G will use the A-interface,
* 3G aka UMTS will use the Iu-interface (for the MSC, it's IuCS).
*
* To allow linking parts of the MSC code without having to include entire
* infrastructures of external libraries, the core transmitting and receiving
* functions are left unimplemented. For example, a unit test does not need to
* link against external ASN1 libraries if it is never going to encode actual
* outgoing messages. It is up to each building scope to implement real world
* functions or to plug mere dummy implementations.
*
* For example, msc_tx_dtap(conn, msg), depending on conn->via_iface, will call
* either iu_tx() or a_tx() [note: at time of writing, the A-interface is not
* yet implemented]. When you try to link against libmsc, you will find that
* the compiler complains about an undefined reference to iu_tx(). If you,
* however, link against libiu as well as the osmo-iuh libs (etc.), iu_tx() is
* available. A unit test may instead simply implement a dummy iu_tx() function
* and not link against osmo-iuh.
*/
/* Each main linkage must implement this function (see comment above). */
extern int iu_tx(struct msgb *msg, uint8_t sapi);
/* So far this is a dummy implemented in libmsc/a_iface.c. When A-interface
* gets implemented, it should be in a separate lib (like libiu), this function
* should move there, and the following comment should remain here: "
* Each main linkage must implement this function (see comment above).
* " */
extern int a_tx(struct msgb *msg);
int msc_tx_dtap(struct gsm_subscriber_connection *conn,
struct msgb *msg);
int msc_gsm48_tx_mm_serv_ack(struct gsm_subscriber_connection *conn);
int msc_gsm48_tx_mm_serv_rej(struct gsm_subscriber_connection *conn,
enum gsm48_reject_value value);
/* TODO: specific to A interface, move this away */
int msc_gsm0808_tx_cipher_mode(struct gsm_subscriber_connection *conn, int cipher,
const uint8_t *key, int len, int include_imeisv);
int msc_tx_common_id(struct gsm_subscriber_connection *conn);
int msc_call_assignment(struct gsm_trans *trans);
int msc_call_bridge(struct gsm_trans *trans1, struct gsm_trans *trans2);

View File

@@ -27,9 +27,10 @@
struct msgb;
struct osmo_oap_message;
/* This is the config part for vty. It is essentially copied in oap_state,
* where values are copied over once the config is considered valid. */
struct oap_config {
/* This is the config part for vty. It is essentially copied in
* oap_client_state, where values are copied over once the config is
* considered valid. */
struct oap_client_config {
uint16_t client_id;
int secret_k_present;
uint8_t secret_k[16];
@@ -38,9 +39,10 @@ struct oap_config {
};
/* The runtime state of the OAP client. client_id and the secrets are in fact
* duplicated from oap_config, so that a separate validation of the config data
* is possible, and so that only a struct oap_state* is passed around. */
struct oap_state {
* duplicated from oap_client_config, so that a separate validation of the
* config data is possible, and so that only a struct oap_client_state* is
* passed around. */
struct oap_client_state {
enum {
OAP_UNINITIALIZED = 0, /* just allocated. */
OAP_DISABLED, /* disabled by config. */
@@ -56,23 +58,25 @@ struct oap_state {
};
/* From config, initialize state. Return 0 on success. */
int oap_init(struct oap_config *config, struct oap_state *state);
int oap_client_init(struct oap_client_config *config,
struct oap_client_state *state);
/* Construct an OAP registration message and return in *msg_tx. Use
* state->client_id and update state->state.
* Return 0 on success, or a negative value on error.
* If an error is returned, *msg_tx is guaranteed to be NULL. */
int oap_register(struct oap_state *state, struct msgb **msg_tx);
int oap_client_register(struct oap_client_state *state, struct msgb **msg_tx);
/* Decode and act on a received OAP message msg_rx. Update state->state. If a
* non-NULL pointer is returned in *msg_tx, that msgb should be sent to the OAP
* server (and freed) by the caller. The received msg_rx is not freed.
* Return 0 on success, or a negative value on error.
* If an error is returned, *msg_tx is guaranteed to be NULL. */
int oap_handle(struct oap_state *state, const struct msgb *msg_rx, struct msgb **msg_tx);
/* Allocate a msgb and in it, return the encoded oap_msg. Return NULL on
* error. (Like oap_encode(), but also allocates a msgb.)
* About the name: the idea is do_something(oap_encoded(my_struct)) */
struct msgb *oap_encoded(const struct osmo_oap_message *oap_msg);
int oap_client_handle(struct oap_client_state *state,
const struct msgb *msg_rx, struct msgb **msg_tx);
/* Allocate a msgb and in it, return the encoded oap_client_msg. Return
* NULL on error. (Like oap_client_encode(), but also allocates a msgb.)
* About the name: the idea is do_something(oap_client_encoded(my_struct))
*/
struct msgb *oap_client_encoded(const struct osmo_oap_message *oap_client_msg);

View File

@@ -1,70 +0,0 @@
/* Osmocom Authentication Protocol message encoder/decoder */
/* (C) 2015 by Sysmocom s.f.m.c. GmbH
* All Rights Reserved
*
* Author: Neels Hofmeyr
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <stdint.h>
#include <osmocom/core/msgb.h>
#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
/* Some numbers are out of sequence because (so far) they match gprs_gsup_iei.
*/
enum oap_iei {
OAP_CAUSE_IE = 0x02,
OAP_RAND_IE = 0x20,
OAP_AUTN_IE = 0x23,
OAP_XRES_IE = 0x24,
OAP_AUTS_IE = 0x25,
OAP_CLIENT_ID_IE = 0x30,
};
enum osmo_oap_message_type {
OAP_MSGT_REGISTER_REQUEST = 0b00000100,
OAP_MSGT_REGISTER_ERROR = 0b00000101,
OAP_MSGT_REGISTER_RESULT = 0b00000110,
OAP_MSGT_CHALLENGE_REQUEST = 0b00001000,
OAP_MSGT_CHALLENGE_ERROR = 0b00001001,
OAP_MSGT_CHALLENGE_RESULT = 0b00001010,
OAP_MSGT_SYNC_REQUEST = 0b00001100,
OAP_MSGT_SYNC_ERROR = 0b00001101,
OAP_MSGT_SYNC_RESULT = 0b00001110,
};
struct osmo_oap_message {
enum osmo_oap_message_type message_type;
enum gsm48_gmm_cause cause;
uint16_t client_id;
int rand_present;
uint8_t rand[16];
int autn_present;
uint8_t autn[16];
int xres_present;
uint8_t xres[8];
int auts_present;
uint8_t auts[16];
};
int osmo_oap_decode(struct osmo_oap_message *oap_msg,
const uint8_t *data, size_t data_len);
void osmo_oap_encode(struct msgb *msg, const struct osmo_oap_message *oap_msg);

View File

@@ -46,11 +46,6 @@ struct osmo_bsc_sccp_con {
struct bsc_filter_state filter_state;
};
struct gsm_network *bsc_network_init(void *ctx,
uint16_t country_code,
uint16_t network_code,
mncc_recv_cb_t mncc_recv);
struct bsc_api *osmo_bsc_api();
int bsc_queue_for_msc(struct osmo_bsc_sccp_con *conn, struct msgb *msg);

View File

@@ -21,7 +21,7 @@
#ifndef OSMO_BSC_GRACE_H
#define OSMO_BSC_GRACE_H
#include "gsm_data.h"
#include <openbsc/gsm_data.h>
struct osmo_msc_data;

View File

@@ -5,15 +5,7 @@
#include "bsc_api.h"
enum {
MSC_CONN_ACCEPT = 0,
MSC_CONN_REJECT = 1,
};
struct bsc_api *msc_bsc_api();
int msc_compl_l3(struct gsm_subscriber_connection *conn, struct msgb *msg,
uint16_t chosen_channel);
void msc_release_connection(struct gsm_subscriber_connection *conn);
#endif

View File

@@ -24,10 +24,11 @@
#include <string.h>
#include <osmocom/core/linuxlist.h>
#include "gsm_data.h"
#include "gsm_subscriber.h"
#include <osmocom/core/timer.h>
#include <openbsc/gsm_data.h>
#include <openbsc/gsm_subscriber.h>
/**
* A pending paging request
*/

View File

@@ -0,0 +1,15 @@
#ifndef _REG_PROXY_H
#define _REG_PROXY_H
#include <openbsc/sup_server.h>
#include <openbsc/sip_client.h>
#include <osip2/osip.h>
void *tall_reg_ctx;
struct reg_proxy {
struct gsm_sup_server *sup_server;
struct sip_client *sip_client;
osip_t *osip;
};
#endif /* _REG_PROXY_H */

View File

@@ -6,7 +6,7 @@
#include <osmocom/crypt/gprs_cipher.h>
#include <osmocom/gprs/gprs_ns.h>
#include <openbsc/gprs_sgsn.h>
#include <openbsc/oap.h>
#include <openbsc/oap_client.h>
#include <ares.h>
@@ -92,7 +92,7 @@ struct sgsn_config {
int dynamic_lookup;
struct oap_config oap;
struct oap_client_config oap;
/* RFC1144 TCP/IP header compression */
struct {
@@ -123,7 +123,7 @@ struct sgsn_instance {
/* GSN instance for libgtp */
struct gsn_t *gsn;
/* Subscriber */
struct gprs_gsup_client *gsup_client;
struct gsup_client *gsup_client;
/* LLME inactivity timer */
struct osmo_timer_list llme_timer;

View File

@@ -0,0 +1,16 @@
#ifndef _SIP_H
#define _SIP_H
#include <openbsc/sip_client.h>
#include <openbsc/reg_proxy.h>
#include <osip2/osip.h>
#include <osmocom/gsm/gsm0480.h>
int tx_ss_handle(struct sip_client *sip_client, osip_t *osip, struct ss_request *ss,
const char *extention);
int tx_sip_register(struct sip_client *sip_client, osip_t *osip, char *imsi, int expires_time);
int sip_client_init(struct reg_proxy *reg, const char *src_ip, u_int16_t src_port,
const char *dst_ip, u_int16_t dst_port, int expires_time);
#endif /* _SIP_H */

View File

@@ -0,0 +1,36 @@
#pragma once
#include <osmocom/core/timer.h>
#define SIP_RECONNECT_INTERVAL 10
struct msgb;
struct ipa_client_conn;
struct sip_client;
/* Expects message in msg->l2h */
typedef int (*sip_read_cb_t)(struct sip_client *sip_client, struct msgb *msg);
struct sip_client {
struct tcp_client_conn *link;
sip_read_cb_t read_cb;
void *data;
struct osmo_timer_list connect_timer;
int is_connected;
char *src_ip;
char *dst_ip;
u_int16_t src_port;
u_int16_t dst_port;
int expires_time;
};
struct sip_client *sip_client_create(const char *src_ip, u_int16_t src_port,
const char *dst_ip, u_int16_t dst_port,
int expires_time, sip_read_cb_t read_cb,
void *data);
void sip_client_destroy(struct sip_client *sip_client);
int sip_client_send(struct sip_client *sip_client, struct msgb *msg);
struct msgb *sip_msgb_alloc(void);

View File

@@ -0,0 +1,19 @@
#ifndef _SUP_H
#define _SUP_H
#include <openbsc/reg_proxy.h>
#define LOGGSUPP(level, sup, fmt, args...) \
LOGP(DGPRS, level, "SUP(%s) " fmt, \
(sup)->imsi, \
## args)
int sup_server_init(struct reg_proxy *reg);
int handle_location_update_result(struct gsm_sup_server *sup_server,
char *imsi, char *msisdn);
int handle_purge_ms_result(struct gsm_sup_server *sup_server,
char *imsi);
#endif /* _SUP_H */

View File

@@ -0,0 +1,29 @@
#ifndef _SUP_SERVER_H
#define _SUP_SERVER_H
#include <osmocom/abis/ipa.h>
//struct msgb;
struct ipa_server_conn;
struct gsm_sup_server;
/* Expects message in msg->l2h */
typedef int (*sup_read_cb_t)(struct gsm_sup_server *sup_server, struct msgb *msg);
struct gsm_sup_server {
struct ipa_server_link *link;
sup_read_cb_t read_cb;
void *data;
struct osmo_fd fd;
struct ipa_server_conn *server_conn;
void *app;
};
struct gsm_sup_server *sup_server_create(const char *ip_addr,
unsigned int tcp_port,
sup_read_cb_t read_cb,
void *app);
int sup_server_send(struct gsm_sup_server *sup_server, struct msgb *msg);
#endif /* _SUP_SERVER_H */

View File

@@ -3,14 +3,17 @@
#include <osmocom/gsm/sysinfo.h>
#include <openbsc/arfcn_range_encode.h>
struct gsm_bts;
int gsm_generate_si(struct gsm_bts *bts, enum osmo_sysinfo_type type);
uint16_t encode_fdd(uint16_t scramble, bool diversity);
unsigned uarfcn_size(const uint16_t *u, const uint16_t *sc, size_t u_len);
unsigned earfcn_size(const struct osmo_earfcn_si2q *e);
unsigned range1024_p(unsigned n);
unsigned range512_q(unsigned m);
int range_encode(enum gsm48_range r, int *arfcns, int arfcns_used, int *w,
int f0, uint8_t *chan_list);
bool si2q_size_check(const struct gsm_bts *bts);
int bts_uarfcn_del(struct gsm_bts *bts, uint16_t arfcn, uint16_t scramble);
int bts_uarfcn_add(struct gsm_bts *bts, uint16_t arfcn, uint16_t scramble,

View File

@@ -0,0 +1,51 @@
#ifndef _TCP_CLIENT_H_
#define _TCP_CLIENT_H_
#include <stdint.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/select.h>
struct msgb;
enum tcp_client_conn_state {
TCP_CLIENT_LINK_STATE_NONE = 0,
TCP_CLIENT_LINK_STATE_CONNECTING = 1,
TCP_CLIENT_LINK_STATE_CONNECTED = 2,
TCP_CLIENT_LINK_STATE_MAX
};
struct tcp_client_conn {
struct osmo_fd *ofd;
struct llist_head tx_queue;
struct osmo_timer_list timer;
enum tcp_client_conn_state state;
const char *src_addr;
uint16_t src_port;
const char *dst_addr;
uint16_t dst_port;
void (*updown_cb)(struct tcp_client_conn *link, int up);
int (*read_cb)(struct tcp_client_conn *link, struct msgb *msg);
int (*write_cb)(struct tcp_client_conn *link);
void *data;
struct msgb *pending_msg;
};
struct tcp_client_conn *
tcp_client_conn_create(void *ctx, int priv_nr,
const char *dst_addr, uint16_t dst_port,
const char *src_addr, uint16_t src_port,
void (*updown)(struct tcp_client_conn *link, int),
int (*read_cb)(struct tcp_client_conn *link, struct msgb *msgb),
int (*write_cb)(struct tcp_client_conn *link),
void *data);
void tcp_client_conn_destroy(struct tcp_client_conn *link);
int tcp_client_conn_open(struct tcp_client_conn *link);
void tcp_client_conn_close(struct tcp_client_conn *link);
void tcp_client_conn_send(struct tcp_client_conn *link, struct msgb *msg);
size_t tcp_client_conn_clear_queue(struct tcp_client_conn *link);
#endif

View File

@@ -32,6 +32,11 @@ struct gsm_trans {
/* reference from MNCC or other application */
uint32_t callref;
/* SMS RP message reference */
uint8_t msg_ref;
/* handle SMS local */
uint8_t sms_local;
/* if traffic channel receive was requested */
int tch_recv;
@@ -56,6 +61,11 @@ struct gsm_trans {
struct gsm_sms *sms;
} sms;
struct {
uint8_t invoke_id;
uint8_t mo;
uint8_t dirty;
} ss;
};
};
@@ -65,6 +75,8 @@ struct gsm_trans *trans_find_by_id(struct gsm_subscriber_connection *conn,
uint8_t proto, uint8_t trans_id);
struct gsm_trans *trans_find_by_callref(struct gsm_network *net,
uint32_t callref);
struct gsm_trans *trans_find_by_msgref(struct gsm_subscriber_connection *conn,
uint8_t msg_ref);
struct gsm_trans *trans_alloc(struct gsm_network *net,
struct gsm_subscriber *subscr,

View File

@@ -5,6 +5,19 @@
#include <osmocom/core/msgb.h>
#define USSD_MO 1
#define USSD_MT 0
int handle_rcv_ussd(struct gsm_subscriber_connection *conn, struct msgb *msg);
int on_ussd_response(struct gsm_network *net,
uint32_t ref,
struct ss_header *reqhdr,
const uint8_t *component,
const char* extention);
void _ussd_trans_free(struct gsm_trans *trans);
#endif

View File

@@ -29,6 +29,7 @@ enum bsc_vty_node {
NAT_BSC_NODE,
MSC_NODE,
OM2K_NODE,
OM2K_CON_GROUP_NODE,
TRUNK_NODE,
PGROUP_NODE,
MNCC_INT_NODE,
@@ -37,7 +38,6 @@ enum bsc_vty_node {
SMPP_NODE,
SMPP_ESME_NODE,
GTPHUB_NODE,
CSCN_NODE,
};
extern int bsc_vty_is_config_node(struct vty *vty, int node);
@@ -47,8 +47,6 @@ struct log_info;
int bsc_vty_init(const struct log_info *cat, struct gsm_network *network);
int bsc_vty_init_extra(void);
void cscn_vty_init(struct gsm_network *cscn_network);
struct gsm_network *gsmnet_from_vty(struct vty *vty);
#endif

3
openbsc/m4/README Normal file
View File

@@ -0,0 +1,3 @@
We want to avoid creating too many external build-time dependencies
like this one to autoconf-archive. This directory provides a local
copy of required m4 rules.

View File

@@ -0,0 +1,74 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# Check whether the given FLAG works with the current language's compiler
# or gives an error. (Warnings, however, are ignored)
#
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
# success/failure.
#
# If EXTRA-FLAGS is defined, it is added to the current language's default
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 4
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CHECK_COMPILE_FLAGS

View File

@@ -27,7 +27,7 @@ SUBDIRS = \
libmsc \
libtrau \
libfilter \
libxsc \
libcommon-cs \
$(NULL)
# Conditional Libraries
@@ -39,11 +39,13 @@ endif
# Programs
SUBDIRS += \
osmo-cscn \
osmo-nitb \
osmo-bsc_mgcp \
utils \
ipaccess \
gprs \
reg-proxy \
ussd-proxy \
$(NULL)
# Conditional Programs

View File

@@ -87,12 +87,9 @@ osmo_sgsn_SOURCES = \
sgsn_auth.c \
gprs_subscriber.c \
gprs_utils.c \
gprs_gsup_client.c \
sgsn_cdr.c \
sgsn_ares.c \
slhc.c \
oap.c \
oap_messages.c \
gprs_llc_xid.c \
v42bis.c \
$(NULL)

View File

@@ -318,7 +318,7 @@ static void gbproxy_reset_imsi_acquisition(struct gbproxy_link_info* link_info)
link_info->vu_gen_tx_bss = GBPROXY_INIT_VU_GEN_TX;
}
static void gbproxy_flush_stored_messages(struct gbproxy_peer *peer,
static int gbproxy_flush_stored_messages(struct gbproxy_peer *peer,
struct msgb *msg,
time_t now,
struct gbproxy_link_info* link_info,
@@ -349,8 +349,13 @@ static void gbproxy_flush_stored_messages(struct gbproxy_peer *peer,
peer, link_info, &len_change,
&tmp_parse_ctx);
gbproxy_update_link_state_after(peer, link_info, now,
&tmp_parse_ctx);
rc = gbproxy_update_link_state_after(peer, link_info, now,
&tmp_parse_ctx);
if (rc == 1) {
LOGP(DLLC, LOGL_NOTICE, "link_info deleted while flushing stored messages\n");
msgb_free(stored_msg);
return -1;
}
rc = gbprox_relay2sgsn(peer->cfg, stored_msg,
msgb_bvci(msg), link_info->sgsn_nsei);
@@ -364,6 +369,8 @@ static void gbproxy_flush_stored_messages(struct gbproxy_peer *peer,
parse_ctx->llc_msg_name : "BSSGP");
msgb_free(stored_msg);
}
return 0;
}
static int gbproxy_gsm48_to_peer(struct gbproxy_peer *peer,
@@ -465,9 +472,12 @@ static int gbproxy_imsi_acquisition(struct gbproxy_peer *peer,
gsm48_hdr_pdisc(parse_ctx->g48_hdr) == GSM48_PDISC_MM_GPRS &&
gsm48_hdr_msg_type(parse_ctx->g48_hdr) == GSM48_MT_GMM_ID_RESP;
/* The IMSI is now available */
gbproxy_flush_stored_messages(peer, msg, now, link_info,
parse_ctx);
/* The IMSI is now available. If flushing the messages fails,
* then link_info has been deleted and we should return
* immediately. */
if (gbproxy_flush_stored_messages(peer, msg, now, link_info,
parse_ctx) < 0)
return 0;
gbproxy_reset_imsi_acquisition(link_info);

View File

@@ -189,8 +189,6 @@ static void handle_options(int argc, char **argv)
}
}
extern void *tall_msgb_ctx;
extern int bsc_vty_go_parent(struct vty *vty);
static struct vty_app_info vty_info = {
@@ -231,7 +229,7 @@ int main(int argc, char **argv)
int rc;
tall_bsc_ctx = talloc_named_const(NULL, 0, "nsip_proxy");
tall_msgb_ctx = talloc_named_const(tall_bsc_ctx, 0, "msgb");
msgb_talloc_ctx_init(tall_bsc_ctx, 0);
signal(SIGINT, &signal_handler);
signal(SIGABRT, &signal_handler);

View File

@@ -348,18 +348,18 @@ static void gbproxy_touch_link_info(struct gbproxy_peer *peer,
gbproxy_attach_link_info(peer, now, link_info);
}
static void gbproxy_unregister_link_info(struct gbproxy_peer *peer,
static int gbproxy_unregister_link_info(struct gbproxy_peer *peer,
struct gbproxy_link_info *link_info)
{
if (!link_info)
return;
return 1;
if (link_info->tlli.ptmsi == GSM_RESERVED_TMSI && !link_info->imsi_len) {
LOGP(DGPRS, LOGL_INFO,
"Removing TLLI %08x from list (P-TMSI or IMSI are not set)\n",
link_info->tlli.current);
gbproxy_delete_link_info(peer, link_info);
return;
return 1;
}
link_info->tlli.current = 0;
@@ -371,7 +371,7 @@ static void gbproxy_unregister_link_info(struct gbproxy_peer *peer,
gbproxy_reset_link(link_info);
return;
return 0;
}
int gbproxy_imsi_matches(struct gbproxy_config *cfg,
@@ -668,12 +668,13 @@ struct gbproxy_link_info *gbproxy_update_link_state_dl(
return link_info;
}
void gbproxy_update_link_state_after(
int gbproxy_update_link_state_after(
struct gbproxy_peer *peer,
struct gbproxy_link_info *link_info,
time_t now,
struct gprs_gb_parse_context *parse_ctx)
{
int rc = 0;
if (parse_ctx->invalidate_tlli && link_info) {
int keep_info =
peer->cfg->keep_link_infos == GBPROX_KEEP_ALWAYS ||
@@ -684,11 +685,12 @@ void gbproxy_update_link_state_after(
if (keep_info) {
LOGP(DGPRS, LOGL_INFO, "Unregistering TLLI %08x\n",
link_info->tlli.current);
gbproxy_unregister_link_info(peer, link_info);
rc = gbproxy_unregister_link_info(peer, link_info);
} else {
LOGP(DGPRS, LOGL_INFO, "Removing TLLI %08x from list\n",
link_info->tlli.current);
gbproxy_delete_link_info(peer, link_info);
rc = 1;
}
} else if (parse_ctx->to_bss && parse_ctx->tlli_enc &&
parse_ctx->new_ptmsi_enc && link_info) {
@@ -714,6 +716,8 @@ void gbproxy_update_link_state_after(
}
gbproxy_remove_stale_link_infos(peer, now);
return rc;
}

View File

@@ -398,7 +398,7 @@ int gprs_gb_parse_llc(uint8_t *llc, size_t llc_len,
/* parse LLC */
rc = gprs_llc_hdr_parse(ghp, llc, llc_len);
gprs_llc_hdr_dump(ghp);
gprs_llc_hdr_dump(ghp, NULL);
if (rc != 0) {
LOGP(DLLC, LOGL_NOTICE, "Error during LLC header parsing\n");
return 0;

View File

@@ -42,6 +42,7 @@
#include <osmocom/core/signal.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/rate_ctr.h>
#include <osmocom/core/utils.h>
#include <osmocom/crypt/auth.h>
#include <osmocom/gsm/apn.h>
#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
@@ -65,10 +66,7 @@
#include <openbsc/gprs_utils.h>
#include <openbsc/sgsn.h>
#include <openbsc/signal.h>
#ifdef BUILD_IU
#include <openbsc/iu.h>
#endif
#include <pdp.h>
@@ -107,6 +105,15 @@ static const struct tlv_definition gsm48_sm_att_tlvdef = {
},
};
static const struct value_string gprs_pmm_state_names[] = {
{ PMM_DETACHED, "PMM DETACH" },
{ PMM_CONNECTED, "PMM CONNECTED" },
{ PMM_IDLE, "PMM IDLE" },
{ MM_IDLE, "MM IDLE" },
{ MM_READY, "MM READY" },
{ MM_STANDBY, "MM STANDBY" },
};
static int gsm48_gmm_authorize(struct sgsn_mm_ctx *ctx);
static void mmctx_change_gtpu_endpoints_to_sgsn(struct sgsn_mm_ctx *mm_ctx)
@@ -121,28 +128,45 @@ static void mmctx_change_gtpu_endpoints_to_sgsn(struct sgsn_mm_ctx *mm_ctx)
void mmctx_set_pmm_state(struct sgsn_mm_ctx *ctx, enum gprs_pmm_state state)
{
if (ctx->ran_type != MM_CTX_T_UTRAN_Iu)
return;
if (ctx->pmm_state == state)
return;
LOGMMCTXP(LOGL_INFO, ctx, "Changing PMM state from %i to %i\n", ctx->pmm_state, state);
LOGMMCTXP(LOGL_INFO, ctx, "Changing PMM state from %s to %s\n",
get_value_string(gprs_pmm_state_names, ctx->pmm_state),
get_value_string(gprs_pmm_state_names, state));
if (ctx->ran_type == MM_CTX_T_UTRAN_Iu)
{
switch (state) {
case PMM_IDLE:
/* TODO: start RA Upd timer */
mmctx_change_gtpu_endpoints_to_sgsn(ctx);
break;
case PMM_CONNECTED:
break;
default:
break;
}
switch (state) {
case PMM_IDLE:
/* TODO: start RA Upd timer */
mmctx_change_gtpu_endpoints_to_sgsn(ctx);
break;
case PMM_CONNECTED:
break;
default:
break;
}
ctx->pmm_state = state;
}
void mmctx_set_mm_state(struct sgsn_mm_ctx *ctx, enum gprs_pmm_state state)
{
if (ctx->ran_type != MM_CTX_T_GERAN_Gb)
return;
if (ctx->pmm_state == state)
return;
LOGMMCTXP(LOGL_INFO, ctx, "Changing MM state from %s to %s\n",
get_value_string(gprs_pmm_state_names, ctx->pmm_state),
get_value_string(gprs_pmm_state_names, state));
ctx->pmm_state = state;
}
#ifdef BUILD_IU
int sgsn_ranap_rab_ass_resp(struct sgsn_mm_ctx *ctx, RANAP_RAB_SetupOrModifiedItemIEs_t *setup_ies);
int sgsn_ranap_iu_event(struct ue_conn_ctx *ctx, enum iu_event_type type, void *data)
@@ -151,33 +175,25 @@ int sgsn_ranap_iu_event(struct ue_conn_ctx *ctx, enum iu_event_type type, void *
int rc = -1;
mm = sgsn_mm_ctx_by_ue_ctx(ctx);
#define REQUIRE_MM \
if (!mm) { \
LOGP(DRANAP, LOGL_NOTICE, "Cannot find mm ctx for IU event %i!\n", type); \
return rc; \
if (!mm) {
LOGP(DRANAP, LOGL_NOTICE, "Cannot find mm ctx for IU event %i!\n", type);
return rc;
}
switch (type) {
case IU_EVENT_RAB_ASSIGN:
REQUIRE_MM
rc = sgsn_ranap_rab_ass_resp(mm, (RANAP_RAB_SetupOrModifiedItemIEs_t *)data);
break;
case IU_EVENT_IU_RELEASE:
/* fall thru */
case IU_EVENT_LINK_INVALIDATED:
/* Clean up ue_conn_ctx here */
if (mm)
LOGMMCTXP(LOGL_INFO, mm, "IU release for imsi %s\n", mm->imsi);
else
LOGMMCTXP(LOGL_INFO, mm, "IU release for UE conn 0x%x\n",
ctx->conn_id);
if (mm && mm->pmm_state == PMM_CONNECTED)
LOGMMCTXP(LOGL_INFO, mm, "IU release for imsi %s\n", mm->imsi);
if (mm->pmm_state == PMM_CONNECTED)
mmctx_set_pmm_state(mm, PMM_IDLE);
rc = 0;
break;
case IU_EVENT_SECURITY_MODE_COMPLETE:
REQUIRE_MM
/* Continue authentication here */
mm->iu.ue_ctx->integrity_active = 1;
rc = gsm48_gmm_authorize(mm);
@@ -284,9 +300,9 @@ static void mm_ctx_cleanup_free(struct sgsn_mm_ctx *ctx, const char *log_text)
LOGMMCTXP(LOGL_INFO, ctx, "Cleaning MM context due to %s\n", log_text);
/* Mark MM state as deregistered */
ctx->mm_state = GMM_DEREGISTERED;
ctx->gmm_state = GMM_DEREGISTERED;
mmctx_set_pmm_state(ctx, PMM_DETACHED);
mmctx_set_pmm_state(ctx, MM_IDLE);
sgsn_mm_ctx_cleanup_free(ctx);
}
@@ -651,7 +667,9 @@ static int gsm48_rx_gmm_auth_ciph_resp(struct sgsn_mm_ctx *ctx,
memcmp(TLVP_VAL(&tp, GSM48_IE_GMM_AUTH_SRES), at->vec.sres,
sizeof(at->vec.sres)) != 0) {
LOGMMCTXP(LOGL_NOTICE, ctx, "Received SRES doesn't match\n");
LOGMMCTXP(LOGL_NOTICE, ctx, "Received SRES doesn't match "
"expected RES %s\n", osmo_hexdump(at->vec.sres,
sizeof(at->vec.sres)));
rc = gsm48_tx_gmm_auth_ciph_rej(ctx);
mm_ctx_cleanup_free(ctx, "GPRS AUTH AND CIPH REJECT");
return rc;
@@ -692,11 +710,10 @@ static void extract_subscr_msisdn(struct sgsn_mm_ctx *ctx)
/* Prepend a '+' for international numbers */
if (called.plan == 1 && called.type == 1) {
ctx->msisdn[0] = '+';
strncpy(&ctx->msisdn[1], called.number,
sizeof(ctx->msisdn) - 1);
osmo_strlcpy(&ctx->msisdn[1], called.number,
sizeof(ctx->msisdn));
} else {
strncpy(&ctx->msisdn[0], called.number,
sizeof(ctx->msisdn) - 1);
osmo_strlcpy(ctx->msisdn, called.number, sizeof(ctx->msisdn));
}
}
@@ -734,7 +751,7 @@ static void extract_subscr_hlr(struct sgsn_mm_ctx *ctx)
return;
}
strncpy(&ctx->hlr[0], called.number, sizeof(ctx->hlr) - 1);
osmo_strlcpy(ctx->hlr, called.number, sizeof(ctx->hlr));
}
#ifdef BUILD_IU
@@ -891,7 +908,7 @@ static int gsm48_gmm_authorize(struct sgsn_mm_ctx *ctx)
memset(&sig_data, 0, sizeof(sig_data));
sig_data.mm = mmctx;
osmo_signal_dispatch(SS_SGSN, S_SGSN_ATTACH, &sig_data);
ctx->mm_state = GMM_REGISTERED_NORMAL;
ctx->gmm_state = GMM_REGISTERED_NORMAL;
#endif
return gsm48_tx_gmm_att_ack(ctx);
@@ -930,7 +947,7 @@ void gsm0408_gprs_authenticate(struct sgsn_mm_ctx *ctx)
void gsm0408_gprs_access_granted(struct sgsn_mm_ctx *ctx)
{
switch (ctx->mm_state) {
switch (ctx->gmm_state) {
case GMM_COMMON_PROC_INIT:
LOGMMCTXP(LOGL_NOTICE, ctx,
"Authorized, continuing procedure, IMSI=%s\n",
@@ -950,7 +967,7 @@ void gsm0408_gprs_access_denied(struct sgsn_mm_ctx *ctx, int gmm_cause)
if (gmm_cause == SGSN_ERROR_CAUSE_NONE)
gmm_cause = GMM_CAUSE_GPRS_NOTALLOWED;
switch (ctx->mm_state) {
switch (ctx->gmm_state) {
case GMM_COMMON_PROC_INIT:
LOGMMCTXP(LOGL_NOTICE, ctx,
"Not authorized, rejecting ATTACH REQUEST "
@@ -1043,10 +1060,10 @@ static int gsm48_rx_gmm_id_resp(struct sgsn_mm_ctx *ctx, struct msgb *msg)
mm_ctx_cleanup_free(ictx, "GPRS IMSI re-use");
}
}
strncpy(ctx->imsi, mi_string, sizeof(ctx->imsi) - 1);
osmo_strlcpy(ctx->imsi, mi_string, sizeof(ctx->imsi));
break;
case GSM_MI_TYPE_IMEI:
strncpy(ctx->imei, mi_string, sizeof(ctx->imei) - 1);
osmo_strlcpy(ctx->imei, mi_string, sizeof(ctx->imei));
break;
case GSM_MI_TYPE_IMEISV:
break;
@@ -1084,7 +1101,8 @@ static int gsm48_rx_gmm_att_req(struct sgsn_mm_ctx *ctx, struct msgb *msg,
if (!msg->dst) {
/* Gb mode */
cid = bssgp_parse_cell_id(&ra_id, msgb_bcid(msg));
}
} else
ra_id = ((struct ue_conn_ctx*)msg->dst)->ra_id;
/* MS network capability 10.5.5.12 */
msnc_len = *cur++;
@@ -1141,12 +1159,12 @@ static int gsm48_rx_gmm_att_req(struct sgsn_mm_ctx *ctx, struct msgb *msg,
if (msg->dst)
ctx = sgsn_mm_ctx_alloc_iu(msg->dst);
else
ctx = sgsn_mm_ctx_alloc(0, &ra_id);
ctx = sgsn_mm_ctx_alloc_gb(0, &ra_id);
if (!ctx) {
reject_cause = GMM_CAUSE_NET_FAIL;
goto rejected;
}
strncpy(ctx->imsi, mi_string, sizeof(ctx->imsi) - 1);
osmo_strlcpy(ctx->imsi, mi_string, sizeof(ctx->imsi));
#endif
}
if (ctx->ran_type == MM_CTX_T_GERAN_Gb) {
@@ -1167,7 +1185,7 @@ static int gsm48_rx_gmm_att_req(struct sgsn_mm_ctx *ctx, struct msgb *msg,
if (msg->dst)
ctx = sgsn_mm_ctx_alloc_iu(msg->dst);
else
ctx = sgsn_mm_ctx_alloc(msgb_tlli(msg), &ra_id);
ctx = sgsn_mm_ctx_alloc_gb(msgb_tlli(msg), &ra_id);
ctx->p_tmsi = tmsi;
}
if (ctx->ran_type == MM_CTX_T_GERAN_Gb) {
@@ -1233,11 +1251,11 @@ static int gsm48_rx_gmm_att_req(struct sgsn_mm_ctx *ctx, struct msgb *msg,
#ifdef PTMSI_ALLOC
/* Allocate a new P-TMSI (+ P-TMSI signature) and update TLLI */
/* Don't change the P-TMSI if a P-TMSI re-assignment is under way */
if (ctx->mm_state != GMM_COMMON_PROC_INIT) {
if (ctx->gmm_state != GMM_COMMON_PROC_INIT) {
ctx->p_tmsi_old = ctx->p_tmsi;
ctx->p_tmsi = sgsn_alloc_ptmsi();
}
ctx->mm_state = GMM_COMMON_PROC_INIT;
ctx->gmm_state = GMM_COMMON_PROC_INIT;
#endif
if (ctx->ran_type == MM_CTX_T_GERAN_Gb) {
@@ -1423,7 +1441,7 @@ static int gsm48_rx_gmm_ra_upd_req(struct sgsn_mm_ctx *mmctx, struct msgb *msg,
struct gprs_ra_id old_ra_id;
struct tlv_parsed tp;
uint8_t upd_type;
enum gsm48_gmm_cause reject_cause;
enum gsm48_gmm_cause reject_cause = GMM_CAUSE_PROTO_ERR_UNSPEC;
int rc;
/* TODO: In iu mode - handle follow-on request */
@@ -1508,10 +1526,10 @@ static int gsm48_rx_gmm_ra_upd_req(struct sgsn_mm_ctx *mmctx, struct msgb *msg,
mmctx->ra.mcc, mmctx->ra.mnc,
mmctx->ra.lac, mmctx->ra.rac);
mmctx->mm_state = GMM_COMMON_PROC_INIT;
mmctx->gmm_state = GMM_COMMON_PROC_INIT;
}
} else if (!gprs_ra_id_equals(&mmctx->ra, &old_ra_id) ||
mmctx->mm_state == GMM_DEREGISTERED)
mmctx->gmm_state == GMM_DEREGISTERED)
{
/* We cannot use the mmctx */
LOGMMCTXP(LOGL_INFO, mmctx,
@@ -1553,7 +1571,7 @@ static int gsm48_rx_gmm_ra_upd_req(struct sgsn_mm_ctx *mmctx, struct msgb *msg,
#ifdef PTMSI_ALLOC
/* Don't change the P-TMSI if a P-TMSI re-assignment is under way */
if (mmctx->mm_state != GMM_COMMON_PROC_INIT) {
if (mmctx->gmm_state != GMM_COMMON_PROC_INIT) {
mmctx->p_tmsi_old = mmctx->p_tmsi;
mmctx->p_tmsi = sgsn_alloc_ptmsi();
}
@@ -1561,10 +1579,10 @@ static int gsm48_rx_gmm_ra_upd_req(struct sgsn_mm_ctx *mmctx, struct msgb *msg,
mmctx->t3350_mode = GMM_T3350_MODE_RAU;
mmctx_timer_start(mmctx, 3350, sgsn->cfg.timers.T3350);
mmctx->mm_state = GMM_COMMON_PROC_INIT;
mmctx->gmm_state = GMM_COMMON_PROC_INIT;
#else
/* Make sure we are NORMAL (i.e. not SUSPENDED anymore) */
mmctx->mm_state = GMM_REGISTERED_NORMAL;
mmctx->gmm_state = GMM_REGISTERED_NORMAL;
memset(&sig_data, 0, sizeof(sig_data));
sig_data.mm = mmctx;
@@ -1687,7 +1705,7 @@ static int gsm48_rx_gmm_service_req(struct sgsn_mm_ctx *ctx, struct msgb *msg)
goto rejected;
}
ctx->mm_state = GMM_COMMON_PROC_INIT;
ctx->gmm_state = GMM_COMMON_PROC_INIT;
ctx->iu.service.type = service_type;
@@ -1839,8 +1857,9 @@ static int gsm0408_rcv_gmm(struct sgsn_mm_ctx *mmctx, struct msgb *msg,
gprs_llgmm_assign(mmctx->gb.llme, 0xffffffff,
mmctx->gb.tlli_new);
}
mmctx->mm_state = GMM_REGISTERED_NORMAL;
mmctx->gmm_state = GMM_REGISTERED_NORMAL;
mmctx_set_pmm_state(mmctx, PMM_CONNECTED);
mmctx_set_mm_state(mmctx, MM_READY);
rc = 0;
memset(&sig_data, 0, sizeof(sig_data));
@@ -1862,8 +1881,9 @@ static int gsm0408_rcv_gmm(struct sgsn_mm_ctx *mmctx, struct msgb *msg,
gprs_llgmm_assign(mmctx->gb.llme, 0xffffffff,
mmctx->gb.tlli_new);
}
mmctx->mm_state = GMM_REGISTERED_NORMAL;
mmctx->gmm_state = GMM_REGISTERED_NORMAL;
mmctx_set_pmm_state(mmctx, PMM_CONNECTED);
mmctx_set_mm_state(mmctx, MM_READY);
rc = 0;
memset(&sig_data, 0, sizeof(sig_data));
@@ -1986,7 +2006,7 @@ static void pdpctx_timer_start(struct sgsn_pdp_ctx *pdp, unsigned int T,
unsigned int seconds)
{
if (osmo_timer_pending(&pdp->timer))
LOGMMCTXP(LOGL_ERROR, pdp->mm, "Starting MM timer %u while old "
LOGPDPCTXP(LOGL_ERROR, pdp, "Starting PDP timer %u while old "
"timer %u pending\n", T, pdp->T);
pdp->T = T;
pdp->num_T_exp = 0;
@@ -1998,6 +2018,14 @@ static void pdpctx_timer_start(struct sgsn_pdp_ctx *pdp, unsigned int T,
osmo_timer_schedule(&pdp->timer, seconds, 0);
}
static void pdpctx_timer_stop(struct sgsn_pdp_ctx *pdp, unsigned int T)
{
if (pdp->T != T)
LOGPDPCTXP(LOGL_ERROR, pdp, "Stopping PDP timer %u but "
"%u is running\n", T, pdp->T);
osmo_timer_del(&pdp->timer);
}
#if 0
static void msgb_put_pdp_addr_ipv4(struct msgb *msg, uint32_t ipaddr)
{
@@ -2169,6 +2197,7 @@ static void ggsn_lookup_cb(void *arg, int status, int timeouts, struct hostent *
/* The context is gone while we made a request */
if (!lookup->mmctx) {
talloc_free(lookup->orig_msg);
talloc_free(lookup);
return;
}
@@ -2230,6 +2259,7 @@ static void ggsn_lookup_cb(void *arg, int status, int timeouts, struct hostent *
lookup->sapi, &lookup->tp, 1);
/* Now free it */
talloc_free(lookup->orig_msg);
talloc_free(lookup);
return;
@@ -2237,10 +2267,11 @@ reject_due_failure:
gsm48_tx_gsm_act_pdp_rej(lookup->mmctx, lookup->ti,
GMM_CAUSE_NET_FAIL, 0, NULL);
lookup->mmctx->ggsn_lookup = NULL;
talloc_free(lookup->orig_msg);
talloc_free(lookup);
}
static int do_act_pdp_req(struct sgsn_mm_ctx *mmctx, struct msgb *msg)
static int do_act_pdp_req(struct sgsn_mm_ctx *mmctx, struct msgb *msg, bool *delete)
{
struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_gmmh(msg);
struct gsm48_act_pdp_ctx_req *act_req = (struct gsm48_act_pdp_ctx_req *) gh->data;
@@ -2389,6 +2420,7 @@ static int do_act_pdp_req(struct sgsn_mm_ctx *mmctx, struct msgb *msg)
LOGMMCTXP(LOGL_ERROR, mmctx, "Failed to start ares query.\n");
goto no_context;
}
*delete = 0;
return 0;
@@ -2402,6 +2434,7 @@ no_context:
static int gsm48_rx_gsm_act_pdp_req(struct sgsn_mm_ctx *mmctx,
struct msgb *_msg)
{
bool delete = 1;
struct msgb *msg;
int rc;
@@ -2428,8 +2461,9 @@ static int gsm48_rx_gsm_act_pdp_req(struct sgsn_mm_ctx *mmctx,
0, NULL);
}
rc = do_act_pdp_req(mmctx, _msg);
msgb_free(msg);
rc = do_act_pdp_req(mmctx, msg, &delete);
if (delete)
msgb_free(msg);
return rc;
}
@@ -2472,7 +2506,8 @@ static int gsm48_rx_gsm_deact_pdp_ack(struct sgsn_mm_ctx *mm, struct msgb *msg)
mm->imsi, transaction_id);
return 0;
}
/* stop timer 3395 */
pdpctx_timer_stop(pdp, 3395);
return sgsn_delete_pdp_ctx(pdp);
}
@@ -2675,15 +2710,15 @@ int gprs_gmm_rx_suspend(struct gprs_ra_id *raid, uint32_t tlli)
return -EINVAL;
}
if (mmctx->mm_state != GMM_REGISTERED_NORMAL &&
mmctx->mm_state != GMM_REGISTERED_SUSPENDED) {
if (mmctx->gmm_state != GMM_REGISTERED_NORMAL &&
mmctx->gmm_state != GMM_REGISTERED_SUSPENDED) {
LOGMMCTXP(LOGL_NOTICE, mmctx, "SUSPEND request while state "
"!= REGISTERED (TLLI=%08x)\n", tlli);
return -EINVAL;
}
/* Transition from REGISTERED_NORMAL to REGISTERED_SUSPENDED */
mmctx->mm_state = GMM_REGISTERED_SUSPENDED;
mmctx->gmm_state = GMM_REGISTERED_SUSPENDED;
return 0;
}
@@ -2701,8 +2736,8 @@ int gprs_gmm_rx_resume(struct gprs_ra_id *raid, uint32_t tlli,
return -EINVAL;
}
if (mmctx->mm_state != GMM_REGISTERED_NORMAL &&
mmctx->mm_state != GMM_REGISTERED_SUSPENDED) {
if (mmctx->gmm_state != GMM_REGISTERED_NORMAL &&
mmctx->gmm_state != GMM_REGISTERED_SUSPENDED) {
LOGMMCTXP(LOGL_NOTICE, mmctx, "RESUME request while state "
"!= SUSPENDED (TLLI=%08x)\n", tlli);
/* FIXME: should we not simply ignore it? */
@@ -2710,7 +2745,7 @@ int gprs_gmm_rx_resume(struct gprs_ra_id *raid, uint32_t tlli,
}
/* Transition from SUSPENDED to NORMAL */
mmctx->mm_state = GMM_REGISTERED_NORMAL;
mmctx->gmm_state = GMM_REGISTERED_NORMAL;
return 0;
}

View File

@@ -39,6 +39,7 @@
#include <openbsc/gprs_llc.h>
#include <openbsc/crc24.h>
#include <openbsc/sgsn.h>
#include <openbsc/gsm_subscriber.h>
#include <openbsc/gprs_llc_xid.h>
#include <openbsc/gprs_sndcp_comp.h>
#include <openbsc/gprs_sndcp.h>
@@ -77,9 +78,9 @@ static int gprs_llc_generate_xid(uint8_t *bytes, int bytes_len,
xid_n201i.data_len = 2;
/* Add locally managed XID Fields */
llist_add(&xid_n201i.list, &xid_fields);
llist_add(&xid_n201u.list, &xid_fields);
llist_add(&xid_version.list, &xid_fields);
llist_add(&xid_n201u.list, &xid_fields);
llist_add(&xid_n201i.list, &xid_fields);
/* Append layer 3 XID field (if present) */
if (l3_xid_field) {
@@ -136,7 +137,7 @@ static int gprs_llc_process_xid_conf(uint8_t *bytes, int bytes_len,
struct gprs_llc_lle *lle)
{
/* Note: This function handles the response of a network originated
* XID-Request. There XID messages reflected by the phone are analyzed
* XID-Request. There XID messages reflected by the MS are analyzed
* and processed here. The caller is called by rx_llc_xid(). */
struct llist_head *xid_fields;
@@ -178,8 +179,10 @@ static int gprs_llc_process_xid_conf(uint8_t *bytes, int bytes_len,
* inquiry. There is a remainig risk of
* malfunction! */
LOGP(DLLC, LOGL_NOTICE,
"Ignoring XID-Field: XID: type=%d, data_len=%d, data=%s\n",
xid_field->type, xid_field->data_len,
"Ignoring XID-Field: XID: type %s, data_len=%d, data=%s\n",
get_value_string(gprs_llc_xid_type_names,
xid_field->type),
xid_field->data_len,
osmo_hexdump_nospc(xid_field->data,
xid_field->data_len));
}
@@ -202,7 +205,7 @@ static int gprs_llc_process_xid_ind(uint8_t *bytes_request,
struct gprs_llc_lle *lle)
{
/* Note: This function computes the response that is sent back to the
* phone when a phone originated XID is received. The function is
* MS when a mobile originated XID is received. The function is
* called by rx_llc_xid() */
int rc = -EINVAL;
@@ -229,11 +232,13 @@ static int gprs_llc_process_xid_ind(uint8_t *bytes_request,
* for validity. Currently we just blindly
* accept all XID fields by just echoing them.
* There is a remaining risk of malfunction
* when a phone submits values which defer from
* when a MS submits values which defer from
* the default! */
LOGP(DLLC, LOGL_NOTICE,
"Echoing XID-Field: XID: type=%d, data_len=%d, data=%s\n",
xid_field->type, xid_field->data_len,
"Echoing XID-Field: XID: type %s, data_len=%d, data=%s\n",
get_value_string(gprs_llc_xid_type_names,
xid_field->type),
xid_field->data_len,
osmo_hexdump_nospc(xid_field->data,
xid_field->data_len));
xid_field_response =
@@ -271,7 +276,7 @@ static int gprs_llc_process_xid_ind(uint8_t *bytes_request,
return rc;
}
/* Dispatch XID indications and responses comming from the Phone */
/* Dispatch XID indications and responses comming from the MS */
static void rx_llc_xid(struct gprs_llc_lle *lle,
struct gprs_llc_hdr_parsed *gph)
{
@@ -281,7 +286,7 @@ static void rx_llc_xid(struct gprs_llc_lle *lle,
/* FIXME: 8.5.3.3: check if XID is invalid */
if (gph->is_cmd) {
LOGP(DLLC, LOGL_NOTICE,
"Received XID indication from phone.\n");
"Received XID indication from MS.\n");
struct msgb *resp;
uint8_t *xid;
@@ -301,14 +306,13 @@ static void rx_llc_xid(struct gprs_llc_lle *lle,
gprs_llc_tx_xid(lle, resp, 0);
} else {
LOGP(DLLC, LOGL_NOTICE,
"Received XID confirmation from phone.\n");
"Received XID confirmation from MS.\n");
gprs_llc_process_xid_conf(gph->data, gph->data_len, lle);
/* FIXME: if we had sent a XID reset, send
* LLGMM-RESET.conf to GMM */
}
}
/* Set of LL-XID negotiation (See also: TS 101 351, Section 7.2.2.4) */
int gprs_ll_xid_req(struct gprs_llc_lle *lle,
struct gprs_llc_xid_field *l3_xid_field)
@@ -319,6 +323,7 @@ int gprs_ll_xid_req(struct gprs_llc_lle *lle,
int xid_bytes_len;
uint8_t *xid;
struct msgb *msg;
const char *ftype;
/* Generate XID */
xid_bytes_len =
@@ -331,7 +336,13 @@ int gprs_ll_xid_req(struct gprs_llc_lle *lle,
msg = msgb_alloc_headroom(4096, 1024, "LLC_XID");
xid = msgb_put(msg, xid_bytes_len);
memcpy(xid, xid_bytes, xid_bytes_len);
LOGP(DLLC, LOGL_NOTICE, "Sending XID request to phone...\n");
if (l3_xid_field)
ftype = get_value_string(gprs_llc_xid_type_names,
l3_xid_field->type);
else
ftype = "NULL";
LOGP(DLLC, LOGL_NOTICE, "Sending XID type %s (%d bytes) request"
" to MS...\n", ftype, xid_bytes_len);
gprs_llc_tx_xid(lle, msg, 1);
} else {
LOGP(DLLC, LOGL_ERROR,
@@ -774,6 +785,9 @@ int gprs_llc_tx_ui(struct msgb *msg, uint8_t sapi, int command,
}
}
rate_ctr_inc(&sgsn->rate_ctrs->ctr[CTR_LLC_DL_PACKETS]);
rate_ctr_add(&sgsn->rate_ctrs->ctr[CTR_LLC_DL_BYTES], msg->len);
/* Identifiers passed down: (BVCI, NSEI) */
/* Send BSSGP-DL-UNITDATA.req */
@@ -855,7 +869,7 @@ int gprs_llc_rcvmsg(struct msgb *msg, struct tlv_parsed *tv)
{
struct gprs_llc_hdr *lh = (struct gprs_llc_hdr *) msgb_llch(msg);
struct gprs_llc_hdr_parsed llhp;
struct gprs_llc_lle *lle;
struct gprs_llc_lle *lle = NULL;
bool drop_cipherable = false;
int rc = 0;
@@ -863,7 +877,6 @@ int gprs_llc_rcvmsg(struct msgb *msg, struct tlv_parsed *tv)
memset(&llhp, 0, sizeof(llhp));
rc = gprs_llc_hdr_parse(&llhp, (uint8_t *) lh, TLVP_LEN(tv, BSSGP_IE_LLC_PDU));
gprs_llc_hdr_dump(&llhp);
if (rc < 0) {
LOGP(DLLC, LOGL_NOTICE, "Error during LLC header parsing\n");
return rc;
@@ -896,7 +909,7 @@ int gprs_llc_rcvmsg(struct msgb *msg, struct tlv_parsed *tv)
}
return 0;
}
gprs_llc_hdr_dump(&llhp, lle);
/* reset age computation */
lle->llme->age_timestamp = GPRS_LLME_RESET_AGE;

View File

@@ -67,11 +67,19 @@ int gprs_llc_fcs(uint8_t *data, unsigned int len)
return fcs_calc;
}
void gprs_llc_hdr_dump(struct gprs_llc_hdr_parsed *gph)
void gprs_llc_hdr_dump(struct gprs_llc_hdr_parsed *gph, struct gprs_llc_lle *lle)
{
DEBUGP(DLLC, "LLC SAPI=%u %c %c FCS=0x%06x",
gph->sapi, gph->is_cmd ? 'C' : 'R', gph->ack_req ? 'A' : ' ',
gph->fcs);
const char *gea;
uint32_t iov_ui = 0;
if (lle) {
gea = get_value_string(gprs_cipher_names, lle->llme->algo);
iov_ui = lle->llme->iov_ui;
} else
gea = "GEA?";
DEBUGP(DLLC, "LLC SAPI=%u %c %c %c %s IOV-UI=0x%06x FCS=0x%06x ",
gph->sapi, gph->is_cmd ? 'C' : 'R', gph->ack_req ? 'A' : ' ',
gph->is_encrypted ? 'E' : 'U',
gea, iov_ui, gph->fcs);
if (gph->cmd)
DEBUGPC(DLLC, "CMD=%s ", get_value_string(llc_cmd_strs, gph->cmd));

View File

@@ -73,9 +73,11 @@ static void vty_dump_llme(struct vty *vty, struct gprs_llc_llme *llme)
struct timespec now_tp = {0};
clock_gettime(CLOCK_MONOTONIC, &now_tp);
vty_out(vty, "TLLI %08x (Old TLLI %08x) BVCI=%u NSEI=%u Age=%d: State %s%s",
llme->tlli, llme->old_tlli, llme->bvci, llme->nsei,
llme->age_timestamp == GPRS_LLME_RESET_AGE ? 0 :
vty_out(vty, "TLLI %08x (Old TLLI %08x) BVCI=%u NSEI=%u %s: "
"IOV-UI=0x%06x CKSN=%d Age=%d: State %s%s", llme->tlli,
llme->old_tlli, llme->bvci, llme->nsei,
get_value_string(gprs_cipher_names, llme->algo), llme->iov_ui,
llme->cksn, llme->age_timestamp == GPRS_LLME_RESET_AGE ? 0 :
(int)(now_tp.tv_sec - (time_t)llme->age_timestamp),
get_value_string(gprs_llc_state_strs, llme->state), VTY_NEWLINE);

View File

@@ -35,6 +35,23 @@
#include <openbsc/sgsn.h>
#include <openbsc/gprs_llc_xid.h>
const struct value_string gprs_llc_xid_type_names[] = {
{ GPRS_LLC_XID_T_VERSION, "VERSION"},
{ GPRS_LLC_XID_T_IOV_UI, "IOV_UI"},
{ GPRS_LLC_XID_T_IOV_I, "IOV_I"},
{ GPRS_LLC_XID_T_T200, "T200"},
{ GPRS_LLC_XID_T_N200, "N200"},
{ GPRS_LLC_XID_T_N201_U, "N201_"},
{ GPRS_LLC_XID_T_N201_I, "N201_I"},
{ GPRS_LLC_XID_T_mD, "mD"},
{ GPRS_LLC_XID_T_mU, "mU"},
{ GPRS_LLC_XID_T_kD, "kD"},
{ GPRS_LLC_XID_T_kU, "kU"},
{ GPRS_LLC_XID_T_L3_PAR, "L3_PAR"},
{ GPRS_LLC_XID_T_RESET, "RESET"},
{ 0, NULL },
};
/* Parse XID parameter field */
static int decode_xid_field(struct gprs_llc_xid_field *xid_field,
const uint8_t *src, uint8_t src_len)
@@ -249,8 +266,10 @@ void gprs_llc_dump_xid_fields(const struct llist_head *xid_fields,
if (xid_field->data_len) {
OSMO_ASSERT(xid_field->data);
LOGP(DLLC, logl,
"XID: type=%d, data_len=%d, data=%s\n",
xid_field->type, xid_field->data_len,
"XID: type %s, data_len=%d, data=%s\n",
get_value_string(gprs_llc_xid_type_names,
xid_field->type),
xid_field->data_len,
osmo_hexdump_nospc(xid_field->data,
xid_field->data_len));
} else {

View File

@@ -209,8 +209,8 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_by_imsi(const char *imsi)
}
/* Allocate a new SGSN MM context */
struct sgsn_mm_ctx *sgsn_mm_ctx_alloc(uint32_t tlli,
/* Allocate a new SGSN MM context for GERAN_Gb */
struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_gb(uint32_t tlli,
const struct gprs_ra_id *raid)
{
struct sgsn_mm_ctx *ctx;
@@ -222,9 +222,12 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_alloc(uint32_t tlli,
memcpy(&ctx->ra, raid, sizeof(ctx->ra));
ctx->ran_type = MM_CTX_T_GERAN_Gb;
ctx->gb.tlli = tlli;
ctx->mm_state = GMM_DEREGISTERED;
ctx->gmm_state = GMM_DEREGISTERED;
ctx->pmm_state = MM_IDLE;
ctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL;
ctx->ciph_algo = sgsn->cfg.cipher;
LOGMMCTXP(LOGL_DEBUG, ctx, "Allocated with %s cipher.\n",
get_value_string(gprs_cipher_names, ctx->ciph_algo));
ctx->ctrg = rate_ctr_group_alloc(ctx, &mmctx_ctrg_desc, tlli);
INIT_LLIST_HEAD(&ctx->pdp_list);
@@ -245,7 +248,7 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_iu(void *uectx)
ctx->ran_type = MM_CTX_T_UTRAN_Iu;
ctx->iu.ue_ctx = uectx;
ctx->iu.new_key = 1;
ctx->mm_state = GMM_DEREGISTERED;
ctx->gmm_state = GMM_DEREGISTERED;
ctx->pmm_state = PMM_DETACHED;
ctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL;
ctx->ctrg = rate_ctr_group_alloc(ctx, &mmctx_ctrg_desc, 0);
@@ -656,7 +659,7 @@ failed:
static void drop_one_pdp(struct sgsn_pdp_ctx *pdp)
{
if (pdp->mm->mm_state == GMM_REGISTERED_NORMAL)
if (pdp->mm->gmm_state == GMM_REGISTERED_NORMAL)
gsm48_tx_gsm_deact_pdp_req(pdp, GSM_CAUSE_NET_FAIL);
else {
/* FIXME: GPRS paging in case MS is SUSPENDED */

View File

@@ -911,6 +911,7 @@ static int sndcp_rx_llc_prim()
case LL_DATA_CONF:
case LL_UNITDATA_IND:
case LL_STATUS_IND:
}
}
#endif
@@ -960,8 +961,13 @@ static int gprs_llc_gen_sndcp_xid(uint8_t *bytes, int bytes_len, uint8_t nsapi)
llist_add(&v42bis_comp_field.list, &comp_fields);
}
/* Do not attempt to compile anything if there is no data in the list */
if (llist_empty(&comp_fields))
return 0;
/* Compile bytestream */
return gprs_sndcp_compile_xid(bytes, bytes_len, &comp_fields);
return gprs_sndcp_compile_xid(bytes, bytes_len, &comp_fields,
DEFAULT_SNDCP_VERSION);
}
/* Set of SNDCP-XID bnegotiation (See also: TS 144 065,
@@ -1106,6 +1112,7 @@ int sndcp_sn_xid_ind(struct gprs_llc_xid_field *xid_field_indication,
int rc;
int compclass;
int version;
struct llist_head *comp_fields;
struct gprs_sndcp_comp_field *comp_field;
@@ -1115,22 +1122,13 @@ int sndcp_sn_xid_ind(struct gprs_llc_xid_field *xid_field_indication,
OSMO_ASSERT(lle);
/* Parse SNDCP-CID XID-Field */
comp_fields = gprs_sndcp_parse_xid(lle->llme,
comp_fields = gprs_sndcp_parse_xid(&version, lle->llme,
xid_field_indication->data,
xid_field_indication->data_len,
NULL);
if (!comp_fields)
return -EINVAL;
/* Don't bother with empty indications */
if (llist_empty(comp_fields)) {
xid_field_response->data = NULL;
xid_field_response->data_len = 0;
DEBUGP(DSNDCP,
"SNDCP-XID indication did not contain any parameters!\n");
return 0;
}
/* Handle compression entites */
DEBUGP(DSNDCP, "SNDCP-XID-IND (ms):\n");
gprs_sndcp_dump_comp_fields(comp_fields, LOGL_DEBUG);
@@ -1168,7 +1166,7 @@ int sndcp_sn_xid_ind(struct gprs_llc_xid_field *xid_field_indication,
/* Compile modified SNDCP-XID bytes */
rc = gprs_sndcp_compile_xid(xid_field_response->data,
xid_field_indication->data_len,
comp_fields);
comp_fields, 0);
if (rc > 0)
xid_field_response->data_len = rc;
@@ -1210,7 +1208,7 @@ int sndcp_sn_xid_conf(struct gprs_llc_xid_field *xid_field_conf,
OSMO_ASSERT(xid_field_request);
/* Parse SNDCP-CID XID-Field */
comp_fields_req = gprs_sndcp_parse_xid(lle->llme,
comp_fields_req = gprs_sndcp_parse_xid(NULL, lle->llme,
xid_field_request->data,
xid_field_request->data_len,
NULL);
@@ -1221,7 +1219,7 @@ int sndcp_sn_xid_conf(struct gprs_llc_xid_field *xid_field_conf,
gprs_sndcp_dump_comp_fields(comp_fields_req, LOGL_DEBUG);
/* Parse SNDCP-CID XID-Field */
comp_fields_conf = gprs_sndcp_parse_xid(lle->llme,
comp_fields_conf = gprs_sndcp_parse_xid(NULL, lle->llme,
xid_field_conf->data,
xid_field_conf->data_len,
comp_fields_req);

View File

@@ -70,9 +70,9 @@ static struct gprs_sndcp_comp *gprs_sndcp_comp_create(const void *ctx,
comp_field->v42bis_params->nsapi,
sizeof(comp_entity->nsapi));
} else if (comp_field->v44_params) {
comp_entity->nsapi_len = comp_field->v42bis_params->nsapi_len;
comp_entity->nsapi_len = comp_field->v44_params->nsapi_len;
memcpy(comp_entity->nsapi,
comp_field->v42bis_params->nsapi,
comp_field->v44_params->nsapi,
sizeof(comp_entity->nsapi));
} else {
/* The caller is expected to check carefully if the all
@@ -107,13 +107,14 @@ static struct gprs_sndcp_comp *gprs_sndcp_comp_create(const void *ctx,
}
}
/* Display info message */
/* Bail on failure */
if (comp_entity == NULL) {
LOGP(DSNDCP, LOGL_ERROR,
"Compression entity (%d) creation failed!\n",
comp_entity->entity);
"Compression entity creation failed!\n");
return NULL;
}
/* Display info message */
if (comp_entity->compclass == SNDCP_XID_PROTOCOL_COMPRESSION) {
LOGP(DSNDCP, LOGL_INFO,
"New header compression entity (%d) created.\n",

View File

@@ -84,6 +84,7 @@ int gprs_sndcp_dcomp_init(const void *ctx, struct gprs_sndcp_comp *comp_entity,
if (comp_entity->compclass == SNDCP_XID_DATA_COMPRESSION
&& comp_entity->algo == V42BIS) {
OSMO_ASSERT(comp_field->v42bis_params);
comp_entity->state =
v42bis_init(ctx, NULL, comp_field->v42bis_params->p0,
comp_field->v42bis_params->p1,

View File

@@ -54,6 +54,7 @@ int gprs_sndcp_pcomp_init(const void *ctx, struct gprs_sndcp_comp *comp_entity,
if (comp_entity->compclass == SNDCP_XID_PROTOCOL_COMPRESSION
&& comp_entity->algo == RFC_1144) {
OSMO_ASSERT(comp_field->rfc1144_params);
comp_entity->state =
slhc_init(ctx, comp_field->rfc1144_params->s01 + 1,
comp_field->rfc1144_params->s01 + 1);
@@ -141,6 +142,7 @@ static int rfc1144_expand(uint8_t *data, unsigned int len, uint8_t pcomp_index,
switch (pcomp_index) {
case 0:
type = SL_TYPE_IP;
break;
case 1:
type = SL_TYPE_UNCOMPRESSED_TCP;
break;

View File

@@ -206,7 +206,6 @@ static int encode_pcomp_rohc_params(uint8_t *dst, unsigned int dst_maxlen,
/* Bail if number of ROHC profiles exceeds limit
* (ROHC supports only a maximum of 16 different profiles) */
OSMO_ASSERT(params->profile_len >= 0);
OSMO_ASSERT(params->profile_len <= 16);
/* Zero out buffer */
@@ -475,8 +474,7 @@ static int encode_comp_field(uint8_t *dst, unsigned int dst_maxlen,
for (i = 0; i < comp_field->comp_len; i++) {
/* Check if submitted PCOMP/DCOMP
values are within bounds */
if ((comp_field->comp[i] < 0)
|| (comp_field->comp[i] > 0x0F))
if (comp_field->comp[i] > 0x0F)
return -EINVAL;
if (i & 1) {
@@ -551,26 +549,29 @@ static int gprs_sndcp_pack_fields(const struct llist_head *comp_fields,
/* Transform a list with compression fields into an SNDCP-XID message (dst) */
int gprs_sndcp_compile_xid(uint8_t *dst, unsigned int dst_maxlen,
const struct llist_head *comp_fields)
const struct llist_head *comp_fields, int version)
{
int rc;
int byte_counter = 0;
uint8_t comp_bytes[512];
uint8_t xid_version_number[1] = { CURRENT_SNDCP_VERSION };
uint8_t xid_version_number[1];
OSMO_ASSERT(comp_fields);
OSMO_ASSERT(dst);
OSMO_ASSERT(dst_maxlen >= 2 + sizeof(xid_version_number));
/* Bail if there is no input */
if (llist_empty(comp_fields))
return -EINVAL;
/* Prepend header with version number */
if (version >= 0) {
xid_version_number[0] = (uint8_t) (version & 0xff);
dst =
tlv_put(dst, SNDCP_XID_VERSION_NUMBER,
sizeof(xid_version_number), xid_version_number);
byte_counter += (sizeof(xid_version_number) + 2);
}
/* Prepend header */
dst =
tlv_put(dst, SNDCP_XID_VERSION_NUMBER,
sizeof(xid_version_number), xid_version_number);
byte_counter += (sizeof(xid_version_number) + 2);
/* Stop if there is no compression fields supplied */
if (llist_empty(comp_fields))
return byte_counter;
/* Add data compression fields */
rc = gprs_sndcp_pack_fields(comp_fields, comp_bytes,
@@ -1285,11 +1286,10 @@ static int decode_xid_block(struct llist_head *comp_fields, uint8_t tag,
}
/* Transform an SNDCP-XID message (src) into a list of SNDCP-XID fields */
static int gprs_sndcp_decode_xid(struct llist_head *comp_fields,
static int gprs_sndcp_decode_xid(int *version, struct llist_head *comp_fields,
const uint8_t *src, unsigned int src_len,
const struct
entity_algo_table
*lt, unsigned int lt_len)
const struct entity_algo_table *lt,
unsigned int lt_len)
{
int src_pos = 0;
uint8_t tag;
@@ -1299,6 +1299,10 @@ static int gprs_sndcp_decode_xid(struct llist_head *comp_fields,
int rc;
int tlv_count = 0;
/* Preset version value as invalid */
if (version)
*version = -1;
/* Valid TLV-Tag and types */
static const struct tlv_definition sndcp_xid_def = {
.def = {
@@ -1329,6 +1333,10 @@ static int gprs_sndcp_decode_xid(struct llist_head *comp_fields,
return -EINVAL;
}
/* Decode sndcp xid version number */
if (version && tag == SNDCP_XID_VERSION_NUMBER)
*version = val[0];
/* Decode compression parameters */
if ((tag == SNDCP_XID_PROTOCOL_COMPRESSION)
|| (tag == SNDCP_XID_DATA_COMPRESSION)) {
@@ -1360,26 +1368,29 @@ static int gprs_sndcp_fill_table(struct
{
struct gprs_sndcp_comp_field *comp_field;
int i = 0;
int rc;
if (!comp_fields)
return -EINVAL;
if (!lt)
return -EINVAL;
memset(lt, 0, lt_len * sizeof(lt));
memset(lt, 0, sizeof(*lt));
llist_for_each_entry(comp_field, comp_fields, list) {
if (comp_field->algo >= 0) {
lt[i].entity = comp_field->entity;
lt[i].algo = comp_field->algo;
rc = gprs_sndcp_get_compression_class(comp_field);
lt[i].entity = comp_field->entity;
lt[i].algo = comp_field->algo;
lt[i].compclass = gprs_sndcp_get_compression_class(comp_field);
if (rc < 0) {
memset(lt, 0, sizeof(*lt));
return -EINVAL;
}
if (lt[i].compclass < 0) {
memset(lt, 0, lt_len * sizeof(lt));
return -EINVAL;
lt[i].compclass = rc;
i++;
}
i++;
}
return i;
@@ -1547,7 +1558,8 @@ static int gprs_sndcp_complete_comp_fields(struct llist_head
}
/* Transform an SNDCP-XID message (src) into a list of SNDCP-XID fields */
struct llist_head *gprs_sndcp_parse_xid(const void *ctx,
struct llist_head *gprs_sndcp_parse_xid(int *version,
const void *ctx,
const uint8_t *src,
unsigned int src_len,
const struct llist_head
@@ -1558,6 +1570,12 @@ struct llist_head *gprs_sndcp_parse_xid(const void *ctx,
struct llist_head *comp_fields;
struct entity_algo_table lt[MAX_ENTITIES * 2];
/* In case of a zero length field, just exit */
if (src_len == 0)
return NULL;
/* We should go any further if we have a field length greater
* zero and a null pointer as buffer! */
OSMO_ASSERT(src);
comp_fields = talloc_zero(ctx, struct llist_head);
@@ -1574,8 +1592,8 @@ struct llist_head *gprs_sndcp_parse_xid(const void *ctx,
}
/* Parse SNDCP-CID XID-Field */
rc = gprs_sndcp_decode_xid(comp_fields, src, src_len, lt,
lt_len);
rc = gprs_sndcp_decode_xid(version, comp_fields, src, src_len,
lt, lt_len);
if (rc < 0) {
talloc_free(comp_fields);
return NULL;
@@ -1590,7 +1608,8 @@ struct llist_head *gprs_sndcp_parse_xid(const void *ctx,
} else {
/* Parse SNDCP-CID XID-Field */
rc = gprs_sndcp_decode_xid(comp_fields, src, src_len, NULL, 0);
rc = gprs_sndcp_decode_xid(version, comp_fields, src, src_len,
NULL, 0);
if (rc < 0) {
talloc_free(comp_fields);
return NULL;

View File

@@ -22,8 +22,9 @@
#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
#include <osmocom/gsm/gsup.h>
#include <osmocom/core/utils.h>
#include <openbsc/gsm_subscriber.h>
#include <openbsc/gprs_gsup_client.h>
#include <openbsc/gsup_client.h>
#include <openbsc/sgsn.h>
#include <openbsc/gprs_sgsn.h>
@@ -45,7 +46,7 @@
extern void *tall_bsc_ctx;
static int gsup_read_cb(struct gprs_gsup_client *gsupc, struct msgb *msg);
static int gsup_read_cb(struct gsup_client *gsupc, struct msgb *msg);
/* TODO: Some functions are specific to the SGSN, but this file is more general
* (it has gprs_* name). Either move these functions elsewhere, split them and
@@ -62,7 +63,7 @@ int gprs_subscr_init(struct sgsn_instance *sgi)
addr_str = inet_ntoa(sgi->cfg.gsup_server_addr.sin_addr);
sgi->gsup_client = gprs_gsup_client_create(
sgi->gsup_client = gsup_client_create(
addr_str, sgi->cfg.gsup_server_port,
&gsup_read_cb,
&sgi->cfg.oap);
@@ -73,7 +74,7 @@ int gprs_subscr_init(struct sgsn_instance *sgi)
return 1;
}
static int gsup_read_cb(struct gprs_gsup_client *gsupc, struct msgb *msg)
static int gsup_read_cb(struct gsup_client *gsupc, struct msgb *msg)
{
int rc;
@@ -161,10 +162,11 @@ void gprs_subscr_cancel(struct gsm_subscriber *subscr)
static int gprs_subscr_tx_gsup_message(struct gsm_subscriber *subscr,
struct osmo_gsup_message *gsup_msg)
{
struct msgb *msg = gprs_gsup_msgb_alloc();
struct msgb *msg = gsup_client_msgb_alloc();
if (strlen(gsup_msg->imsi) == 0 && subscr)
strncpy(gsup_msg->imsi, subscr->imsi, sizeof(gsup_msg->imsi) - 1);
osmo_strlcpy(gsup_msg->imsi, subscr->imsi,
sizeof(gsup_msg->imsi));
gsup_msg->cn_domain = OSMO_GSUP_CN_DOMAIN_PS;
osmo_gsup_encode(msg, gsup_msg);
@@ -176,7 +178,7 @@ static int gprs_subscr_tx_gsup_message(struct gsm_subscriber *subscr,
return -ENOTSUP;
}
return gprs_gsup_client_send(sgsn->gsup_client, msg);
return gsup_client_send(sgsn->gsup_client, msg);
}
static int gprs_subscr_tx_gsup_error_reply(struct gsm_subscriber *subscr,
@@ -185,7 +187,8 @@ static int gprs_subscr_tx_gsup_error_reply(struct gsm_subscriber *subscr,
{
struct osmo_gsup_message gsup_reply = {0};
strncpy(gsup_reply.imsi, gsup_orig->imsi, sizeof(gsup_reply.imsi) - 1);
osmo_strlcpy(gsup_reply.imsi, gsup_orig->imsi,
sizeof(gsup_reply.imsi));
gsup_reply.cause = cause;
gsup_reply.message_type =
OSMO_GSUP_TO_MSGT_ERROR(gsup_orig->message_type);
@@ -778,11 +781,8 @@ struct gsm_subscriber *gprs_subscr_get_or_create_by_mmctx(struct sgsn_mm_ctx *mm
subscr->flags &= ~GPRS_SUBSCRIBER_ENABLE_PURGE;
}
if (strcpy(subscr->equipment.imei, mmctx->imei) != 0) {
strncpy(subscr->equipment.imei, mmctx->imei,
sizeof(subscr->equipment.imei)-1);
subscr->equipment.imei[sizeof(subscr->equipment.imei)-1] = 0;
}
osmo_strlcpy(subscr->equipment.imei, mmctx->imei,
sizeof(subscr->equipment.imei));
if (subscr->lac != mmctx->ra.lac)
subscr->lac = mmctx->ra.lac;

View File

@@ -553,7 +553,7 @@ static void gtp_decode(const uint8_t *data, int data_len,
}
#if 1
/* TODO if (<loglevel is debug>) { ...
/* TODO if (<loglevel is debug>)
(waiting for a commit from jerlbeck) */
int i;
@@ -1039,6 +1039,9 @@ const char *gtphub_tunnel_str(struct gtphub_tunnel *tun)
int left = sizeof(buf);
int l;
if (!tun)
return "null-tunnel";
APPEND("TEI=%x: ", tun->tei_repl);
APPEND("%s", gtphub_tunnel_side_str(tun, GTPH_SIDE_SGSN));
APPEND(" <-> %s", gtphub_tunnel_side_str(tun, GTPH_SIDE_GGSN));
@@ -2357,8 +2360,7 @@ void gtphub_resolved_ggsn(struct gtphub *hub, const char *apn_oi_str,
ggsn->peer = pp;
gtphub_port_ref_count_inc(pp);
strncpy(ggsn->apn_oi_str, apn_oi_str, sizeof(ggsn->apn_oi_str));
ggsn->apn_oi_str[sizeof(ggsn->apn_oi_str) - 1] = '\0';
osmo_strlcpy(ggsn->apn_oi_str, apn_oi_str, sizeof(ggsn->apn_oi_str));
ggsn->expiry_entry.del_cb = resolved_gssn_del_cb;
expiry_add(&hub->expire_slowly, &ggsn->expiry_entry, now);

View File

@@ -121,8 +121,8 @@ static void make_addr_str(struct ggsn_lookup *lookup)
apn_oi_str = osmo_apn_qualify_from_imsi(lookup->imsi_str,
lookup->apn_ni_str,
lookup->have_3dig_mnc);
strncpy(lookup->apn_oi_str, apn_oi_str, sizeof(lookup->apn_oi_str));
lookup->apn_oi_str[sizeof(lookup->apn_oi_str)-1] = '\0';
osmo_strlcpy(lookup->apn_oi_str, apn_oi_str,
sizeof(lookup->apn_oi_str));
}
static int start_ares_query(struct ggsn_lookup *lookup)
@@ -170,11 +170,9 @@ struct gtphub_peer_port *gtphub_resolve_ggsn_addr(struct gtphub *hub,
expiring_item_init(&lookup->expiry_entry);
lookup->hub = hub;
strncpy(lookup->imsi_str, imsi_str, sizeof(lookup->imsi_str));
lookup->imsi_str[sizeof(lookup->imsi_str)-1] = '\0';
strncpy(lookup->apn_ni_str, apn_ni_str, sizeof(lookup->apn_ni_str));
lookup->apn_ni_str[sizeof(lookup->apn_ni_str)-1] = '\0';
osmo_strlcpy(lookup->imsi_str, imsi_str, sizeof(lookup->imsi_str));
osmo_strlcpy(lookup->apn_ni_str, apn_ni_str,
sizeof(lookup->apn_ni_str));
make_addr_str(lookup);

View File

@@ -299,6 +299,7 @@ int main(int argc, char **argv)
struct gtphub *hub = &_hub;
osmo_gtphub_ctx = talloc_named_const(NULL, 0, "osmo_gtphub");
msgb_talloc_ctx_init(osmo_gtphub_ctx, 0);
signal(SIGINT, &signal_handler);
signal(SIGABRT, &signal_handler);

View File

@@ -1,178 +0,0 @@
/* Osmocom Authentication Protocol message encoder/decoder */
/* (C) 2015 by Sysmocom s.f.m.c. GmbH
* All Rights Reserved
*
* Author: Neels Hofmeyr
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <osmocom/core/utils.h>
#include <openbsc/oap_messages.h>
#include <openbsc/debug.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/core/msgb.h>
#include <stdint.h>
int osmo_oap_decode(struct osmo_oap_message *oap_msg,
const uint8_t *const_data, size_t data_len)
{
int rc;
uint8_t tag;
/* the shift/match functions expect non-const pointers, but we'll
* either copy the data or cast pointers back to const before returning
* them
*/
uint8_t *data = (uint8_t *)const_data;
uint8_t *value;
size_t value_len;
memset(oap_msg, 0, sizeof(*oap_msg));
/* message type */
rc = osmo_shift_v_fixed(&data, &data_len, 1, &value);
if (rc < 0)
return -GMM_CAUSE_INV_MAND_INFO;
oap_msg->message_type = osmo_decode_big_endian(value, 1);
/* specific parts */
while (data_len > 0) {
enum oap_iei iei;
rc = osmo_shift_tlv(&data, &data_len, &tag, &value, &value_len);
if (rc < 0)
return -GMM_CAUSE_PROTO_ERR_UNSPEC;
iei = tag;
switch (iei) {
case OAP_CLIENT_ID_IE:
if (value_len != 2) {
LOGP(DGPRS, LOGL_NOTICE,
"OAP IE type client ID (%d) should be 2 octets, but has %d\n",
(int)iei, (int)value_len);
return -GMM_CAUSE_PROTO_ERR_UNSPEC;
}
oap_msg->client_id = osmo_decode_big_endian(value, value_len);
if (oap_msg->client_id == 0) {
LOGP(DGPRS, LOGL_NOTICE,
"OAP IE type client ID (%d): client ID must be nonzero.\n",
(int)iei);
return -GMM_CAUSE_PROTO_ERR_UNSPEC;
}
break;
case OAP_AUTN_IE:
if (value_len != sizeof(oap_msg->autn)) {
LOGP(DGPRS, LOGL_NOTICE,
"OAP IE type AUTN (%d) should be %d octets, but has %d\n",
(int)iei, (int)sizeof(oap_msg->autn), (int)value_len);
return -GMM_CAUSE_PROTO_ERR_UNSPEC;
}
memcpy(oap_msg->autn, value, value_len);
oap_msg->autn_present = value_len;
break;
case OAP_RAND_IE:
if (value_len != sizeof(oap_msg->rand)) {
LOGP(DGPRS, LOGL_NOTICE,
"OAP IE type RAND (%d) should be %d octets, but has %d\n",
(int)iei, (int)sizeof(oap_msg->rand), (int)value_len);
return -GMM_CAUSE_PROTO_ERR_UNSPEC;
}
memcpy(oap_msg->rand, value, value_len);
oap_msg->rand_present = value_len;
break;
case OAP_XRES_IE:
if (value_len != sizeof(oap_msg->xres)) {
LOGP(DGPRS, LOGL_NOTICE,
"OAP IE type XRES (%d) should be %d octets, but has %d\n",
(int)iei, (int)sizeof(oap_msg->xres), (int)value_len);
return -GMM_CAUSE_PROTO_ERR_UNSPEC;
}
memcpy(oap_msg->xres, value, value_len);
oap_msg->xres_present = value_len;
break;
case OAP_AUTS_IE:
if (value_len != sizeof(oap_msg->auts)) {
LOGP(DGPRS, LOGL_NOTICE,
"OAP IE type AUTS (%d) should be %d octets, but has %d\n",
(int)iei, (int)sizeof(oap_msg->auts), (int)value_len);
return -GMM_CAUSE_PROTO_ERR_UNSPEC;
}
memcpy(oap_msg->auts, value, value_len);
oap_msg->auts_present = value_len;
break;
case OAP_CAUSE_IE:
if (value_len > 1) {
LOGP(DGPRS, LOGL_ERROR,
"OAP cause may not exceed one octet, is %d", (int)value_len);
return -GMM_CAUSE_PROTO_ERR_UNSPEC;
}
oap_msg->cause = *value;
break;
default:
LOGP(DGPRS, LOGL_NOTICE,
"OAP IE type %d unknown\n", iei);
continue;
}
}
return 0;
}
void osmo_oap_encode(struct msgb *msg, const struct osmo_oap_message *oap_msg)
{
uint8_t u8;
/* generic part */
OSMO_ASSERT(oap_msg->message_type);
msgb_v_put(msg, (uint8_t)oap_msg->message_type);
/* specific parts */
if ((u8 = oap_msg->cause))
msgb_tlv_put(msg, OAP_CAUSE_IE, sizeof(u8), &u8);
if (oap_msg->client_id > 0)
msgb_tlv_put(msg, OAP_CLIENT_ID_IE, sizeof(oap_msg->client_id),
osmo_encode_big_endian(oap_msg->client_id,
sizeof(oap_msg->client_id)));
if (oap_msg->rand_present)
msgb_tlv_put(msg, OAP_RAND_IE, sizeof(oap_msg->rand), oap_msg->rand);
if (oap_msg->autn_present)
msgb_tlv_put(msg, OAP_AUTN_IE, sizeof(oap_msg->autn), oap_msg->autn);
if (oap_msg->auts_present)
msgb_tlv_put(msg, OAP_AUTS_IE, sizeof(oap_msg->auts), oap_msg->auts);
if (oap_msg->xres_present)
msgb_tlv_put(msg, OAP_XRES_IE, sizeof(oap_msg->xres), oap_msg->xres);
msg->l2h = msg->data;
}

View File

@@ -20,6 +20,7 @@
*/
#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
#include <osmocom/core/utils.h>
#include <openbsc/sgsn.h>
#include <openbsc/gprs_sgsn.h>
#include <openbsc/gprs_gmm.h>
@@ -62,7 +63,7 @@ int sgsn_acl_add(const char *imsi, struct sgsn_config *cfg)
acl = talloc_zero(NULL, struct imsi_acl_entry);
if (!acl)
return -ENOMEM;
strncpy(acl->imsi, imsi, sizeof(acl->imsi) - 1);
osmo_strlcpy(acl->imsi, imsi, sizeof(acl->imsi));
llist_add(&acl->list, &cfg->imsi_acl);

View File

@@ -59,6 +59,15 @@
#include <gtp.h>
#include <pdp.h>
/* TS 23.003: The MSISDN shall take the dummy MSISDN value composed of
* 15 digits set to 0 (encoded as an E.164 international number) when
* the MSISDN is not available in messages in which the presence of the
* MSISDN parameter */
static const uint8_t dummy_msisdn[] =
{ 0x91, /* No extension, international, E.164 */
0, 0, 0, 0, 0, 0, 0, /* 14 digits of zeroes */
0xF0 /* 15th digit of zero + padding */ };
const struct value_string gtp_cause_strs[] = {
{ GTPCAUSE_REQ_IMSI, "Request IMSI" },
{ GTPCAUSE_REQ_IMEI, "Request IMEI" },
@@ -167,12 +176,16 @@ struct sgsn_pdp_ctx *sgsn_create_pdp_ctx(struct sgsn_ggsn_ctx *ggsn,
/* IMSI, TEID/TEIC, FLLU/FLLC, TID, NSAPI set in pdp_newpdp */
/* Put the MSISDN in case we have it */
if (mmctx->subscr) {
if (mmctx->subscr && mmctx->subscr->sgsn_data->msisdn_len) {
pdp->msisdn.l = mmctx->subscr->sgsn_data->msisdn_len;
if (pdp->msisdn.l > sizeof(pdp->msisdn.v))
pdp->msisdn.l = sizeof(pdp->msisdn.v);
memcpy(pdp->msisdn.v, mmctx->subscr->sgsn_data->msisdn,
pdp->msisdn.l);
} else {
/* use the dummy 15-digits-zero MSISDN value */
pdp->msisdn.l = sizeof(dummy_msisdn);
memcpy(pdp->msisdn.v, dummy_msisdn, pdp->msisdn.l);
}
/* End User Address from GMM requested PDP address */
@@ -234,8 +247,12 @@ struct sgsn_pdp_ctx *sgsn_create_pdp_ctx(struct sgsn_ggsn_ctx *ggsn,
memcpy(pdp->gsnlu.v, &sgsn->cfg.gtp_listenaddr.sin_addr,
sizeof(sgsn->cfg.gtp_listenaddr.sin_addr));
/* Routing Area Identifier with LAC and RAC fixed values, as
* requested in 29.006 7.3.1 */
/* Assume we are a GERAN system */
pdp->rattype.l = 1;
pdp->rattype.v[0] = 2;
pdp->rattype_given = 1;
/* Include RAI and ULI all the time */
pdp->rai_given = 1;
pdp->rai.l = 6;
raid = mmctx->ra;
@@ -243,24 +260,10 @@ struct sgsn_pdp_ctx *sgsn_create_pdp_ctx(struct sgsn_ggsn_ctx *ggsn,
raid.rac = 0xFF;
gsm48_construct_ra(pdp->rai.v, &raid);
pdp->rattype.l = 1;
pdp->rattype_given = 1;
switch (mmctx->ran_type) {
case MM_CTX_T_GERAN_Gb:
case MM_CTX_T_GERAN_Iu:
pdp->rattype.v[0] = 2;
/* User Location Information */
pdp->userloc_given = 1;
pdp->userloc.l = 8;
pdp->userloc.v[0] = 0; /* CGI for GERAN */
bssgp_create_cell_id(&pdp->userloc.v[1], &mmctx->ra, mmctx->gb.cell_id);
break;
case MM_CTX_T_UTRAN_Iu:
pdp->rattype.v[0] = 1;
/* FIXME: Optional User Location Information with SAI */
break;
}
pdp->userloc_given = 1;
pdp->userloc.l = 8;
pdp->userloc.v[0] = 0; /* CGI for GERAN */
bssgp_create_cell_id(&pdp->userloc.v[1], &mmctx->ra, mmctx->gb.cell_id);
/* include the IMEI(SV) */
pdp->imeisv_given = 1;
@@ -673,7 +676,7 @@ static int cb_data_ind(struct pdp_t *lib, void *packet, unsigned int len)
msgb_bvci(msg) = mm->gb.bvci;
msgb_nsei(msg) = mm->gb.nsei;
switch (mm->mm_state) {
switch (mm->gmm_state) {
case GMM_REGISTERED_SUSPENDED:
/* initiate PS PAGING procedure */
memset(&pinfo, 0, sizeof(pinfo));
@@ -692,7 +695,7 @@ static int cb_data_ind(struct pdp_t *lib, void *packet, unsigned int len)
break;
default:
LOGP(DGPRS, LOGL_ERROR, "GTP DATA IND for TLLI %08X in state "
"%u\n", mm->gb.tlli, mm->mm_state);
"%u\n", mm->gb.tlli, mm->gmm_state);
msgb_free(msg);
return -1;
}

View File

@@ -163,7 +163,6 @@ static void signal_handler(int signal)
/* NSI that BSSGP uses when transmitting on NS */
extern struct gprs_ns_inst *bssgp_nsi;
extern void *tall_msgb_ctx;
extern int bsc_vty_go_parent(struct vty *vty);
@@ -328,7 +327,7 @@ int main(int argc, char **argv)
srand(time(NULL));
tall_bsc_ctx = talloc_named_const(NULL, 0, "osmo_sgsn");
tall_msgb_ctx = talloc_named_const(tall_bsc_ctx, 0, "msgb");
msgb_talloc_ctx_init(tall_bsc_ctx, 0);
signal(SIGINT, &signal_handler);
signal(SIGABRT, &signal_handler);
@@ -389,8 +388,6 @@ int main(int argc, char **argv)
/* start control interface after reading config for
* ctrl_vty_get_bind_addr() */
LOGP(DGPRS, LOGL_NOTICE, "CTRL at %s %d\n",
ctrl_vty_get_bind_addr(), OSMO_CTRL_PORT_SGSN);
ctrl = sgsn_controlif_setup(NULL, ctrl_vty_get_bind_addr(),
OSMO_CTRL_PORT_SGSN);
if (!ctrl) {

View File

@@ -1,5 +1,5 @@
/*
* (C) 2010-2013 by Harald Welte <laforge@gnumonks.org>
* (C) 2010-2016 by Harald Welte <laforge@gnumonks.org>
* (C) 2010 by On-Waves
* (C) 2015 by Holger Hans Peter Freyther
* All Rights Reserved
@@ -34,7 +34,7 @@
#include <osmocom/gprs/gprs_ns.h>
#include <openbsc/gprs_sgsn.h>
#include <openbsc/vty.h>
#include <openbsc/gprs_gsup_client.h>
#include <openbsc/gsup_client.h>
#include <osmocom/vty/command.h>
#include <osmocom/vty/vty.h>
@@ -63,7 +63,7 @@ const struct value_string sgsn_auth_pol_strs[] = {
#define GSM0408_T3360_SECS 6 /* waiting for AUTH/CIPH RESP */
#define GSM0408_T3370_SECS 6 /* waiting for ID RESP */
/* Section 11.2.2 / Table 11.4a MM timers netwokr side */
/* Section 11.2.2 / Table 11.4a MM timers network side */
#define GSM0408_T3313_SECS 30 /* waiting for paging response */
#define GSM0408_T3314_SECS 44 /* force to STBY on expiry, Ready timer */
#define GSM0408_T3316_SECS 44
@@ -442,18 +442,37 @@ const struct value_string gprs_mm_st_strs[] = {
{ 0, NULL }
};
static char *gtp_ntoa(struct ul16_t *ul)
{
if (ul->l == 4) {
struct in_addr *ia = (struct in_addr *) ul;
return inet_ntoa(*ia);
} else {
return "UNKNOWN";
}
}
static void vty_dump_pdp(struct vty *vty, const char *pfx,
struct sgsn_pdp_ctx *pdp)
{
const char *imsi = pdp->mm ? pdp->mm->imsi : "(detaching)";
vty_out(vty, "%sPDP Context IMSI: %s, SAPI: %u, NSAPI: %u%s",
pfx, imsi, pdp->sapi, pdp->nsapi, VTY_NEWLINE);
vty_out(vty, "%sPDP Context IMSI: %s, SAPI: %u, NSAPI: %u, TI: %u%s",
pfx, imsi, pdp->sapi, pdp->nsapi, pdp->ti, VTY_NEWLINE);
vty_out(vty, "%s APN: %s%s", pfx,
gprs_apn2str(pdp->lib->apn_use.v, pdp->lib->apn_use.l),
VTY_NEWLINE);
vty_out(vty, "%s PDP Address: %s%s", pfx,
gprs_pdpaddr2str(pdp->lib->eua.v, pdp->lib->eua.l),
VTY_NEWLINE);
vty_out(vty, "%s GTP Local Control(%s / TEIC: 0x%08x) ", pfx,
gtp_ntoa(&pdp->lib->gsnlc), pdp->lib->teic_own);
vty_out(vty, "Data(%s / TEID: 0x%08x)%s",
gtp_ntoa(&pdp->lib->gsnlu), pdp->lib->teid_own, VTY_NEWLINE);
vty_out(vty, "%s GTP Remote Control(%s / TEIC: 0x%08x) ", pfx,
gtp_ntoa(&pdp->lib->gsnrc), pdp->lib->teic_gn);
vty_out(vty, "Data(%s / TEID: 0x%08x)%s",
gtp_ntoa(&pdp->lib->gsnru), pdp->lib->teid_gn, VTY_NEWLINE);
vty_out_rate_ctr_group(vty, " ", pdp->ctrg);
}
@@ -466,7 +485,7 @@ static void vty_dump_mmctx(struct vty *vty, const char *pfx,
pfx, mm->msisdn, mm->gb.tlli, mm->hlr, VTY_NEWLINE);
vty_out(vty, "%s MM State: %s, Routeing Area: %u-%u-%u-%u, "
"Cell ID: %u%s", pfx,
get_value_string(gprs_mm_st_strs, mm->mm_state),
get_value_string(gprs_mm_st_strs, mm->gmm_state),
mm->ra.mcc, mm->ra.mnc, mm->ra.lac, mm->ra.rac,
mm->gb.cell_id, VTY_NEWLINE);
@@ -677,15 +696,30 @@ static void subscr_dump_full_vty(struct vty *vty, struct gsm_subscriber *subscr,
vty_out(vty, " A3A8 tuple (used %d times): ",
at->use_count);
vty_out(vty, " seq # : %d, ",
vty_out(vty, " CKSN: %d, ",
at->key_seq);
vty_out(vty, " RAND : %s, ",
osmo_hexdump(at->vec.rand, sizeof(at->vec.rand)));
vty_out(vty, " SRES : %s, ",
osmo_hexdump(at->vec.sres, sizeof(at->vec.sres)));
vty_out(vty, " Kc : %s%s",
osmo_hexdump(at->vec.kc, sizeof(at->vec.kc)),
VTY_NEWLINE);
if (at->vec.auth_types & OSMO_AUTH_TYPE_GSM) {
vty_out(vty, "RAND: %s, ",
osmo_hexdump(at->vec.rand,
sizeof(at->vec.rand)));
vty_out(vty, "SRES: %s, ",
osmo_hexdump(at->vec.sres,
sizeof(at->vec.sres)));
vty_out(vty, "Kc: %s%s",
osmo_hexdump(at->vec.kc,
sizeof(at->vec.kc)), VTY_NEWLINE);
}
if (at->vec.auth_types & OSMO_AUTH_TYPE_UMTS) {
vty_out(vty, " AUTN: %s, ",
osmo_hexdump(at->vec.autn,
sizeof(at->vec.autn)));
vty_out(vty, "RES: %s, ",
osmo_hexdump(at->vec.res, at->vec.res_len));
vty_out(vty, "IK: %s, ",
osmo_hexdump(at->vec.ik, sizeof(at->vec.ik)));
vty_out(vty, "CK: %s, ",
osmo_hexdump(at->vec.ck, sizeof(at->vec.ck)));
}
}
llist_for_each_entry(pdp, &subscr->sgsn_data->pdp_list, list) {

View File

@@ -48,10 +48,9 @@ ipaccess_config_SOURCES = \
# FIXME: resolve the bogus dependencies patched around here:
ipaccess_config_LDADD = \
$(top_builddir)/src/libbsc/libbsc.a \
$(top_builddir)/src/libxsc/libxsc.a \
$(top_builddir)/src/libcommon-cs/libcommon-cs.a \
$(top_builddir)/src/libtrau/libtrau.a \
$(top_builddir)/src/libcommon/libcommon.a \
$(LIBCRYPT) \
$(OSMO_LIBS) \
$(NULL)

View File

@@ -138,8 +138,8 @@ static int read_response(int fd)
if (len < 0)
return len;
/* 2 bytes length, 1 byte protocol (0xfe) */
if (buf[2] != 0xfe)
/* 2 bytes length, 1 byte protocol */
if (buf[2] != IPAC_PROTO_IPACCESS)
return 0;
if (buf[4] != IPAC_MSGT_ID_RESP)
@@ -194,7 +194,11 @@ int main(int argc, char **argv)
exit(1);
}
osmo_fd_register(&bfd);
rc = osmo_fd_register(&bfd);
if (rc < 0) {
fprintf(stderr, "Cannot register FD\n");
exit(1);
}
timer.cb = timer_cb;
timer.data = &bfd;

Some files were not shown because too many files have changed in this diff Show More