aboutsummaryrefslogtreecommitdiffstats
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
parent8c1402ea99750a4d0175e2464d445ade27d0826e (diff)
sccp: Allow to create a _udt message with the given parameter.
-rw-r--r--include/sccp/sccp.h2
-rw-r--r--src/sccp.c21
2 files changed, 20 insertions, 3 deletions
diff --git a/include/sccp/sccp.h b/include/sccp/sccp.h
index fd468c5..4d7f727 100644
--- a/include/sccp/sccp.h
+++ b/include/sccp/sccp.h
@@ -166,6 +166,8 @@ struct msgb *sccp_create_refuse(struct sccp_source_reference *src_ref, int cause
struct msgb *sccp_create_cc(struct sccp_source_reference *src_ref, struct sccp_source_reference *dst_ref);
struct msgb *sccp_create_rlsd(struct sccp_source_reference *src_ref, struct sccp_source_reference *dst_ref, int cause);
struct msgb *sccp_create_dt1(struct sccp_source_reference *dst_ref, uint8_t *data, uint8_t len);
+struct msgb *sccp_create_udt(int _class, const struct sockaddr_sccp *sock_sender,
+ const struct sockaddr_sccp *sock_target, struct msgb *msg);
/**
* Below this are helper functions and structs for parsing SCCP messages
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;
}