sccp: Allow to create a _udt message with the given parameter.

This commit is contained in:
Holger Hans Peter Freyther 2010-08-01 20:52:01 +08:00
parent 8c1402ea99
commit d2a7174414
2 changed files with 20 additions and 3 deletions

View File

@ -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

View File

@ -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;
}