bssgp: Fix bssgp_tx_fc_bvc parameter type

Currently large values for Bmax default MS get sliced since a uint16_t is
used as the type of the corresponding parameter of bssgp_tx_fc_bvc.
GSM 48.018, 11.3.2 which in turn refers to 11.3.5 specifies a maximum
of 6MB (0xffff * 100).

This commit changes the type to uint32_t to cover the full value
range.

Sponsored-by: On-Waves ehf
This commit is contained in:
Jacob Erlbeck 2015-05-06 09:29:32 +02:00 committed by Holger Hans Peter Freyther
parent 455d34f476
commit 9385d1e01b
5 changed files with 82 additions and 2 deletions

View File

@ -1 +1,2 @@
#library what description / commit summary line
libosmogb abi-change bssgp: Fix bssgp_tx_fc_bvc parameter type

View File

@ -65,7 +65,7 @@ int bssgp_rx_paging(struct bssgp_paging_info *pinfo,
int bssgp_tx_fc_bvc(struct bssgp_bvc_ctx *bctx, uint8_t tag,
uint32_t bucket_size, uint32_t bucket_leak_rate,
uint16_t bmax_default_ms, uint32_t r_default_ms,
uint32_t bmax_default_ms, uint32_t r_default_ms,
uint8_t *bucket_full_ratio, uint32_t *queue_delay_ms);
int bssgp_tx_fc_ms(struct bssgp_bvc_ctx *bctx, uint32_t tlli, uint8_t tag,

View File

@ -315,7 +315,7 @@ int bssgp_tx_bvc_reset(struct bssgp_bvc_ctx *bctx, uint16_t bvci, uint8_t cause)
*/
int bssgp_tx_fc_bvc(struct bssgp_bvc_ctx *bctx, uint8_t tag,
uint32_t bucket_size, uint32_t bucket_leak_rate,
uint16_t bmax_default_ms, uint32_t r_default_ms,
uint32_t bmax_default_ms, uint32_t r_default_ms,
uint8_t *bucket_full_ratio, uint32_t *queue_delay_ms)
{
struct msgb *msg;

View File

@ -17,6 +17,7 @@
#include <osmocom/core/prim.h>
#include <osmocom/gprs/gprs_bssgp.h>
#include <osmocom/gprs/gprs_ns.h>
#include <osmocom/gprs/gprs_bssgp_bss.h>
#include <stdio.h>
#include <stdlib.h>
@ -60,6 +61,17 @@ int gprs_ns_callback(enum gprs_ns_evt event, struct gprs_nsvc *nsvc,
return 0;
}
struct msgb *last_ns_tx_msg = NULL;
/* override */
int gprs_ns_sendmsg(struct gprs_ns_inst *nsi, struct msgb *msg)
{
msgb_free(last_ns_tx_msg);
last_ns_tx_msg = msg;
return msgb_length(msg);
}
int bssgp_prim_cb(struct osmo_prim_hdr *oph, void *ctx)
{
printf("BSSGP primitive, SAP %d, prim = %d, op = %d, msg = %s\n",
@ -174,6 +186,68 @@ static void test_bssgp_bad_reset()
msgb_bssgp_send_and_free(msg);
}
static void test_bssgp_flow_control_bvc(void)
{
struct bssgp_bvc_ctx bctx = {
.nsei = 0x1234,
.bvci = 0x5678,
};
const uint8_t tag = 42;
const uint32_t bmax = 0x1022 * 100;
const uint32_t rate = 0xc040 / 8 * 100;
const uint32_t bmax_ms = bmax / 2;
const uint32_t rate_ms = rate / 2;
uint8_t ratio = 0x78;
uint32_t qdelay = 0x1144 * 10;
int rc;
static uint8_t expected_simple_msg[] = {
0x26,
0x1e, 0x81, 0x2a, /* tag */
0x05, 0x82, 0x10, 0x22, /* Bmax */
0x03, 0x82, 0xc0, 0x40, /* R */
0x01, 0x82, 0x08, 0x11, /* Bmax_MS */
0x1c, 0x82, 0x60, 0x20, /* R_MS */
};
static uint8_t expected_ext_msg[] = {
0x26,
0x1e, 0x81, 0x2a, /* tag */
0x05, 0x82, 0x10, 0x22, /* Bmax */
0x03, 0x82, 0xc0, 0x40, /* R */
0x01, 0x82, 0x08, 0x11, /* Bmax_MS */
0x1c, 0x82, 0x60, 0x20, /* R_MS */
0x3c, 0x81, 0x78, /* ratio */
0x06, 0x82, 0x11, 0x44, /* Qdelay */
};
printf("----- %s START\n", __func__);
rc = bssgp_tx_fc_bvc(&bctx, tag, bmax, rate, bmax_ms, rate_ms,
NULL, NULL);
OSMO_ASSERT(rc >= 0);
OSMO_ASSERT(last_ns_tx_msg != NULL);
printf("Got message: %s\n", msgb_hexdump(last_ns_tx_msg));
OSMO_ASSERT(msgb_length(last_ns_tx_msg) == sizeof(expected_simple_msg));
OSMO_ASSERT(0 == memcmp(msgb_data(last_ns_tx_msg),
expected_simple_msg, sizeof(expected_simple_msg)));
rc = bssgp_tx_fc_bvc(&bctx, tag, bmax, rate, bmax_ms, rate_ms,
&ratio, &qdelay);
OSMO_ASSERT(rc >= 0);
OSMO_ASSERT(last_ns_tx_msg != NULL);
printf("Got message: %s\n", msgb_hexdump(last_ns_tx_msg));
OSMO_ASSERT(msgb_length(last_ns_tx_msg) == sizeof(expected_ext_msg));
OSMO_ASSERT(0 == memcmp(msgb_data(last_ns_tx_msg),
expected_ext_msg, sizeof(expected_ext_msg)));
msgb_free(last_ns_tx_msg);
last_ns_tx_msg = NULL;
printf("----- %s END\n", __func__);
}
static struct log_info info = {};
@ -198,6 +272,7 @@ int main(int argc, char **argv)
test_bssgp_suspend_resume();
test_bssgp_status();
test_bssgp_bad_reset();
test_bssgp_flow_control_bvc();
printf("===== BSSGP test END\n\n");
exit(EXIT_SUCCESS);

View File

@ -7,5 +7,9 @@ BSSGP primitive, SAP 16777219, prim = 4, op = 0, msg = 0e 1f 84 f0 12 34 56 1b 8
BSSGP primitive, SAP 16777221, prim = 11, op = 2, msg = 41 07 81 27
BSSGP primitive, SAP 16777221, prim = 11, op = 2, msg = 41 07 81 05 04 82 04 d2
----- test_bssgp_status END
----- test_bssgp_flow_control_bvc START
Got message: 26 1e 81 2a 05 82 10 22 03 82 c0 40 01 82 08 11 1c 82 60 20
Got message: 26 1e 81 2a 05 82 10 22 03 82 c0 40 01 82 08 11 1c 82 60 20 3c 81 78 06 82 11 44
----- test_bssgp_flow_control_bvc END
===== BSSGP test END