From 60fa0efcc87d3575b2ab8950c177c1633dafc675 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sat, 15 May 2010 01:04:42 +0800 Subject: [sccp] Make it optional to send data on a SCCP Connection Refuse This can be used to send a Location Updating Reject down to the BSC when it is clear that a subscriber is not allowed. --- openbsc/include/sccp/sccp.h | 2 +- openbsc/src/nat/bsc_nat.c | 2 +- openbsc/src/sccp/sccp.c | 11 +++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) (limited to 'openbsc') diff --git a/openbsc/include/sccp/sccp.h b/openbsc/include/sccp/sccp.h index 5dfcc31bf..2aa03224f 100644 --- a/openbsc/include/sccp/sccp.h +++ b/openbsc/include/sccp/sccp.h @@ -148,7 +148,7 @@ 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); +struct msgb *sccp_create_refuse(struct sccp_source_reference *src_ref, int cause, uint8_t *data, int length); /** * Below this are helper functions and structs for parsing SCCP messages diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c index 9a88744f7..a6769805d 100644 --- a/openbsc/src/nat/bsc_nat.c +++ b/openbsc/src/nat/bsc_nat.c @@ -677,7 +677,7 @@ exit2: exit3: /* send a SCCP Connection Refused */ - refuse = sccp_create_refuse(parsed->src_local_ref, SCCP_REFUSAL_SCCP_FAILURE); + refuse = sccp_create_refuse(parsed->src_local_ref, SCCP_REFUSAL_SCCP_FAILURE, NULL, 0); if (refuse) { bsc_send_data(bsc, refuse->l2h, msgb_l2len(refuse), IPAC_PROTO_SCCP); msgb_free(refuse); diff --git a/openbsc/src/sccp/sccp.c b/openbsc/src/sccp/sccp.c index 35589dc8a..f7c31e8a7 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); } -struct msgb *sccp_create_refuse(struct sccp_source_reference *src_ref, int cause) +struct msgb *sccp_create_refuse(struct sccp_source_reference *src_ref, int cause, uint8_t *inp, int length) { struct msgb *msgb; struct sccp_connection_refused *ref; @@ -660,6 +660,13 @@ struct msgb *sccp_create_refuse(struct sccp_source_reference *src_ref, int cause ref->cause = cause; ref->optional_start = 1; + if (inp) { + data = msgb_put(msgb, 1 + 1 + length); + data[0] = SCCP_PNC_DATA; + data[1] = length; + memcpy(&data[2], inp, length); + } + data = msgb_put(msgb, 1); data[0] = SCCP_PNC_END_OF_OPTIONAL; return msgb; @@ -667,7 +674,7 @@ struct msgb *sccp_create_refuse(struct sccp_source_reference *src_ref, int cause static int _sccp_send_refuse(struct sccp_source_reference *src_ref, int cause) { - struct msgb *msgb = sccp_create_refuse(src_ref, cause); + struct msgb *msgb = sccp_create_refuse(src_ref, cause, NULL, 0); if (!msgb) return -1; -- cgit v1.2.3