diff options
author | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2014-12-19 18:19:50 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2015-01-18 13:25:24 +0100 |
commit | e21e184d84d6a932b58079084d254f498599e29e (patch) | |
tree | f6c992452150a7a8241ee0e24d36ed501543a6fc | |
parent | 771573c535ae97ce7c7ed7694670e3b98eeae48a (diff) |
sgsn/test: Add wrapper for gprs_subscr_rx_gsup_message
Currently, several lines of boiler plate are needed around a call to
gprs_subscr_rx_gsup_message.
This patch puts all of this (including the call to
gprs_subscr_rx_gsup_message) into a separate function.
Sponsored-by: On-Waves ehf
-rw-r--r-- | openbsc/tests/sgsn/sgsn_test.c | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c index 58d3a4f86..e36fa5a19 100644 --- a/openbsc/tests/sgsn/sgsn_test.c +++ b/openbsc/tests/sgsn/sgsn_test.c @@ -325,6 +325,21 @@ static void test_auth_triplets(void) #define TEST_GSUP_IMSI1_IE 0x01, 0x05, 0x21, 0x43, 0x65, 0x87, 0x09 +static int rx_gsup_message(const uint8_t *data, size_t data_len) +{ + struct msgb *msg; + int rc; + + msg = msgb_alloc(1024, __func__); + msg->l2h = msgb_put(msg, data_len); + OSMO_ASSERT(msg->l2h != NULL); + memcpy(msg->l2h, data, data_len); + rc = gprs_subscr_rx_gsup_message(msg); + msgb_free(msg); + + return rc; +} + static void test_subscriber_gsup(void) { struct gsm_subscriber *s1, *s1found; @@ -333,7 +348,6 @@ static void test_subscriber_gsup(void) struct gprs_ra_id raid = { 0, }; uint32_t local_tlli = 0xffeeddcc; struct gprs_llc_llme *llme; - struct msgb *msg; int rc; static const uint8_t send_auth_info_res[] = { @@ -413,11 +427,7 @@ static void test_subscriber_gsup(void) ctx->subscr->sgsn_data->mm = ctx; /* Inject SendAuthInfoReq GSUP message */ - msg = msgb_alloc(1024, __func__); - msg->l2h = msgb_put(msg, sizeof(send_auth_info_res)); - memcpy(msg->l2h, send_auth_info_res, sizeof(send_auth_info_res)); - rc = gprs_subscr_rx_gsup_message(msg); - msgb_free(msg); + rc = rx_gsup_message(send_auth_info_res, sizeof(send_auth_info_res)); OSMO_ASSERT(rc >= 0); OSMO_ASSERT(last_updated_subscr == s1); @@ -427,11 +437,7 @@ static void test_subscriber_gsup(void) OSMO_ASSERT(s1->sgsn_data->auth_triplets[2].key_seq == GSM_KEY_SEQ_INVAL); /* Inject SendAuthInfoErr GSUP message */ - msg = msgb_alloc(1024, __func__); - msg->l2h = msgb_put(msg, sizeof(send_auth_info_err)); - memcpy(msg->l2h, send_auth_info_err, sizeof(send_auth_info_err)); - rc = gprs_subscr_rx_gsup_message(msg); - msgb_free(msg); + rc = rx_gsup_message(send_auth_info_err, sizeof(send_auth_info_err)); OSMO_ASSERT(rc >= 0); OSMO_ASSERT(last_updated_subscr == s1); @@ -441,11 +447,7 @@ static void test_subscriber_gsup(void) OSMO_ASSERT(s1->sgsn_data->auth_triplets[2].key_seq == GSM_KEY_SEQ_INVAL); /* Inject UpdateLocReq GSUP message */ - msg = msgb_alloc(1024, __func__); - msg->l2h = msgb_put(msg, sizeof(update_location_res)); - memcpy(msg->l2h, update_location_res, sizeof(update_location_res)); - rc = gprs_subscr_rx_gsup_message(msg); - msgb_free(msg); + rc = rx_gsup_message(update_location_res, sizeof(update_location_res)); OSMO_ASSERT(rc >= 0); OSMO_ASSERT(last_updated_subscr == s1); @@ -453,11 +455,7 @@ static void test_subscriber_gsup(void) OSMO_ASSERT(s1->authorized == 1); /* Inject UpdateLocErr GSUP message */ - msg = msgb_alloc(1024, __func__); - msg->l2h = msgb_put(msg, sizeof(update_location_err)); - memcpy(msg->l2h, update_location_err, sizeof(update_location_err)); - rc = gprs_subscr_rx_gsup_message(msg); - msgb_free(msg); + rc = rx_gsup_message(update_location_err, sizeof(update_location_err)); OSMO_ASSERT(rc >= 0); OSMO_ASSERT(last_updated_subscr == s1); @@ -465,12 +463,8 @@ static void test_subscriber_gsup(void) OSMO_ASSERT(s1->authorized == 0); /* Inject UpdateLocReq GSUP message */ - msg = msgb_alloc(1024, __func__); - msg->l2h = msgb_put(msg, sizeof(location_cancellation_req)); - memcpy(msg->l2h, - location_cancellation_req, sizeof(location_cancellation_req)); - rc = gprs_subscr_rx_gsup_message(msg); - msgb_free(msg); + rc = rx_gsup_message(location_cancellation_req, + sizeof(location_cancellation_req)); OSMO_ASSERT(rc >= 0); OSMO_ASSERT(last_updated_subscr == s1); |