diff --git a/TODO-RELEASE b/TODO-RELEASE index 43b1e8ef1..d03aa493a 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -1 +1,2 @@ #library what description / commit summary line +libosmogb abi-change bssgp: Fix bssgp_tx_fc_bvc parameter type diff --git a/include/osmocom/gprs/gprs_bssgp_bss.h b/include/osmocom/gprs/gprs_bssgp_bss.h index e426698ce..d79b2100f 100644 --- a/include/osmocom/gprs/gprs_bssgp_bss.h +++ b/include/osmocom/gprs/gprs_bssgp_bss.h @@ -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, diff --git a/src/gb/gprs_bssgp_bss.c b/src/gb/gprs_bssgp_bss.c index 573195970..962bf2e8d 100644 --- a/src/gb/gprs_bssgp_bss.c +++ b/src/gb/gprs_bssgp_bss.c @@ -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; diff --git a/tests/gb/gprs_bssgp_test.c b/tests/gb/gprs_bssgp_test.c index b454430b6..63abf8b36 100644 --- a/tests/gb/gprs_bssgp_test.c +++ b/tests/gb/gprs_bssgp_test.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -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); diff --git a/tests/gb/gprs_bssgp_test.ok b/tests/gb/gprs_bssgp_test.ok index 0392e6a5c..a011bee0a 100644 --- a/tests/gb/gprs_bssgp_test.ok +++ b/tests/gb/gprs_bssgp_test.ok @@ -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