summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2012-01-27 00:00:44 +0100
committerHarald Welte <laforge@gnumonks.org>2012-01-27 00:00:44 +0100
commit8819d8289dd2c11627ba93189ad627ce1f818608 (patch)
tree2f433836c98a37774e8f602ed520c1f7739f4dd5
parentcf149eebb69ac015dc0f4a3eed57821c862300de (diff)
mgcp_test: remove duplicate code
-rw-r--r--openbsc/tests/mgcp/mgcp_test.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/openbsc/tests/mgcp/mgcp_test.c b/openbsc/tests/mgcp/mgcp_test.c
index f29d5b80d..66d0428b7 100644
--- a/openbsc/tests/mgcp/mgcp_test.c
+++ b/openbsc/tests/mgcp/mgcp_test.c
@@ -24,22 +24,15 @@
#include <osmocom/core/talloc.h>
#include <string.h>
-static struct msgb *create_auep1()
-{
- struct msgb *msg;
-
- msg = msgb_alloc_headroom(4096, 128, "MGCP msg");
- int len = sprintf((char *)msg->data, "AUEP 158663169 ds/e1-1/2@172.16.6.66 MGCP 1.0\r\n");
- msg->l2h = msgb_put(msg, len);
- return msg;
-}
+#define AUEP1 "AUEP 158663169 ds/e1-1/2@172.16.6.66 MGCP 1.0\r\n"
+#define AUEP2 "AUEP 18983213 ds/e1-2/1@172.16.6.66 MGCP 1.0\r\n"
-static struct msgb *create_auep2()
+static struct msgb *create_msg(const char *str)
{
struct msgb *msg;
msg = msgb_alloc_headroom(4096, 128, "MGCP msg");
- int len = sprintf((char *)msg->data, "AUEP 18983213 ds/e1-2/1@172.16.6.66 MGCP 1.0\r\n");
+ int len = sprintf((char *)msg->data, str);
msg->l2h = msgb_put(msg, len);
return msg;
}
@@ -58,7 +51,7 @@ static void test_auep(void)
mgcp_endpoints_allocate(mgcp_trunk_alloc(cfg, 1));
- inp = create_auep1();
+ inp = create_msg(AUEP1);
msg = mgcp_handle_message(cfg, inp);
msgb_free(inp);
if (strcmp((char *) msg->data, "200 158663169 OK\r\n") != 0)
@@ -66,7 +59,7 @@ static void test_auep(void)
/* Verify that the endpoint is fine */
msgb_free(msg);
- inp = create_auep2();
+ inp = create_msg(AUEP2);
msg = mgcp_handle_message(cfg, inp);
msgb_free(inp);
/* Verify that the endpoint is not fine */