diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-05-16 18:33:26 +0800 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-05-16 20:45:15 +0800 |
commit | 01ffc204f3c624f37145a2441ca3c8c5e235c291 (patch) | |
tree | 85a4744e059e0f601e8387650428ae08d75fac0a | |
parent | 466c40bec25e69d9fc746dd562f62c70ea6a00be (diff) |
[sccp] Create a method to create RLSD messages.
-rw-r--r-- | openbsc/include/sccp/sccp.h | 1 | ||||
-rw-r--r-- | openbsc/src/sccp/sccp.c | 24 |
2 files changed, 22 insertions, 3 deletions
diff --git a/openbsc/include/sccp/sccp.h b/openbsc/include/sccp/sccp.h index c3512bb48..b71549760 100644 --- a/openbsc/include/sccp/sccp.h +++ b/openbsc/include/sccp/sccp.h @@ -150,6 +150,7 @@ 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); +struct msgb *sccp_create_rlsd(struct sccp_source_reference *src_ref, struct sccp_source_reference *dst_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 24dc9b0ff..afc42a96f 100644 --- a/openbsc/src/sccp/sccp.c +++ b/openbsc/src/sccp/sccp.c @@ -846,7 +846,8 @@ static int _sccp_send_connection_it(struct sccp_connection *conn) return 0; } -static int _sccp_send_connection_released(struct sccp_connection *conn, int cause) +struct msgb *sccp_create_rlsd(struct sccp_source_reference *src_ref, + struct sccp_source_reference *dst_ref, int cause) { struct msgb *msg; struct sccp_connection_released *rel; @@ -854,19 +855,36 @@ static int _sccp_send_connection_released(struct sccp_connection *conn, int caus msg = msgb_alloc_headroom(SCCP_MSG_SIZE, SCCP_MSG_HEADROOM, "sccp: connection released"); + if (!msg) { + LOGP(DSCCP, LOGL_ERROR, "Failed to allocate RLSD.\n"); + return NULL; + } + msg->l2h = &msg->data[0]; rel = (struct sccp_connection_released *) msgb_put(msg, sizeof(*rel)); rel->type = SCCP_MSG_TYPE_RLSD; rel->release_cause = cause; /* copy the source references */ - memcpy(&rel->destination_local_reference, &conn->destination_local_reference, + memcpy(&rel->destination_local_reference, dst_ref, sizeof(struct sccp_source_reference)); - memcpy(&rel->source_local_reference, &conn->source_local_reference, + memcpy(&rel->source_local_reference, src_ref, sizeof(struct sccp_source_reference)); data = msgb_put(msg, 1); data[0] = SCCP_PNC_END_OF_OPTIONAL; + return msg; +} + +static int _sccp_send_connection_released(struct sccp_connection *conn, int cause) +{ + struct msgb *msg; + + msg = sccp_create_rlsd(&conn->source_local_reference, + &conn->destination_local_reference, + cause); + if (!msg) + return -1; _sccp_set_connection_state(conn, SCCP_CONNECTION_STATE_RELEASE); _send_msg(msg); |