laforge has submitted this change. (
https://gerrit.osmocom.org/c/libosmo-sccp/+/29170 )
Change subject: SIGTRAN: add osmo_sccp_tx_disconn_data() helper
......................................................................
SIGTRAN: add osmo_sccp_tx_disconn_data() helper
SCCP RLSD message might have up to 130 bytes of optional data according to ITU-T Rec Q.713
§4.5 - add helper which
allows sending it and use it in example code.
Related: OS#5579
Change-Id: I92ae22d2cab5863245fba3d904a300055fda34fe
---
M examples/sccp_test_vty.c
M include/osmocom/sigtran/sccp_helpers.h
M src/sccp_helpers.c
3 files changed, 24 insertions(+), 6 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
diff --git a/examples/sccp_test_vty.c b/examples/sccp_test_vty.c
index 3f644e2..f6f86f7 100644
--- a/examples/sccp_test_vty.c
+++ b/examples/sccp_test_vty.c
@@ -94,14 +94,16 @@
}
DEFUN(scu_disc_req, scu_disc_req_cmd,
- "disconnect-req <0-16777216>",
+ "disconnect-req <0-16777216> [DATA]",
"N-DISCONNT.req\n"
- "Connection ID\n")
+ "Connection ID\n"
+ "Optional Data\n")
{
struct osmo_sccp_user *scu = vty->index;
int conn_id = atoi(argv[0]);
- osmo_sccp_tx_disconn(scu, conn_id, NULL, 42);
+ osmo_sccp_tx_disconn_data(scu, conn_id, NULL, 42, (const uint8_t *)argv[1], (argc >
1) ? strlen(argv[1]) + 1 : 0);
+
return CMD_SUCCESS;
}
diff --git a/include/osmocom/sigtran/sccp_helpers.h
b/include/osmocom/sigtran/sccp_helpers.h
index a575169..44fd9bf 100644
--- a/include/osmocom/sigtran/sccp_helpers.h
+++ b/include/osmocom/sigtran/sccp_helpers.h
@@ -44,6 +44,10 @@
const struct osmo_sccp_addr *resp_addr,
uint32_t cause);
+int osmo_sccp_tx_disconn_data(struct osmo_sccp_user *scu, uint32_t conn_id,
+ const struct osmo_sccp_addr *resp_addr,
+ uint32_t cause, const uint8_t *data, size_t len);
+
int osmo_sccp_tx_conn_resp_msg(struct osmo_sccp_user *scu, uint32_t conn_id,
const struct osmo_sccp_addr *resp_addr,
struct msgb *msg);
diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c
index ae7c526..38561be 100644
--- a/src/sccp_helpers.c
+++ b/src/sccp_helpers.c
@@ -193,9 +193,9 @@
}
/* N-DISCONNECT.req */
-int osmo_sccp_tx_disconn(struct osmo_sccp_user *scu, uint32_t conn_id,
- const struct osmo_sccp_addr *resp_addr,
- uint32_t cause)
+int osmo_sccp_tx_disconn_data(struct osmo_sccp_user *scu, uint32_t conn_id,
+ const struct osmo_sccp_addr *resp_addr,
+ uint32_t cause, const uint8_t *data, size_t len)
{
struct msgb *msg;
struct osmo_scu_prim *prim;
@@ -219,9 +219,21 @@
param->conn_id = conn_id;
param->cause = cause;
+ if (data && len) {
+ msg->l2h = msgb_put(msg, len);
+ memcpy(msg->l2h, data, len);
+ }
+
return osmo_sccp_user_sap_down(scu, &prim->oph);
}
+int osmo_sccp_tx_disconn(struct osmo_sccp_user *scu, uint32_t conn_id,
+ const struct osmo_sccp_addr *resp_addr,
+ uint32_t cause)
+{
+ return osmo_sccp_tx_disconn_data(scu, conn_id, resp_addr, cause, NULL, 0);
+}
+
/* N-CONNECT.resp */
int osmo_sccp_tx_conn_resp_msg(struct osmo_sccp_user *scu, uint32_t conn_id,
const struct osmo_sccp_addr *resp_addr,
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-sccp/+/29170
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: I92ae22d2cab5863245fba3d904a300055fda34fe
Gerrit-Change-Number: 29170
Gerrit-PatchSet: 5
Gerrit-Owner: msuraev <msuraev(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged