summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-03-26 05:44:21 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-03-26 05:44:21 +0100
commita9e39c3264a4acf36b25d38207cb3bd9bb00c9ac (patch)
tree25eec296ea9024eb5e979ae570976297c384dac6 /tests
parente929c0c8435a812cdf3ad7075aed8ee94b4eb8d8 (diff)
sccp: Change the ownership of the msgb passed to the callback
Instead of deleting the msgb within the SCCP library the implementor of the write callback needs to free it. This is required for non blocking io with the server.
Diffstat (limited to 'tests')
-rw-r--r--tests/sccp/sccp_test.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/tests/sccp/sccp_test.c b/tests/sccp/sccp_test.c
index eb41d3e..0c2adc8 100644
--- a/tests/sccp/sccp_test.c
+++ b/tests/sccp/sccp_test.c
@@ -354,14 +354,14 @@ int sccp_read_cb(struct msgb *data, unsigned len, void *context)
return 0;
}
-int sccp_write_cb(struct msgb *data, void *ctx)
+void sccp_write_cb(struct msgb *data, void *ctx)
{
int i = 0;
const u_int8_t *got, *wanted;
if (test_data[current_test].response == NULL) {
FAIL("Didn't expect write callback\n");
- return -1;
+ goto exit;
} else if (test_data[current_test].response_length != msgb_l2len(data)) {
FAIL("Size does not match. Got: %d Wanted: %d\n",
msgb_l2len(data), test_data[current_test].response_length);
@@ -374,12 +374,14 @@ int sccp_write_cb(struct msgb *data, void *ctx)
if (got[i] != wanted[i]) {
FAIL("Failed to compare byte. Got: 0x%x Wanted: 0x%x at %d\n",
got[i], wanted[i], i);
- return -1;
+ goto exit;
}
}
write_called = 1;
- return 0;
+
+exit:
+ msgb_free(data);
}
void sccp_c_read(struct sccp_connection *connection, struct msgb *msgb, unsigned int len)
@@ -409,7 +411,7 @@ int sccp_accept_cb(struct sccp_connection *connection, void *user_data)
return 0;
}
-static int sccp_udt_write_cb(struct msgb *data, void *context)
+static void sccp_udt_write_cb(struct msgb *data, void *context)
{
const u_int8_t *got, *wanted;
int i;
@@ -419,7 +421,7 @@ static int sccp_udt_write_cb(struct msgb *data, void *context)
if (send_data[current_test].length != msgb_l2len(data)) {
FAIL("Size does not match. Got: %d Wanted: %d\n",
msgb_l2len(data), send_data[current_test].length);
- return -1;
+ goto exit;
}
got = &data->l2h[0];
@@ -429,12 +431,14 @@ static int sccp_udt_write_cb(struct msgb *data, void *context)
if (got[i] != wanted[i]) {
FAIL("Failed to compare byte. Got: 0x%x Wanted: 0x%x at %d\n",
got[i], wanted[i], i);
- return -1;
+ goto exit;
}
}
matched = 1;
- return 0;
+
+exit:
+ msgb_free(data);
}
static void test_sccp_system(void)
@@ -504,11 +508,11 @@ static int sccp_udt_read(struct msgb *data, unsigned int len, void *context)
return 0;
}
-static int sccp_write_loop(struct msgb *data, void *context)
+static void sccp_write_loop(struct msgb *data, void *context)
{
/* send it back to us */
sccp_system_incoming(data);
- return 0;
+ msgb_free(data);
}
static void test_sccp_udt_communication(void)