aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-05-16 17:55:07 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-05-16 20:45:15 +0800
commit466c40bec25e69d9fc746dd562f62c70ea6a00be (patch)
tree7415b68cc3b5d82d11ece4bf1bb603518a09718a
parent60a2f4a7e6d9dbcd76eb59ed943a415303247265 (diff)
[sccp] Create a SCCP CC creation routine.
-rw-r--r--openbsc/include/sccp/sccp.h1
-rw-r--r--openbsc/src/sccp/sccp.c31
2 files changed, 24 insertions, 8 deletions
diff --git a/openbsc/include/sccp/sccp.h b/openbsc/include/sccp/sccp.h
index 2aa03224f..c3512bb48 100644
--- a/openbsc/include/sccp/sccp.h
+++ b/openbsc/include/sccp/sccp.h
@@ -149,6 +149,7 @@ 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, uint8_t *data, int length);
+struct msgb *sccp_create_cc(struct sccp_source_reference *src_ref, struct sccp_source_reference *dst_ref);
/**
* 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 f7c31e8a7..24dc9b0ff 100644
--- a/openbsc/src/sccp/sccp.c
+++ b/openbsc/src/sccp/sccp.c
@@ -682,33 +682,48 @@ static int _sccp_send_refuse(struct sccp_source_reference *src_ref, int cause)
return 0;
}
-static int _sccp_send_connection_confirm(struct sccp_connection *connection)
+struct msgb *sccp_create_cc(struct sccp_source_reference *src_ref,
+ struct sccp_source_reference *dst_ref)
{
struct msgb *response;
struct sccp_connection_confirm *confirm;
u_int8_t *optional_data;
- if (assign_source_local_reference(connection) != 0)
- return -1;
-
response = msgb_alloc_headroom(SCCP_MSG_SIZE,
SCCP_MSG_HEADROOM, "sccp confirm");
+ if (!response) {
+ LOGP(DSCCP, LOGL_ERROR, "Failed to create SCCP Confirm.\n");
+ return NULL;
+ }
+
response->l2h = &response->data[0];
confirm = (struct sccp_connection_confirm *) msgb_put(response, sizeof(*confirm));
confirm->type = SCCP_MSG_TYPE_CC;
memcpy(&confirm->destination_local_reference,
- &connection->destination_local_reference,
- sizeof(connection->destination_local_reference));
+ dst_ref, sizeof(*dst_ref));
memcpy(&confirm->source_local_reference,
- &connection->source_local_reference,
- sizeof(connection->source_local_reference));
+ src_ref, sizeof(*src_ref));
confirm->proto_class = 2;
confirm->optional_start = 1;
optional_data = (u_int8_t *) msgb_put(response, 1);
optional_data[0] = SCCP_PNC_END_OF_OPTIONAL;
+ return response;
+}
+
+static int _sccp_send_connection_confirm(struct sccp_connection *connection)
+{
+ struct msgb *response;
+
+ if (assign_source_local_reference(connection) != 0)
+ return -1;
+
+ response = sccp_create_cc(&connection->source_local_reference,
+ &connection->destination_local_reference);
+ if (!response)
+ return -1;
_send_msg(response);
_sccp_set_connection_state(connection, SCCP_CONNECTION_STATE_ESTABLISHED);