osmux: Take into account configured osmux_in_handle->osmux_seq field
It was not being used anywhere, yet older applications used to set it (always to 0, which was the default value applied internally). Let's make use of it and apply it as first seqnum to be used on a circuit. This value is applied upon call to osmux_xfrm_input_open_circuit(), hence it can be set independently for every new circuit. Change-Id: Ia26fcba5d7364a5744b2d64d0542a2b3880eee34
This commit is contained in:
parent
11f725ae78
commit
b0369f375f
|
@ -57,6 +57,7 @@ struct osmux_hdr {
|
|||
|
||||
/* one to handle all existing RTP flows */
|
||||
struct osmux_in_handle {
|
||||
/* Initial Osmux seqnum for each circuit, set during osmux_xfrm_input_open_circuit() */
|
||||
uint8_t osmux_seq;
|
||||
uint8_t batch_factor;
|
||||
uint16_t batch_size;
|
||||
|
|
|
@ -859,6 +859,7 @@ int osmux_xfrm_input_open_circuit(struct osmux_in_handle *h, int ccid,
|
|||
}
|
||||
|
||||
circuit->ccid = ccid;
|
||||
circuit->seq = h->osmux_seq;
|
||||
INIT_LLIST_HEAD(&circuit->msg_list);
|
||||
llist_add_tail(&circuit->head, &batch->circuit_list);
|
||||
|
||||
|
|
|
@ -346,6 +346,74 @@ static void test_last_amr_cmr_f_q_used(void)
|
|||
osmux_xfrm_input_fini(&h_input);
|
||||
}
|
||||
|
||||
static void test_initial_osmux_seqnum_osmux_deliver_cb(struct msgb *batch_msg, void *data)
|
||||
{
|
||||
struct osmux_hdr *osmuxh;
|
||||
char buf[2048];
|
||||
bool *osmux_transmitted = (bool *)data;
|
||||
|
||||
osmux_snprintf(buf, sizeof(buf), batch_msg);
|
||||
clock_debug("OSMUX message (len=%d): %s\n", batch_msg->len, buf);
|
||||
|
||||
/* We expect 1 batch: */
|
||||
osmuxh = osmux_xfrm_output_pull(batch_msg);
|
||||
/* Check seqnum is the one configured beforehand: */
|
||||
OSMO_ASSERT(osmuxh->seq == 123);
|
||||
|
||||
osmuxh = osmux_xfrm_output_pull(batch_msg);
|
||||
OSMO_ASSERT(osmuxh == NULL);
|
||||
|
||||
msgb_free(batch_msg);
|
||||
|
||||
*osmux_transmitted = true;
|
||||
}
|
||||
/* Test that the first transmitted osmux header is set according to what has been configured. */
|
||||
static void test_initial_osmux_seqnum(void)
|
||||
{
|
||||
struct msgb *msg;
|
||||
int rc;
|
||||
const uint8_t cid = 33;
|
||||
bool osmux_transmitted = false;
|
||||
struct amr_hdr *amrh;
|
||||
|
||||
printf("===%s===\n", __func__);
|
||||
|
||||
|
||||
|
||||
clock_override_enable(true);
|
||||
clock_override_set(0, 0);
|
||||
rtp_init(0, 0);
|
||||
|
||||
struct osmux_in_handle h_input = {
|
||||
.osmux_seq = 123, /* sequence number to start OSmux message from */
|
||||
.batch_factor = 1, /* batch up to 1 RTP messages */
|
||||
.deliver = test_initial_osmux_seqnum_osmux_deliver_cb,
|
||||
.data = &osmux_transmitted,
|
||||
};
|
||||
|
||||
osmux_xfrm_input_init(&h_input);
|
||||
osmux_xfrm_input_open_circuit(&h_input, cid, false);
|
||||
|
||||
/* First RTP frame at t=0 */
|
||||
msg = rtp_next();
|
||||
amrh = rtp_append_amr(msg, AMR_FT_2);
|
||||
amrh->f = 1;
|
||||
amrh->q = 1;
|
||||
amrh->cmr = 0;
|
||||
rc = osmux_xfrm_input(&h_input, msg, cid);
|
||||
OSMO_ASSERT(rc == 0);
|
||||
|
||||
/* t=20, osmux batch is scheduled to be transmitted: */
|
||||
clock_debug("Submit 2nd RTP packet, CMR changes");
|
||||
clock_override_add(0, TIME_RTP_PKT_MS*1000);
|
||||
osmo_select_main(0);
|
||||
OSMO_ASSERT(osmux_transmitted == true);
|
||||
|
||||
clock_debug("Closing circuit");
|
||||
osmux_xfrm_input_close_circuit(&h_input, cid);
|
||||
osmux_xfrm_input_fini(&h_input);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
|
@ -365,6 +433,7 @@ int main(int argc, char **argv)
|
|||
|
||||
test_amr_ft_change_middle_batch();
|
||||
test_last_amr_cmr_f_q_used();
|
||||
test_initial_osmux_seqnum();
|
||||
|
||||
fprintf(stdout, "OK: Test passed\n");
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
@ -21,4 +21,11 @@ sys={0.060000}, mono={0.060000}: Osmux frame should now be transmitted
|
|||
sys={0.060000}, mono={0.060000}: OSMUX message (len=49): OSMUX seq=000 ccid=032 ft=1 rtp_m=0 ctr=2 amr_f=0 amr_q=0 amr_ft=02 amr_cmr=02 [ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ]
|
||||
|
||||
sys={0.060000}, mono={0.060000}: Closing circuit
|
||||
===test_initial_osmux_seqnum===
|
||||
sys={0.000000}, mono={0.000000}: clock_override_set
|
||||
sys={0.000000}, mono={0.000000}: Submit 2nd RTP packet, CMR changes
|
||||
sys={0.020000}, mono={0.020000}: clock_override_add
|
||||
sys={0.020000}, mono={0.020000}: OSMUX message (len=19): OSMUX seq=123 ccid=033 ft=1 rtp_m=0 ctr=0 amr_f=1 amr_q=1 amr_ft=02 amr_cmr=00 [ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ]
|
||||
|
||||
sys={0.020000}, mono={0.020000}: Closing circuit
|
||||
OK: Test passed
|
||||
|
|
Loading…
Reference in New Issue