Commit Graph

4106 Commits

Author SHA1 Message Date
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
Alexander Chemeris 84402c0c82 sgsn: Fix lengths of MS Network Capability and MS Radio Access Capability elements.
Original code was inconsistent about lengths and could lead to out
of bounds write. Lengths were also inconsistent with the TS 24.008.

Fixes: Coverity CID 1040714.
2013-07-04 18:34:49 +02:00
Holger Hans Peter Freyther f0167ddfc2 hsl: Remove the support for the HSL bts from OpenBSC
The support has been implemented for an old model, we were told that
newer versions would be made incompatible with OpenBSC. Ther are
various warnings in the code and coverity has found some new ones.

Just remove the code as we don't know of anyone using this code.
2013-07-03 16:19:41 +02:00
Holger Hans Peter Freyther a164d5291e nat: Fix compiler warning and cast uint16_t to uint8_t 2013-07-03 16:18:37 +02:00
Holger Hans Peter Freyther 1eba7de0c2 mgcp: Make sure the save pointer is initialized with NULL.
Coverity is not happy about it but it doesn't appear to be a real
issue as the data will not be NULL on the first call.

Addresses: Coverity CID 1040704
2013-07-03 10:23:35 +02:00
Holger Hans Peter Freyther d5c270e71c ipaccess-find: Address a warning by coverity of unitialized memory
Use a memset on the sockaddr_in to make coverity happy.

Fixes: CID 1040705
2013-07-03 10:19:37 +02:00
Holger Hans Peter Freyther 8690b98e7c isdnsync: Remove a double close of the isdn device
The fd is already closed above the if statement and Coverity
detected this as a double close.

Fixes: Coverity CID 1040703
2013-07-03 10:17:37 +02:00
Holger Hans Peter Freyther 8bb0720ebb nanobts: Do not crash on an invalid TRX number
In case the specified trx number is not configured, do not crash
but return NULL from the function. The libosmo-abis library should
close the connection for us then.
2013-06-30 20:11:46 +02:00
Holger Hans Peter Freyther eb0acb6e02 tests: Add a custom test runner to test the VTY functionality.
Begin with the NAT code. It is not clear yet if we will have one
file with all the tests or will have a sub directory with *.py files.
In the long run the base class will move to the osmo-python-tests
module.
2013-06-24 16:13:55 +02:00
Holger Hans Peter Freyther 9e22e69266 misc: Ignore compiled python code and another test case 2013-06-24 14:04:55 +02:00
Katerina Barone-Adesi e0aee7aaa9 Introduced support for external python tests
The test scripts warn about missing documentation, untested configs,
check common errors, and stub out testing individual VTY commands.
The scripts have been moved to the another osmocom repository,
python/osmo-python-tests

The features were requested by zecke.
2013-06-24 13:22:34 +02:00
Harald Welte cc6b2d2fa3 ctrlif: Flush/Clear write_queue when closing the control socket 2013-06-24 10:59:40 +02:00
Harald Welte 1304b35a64 bsc_vty: Print human-readable string version of NM ADM STATE 2013-06-24 10:59:33 +02:00
Harald Welte abadd54346 GPRS LLC: Add non-standard method of sequence number recovery
In some situations (like MS reboot without prior DETACH or SGSN reboot
without prior MS detach), the LLC sequence numbers for UI mode could
be different on both sides.

The LLC spec unfortunately doesn't permit us to send something like a
FRMR in this case, but instructs us to silently discard the frame.  At
that time the remote LLC entity will re-transmit the frame with the same
seqeunce number over and over again, which we will drop again and again.

The mthod used now will keep track of the last received UI sequence
number.  If that number is retransmitted for three times in a row, then
we accept this sequence number and recover from that point on.
2013-06-21 14:06:18 +02:00
Harald Welte 22ce59826a osmo-bsc VTY: fix saving of codec-list
the codec-list parser expects only spaces between the elements of the
list, while the 'save' code is putting ", " between the elements
2013-06-19 15:42:44 +02:00
Holger Hans Peter Freyther b0bf1da4c8 smpp: Only write the systemd-id if it is not empty
system_id is a char array, which makes the NULL check a tautology,
so we should check with strlen if the string is empty or not.

This is fixing the "write" command of VTY that would otherwise
create a config file that can not be parsed.
2013-06-12 09:35:43 +02:00
Alexander Huemer a1c09a401d Makefile.am: Use AM_CPPFLAGS
Since automake 1.13 INCLUDES is depricates and causes a warning
2013-06-12 09:16:27 +02:00
Holger Hans Peter Freyther 846d8dca9f vty: Print the state of all GPRS OML objects in show bts
For debugging GB-proxy/IPA issues it is nice to see the state of
the OML objects.
2013-05-29 16:37:27 +02:00