summaryrefslogtreecommitdiffstats
path: root/src/sccp.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-08-01 20:52:01 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-08-01 20:52:01 +0800
commitd2a71744142a9ebf3dba9b1bdb97a81fb9eff3f5 (patch)
treec456aea23cf0a5523dae9afec90106b248457b49 /src/sccp.c
parent8c1402ea99750a4d0175e2464d445ade27d0826e (diff)
sccp: Allow to create a _udt message with the given parameter.
Diffstat (limited to 'src/sccp.c')
-rw-r--r--src/sccp.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/sccp.c b/src/sccp.c
index da14120..23f8776 100644
--- a/src/sccp.c
+++ b/src/sccp.c
@@ -513,19 +513,22 @@ static void create_sccp_addr(struct msgb *msg, const struct sockaddr_sccp *sock)
/*
* Send UDT. Currently we have a fixed address...
*/
-static int _sccp_send_data(int class, const struct sockaddr_sccp *in,
- const struct sockaddr_sccp *out, struct msgb *payload)
+struct msgb *sccp_create_udt(int class, const struct sockaddr_sccp *in,
+ const struct sockaddr_sccp *out, struct msgb *payload)
{
struct sccp_data_unitdata *udt;
uint8_t *data;
if (msgb_l3len(payload) > 256) {
LOGP(DSCCP, LOGL_ERROR, "The payload is too big for one udt\n");
- return -1;
+ return NULL;
}
struct msgb *msg = msgb_alloc_headroom(SCCP_MSG_SIZE,
SCCP_MSG_HEADROOM, "sccp: udt");
+ if (!msg)
+ return NULL;
+
msg->l2h = &msg->data[0];
udt = (struct sccp_data_unitdata *)msgb_put(msg, sizeof(*udt));
@@ -544,6 +547,18 @@ static int _sccp_send_data(int class, const struct sockaddr_sccp *in,
data[0] = msgb_l3len(payload);
memcpy(&data[1], payload->l3h, msgb_l3len(payload));
+ return msg;
+}
+
+static int _sccp_send_data(int class, const struct sockaddr_sccp *in,
+ const struct sockaddr_sccp *out, struct msgb *payload)
+{
+ struct msgb *msg;
+
+ msg = sccp_create_udt(class, in, out, payload);
+ if (!msg)
+ return -1;
+
_send_msg(msg);
return 0;
}