Commit Graph

155 Commits

Author SHA1 Message Date
Holger Hans Peter Freyther 1f9eb78b4f debian: Bump version to build new test packages 2013-12-13 19:36:46 +01:00
Pablo Neira Ayuso 87b3eeaed7 osmux: delete message from output list before calling tx_cb
Valgrind complains about a possible use after free:

==12800== Invalid read of size 4
==12800==    at 0x4073DF6: osmux_tx_sched (linuxlist.h:119)
==12800==    by 0x8052B0F: osmux_read_from_bsc_nat_cb (osmux.c:261)
==12800==    by 0x453F967: ???
==12800==  Address 0x453f710 is 48 bytes inside a block of size 145
+free'd
==12800==    at 0x402750C: free (vg_replace_malloc.c:427)
==12800==    by 0x4064ADE: talloc_free (talloc.c:609)
==12800==    by 0x405AAAA: msgb_free (msgb.c:72)
==12800==    by 0x8052492: scheduled_tx_bts_cb (osmux.c:196)
==12800==    by 0x4072CF8: osmux_tx_cb (osmux.c:554)
==12800==    by 0x4073F03: osmux_tx_sched (osmux.c:582)
==12800==    by 0x8052B0F: osmux_read_from_bsc_nat_cb (osmux.c:261)
==12800==    by 0x453F967: ???

The problem is that osmux_tx_sched may immediately call osmux_tx_cb for
the first extracted RTP message from the osmux batch, which releases the
message after that.

Remove the message from our list of messages to be transmitted before
the message is passed to the tx callback.

Reported by Mattias Lundstrom.
2013-12-13 15:23:04 +01:00
Holger Hans Peter Freyther 9b1c0804d9 debian: Enable hardening for the libosmo-netif package 2013-12-12 12:50:35 +01:00
Holger Hans Peter Freyther 350c577f50 debian: Build a newer version of the nat 2013-11-15 15:02:48 +01:00
Holger Hans Peter Freyther bc730e531c misc: Ignore files generated by autotest 2013-11-15 15:02:48 +01:00
Pablo Neira Ayuso ceda50fa70 osmux: add artificial limit for cloned RTP packets
Avoid spamming lots of cloned RTP packets in case of severe
gaps.
2013-09-12 13:19:32 +02:00
Pablo Neira Ayuso 7b37afba33 osmux: sanity check too big RTP/RTCP messages as input
Holger spotted that the caller may loop forever in case it receives
big RTP/RCTP packets, that are likely to be spoofed.
2013-08-27 17:15:27 +02:00
Pablo Neira Ayuso ce4bc15a9c ipa_unit: use talloc_strdup
Reported by Holger.
2013-08-25 14:24:46 +02:00
Pablo Neira Ayuso dd24cdd95f tests: osmux-test: double timing validation threshold
Double timing validation to avoid hitting errors easily.
2013-05-27 11:19:35 +02:00
Pablo Neira Ayuso 8c1f31a3dc osmux: disable timing debugging
Disable timing debugging by default.
2013-05-27 01:30:36 +02:00
Pablo Neira Ayuso bd847cd71b tests: osmux_test: exercise osmux_replay_lost_packets
Emulate RTP message loss to test osmux_replay_lost_packets code
in src/osmux.c.

After this test, lcov reports 90.3% line coverage of osmux.c
2013-05-24 13:12:14 +02:00
Pablo Neira Ayuso 390872055d osmux: nul-terminate all strings generated by _snprintf
Make sure all strings are null-terminated.

Spotted by Holger Hans Peter Freyther.
2013-05-24 12:51:02 +02:00
Pablo Neira Ayuso af8cc087ee osmux: fix wrong OSMUX header description in header file
It was not matching with the current code.
2013-05-24 12:44:46 +02:00
Pablo Neira Ayuso 70214a15d1 osmux: further sanity checkings for AMR FT
According to RFC3267, AMR FT upper 9 should be discarded. This patch
adds extra validation to make sure that input RTP traffic encapsulating
AMR payload and OSMUX amr_ft field are OK with regards to that
restriction.
2013-05-24 12:16:49 +02:00
Pablo Neira Ayuso 9d6d126c23 tests: osmux_test: deadline after 10 seconds
If the test takes longer than 10 seconds (it barely takes less than
a second according to `time'), bail out and report an error.
2013-05-24 11:22:41 +02:00
Pablo Neira Ayuso b1f92341c3 amr: add AMR FT SID definition
According to RFC3267, AMR FT 8 is reserved to SID and its size is
8 bytes.
2013-05-24 11:18:40 +02:00
Pablo Neira Ayuso 1ee6d39921 osmux: add sanity checking in osmux_xfrm_output_pull
Osmux infers the size of the AMR payload from the FT type.
Make sure we get enough data from the network according to
what we expect.
2013-05-24 10:47:59 +02:00
Holger Hans Peter Freyther b5be2f73e0 tests: Use the libosmonetif we just built for the tests
Use the library we just built instead for one already installed
in the system.
2013-05-24 07:58:10 +02:00
Holger Hans Peter Freyther c8fcc5b8d6 debian: Build a new package 2013-05-24 07:45:44 +02:00
Pablo Neira Ayuso 479fba171b add testsuite infrastructure and osmux test
This patch adds the testsuite infrastructure and it populates it
with one test for osmux.

The osmux tests makes sure that:

* We get the same number of RTP messages in the input and the output path.
* The payload of the RTP message is reconstructed correctly.
* The reconstructed timing is correct.
2013-05-24 02:20:50 +02:00
Pablo Neira Ayuso dd34adea7a osmux: remove trailing line break from osmux_snprintf 2013-05-23 20:59:13 +02:00
Pablo Neira Ayuso 92b9a4c6a2 rtp: fix wrong time arithmetics in osmo_rtp_build
rtp.c:154:26: warning: The left operand to '/' is always 0
        frame_diff = (usec_diff / 20000);
                      ~~~~~~~~~ ^
rtp.c:157:43: warning: The left operand to '-' is always 0
                long int frame_diff_excess = frame_diff - 1;
                                             ~~~~~~~~~~ ^
rtp.c:153:39: warning: The right operand to '+' is always 0
        usec_diff = tv_diff.tv_sec * 1000000 + tv_diff.tv_usec;
                                             ^ ~~~~~~~~~~~~~~~
rtp.c:153:29: warning: The left operand to '*' is always 0
        usec_diff = tv_diff.tv_sec * 1000000 + tv_diff.tv_usec;
                    ~~~~~~~~~~~~~~ ^
4 warnings generated.

Reported by Holger Hans Peter Freyther.
2013-05-22 12:21:29 +02:00
Holger Hans Peter Freyther 90d4407b64 debian: Increase the version number to 0.0.2
git-version-gen was printing the version as UNKNOWN, create a new
tag to overcome this.
2013-05-22 11:13:26 +02:00
Holger Hans Peter Freyther c0afa36f1e debian: Increase the version to 0.0.1 2013-05-22 11:06:51 +02:00
Holger Hans Peter Freyther ebfec6efbc debian: Add libortp-dev to the dependencies of this package 2013-05-22 08:32:43 +02:00
Pablo Neira Ayuso 3cf3a732ea osmux: fix warning spotted by clang --analyze
osmux.c:622:20: warning: Value stored to 'osmuxh' during its
      initialization is never read
        struct osmux_hdr *osmuxh = (struct osmux_hdr *)msg->data;
                          ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reported by Holger Hans Peter Freyther.
2013-05-22 02:06:33 +02:00
Holger Hans Peter Freyther 3eef26fc8a debian: Initial attempt at a debian package for libosmo-netif 2013-05-21 19:05:40 +02:00
Holger Hans Peter Freyther 23d866eff9 misc: Add missing header files to fix the make distcheck 2013-05-21 18:46:28 +02:00
Pablo Neira Ayuso 56c4681d83 osmux: replay last RTP packet seen under packet loss scenario
If osmux notices a gap between two RTP packets, fill it with
the last RTP packet seen. Without this patch, 10% of packet loss
is enough to get garbage, with it we get glitches in the conversation
with 30%, and pretty much broken conversation with 40% of it.
2013-05-21 00:48:13 +02:00
Pablo Neira Ayuso a9ab95c2c4 osmux: use ccid to identify batches instead of the RTP SSRC
This should reduce the amount of batch nodes that are created
by the maximum number of allowed circuit IDs.
2013-05-20 22:37:31 +02:00
Pablo Neira Ayuso a2c7f909ef osmux: add sanity checking to osmux_snprintf
Add sanity checking to avoid crashes on malformed OSMUX packets
2013-05-12 20:44:00 +02:00
Pablo Neira Ayuso 282aee422f osmux: allow to set initial RTP SSRC
Instead of using the osmuxh->circuit_id.
2013-05-12 19:56:21 +02:00
Pablo Neira Ayuso d32caea9ea osmux: add osmux_snprintf
Useful for debugging purposes. Modify also examples to use it.
2013-02-19 17:14:33 +01:00
Pablo Neira Ayuso aeeb4399a2 examples: use DOSMUX_TEST instead of DLINP in logging messages 2013-02-19 17:13:37 +01:00
Pablo Neira Ayuso 1f43121ef0 osmux: osmux-test-input: fix compilation warning
CC     osmux-test-input.o
osmux-test-input.c:85:2: warning: initialization from incompatible pointer type [enabled by default]
osmux-test-input.c:85:2: warning: (near initialization for ‘h_input.deliver’) [enabled by default]
2013-02-19 16:21:09 +01:00
Pablo Neira Ayuso e0ae0d25c0 osmux: RTP payload type for voice is dynamic
Don't make any assumption on the payload type.
2013-02-19 16:14:32 +01:00
Pablo Neira Ayuso 5cbdd8797a osmux: add talloc context
Good for debugging leaks.
2013-02-19 13:18:48 +01:00
Pablo Neira Ayuso 01537a3678 osmux: initialize batch appropriately in osmux_xfrm_input_init
Use talloc_size not talloc. Should fix:

0xb779401a in rb_erase (node=0x200200, root=0xb779c908) at rbtree.c:230
0xb779401a in rb_erase (node=0x200200, root=0xb779c908) at rbtree.c:230
0xb778ee48 in osmo_timer_del (timer=0x94aacd0) at timer.c:110
0xb778ef65 in osmo_timer_add (timer=0x94aacd0) at timer.c:72
0xb778f03c in osmo_timer_schedule (timer=0x94aacd0, seconds=0, microseconds=64000)
0xb77360ff in osmux_xfrm_input (h=0x94a4280, msg=0x94b8a50, ccid=18) at osmux.c:390

Due to uninitialization batch structures.
2013-02-19 13:17:02 +01:00
Pablo Neira Ayuso 5e9c67ea20 fix osmux-test-input
ccid array was not initialized appropriately
2013-02-12 19:53:02 +01:00
Pablo Neira Ayuso 3f00a9b95f fix osmux_test with pcap file 2013-02-12 19:49:57 +01:00
Pablo Neira Ayuso 92601d0a20 osmux: use ft instead of the cmr
The cmr is the requested codec for the other peer, the ft actually
contains the current codec mode. cmr may contain 15 which means
"don't care".
2013-02-12 19:29:42 +01:00
Pablo Neira Ayuso c92810eccd osmux: remove arrays from osmux_out_handle
there will be one osmux_out_handle per endpoint.
2013-02-12 17:24:13 +01:00
Pablo Neira Ayuso 7ff7a5cd6d osmux: allow to pass data to osmux_deliver 2013-02-11 22:49:27 +01:00
Pablo Neira Ayuso 0f1f41411f osmux: fix missing data set in osmux_tx_sched 2012-10-21 04:12:29 +02:00
Pablo Neira Ayuso 4aa540ae27 dgram: add osmo_dgram_get_data 2012-10-21 03:08:37 +02:00
Pablo Neira Ayuso 5654c43f80 osmux: remove generic functions to register and get ccid
Remove these functions:

- osmux_xfrm_input_get_ccid
- osmux_xfrm_input_register_ccid

The ccid will be managed by the BSC and it will be stored in the
mgcp_endpoint structure.

Also adjust all tests and examples using the API.
2012-10-20 20:17:28 +02:00
Pablo Neira Ayuso 631c6fe0ad ipa: fix compilation warning
Shows up with gcc-4.7

ipa.c: In function 'osmo_ipa_rcvmsg_base':
ipa.c:210:6: warning: variable 'ret' set but not used [-Wunused-but-set-variabl
2012-10-15 23:09:36 +02:00
Pablo Neira Ayuso 7f9ebe2e56 osmux: fix DELTA_RTP_MSG
It should be 16000 and add DELTA_RTP_TIMESTAMP which is 160.
2012-10-15 23:09:36 +02:00
Pablo Neira Ayuso 8c9caa8607 osmux: rewrite batching function
Rework batching routine to reduce its complexity, updates:

* Now it uses a list of lists to store the messages that will be
  batched.

batch list
    |
    `-> node SSRC=a ---> ... ---> node SSRC=b
            |                         |
        msg seq=x1               msg seq=y1
            |                         |
        msg seq=x2               msg seq=y2
            |                         |
        msg seq=x3               msg seq=y3
            |                         |
        msg seq=x4               msg seq y4

This keeps easier the creation of the final batch that is sent from that
data structure.

* We also detect duplicate messages in the batch, ie. messages with the
  same sequence are skipped.

Still pending to resolve reordering, corruption and omissions (reliability
is desired).
2012-10-15 23:09:36 +02:00
Pablo Neira Ayuso e472f44dd3 osmux: RTP timestamp has to be bumped in 160
Between two RTP messages that were extracted from a batch, the
timestamp difference should be 160.

Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2012-10-15 23:09:36 +02:00