Commit Graph

4173 Commits

Author SHA1 Message Date
Holger Hans Peter Freyther 14d1177735 Merge branch 'zecke/features/big-rewrite' 2013-07-31 16:41:22 +02:00
Holger Hans Peter Freyther 52f705eaab nat: Use the DCC region for number rewriting and increase debug output 2013-07-31 16:36:40 +02:00
Holger Hans Peter Freyther 67e423c256 nat: Implement a post-routing for the NAT software
* The post-routing is applied after the first re-writing. To do this
  the new number is copied back into the called data structure.

* Add a testcase that goes from 0172 to 0049 and then back to 0049
  using the post rule with a table lookup.
2013-07-31 16:36:40 +02:00
Holger Hans Peter Freyther 3615a30d3d nat: Fix some memory leaks in the testcases.
The test cases did not free some of the resources it allocated.
Improve the situation a bit. There is still data allocated that
is not freed at exit.
2013-07-31 16:36:40 +02:00
Holger Hans Peter Freyther ddf191eafc nat: Allow to use the prefix lookup to rewrite numbers
* Increase the rewritten rule to five digits (this is the easiest
  for the unit test). This will add another 40kb to the runtime size.

* Create a unit test that tests adding and removing the prefix rules.

* Use the regexp match to replace from one package
2013-07-31 16:36:40 +02:00
Holger Hans Peter Freyther 85d3b34ed2 nat: Introduce a prefix lookup tree (trie) for number rewriting
* It is a trie. The max depth of the trie is the length of the
longest prefix. The lookup is O(lookuped_prefix), but as the prefix
length is limited, the lookup time is constant.

* Each node can hold the entire prefix, has place for the rewrite
  rule with up to three digits.

* A trie with 20k entries will take about 3MB ram.

* Filling the trie 100 times takes ~800ms on my i7 laptop

* 10.000.000 lookups take 315ms.. (for the same prefix).

* 93/99 lines are tested, 6/6 functions are tested, 49 of 54 branches
  are tested. Only memory allocation failures are not covered

* A late addition is to handle the '+' sign and to increase the number
  of chars in the rewrite prefix. The timing/line coverage has not
  been updated after this change.
2013-07-31 16:36:40 +02:00
Holger Hans Peter Freyther b718ad397e nat: Add a no number-rewrite command and call it through a VTY test
The test is just testing the invocation but does not verify that
the side effect of this call. It is good enought for now.
2013-07-31 16:36:13 +02:00
Holger Hans Peter Freyther aa93bac34b gprs_gmm: Avoid assertion in the sending code during routing area update
Use old and new tlli as specified by the caller.

WIP

<000f> sgsn_libgtp.c:321 Received DELETE PDP CTX CONF, cause=128(Request accepted)
<0013> gprs_sndcp.c:320 SNSM-DEACTIVATE.ind (lle=0x8095d08, TLLI=e3ddd574, SAPI=11, NSAPI=5)
<0011> gprs_bssgp.c:376 BSSGP TLLI=0xe3ddd574 Rx UPLINK-UNITDATA
<0012> gprs_llc.c:551 LLC SAPI=1 C   FCS=0xb85a96CMD=UI DATA
<0011> gprs_bssgp.c:376 BSSGP TLLI=0xe3ddd574 Rx UPLINK-UNITDATA
<0012> gprs_llc.c:551 LLC SAPI=1 C   FCS=0xbe5a96CMD=UI DATA
<0002> gprs_gmm.c:214 Starting MM timer 3350 while old timer 3350 pending
<0012> gprs_llc.c:417 LLC TX: unknown TLLI 0xe3ddd574, creating LLME on the fly
Assert failed msgb_tlli(msg) == mmctx->llme->tlli || msgb_tlli(msg) == mmctx->llme->old_tlli || tlli_foreign2local(msgb_tlli(msg)) == mmctx->llme->tlli || tlli_foreign2local(msgb_tlli(msg)) == mmctx->llme->old_tlli gprs_llc.c:123
backtrace() returned 18 addresses
/home/ich/install/openbsc/lib/libosmocore.so.4(osmo_generate_backtrace+0x16) [0xb7bb6a36]
/home/ich/source/gsm/openbsc/openbsc/src/gprs/osmo-sgsn() [0x805224a]
/home/ich/source/gsm/openbsc/openbsc/src/gprs/osmo-sgsn() [0x804a2f6]
/home/ich/source/gsm/openbsc/openbsc/src/gprs/osmo-sgsn() [0x804b687]
/home/ich/source/gsm/openbsc/openbsc/src/gprs/osmo-sgsn() [0x804bc35]
/home/ich/source/gsm/openbsc/openbsc/src/gprs/osmo-sgsn() [0x804bd4e]
/home/ich/source/gsm/openbsc/openbsc/src/gprs/osmo-sgsn() [0x804d20c]
/home/ich/source/gsm/openbsc/openbsc/src/gprs/osmo-sgsn() [0x8052be4]
/home/ich/source/gsm/openbsc/openbsc/src/gprs/osmo-sgsn(bssgp_prim_cb+0x55) [0x804f5a4]
/home/ich/install/openbsc/lib/libosmogb.so.2(bssgp_rcvmsg+0x3b8) [0xb7b626b8]
/home/ich/source/gsm/openbsc/openbsc/src/gprs/osmo-sgsn() [0x804f4f1]
/home/ich/install/openbsc/lib/libosmogb.so.2(gprs_ns_rcvmsg+0x8c7) [0xb7b5ecf7]
/home/ich/install/openbsc/lib/libosmogb.so.2(+0x4311) [0xb7b5f311]
/home/ich/install/openbsc/lib/libosmocore.so.4(osmo_select_main+0x192) [0xb7bb2ed2]
/home/ich/source/gsm/openbsc/openbsc/src/gprs/osmo-sgsn() [0x804fbcd]
/lib/i386-linux-gnu/i686/cmov/libc.so.6(__libc_start_main+0xf5) [0xb796a8f5]
/home/ich/source/gsm/openbsc/openbsc/src/gprs/osmo-sgsn() [0x8049db1]

Program received signal SIGABRT, Aborted.
0xb7fde424 in __kernel_vsyscall ()
(gdb) bt
 #0  0xb7fde424 in __kernel_vsyscall ()
 #1  0xb797f83f in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
 #2  0xb7982cf3 in __GI_abort () at abort.c:90
 #3  0x0805224f in _bssgp_tx_dl_ud (mmctx=0x80932d0, msg=0x80963a8) at gprs_llc.c:120
 #4  gprs_llc_tx_ui (msg=0x80963a8, sapi=1 '\001', command=0, mmctx=0x80932d0)
    at gprs_llc.c:496
 #5  0x0804a2f6 in gsm48_gmm_sendmsg (msg=0x80963a8, command=0, mm=0x80932d0) at gprs_gmm.c:241
 #6  0x0804b687 in gsm48_tx_gmm_ra_upd_ack (mm=0x80932d0) at gprs_gmm.c:851
 #7  0x0804bc35 in gsm48_rx_gmm_ra_upd_req (mmctx=0x80932d0, msg=0x8091ce8, llme=0x8095630)
    at gprs_gmm.c:1004
 #8  0x0804bd4e in gsm0408_rcv_gmm (mmctx=0x80932d0, msg=0x8091ce8, llme=0x8095630)
    at gprs_gmm.c:1036
 #9  0x0804d20c in gsm0408_gprs_rcvmsg (msg=msg@entry=0x8091ce8, llme=0x8095630)
    at gprs_gmm.c:1566
 #10 0x08052be4 in gprs_llc_rcvmsg (msg=0x8091ce8, tv=0xbfffdcb0) at gprs_llc.c:882
 #11 0x0804f5a4 in bssgp_prim_cb (oph=oph@entry=0xbfffdc8c, ctx=ctx@entry=0x0)
    at sgsn_main.c:114
 #12 0xb7b626b8 in bssgp_rx_ul_ud (tp=0xbfffdcb0, msg=0x8091ce8, ctx=<optimized out>)
    at gprs_bssgp.c:398
 #13 bssgp_rx_ptp (bctx=0x8091a08, tp=0xbfffdcb0, msg=0x8091ce8) at gprs_bssgp.c:820
 #14 bssgp_rcvmsg (msg=0x8091ce8) at gprs_bssgp.c:1016
 #15 0x0804f4f1 in sgsn_ns_cb (event=GPRS_NS_EVT_UNIT_DATA, nsvc=0x8090740, msg=0x8091ce8,
    bvci=1801) at sgsn_main.c:92
 #16 0xb7b5ecf7 in gprs_ns_rx_unitdata (msg=0x8091ce8, nsvc=0x8090740) at gprs_ns.c:616
 #17 gprs_ns_rcvmsg (nsi=nsi@entry=0x807fd38, msg=msg@entry=0x8091ce8,
    saddr=saddr@entry=0xbfffedc0, ll=ll@entry=GPRS_NS_LL_UDP) at gprs_ns.c:841
 #18 0xb7b5f311 in handle_nsip_read (bfd=0x807fd58) at gprs_ns.c:991
 #19 nsip_fd_cb (bfd=0x807fd58, what=1) at gprs_ns.c:1024
 #20 0xb7bb2ed2 in osmo_select_main (polling=0) at select.c:158
 #21 0x0804fbcd in main (argc=3, argv=0xbffff234) at sgsn_main.c:369
(gdb) frame 5
 #5  0x0804a2f6 in gsm48_gmm_sendmsg (msg=0x80963a8, command=0, mm=0x80932d0) at gprs_gmm.c:241
241		return gprs_llc_tx_ui(msg, GPRS_SAPI_GMM, command, mm);
(gdb) p msgb_tlli(msg)
$1 = 3822966132
(gdb) frame 4
 #4  gprs_llc_tx_ui (msg=0x80963a8, sapi=1 '\001', command=0, mmctx=0x80932d0)
    at gprs_llc.c:496
496		return _bssgp_tx_dl_ud(msg, mmctx);
(gdb) p mmctx
$2 = (void *) 0x80932d0
(gdb) frame 3
 #3  0x0805224f in _bssgp_tx_dl_ud (mmctx=0x80932d0, msg=0x80963a8) at gprs_llc.c:120
120			OSMO_ASSERT(msgb_tlli(msg) == mmctx->llme->tlli
(gdb) p mmctx
$3 = (struct sgsn_mm_ctx *) 0x80932d0
(gdb) p *mmctx
$4 = {list = {next = 0x8092e28, prev = 0x805c318 <sgsn_mm_ctxts>},
  imsi = "901700000003094\000", mm_state = GMM_REGISTERED_NORMAL, p_tmsi = 296043751,
  p_tmsi_old = 2075232571, p_tmsi_sig = 0, imei = "353943044782210\000",
  msisdn = '\000' <repeats 14 times>, ra = {mnc = 70, mcc = 901, lac = 1, rac = 0 '\000'},
  cell_id = 0, cell_id_age = 0, sac = 0, sac_age = 0, new_sgsn_addr = 0,
  ciph_algo = GPRS_ALGO_GEA0, ms_radio_access_capa = {len = 11 '\v',
    buf = "4\307\003*\240B|\255\341\030\v", '\000' <repeats 38 times>}, ms_network_capa = {
    len = 2 '\002', buf = "\345\200\000\000\000\000\000"}, drx_parms = 3329, mnrg = 0,
  ngaf = 0, ppf = 0, recovery = 0, radio_prio_sms = 0 '\000', pdp_list = {next = 0x8093390,
    prev = 0x8093390}, llme = 0x8095630, tlli = 3822966132, tlli_new = 3517269223,
  nsei = 1801, bvci = 1801, ctrg = 0x8096048, timer = {node = {rb_parent_color = 3082574944,
      rb_right = 0x0, rb_left = 0x0}, list = {next = 0x80933b8, prev = 0x80933b8}, timeout = {
      tv_sec = 1375260414, tv_usec = 864196}, active = 1, cb = 0x804bfd0 <mmctx_timer_cb>,
    data = 0x80932d0}, T = 3350, num_T_exp = 0, t3350_mode = GMM_T3350_MODE_RAU,
  t3370_id_type = 1 '\001'}
(gdb) p msgb_tlli(msg)
No symbol "msgb_tlli" in current context.
(gdb) frame 5
 #5  0x0804a2f6 in gsm48_gmm_sendmsg (msg=0x80963a8, command=0, mm=0x80932d0) at gprs_gmm.c:241
241		return gprs_llc_tx_ui(msg, GPRS_SAPI_GMM, command, mm);
(gdb) frame 6
 #6  0x0804b687 in gsm48_tx_gmm_ra_upd_ack (mm=0x80932d0) at gprs_gmm.c:851
851		return gsm48_gmm_sendmsg(msg, 0, mm);
(gdb) p msgb_tlli(msg)
$5 = 3822966132
(gdb) p mmctx->tlli
No symbol "mmctx" in current context.
(gdb) p mm->tlli
$6 = 3822966132
(gdb) p mm->tlli_new
$7 = 3517269223
(gdb) p mm->llme->tlli
$8 = 3517269223
(gdb) p mm->llme->tlli_old
There is no member named tlli_old.
(gdb) p mm->llme->old_tlli
$9 = 4222716219
(gdb) bt
 #0  0xb7fde424 in __kernel_vsyscall ()
 #1  0xb797f83f in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
 #2  0xb7982cf3 in __GI_abort () at abort.c:90
 #3  0x0805224f in _bssgp_tx_dl_ud (mmctx=0x80932d0, msg=0x80963a8) at gprs_llc.c:120
 #4  gprs_llc_tx_ui (msg=0x80963a8, sapi=1 '\001', command=0, mmctx=0x80932d0)
    at gprs_llc.c:496
 #5  0x0804a2f6 in gsm48_gmm_sendmsg (msg=0x80963a8, command=0, mm=0x80932d0) at gprs_gmm.c:241
 #6  0x0804b687 in gsm48_tx_gmm_ra_upd_ack (mm=0x80932d0) at gprs_gmm.c:851
 #7  0x0804bc35 in gsm48_rx_gmm_ra_upd_req (mmctx=0x80932d0, msg=0x8091ce8, llme=0x8095630)
    at gprs_gmm.c:1004
 #8  0x0804bd4e in gsm0408_rcv_gmm (mmctx=0x80932d0, msg=0x8091ce8, llme=0x8095630)
    at gprs_gmm.c:1036
 #9  0x0804d20c in gsm0408_gprs_rcvmsg (msg=msg@entry=0x8091ce8, llme=0x8095630)
    at gprs_gmm.c:1566
 #10 0x08052be4 in gprs_llc_rcvmsg (msg=0x8091ce8, tv=0xbfffdcb0) at gprs_llc.c:882
 #11 0x0804f5a4 in bssgp_prim_cb (oph=oph@entry=0xbfffdc8c, ctx=ctx@entry=0x0)
    at sgsn_main.c:114
 #12 0xb7b626b8 in bssgp_rx_ul_ud (tp=0xbfffdcb0, msg=0x8091ce8, ctx=<optimized out>)
    at gprs_bssgp.c:398
 #13 bssgp_rx_ptp (bctx=0x8091a08, tp=0xbfffdcb0, msg=0x8091ce8) at gprs_bssgp.c:820
 #14 bssgp_rcvmsg (msg=0x8091ce8) at gprs_bssgp.c:1016
 #15 0x0804f4f1 in sgsn_ns_cb (event=GPRS_NS_EVT_UNIT_DATA, nsvc=0x8090740, msg=0x8091ce8,
    bvci=1801) at sgsn_main.c:92
 #16 0xb7b5ecf7 in gprs_ns_rx_unitdata (msg=0x8091ce8, nsvc=0x8090740) at gprs_ns.c:616
 #17 gprs_ns_rcvmsg (nsi=nsi@entry=0x807fd38, msg=msg@entry=0x8091ce8,
    saddr=saddr@entry=0xbfffedc0, ll=ll@entry=GPRS_NS_LL_UDP) at gprs_ns.c:841
 #18 0xb7b5f311 in handle_nsip_read (bfd=0x807fd58) at gprs_ns.c:991
 #19 nsip_fd_cb (bfd=0x807fd58, what=1) at gprs_ns.c:1024
 #20 0xb7bb2ed2 in osmo_select_main (polling=0) at select.c:158
 #21 0x0804fbcd in main (argc=3, argv=0xbffff234) at sgsn_main.c:369
(gdb) frame 3
 #3  0x0805224f in _bssgp_tx_dl_ud (mmctx=0x80932d0, msg=0x80963a8) at gprs_llc.c:120
120			OSMO_ASSERT(msgb_tlli(msg) == mmctx->llme->tlli
(gdb) p msgb_tlli(msg)
No symbol "msgb_tlli" in current context.
(gdb) frame 4
 #4  gprs_llc_tx_ui (msg=0x80963a8, sapi=1 '\001', command=0, mmctx=0x80932d0)
    at gprs_llc.c:496
496		return _bssgp_tx_dl_ud(msg, mmctx);
(gdb) p msgb_tlli(msg)
No symbol "msgb_tlli" in current context.
(gdb) frame 5
 #5  0x0804a2f6 in gsm48_gmm_sendmsg (msg=0x80963a8, command=0, mm=0x80932d0) at gprs_gmm.c:241
241		return gprs_llc_tx_ui(msg, GPRS_SAPI_GMM, command, mm);
(gdb) p msgb_tlli(msg)
$10 = 3822966132
(gdb) p mm->tlli
$11 = 3822966132
(gdb) p mm->tlli_new
$12 = 3517269223
(gdb) p mm->tlli_new
$13 = 3517269223
(gdb) p mm->llme->tlli
$14 = 3517269223
(gdb) p mm->llme->tlli_old
There is no member named tlli_old.
(gdb) p mm->llme->old_tlli
$15 = 4222716219
(gdb) p mm->llme->state
$16 = GPRS_LLMS_ASSIGNED
(gdb) q
2013-07-31 16:12:02 +02:00
Holger Hans Peter Freyther 7e0fec17ce gprs_llc: Assert that we send frames with either tlli or old_tlli
In case we have access to the context verify that the selected
msgb_tlli is either the old_tlli or the tlli in either local or
foreign format. It is wrong to use any other TLLI.
2013-07-31 14:57:21 +02:00
Holger Hans Peter Freyther 964a9b3e20 gprs_llc: Work on finding the right LLE/LLME in case of routing area update
Attempt to solve what f0901f0067 tried to
solve without breaking the case of someone with a foreign TLLI from a
different network.

Lookup with the foreign TLLI converted to a local one in case we did
not find the TLLI and only then create a LLE/LLME on the fly for the
RX path.
2013-07-31 14:57:21 +02:00
Holger Hans Peter Freyther 012a7eec29 gprs_llc: Lookup lle based on the real TLLI
During the GPRS Attach procedure we might have a foreign tlli and
in the RX create a LLME on the fly for this tlli. The GMM GPRS
Attach handling code will then assign a new TLLI and keep the
foreign tlli as the llme->old_tlli.

When the GMM is sending the identity request the msgb_tlli will
point to the foreign tlli. The GPRS LLC code will then try to find
that foreign tlli but due the conversion this will not be found.
Instead a new ad-hoc LLE/LLME will be created on the fly for
each message (this means there are duplicate LLE/LLMEs in the
list).

Make the code more strict and remove the tlli_foreign2local change
from the look-up routine. This will make the GPRS LLC code find
the right LLE/LLME and the N(U) will be handled correctly.

This partially reverts:
  f0901f0067

Addresses:
  <0012> gprs_llc.c:773 LLC RX: unknown TLLI 0xadf11820, creating LLME on the fly
  ...
  <0012> gprs_llc.c:357 LLC TX: unknown TLLI 0xedf11820, creating LLME on the fly

Reproducable:
  Use pcu_emu (gprs attach) and observe with wireshark.
2013-07-31 14:57:21 +02:00
Holger Hans Peter Freyther 598e7b3cdf gprs_sgsn: In case of a Activate PDP Context timeout we should free pdp
In case of a failure this method didn't set the pctx->lib back to
NULL. In case of a timeout the callback will be made with pdp=NULL
and this would lead to leaking the PDP context. Check for the case
of having a pctx->lib != pdp and free it.

This resolves:
<000f> gprs_sgsn.c:259 freeing PDP context that still has a libgtp handle attached to it, this shouldn't happen!
2013-07-31 14:57:21 +02:00
Holger Hans Peter Freyther 92aa6bb9dc gprs: Fix a typo in the comment 2013-07-28 20:13:01 +02:00
Holger Hans Peter Freyther c0438e3587 tests: TestCase.assertGreater is not available on Python 2.5
The jenkins build node has Python 2.5.X installed and the
assertGreater method is not available. Use assert_ until
we can use newer versions of Python.
2013-07-27 22:23:25 +02:00
Holger Hans Peter Freyther c63f6f1f32 expiration: Allow to disable the periodic location updating procedure
Disable the periodic LU using "no periodic location update" VTY
command. In that case set the expire_lu to 0 which will then be
translated to a NULL in the database layer. This leads to a bit of
copy and paste in the db_sync_subscriber method but I don't see
how we could easily use 'datetime(%i, 'unixepoch')' and 'NULL'
at the same time.

Change the query to find expired queries to check for NOT NULL
and the time being in the past. This means if there are still
old subscribers in the database they might not be expired. One
would need to execute a query like "UPATE Subscriber SET expire_lu
= 0 WHERE expire_lu is null". The same applies when disabling the
periodic LU. One would need to update the database by hand.

Manual tests executed/passed:

1.) periodic LU enabled:

  * use gst LUTest.st to do a LU
  * UPDATE Subscriber SET expire_lu=datetime('now');
  * observe the subscriber being expired (it was)

2.) periodic LU disabled:

  * use gst LUTest.st to do a LU
  * verify that the expire_lu is NULL in the database
2013-07-27 22:02:24 +02:00
Holger Hans Peter Freyther e7bd863f76 expiration: Speculative fixes for the periodic expiring handling
We were expiring subscribers during active calls. This is because
the T3212 is stopped under certain conditions but we didn't stop
that timer at all.

Remember if T3212 timer was stopped due something done by NITB and
update the expiration time at the end of the radio connection, as
the phone should restart it when returning to MM Idle.

It is a bit difficult to decide when we should set the flag. E.g.
in a CM Service Request we don't know if we accept the service and
during a LU we already send MM messages before we accept or reject
the subscriber.

The easiest is to set the flag when receiving a paging response
on known subscribers and at the end of the authentication process.

Do not expire a subscriber that has an active connection that is
marked with the flag, e.g. we would still expire a subscriber that
is being paged.

Manual tests executed/passed:

 * gst LUTest.st verified that a expiration date was set
 * gst SMSTest.st (doing another LU but forcing a timeout on the
   SMS sending). Verified that the expire_lu was updated.
2013-07-27 21:39:13 +02:00
Holger Hans Peter Freyther b97089432f expiration: Print the "expire_lu" time in show subscriber
This can help with debugging subscriber expiration issues.
2013-07-27 20:03:11 +02:00
Holger Hans Peter Freyther a7328a5642 smpp: Move the coding/mode detection into a utils file
Make sure to not ever have issues with this code again, move the
utility code to a new file and create a basic testcase. The method
currently has 100% line and branch coverage. My initial patched
missed the smpp_utils.c file and I re-did the copying (and verifying
the branch coverage)
2013-07-27 20:03:10 +02:00
Holger Hans Peter Freyther 5ecbc93656 misc: Fix compilation warnings
bsc_api.c:417:3: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 7 has type ‘unsigned int’ [-Wformat]
bsc_api.c: In function ‘handle_ass_fail’:
bsc_api.c:458:3: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 7 has type ‘unsigned int’ [-Wformat]

db.c: In function ‘db_sync_subscriber’:
db.c:785:3: warning: format ‘%i’ expects argument of type ‘int’, but argument 8 has type ‘time_t’ [-Wformat]

osmo_msc.c: In function ‘msc_release_connection’:
osmo_msc.c:145:20: warning: unused variable ‘trans’ [-Wunused-variable]

smpp_smsc.c: In function ‘link_accept_cb’:
smpp_smsc.c:891:24: warning: assignment from incompatible pointer type [enabled by default]

smpp_smsc.c:271:1: warning: ‘esme_by_system_id’ defined but not used [-Wunused-function]

smpp_openbsc.c: In function ‘smpp_openbsc_init’:
smpp_openbsc.c:545:2: warning: implicit declaration of function ‘smpp_vty_init’ [-Wimplicit-function-declaration]

osmo_bsc_ctrl.c: In function ‘verify_bts_loc’:
osmo_bsc_ctrl.c:340:19: warning: variable ‘height’ set but not used [-Wunused-but-set-variable

smpp_mirror.c: In function ‘main’:
smpp_mirror.c:297:2: warning: implicit declaration of function ‘osmo_init_logging’ [-Wimplicit-function-declaration]
2013-07-27 20:03:08 +02:00
Harald Welte 649e1ff4b3 sgsn: spelling fixes inside comments 2013-07-21 17:41:46 +08:00
Harald Welte b4b21f59f6 SMPP: complete the VTY help/documentation
As discovered by osmotestconfig.py, a number of SMPP related VTY
commands were missing their help/documentation text.
2013-07-21 16:00:28 +08:00
Harald Welte badb12f6a6 remove 'bind early' from osmo-bsc_mgcp example config
(discovered by osmotestconfig.py)
2013-07-21 15:52:40 +08:00
Harald Welte 3dfb549a6f sgsn: Add "auth-policy" VTY command to enable/disable ACL 2013-07-21 15:44:28 +08:00
Harald Welte 7f6da485f5 sgsn: add a minimalistic ACL
This adds a minimalistic ACL by which certain, individual roaming IMSIs
can be authorized to use the SGSN.  So you can selectively bypass the
'MCC+MNC == first 5 digits of IMSI' checking for a couple of IMSIs
2013-07-21 15:44:24 +08:00
Holger Hans Peter Freyther cb5353d851 oml: Add a missing break switch for NM_OC_BS11
It appears to me that for NM_OC_BS11 mo was either NULL or the
one mo value from NM_OC_BS11_RACK. The break inside the nested
switch case didn't break from the outer one.

Fixes Coverity: CID 1040728
2013-07-18 12:03:31 +02:00
Holger Hans Peter Freyther 1b624ba1f6 smpp: Close the file descriptor when we can't accept the SMSC conn
When we failed to allocate the memory or failed to register the
fd we would have leaked the file descriptor. Close the fd and
avoid the leak.
2013-07-14 09:04:51 +02:00
Holger Hans Peter Freyther c962d45669 smpp: Add the classic check for osmo_fd_register
In case the osmo_fd_register will fail we will need to free the
memory we have allocated.

Fixes: Coverity CID 1042375
2013-07-14 09:04:51 +02:00
Holger Hans Peter Freyther 921b2278df smpp: Fix possible NULL dereference of the emse->acl
The esme->acl is treated like it can be NULL in other places
of the code. Assume it can be NULL during this check as well.

Dereference after null check (FORWARD_NULL)
9. var_deref_op: Dereferencing null pointer "esme->acl".

Fixes: Coverity CID 1042374
2013-07-14 09:04:51 +02:00
Holger Hans Peter Freyther ae9d8d3131 smpp: Checking an array for NULL will always be false
The if (submit->short_message) and if (smsc->system_id) will
always be true.

Fixes: Coverity CID 1042371, CID 1042372
2013-07-14 09:04:50 +02:00
Holger Hans Peter Freyther c9251fa8c9 ipaccess: The proxy code checked the array but not the element
Array compared against 0 (NO_EFFECT)
array_null: Comparing an array to null is not useful: "ipbc->bsc_rsl_conn".

Fixes: Coverity CID 1040718
2013-07-14 09:04:50 +02:00
Holger Hans Peter Freyther 3aedba66bd ipaccess: Fix a resource leak in case the stat is failing
Close the file when the stat is failing.

Fixes: Coverity CID 1040711
2013-07-14 09:04:50 +02:00
Holger Hans Peter Freyther 5ccd015371 nitb: The subscr->imsi is an array will never be NULL
Array compared against 0 (NO_EFFECT)
array_null: Comparing an array to null is not useful: "subscr->imsi"

Fixes: Coverity CID 1040716
2013-07-14 09:04:50 +02:00
Harald Welte 995ff35f39 Fix license header at smpp_openbsc.c and smpp_smsc.c
As Holger pointed out, they contained a GPLv2+ disclaimer rather than
the AGPLv3+ which we use for OpenBSC.  This is not an incompaibility,
but was done unintentionally.  The code was always mean to be under
AGPLv3+.

Nevertheless, anyone using those two files in a version up to this
commit have the right to use it under GPLv2+ as well.  This is not
applicable for any versions after this commit.
2013-07-13 16:35:32 +02:00
Harald Welte 4c5babc06c smpp_openbsc: Fix parsing of 03.38 data coding scheme in MO case 2013-07-11 14:29:31 +02:00
Andreas Eversberg 641475cb81 Fix: Handle CM service request on already secured channel correctly
A CM service request must be acknowledged also, when encryption is already
enabled.

Without encryption enabled, the security status is GSM_SECURITY_NOTAVAIL,
which causes a CM service acknowledge. On initial CM service request, the
security status is GSM_SECURITY_SUCCEED, if encryption is enabled. This
will not lead to an acknowledge, because the cyphering command implies an
acknowlege. An additional CM service request requires an acknowledge, so
I added a new security status: GSM_SECURITY_ALREADY
2013-07-11 08:27:26 +02:00
Pablo Neira Ayuso 46bd4244a1 libmgcp: add enum mgcp_type and use it
This patch replaces the field 'is_transcoded' in the mgcp_endpoint
structure by the enum mgcp_type, that can be further extended with
new types.
2013-07-08 16:46:06 +02:00
Holger Hans Peter Freyther 1e61b25661 mncc: Remove what we believe to be a tautology from the MNCC code
Coverity pointed out that we use trans->subscr after a NULL check,
it is our believe that every transaction will have a subscriber.
Remove the check and add an assert before we are dispatching things.

Fixes: Coverity CID 1040740, CID 1040739
2013-07-06 11:45:38 +02:00
Holger Hans Peter Freyther 096dc3a466 nat: The con variable is not assigned at this point
Coverity pointed out that this code is logically dead. Quickly
judging the code we will forward the RSLD message anyway. Remove
the code for now and next time I work on the NAT/USSD bridge I
will have a look at the flow of the RLSD messages.

Fixes: Coverity CID 1042327
2013-07-05 08:22:03 +02:00
Holger Hans Peter Freyther 7346081ba3 nat: number could point to an address on the stack that can be reused
The number = int_number assignment will make the number point to
the stack and as the int_number goes out of scope at the end of
the if statement other code could re-use this stack for other memory.

Fixes: Coverity CID 1042325
2013-07-05 07:50:30 +02:00
Holger Hans Peter Freyther 9bec10ecd3 nat: Address coverity warning about uninitialized addr
Use memset on the addr to initialize the entire structure.

Fixes: Coverity CID 1042324
2013-07-05 07:48:04 +02:00
Holger Hans Peter Freyther b0b8a34dd5 nat: Please coverity and initialize the saveptr to NULL
Coverity complains about the saveptr used in the strtok_r. This
is not a bug because we pass a string as part of the first call
to strtok_r but it is easier to just initialize it.

Addresses: Coverity CID 1042323
2013-07-05 07:45:08 +02:00
Holger Hans Peter Freyther 9feef48eaf nitb: Add a missing NULL check for searching the subscriber
"subscriber " SUBSCR_TYPES " ID sms pending-send

could fail with an invalid ID/IMSI for the subscriber.

Fixes: Coverity CID 1040715
2013-07-04 20:34:46 +02:00
Holger Hans Peter Freyther e885951f27 db: Fix an issue with the memset
We want to memset the entire area of the atuple and not just the
first four/eight bytes of the data.

Fixes: Coverity CID 1040708
2013-07-04 20:24:02 +02:00
Holger Hans Peter Freyther 81cff91ec0 gsm_subscriber: Fix compiler warning of the printf string
This fixes both a GCC and a Coverity warning:

GCC:
gsm_subscriber.c: In function ‘subscr_expire_callback’:
gsm_subscriber.c:389:2: warning: format ‘%i’ expects argument of type ‘int’, but argument 8 has type ‘long long unsigned int’ [-Wformat]

Coverity:
CID 1040712
2013-07-04 20:22:27 +02:00
Holger Hans Peter Freyther 7b76934f03 nat: The second call didn't really add anything to the test.
Avoid: Coverity CID 1042323
2013-07-04 20:19:44 +02:00
Holger Hans Peter Freyther b18c7456cb ipaccess-config: Add missing break to parsing the -L option
Fixes: Coverity CID 1040738
2013-07-04 18:51:07 +02:00
Holger Hans Peter Freyther 7d8139a42e ipaccess-config: Fix a resource leak in an error path
Fixes: Coverity CID 1040710, CID 1040711
2013-07-04 18:49:04 +02:00
Holger Hans Peter Freyther aa63d70f39 sgsn: Fix the unimplemented/uninstalled show ggsn command
This is fixing a GCC and Coverity warning.

GCC:
sgsn_vty.c: At top level:
sgsn_vty.c:308:1: warning: ‘show_ggsn_cmd’ defined but not used [-Wunused-variable]

Coverity: CID 1040727
2013-07-04 18:45:31 +02:00
Holger Hans Peter Freyther 80e036560d sgsn_vty: Fix uninitialized variable in the gprs_apn2str method
This is fixing a GCC and Coverity warning:

GCC:
sgsn_vty.c: In function ‘vty_dump_pdp’:
sgsn_vty.c:64:5: warning: ‘i’ may be used uninitialized in this function [-Wmaybe-uninitialized]
sgsn_vty.c:49:15: note: ‘i’ was declared here

Coverity: CID 1040706
2013-07-04 18:44:16 +02:00
Holger Hans Peter Freyther 3a708afe63 sgsn: Fix logically dead code in regard to the osmo_fd_register
The code was written like checking the return value of the
osmo_fd_register but the rc variable was not assigned for the
subsequent calls.

Fixes: Coverity CID 1040741
2013-07-04 18:39:52 +02:00