aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-05-14 03:34:35 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-05-14 03:34:35 +0800
commita202342d64f383319f5cad211f3189c0420f833b (patch)
treec4f8b5f472735ef6925ab8a33fcc6739f25da439
parentd275cf64070cb10ed3873ae25ba4cf289bf714d8 (diff)
[sccp] Export function to create SCCP Refuse message.
-rw-r--r--openbsc/include/sccp/sccp.h2
-rw-r--r--openbsc/src/sccp/sccp.c15
2 files changed, 16 insertions, 1 deletions
diff --git a/openbsc/include/sccp/sccp.h b/openbsc/include/sccp/sccp.h
index 604a2ac72..5dfcc31bf 100644
--- a/openbsc/include/sccp/sccp.h
+++ b/openbsc/include/sccp/sccp.h
@@ -148,6 +148,8 @@ extern const struct sockaddr_sccp sccp_ssn_bssap;
u_int32_t sccp_src_ref_to_int(struct sccp_source_reference *ref);
struct sccp_source_reference sccp_src_ref_from_int(u_int32_t);
+struct msgb *sccp_create_refuse(struct sccp_source_reference *src_ref, int cause);
+
/**
* Below this are helper functions and structs for parsing SCCP messages
*/
diff --git a/openbsc/src/sccp/sccp.c b/openbsc/src/sccp/sccp.c
index de18614c3..35589dc8a 100644
--- a/openbsc/src/sccp/sccp.c
+++ b/openbsc/src/sccp/sccp.c
@@ -638,7 +638,7 @@ static void _sccp_set_connection_state(struct sccp_connection *connection, int n
connection->state_cb(connection, old_state);
}
-static int _sccp_send_refuse(struct sccp_source_reference *src_ref, int cause)
+struct msgb *sccp_create_refuse(struct sccp_source_reference *src_ref, int cause)
{
struct msgb *msgb;
struct sccp_connection_refused *ref;
@@ -646,6 +646,11 @@ static int _sccp_send_refuse(struct sccp_source_reference *src_ref, int cause)
msgb = msgb_alloc_headroom(SCCP_MSG_SIZE,
SCCP_MSG_HEADROOM, "sccp ref");
+ if (!msgb) {
+ LOGP(DSCCP, LOGL_ERROR, "Failed to allocate refusal msg.\n");
+ return NULL;
+ }
+
msgb->l2h = &msgb->data[0];
ref = (struct sccp_connection_refused *) msgb_put(msgb, sizeof(*ref));
@@ -657,6 +662,14 @@ static int _sccp_send_refuse(struct sccp_source_reference *src_ref, int cause)
data = msgb_put(msgb, 1);
data[0] = SCCP_PNC_END_OF_OPTIONAL;
+ return msgb;
+}
+
+static int _sccp_send_refuse(struct sccp_source_reference *src_ref, int cause)
+{
+ struct msgb *msgb = sccp_create_refuse(src_ref, cause);
+ if (!msgb)
+ return -1;
_send_msg(msgb);
return 0;