Commit Graph

302 Commits

Author SHA1 Message Date
Holger Hans Peter Freyther a27303094a sgsn/ctrl: Add ctrl interface, implement listing subscribers
Add the control interface with no hierachy right now and implement
the first command to list IMSI + Context Address of active sessions.
sgsn_cmd_handle could share more code with bsc variant.

Fixes: SYS#264, SYS#265
2014-03-23 18:34:58 +01:00
Holger Hans Peter Freyther d883db027b nitb/ctrl: Implement a command to list all active subscribers
This is only useful for small networks. List the IMSI and MSISDN
of all active subscribers.

Fixes: SYS#266
2014-03-23 16:22:55 +01:00
Holger Hans Peter Freyther 2d99eeb7f2 nitb/ctrl: Implement creating and deleting subscribers
Sadly there is no proper foreign key relationship on the tables
that related to the Subscriber. This means we can't use a DELETE
with Cascade and need to delete everything by hand. To make things
worse maybe the SMS/Paging code is still using the subscriber
making the operation more dangerous. I had added NULL checks for
sender_id/receiver_id at 30C3 so we should not crash in this
situation.

Fixes: SYS#274
2014-03-23 14:05:49 +01:00
Holger Hans Peter Freyther 9dbc3f8db7 nitb/ctrl: Add command to add/modify a subscriber to the database
The test has been manually verified. Executing the select for
the subscribers showed:

sqlite> select * from Subscriber;
1|2014-03-23 12:12:46|2014-03-23 12:19:09|2620345||445567|1||0|

This created a subscriber with the right IMSI, MSISDN and has
it authorized.

Fixes: SYS#275
2014-03-23 14:05:49 +01:00
Holger Hans Peter Freyther d092f48648 nitb/ctrl: Add ctrl command to set the TRX max_power_reduction
In case the BTS is connected the new attribute should be set
through OML. This is left as a todo item.

Addresses: SYS#267
2014-03-23 14:05:22 +01:00
Andreas Eversberg f78fc4e76e mncc: Complete definitions for all speech traffic frames at MNCC interface
The new definitions are: half rate and AMR

Change of definition name for bad frame, because it applies to all types of
traffic, not only TCH/F.

Increase MNCC interface version to 4. Version 3 is skipped, because it was
used by older version of Linux-Call-Router which is incompatible with the
current version of the MNCC interface.
2014-03-20 22:36:16 +01:00
Nikola 9e55636fe0 trau: Fix linking on FreeBSD by using LIBRAY_DL 2014-03-11 15:41:50 +01:00
Alexander Chemeris 82a1858eb0 db: Add more tests for retrieving subscribers from a DB. 2014-03-09 10:24:11 +01:00
Holger Hans Peter Freyther ed0d4f6222 nitb/smpp: Add simple test runner for the issues found by daniel
Send the two strings that caused the read handling to misbehave.
Verify that we handle this correctly by still being able to issue
a VTY command. The CPU load issue could not be verified like this.
2014-03-06 23:48:17 +01:00
Ciaby ec6e4f8b3d nitb: Add a test for "show network" in the python testsuite.
Make sure that bsc_gsmnet->bsc_data->rf_ctrl is initialized for
NITB. In commit a9fae1ae66 the
conditions for the rf_ctrl was removed but it was still needed
for the NITB.

Fixes regression from:
a9fae1ae66
bsc: rf_ctrl will always be created, remove the NULL checks
2014-03-06 17:31:23 +01:00
Holger Hans Peter Freyther 4ecc6877a2 nat: Add CTRL command test case for the new control commands 2014-03-06 11:04:56 +01:00
Holger Hans Peter Freyther 3adb772853 libbsc: Add command to set MNC/MCC and apply it if something changed
Change the splitting of the ctrl_test_runner.py. Make sure that
we get one element and all the rest.
2014-03-04 20:38:49 +01:00
Holger Hans Peter Freyther ca114432be sms: Increment the RP Message Reference for each transaction
Each RP-DATA should have a unique msg reference. Currently 42 is
used for all of these. Remember the last reference we used and
increment it on the next SMS. Do not track if the reference is
still in use a clash is a lot less likely now. First unless SMPP
is used only one SMS is delivered at a time, second the transaction
space is a lot smaller than the one for the reference.
2014-02-20 11:35:56 +01:00
Holger Hans Peter Freyther 34235294d7 tests: Remove unused file 2014-02-20 11:19:32 +01:00
Holger Hans Peter Freyther cdfc2061bb mgcp: Round the frame time otherwise we have porting issues
With the current multiplication we might end up with 19999 as
time on i386. When we round it ends up as 20000 on i386 and
should work the same on AMD64.
2014-02-03 13:32:34 +01:00
Holger Hans Peter Freyther ba41978b97 mgcp: transit is a signed variable and should be printed like this
On AMD64 we had a difference in the test result most likely due
the bigger size of integers.
2014-02-03 09:20:06 +01:00
Holger Hans Peter Freyther 757971ade8 mgcp: Use the length modifier for the size_t in the printf
Should fix on AMD64:
mgcp_test.c: In function ‘sendto’:
mgcp_test.c:318:10: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ [-Wformat]
2014-02-03 09:18:51 +01:00
Jacob Erlbeck b281e4e6f4 mgcp/rtp: Base jitter calculation on input timestamps
So far, the jitter computation has been based on output timestamps.

This patch uses the input timestamps instead and resets jitter
computation on SSRC changes.

Sponsored-by: On-Waves ehf
2014-01-31 11:45:25 +01:00
Jacob Erlbeck eacc9b92a1 mgcp/rtp: Compute delta timestamp based on wallclock
Currently, when the SSRC changes within a stream and SSRC fixing is
enabled, the RTP timestamp between the last packet that has been
received with the old SSRC and the first packet of the new SSRC
is always incremented by one packet duration.
This can lead to audio muting (at least with the nanoBTS) when the
wallclock interval between these packets is too large (> 1s).

This patch changes the implementation to base the RTP timestamp offset
on the wallclock interval that has passed between these two packets.

Ticket: OW#466
Sponsored-by: On-Waves ehf
2014-01-31 11:44:16 +01:00
Jacob Erlbeck 303b54a2a4 mgcp/rtp: Fix transit computation units
Currently micro-secs and RTP rate get mixed when the transit value is
computed in mgcp_patch_and_count().

This patch changes get_current_ts() to accept the desired rate as
argument and to use it for the time conversion instead of always
converting to microseconds. If microseconds are needed,
get_current_ts(1000) can be used.
The arrival_time is now measured in 1/rtp_end->rate seconds so that
it can be directly compared to RTP timestamps as required by RFC3550
(section 6.4.1, see definition of 'interarrival jitter').

Sponsored-by: On-Waves ehf
2014-01-31 11:18:25 +01:00
Jacob Erlbeck e763f3e73e mgcp/test: Fake wallclock for RTP timing/stats tests
Currently the stats (jitter, transit) cannot be checked properly,
since they depend on the wallclock time.

This patch fakes clock_gettime (CLOCK_MONOTONIC) to reflect the
scheduling time of the RTP packets. In addition, the RTP statistical
value are written to stdout.
A RTP test case with a SSRC change along with a reference time delay
has been added.

Sponsored-by: On-Waves ehf
2014-01-31 11:18:25 +01:00
Jacob Erlbeck cf577c3492 mgcp/test: Only include conn_mode into test output
Currently the conn_mode and the output_enabled flags are printed to
stdout.

This patch modifies this to print the output_enabled flags to stderr
instead. The bits in conn_mode are shown as RECV, SEND, and LOOP.
This does not reduce the significance of the test, since there is an
assertion already that verifies the values of the output_enabled
flags with respect to the conn_mode.

Sponsored-by: On-Waves ehf
2014-01-31 11:18:25 +01:00
Holger Hans Peter Freyther 6419018e68 nat: Make the access-list deny cause configurable
Add two optional arguments to the imsi-deny rule
for the reject cause and verify that it is saved
out.
2014-01-20 10:14:05 +01:00
Holger Hans Peter Freyther 415cd2eebb nat: Introduce reject cause to bsc_nat_acc_lst_entry
The filtering architecture already allowed to specify a reject
reason but this has not been used for the access-lists. Extend
the access-list to include a reject reason and extend the test
case to honor it.
2014-01-20 10:13:36 +01:00
Jacob Erlbeck ead0529e07 mgcp/test: Don't reset conn_mode between messages
Currently, the conn_mode field is reset after it has been checked.

This patch disables this behaviour and only adds a mark (bit) to
detect modifications.

Sponsored-by: On-Waves ehf
2014-01-20 08:27:03 +01:00
Jacob Erlbeck e35fd13697 mgcp: Synchronize conn mode bits and output enabled flags
This patch changes implementation and the mgcp_connection_mode enum
in a way that net_end.output_enabled (bts_end.output_enabled) flag
always matches the MGCP_CONN_SEND_ONLY (MGCP_CONN_RECV_ONLY) bit of
conn_mode.

Based on this, the conn_mode bits are then used instead of the
output_enabled fields within mgcp_protocol.c.

Sponsored-by: On-Waves ehf
2014-01-20 08:27:03 +01:00
Jacob Erlbeck 8857c90e36 mgcp: Disable output enabled on initialisation
Currently RTP output_enabled is set to 1 on initialisation, which
does not semantically match the initial value of conn_mode
(MGCP_CONN_NONE).

This patch changes this initial value to 0.

Sponsored-by: On-Waves ehf
2014-01-20 08:27:03 +01:00
Jacob Erlbeck 1dc022cb62 openbsc: Fix coverity issues
This patch (hopefully) fixes the new defects reported by coverity.

Addresses:
** CID 1156986:  Negative array index read  (NEGATIVE_RETURNS)
/tests/gsm0408/gsm0408_test.c: 419 in test_si_range_helpers()
/tests/gsm0408/gsm0408_test.c: 423 in test_si_range_helpers()
/tests/gsm0408/gsm0408_test.c: 427 in test_si_range_helpers()

** CID 1156987:  Unchecked return value from library
(CHECKED_RETURN)
/src/libmgcp/mgcp_protocol.c: 1150 in mgcp_keepalive_timer_cb()

** CID 1156988:  Unchecked return value from library
(CHECKED_RETURN)
/src/libmgcp/mgcp_protocol.c: 983 in handle_modify_con()

Sponsored-by: On-Waves ehf
2014-01-17 14:36:51 +01:00
Jacob Erlbeck 075a9ebdcc mgcp: Send RTP keepalive dummy packets to net
So far, a single dummy packet has been sent immediately after the
reception of a MDCX message. There is no dedicated keep alive
mechanism (it just worked because the audio from the MS has always
been forwarded to the NAT until the 'mgcp: Set output_enabled flags
based on the MGCP mode' patch).

This patch adds explicit, timer based keep alive handling that can be
enable per trunk. A VTY command 'rtp keep-alive' command is added for
configuration which can be used to set the interval in seconds, to
send a single packet after the reception of a CRCX/MDCX when RTP data
from the net is expected ('once'), or to disable the feature
completely ('no rtp keep-alive'). In 'send-recv' connections, only
the initial packet is sent if enabled (even when an interval has been
configured). The default is 'once'.

Note that this removes the mgcp_change_cb() from mgcp_main.c.

Sponsored-by: On-Waves ehf
2014-01-16 13:20:51 +01:00
Jacob Erlbeck 2645c9e7fc mgcp: Set output_enabled flags based on the MGCP mode
This patch enhances parse_conn_mode() to set the output_enabled flags
of each end based on the MGCP mode.

Ticket: OW#1044
Sponsored-by: On-Waves ehf
2014-01-16 13:20:44 +01:00
Jacob Erlbeck 84dfba1579 mgcp/test: Show the number of dummy packets sent
This patch extends the test_messages test to show the number of dummy
packets that has been passed to sendto(). This way, dummy packets are
even being counted when sendto() itself failes (e.g. due to the fd
being -1).

Sponsored-by: On-Waves ehf
2014-01-16 13:20:37 +01:00
Jacob Erlbeck 68c74f59a4 mgcp/test: Reset pkt_period_* after each test
Currently these value may leak into the next test.

This patch will reset them after each message has been processed.

Sponsored-by: On-Waves ehf
2014-01-16 12:17:24 +01:00
Jacob Erlbeck 1b653af283 mgcp/test: Test the connection mode parser
This modifies the test MGCP messages to include M:recvonly (CRCX),
M:sendrecv (MDCX) and M:sendonly (MDCX) outputs the resulting
output_enabled flags and the conn_mode after processing the message.

Sponsored-by: On-Waves ehf
2014-01-16 12:17:24 +01:00
Jacob Erlbeck 64277e6514 si: Implement range 128, 256, 1024 encoding
This commit adds the implementation of these range formats to the
encoder. In addition, the work-around that tried range 512 first is
removed, so that the selection is primarily based on the max distance
between frequencies.

Ticket: OW#1061
Sponsored-by: On-Waves ehf
2014-01-16 12:04:30 +01:00
Jacob Erlbeck 45014a0cad si: Fix range1024 encoding
f0 is currently set to arfcns[0] in range_enc_determine_range(),
while GSM 04.08 requires f0 to be ARFCN 0 in range1024 encoding.

This patch modifies range_enc_determine_range() to force f0 to be 0
if this encoding is used. This way the case distinction in
range_enc_filter_arfcns() is not longer necessary.

Sponsored-by: On-Waves ehf
2014-01-16 12:04:30 +01:00
Jacob Erlbeck 131406c86d si: Fix range512 encoding
This patch fixes a bug in the range encoder that leads to wrong
encoding when 17 or more ARFCNs are encoded.

Sponsored-by: On-Waves ehf
2014-01-16 12:04:30 +01:00
Jacob Erlbeck 9444d4f8e2 si/test: Merge si tests into gsm48 tests
Currently tests covering features of the GSM 04.08 specification are
spread over the si and gsm0408 subdirs in tests.

This commit merges all tests from 'si' into 'gsm0408' and removes the
'si' test sub-directory.

Sponsored-by: On-Waves ehf
2014-01-16 12:04:30 +01:00
Jacob Erlbeck 4b903b4afb si/test: Add tests for range encoding/decoding
This commit adds test range encoding tests. They check the property
decoding(encoding(L)) = L and optionally dump the results and
encoded sequences to stdout.

There a 2 test modes:

 - A list of fixed tests
 - A random number based test loop per ARFCN list size (only dumps
   the first failing test)

Sponsored-by: On-Waves ehf
2014-01-16 12:04:29 +01:00
Jacob Erlbeck 65d114fe43 si: Add a config option to disable SI2ter/SI2bis/SI5ter/SI5bis messages
The iPhone5 (US) appears to have some issues with the SIs generated,
or the nanoBTS is not sending them correctly.

Add a configurable hack to put all bands into the SI2/SI5 message.
It is enabled by the bts VTY command 'force-combined-si'.

This is a quick change without much reflection and watching for side
effects. I have verfied that a network with ARFCN 134 and neighbors
ARFCN 130 and 512 do not get generate the SI2ter and announce everything
inside the SI2.

This patch is conceptually based on 'si: Add a hack to disable
SI2ter/SI2bis/SI5ter/SI5bis messages' (692daaf2d2).

Ticket: OW#1062
Sponsored-by: On-Waves ehf
2014-01-16 12:04:22 +01:00
Holger Hans Peter Freyther 900394acf3 db: Avoid crash we have seen with the dbi code when reading a SMS
Avoid a crash when reading a SMS and a Subscriber could not be resolved.
It is not clear why the read was failing. The sender_id and the receiver_id
was valid for the given sms. I assume that the database has been locked
due external access to it.

The side-effect is that in case of such a failure the sms_queue will start
to deliver starting from subscriber id = 0 again.

 #1  0x0000000000428bec in sms_from_result (net=0x156a270, result=0x15eda30) at db.c:1146
 #2  0x000000000042a8e0 in db_sms_get_unsent_by_subscr (net=0x156a270,
     min_subscr_id=<optimized out>, failed=<optimized out>) at db.c:1255
 #3  0x000000000042e900 in take_next_sms (smsq=<optimized out>) at sms_queue.c:193
 #4  sms_submit_pending (_data=0x158e300) at sms_queue.c:227
 #5  0x00007f3fd30de3bc in osmo_timers_update () at timer.c:243
 #6  0x00007f3fd30de69b in osmo_select_main (polling=0) at select.c:133
 #7  0x0000000000406fbc in main (argc=9, argv=<optimized out>) at bsc_hack.c:346
 (gdb) frame 1
 #1  0x0000000000428bec in sms_from_result (net=0x156a270, result=0x15eda30) at db.c:1146
 1146		strncpy(sms->src.addr, sms->sender->extension, sizeof(sms->src.addr)-1);
 (gdb) p *sms
 (gdb) p sms->sender
 $1 = (struct gsm_subscriber *) 0x0
 (gdb) p sender_id
 $2 = <optimized out>
2013-12-27 20:20:55 +01:00
Jacob Erlbeck 4bbddc6de9 mgcp/rtp: Only patch timestamp alignment errors
Currently, all timestamps are force to SeqNo*d + C which is more than
required by the nanoBTS which seems to be sensitive to alignment
errors only (dTS != k*d, d = ptime * rate = 160).

This patch replaces the force_constant_timing feature by a
force_aligned_timing feature. The timestamp offset will only be
changed (and timestamp errors counted) when the alignment does not
match to the raster based on ptime (default 20ms).

The VTY interface does not change.

Sponsored-by: On-Waves ehf
2013-12-19 11:56:11 +01:00
Jacob Erlbeck 65c7a4551a mgcp/test: Use differential output for counters and timestamp
Currently the counter and output timestamp values are written out for
each packet. This makes it difficult to see in the diffs what has
been changed significantly.

This patch changes this by showing differences for those
values. The absolute input values are also shown now. In addition,
the sequence numbers (the difference for the output value) are
written, too.

Sponsored-by: On-Waves ehf
2013-12-19 11:56:11 +01:00
Jacob Erlbeck 93c9da3b37 mgcp/test: Add test cases for constant RTP sequence number
This adds two test cases:
  1. Packet repetition (dSeq=0, dTS=0)
  2. Broken seqNo (dSeq=0, dTS=160)

The second had been already present in the test cases, but it was a
mere copy&paste mistake which turned out to be rather helpful. This
patch therefore turns it into a documented test case.

Sponsored-by: On-Waves ehf
2013-12-19 11:56:11 +01:00
Andreas Eversberg d074f8f396 Add EFR support to TRAU muxer + test case
Decoding and encoding of FR and EFR TRAU frames are put into seperate
functions. CRC check is done to detect bad EFR TRAU frames.

The test case includes FR and EFR transcoding.

EFR support was tested with Nokia InSite BTS and Siemens BS11.
2013-12-19 10:12:28 +01:00
Jacob Erlbeck 0a1bc56e5a mgcp: Optionally send ptime in SDP
Currently the SDP 'ptime' media attribute is never set in generated
MGCP responses.

This patch optionally includes the 'ptime' attribute if
packet_duration_ms is != 0. This behaviour can be enabled/disabled
by using the VTY command "sdp audio-payload send-ptime" (enabled by
default).

Sponsored-by: On-Waves ehf
2013-12-13 13:51:29 +01:00
Jacob Erlbeck 24754f0490 mgcp: Parse SDP to get rate and packet duration
This patch parses the 'ptime' and 'maxptime' SDP attributes, and the
SDP rate information and sets up packet_duration_ms accordingly. If
the packet duration is unknown or allows for different values (e.g.
because 'ptime' uses a range or 'maxptime' allows for more than one
frame) the duration is set to 0.

Sponsored-by: On-Waves ehf
2013-12-13 13:49:32 +01:00
Jacob Erlbeck 2c2ca4df38 mgcp: Put local connection options into a struct
Currently the local connection options have been stored as a string.

This patch replaces this string by a struct (that still contains a
string) along with the parsed fields (only the packetization period
at the moment).

It also re-adds the calls to set_local_cx_options() to the
handle_create_con() and handle_modify_con() functions. Except for
the test program this has no side effects, since the LCO values
aren't used yet.
2013-12-13 13:48:04 +01:00
Jacob Erlbeck ba477d2ba3 mgcp/test: Output the packet duration after MGCP parsing
This also adds additional MDCX tests (based on MDCX4) to test the
analysis of different combinations of 'p' and 'ptime' fields.

Sponsored-by: On-Waves ehf
2013-12-13 13:45:19 +01:00
Holger Hans Peter Freyther e828b661a7 build: db_test does not use dlopen/dlsym.. remove LIBRARY_DL from deps 2013-12-13 10:18:33 +01:00
Holger Hans Peter Freyther a066d38fbf build: channel_test does not use dlopen/dlsym remove LIBRARY_DL dep 2013-12-13 10:18:32 +01:00