diff options
author | Harald Welte <laforge@gnumonks.org> | 2015-12-21 23:35:56 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2015-12-21 23:35:56 +0100 |
commit | 283c7fde3809d3bb010b736c4597641f3d290260 (patch) | |
tree | 5e56e05c534dff33bfb267a98ac15bfbefcfbaf1 /sigtran/sua_test_common.c | |
parent | 71f73a2919ec071de8b8f1972db6cc92c29a55ee (diff) |
Add WIP code for SCCP User Adaptation (SUA) and SCCP User SAP
The idea of this code is to
* provide a SCCP User SAP as boundary between the User of SCCP
or SCCP-like transport like SUA
* implement the minimum subset of SUA to transport RANAP messages
betweene HNB-GW and MSC/SGSN
At this point
* we don't yet implement the proper state machines and timer
* we don't imp[lement the SCCP RESET procedure
* we don't implement AS/ASP management
The code is full of FIXMEs whihc hopefully will get fixed gradually.
After some cleanup + verification, it should move to a library, possibly
either replacing/renaming libomo-sccp, or adding it to libosmo-netif?
Diffstat (limited to 'sigtran/sua_test_common.c')
-rw-r--r-- | sigtran/sua_test_common.c | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/sigtran/sua_test_common.c b/sigtran/sua_test_common.c new file mode 100644 index 0000000..92c2b38 --- /dev/null +++ b/sigtran/sua_test_common.c @@ -0,0 +1,95 @@ +#include "sua_test_common.h" + +static const struct log_info_cat log_cat[] = { + [DMAIN] = { + .name = "DMAIN", .loglevel = LOGL_DEBUG, .enabled = 1, + .color = "", + .description = "Main program", + }, + [DSUA] = { + .name = "DSUA", .loglevel = LOGL_DEBUG, .enabled = 1, + .color = "", + .description = "SCCP User Adaption", + }, + [DXUA] = { + .name = "DXUA", .loglevel = LOGL_DEBUG, .enabled = 1, + .color = "", + .description = "X User Adaption encoding/decoding", + }, + +}; + +const struct log_info test_log_info = { + .cat = log_cat, + .num_cat = ARRAY_SIZE(log_cat), +}; + +int tx_unitdata(struct sua_link *link) +{ + struct msgb *msg = msgb_alloc(1024, "tx_unitdata"); + struct osmo_scu_prim *prim; + struct osmo_scu_unitdata_param *param; + uint8_t *cur; + + prim = (struct osmo_scu_prim *) msgb_put(msg, sizeof(*prim)); + param = &prim->u.unitdata; + param->calling_addr.presence = OSMO_SCCP_ADDR_T_SSN; + param->called_addr.presence = OSMO_SCCP_ADDR_T_SSN; + osmo_prim_init(&prim->oph, SCCP_SAP_USER, OSMO_SCU_PRIM_N_UNITDATA, PRIM_OP_REQUEST, msg); + + cur = msg->l2h = msgb_put(msg, 3); + cur[0] = 1; cur[1] = 2; cur[2] = 3; + + return osmo_osmo_sua_user_link_down(link, &prim->oph); +} + +static void sccp_make_addr_pc_ssn(struct osmo_sccp_addr *addr, uint32_t pc, uint32_t ssn) +{ + addr->presence = OSMO_SCCP_ADDR_T_SSN | OSMO_SCCP_ADDR_T_PC; + addr->ssn = ssn; + addr->pc = pc; +} + +#define SSN_RANAP 142 + +struct osmo_prim_hdr *make_conn_req(uint32_t conn_id) +{ + struct msgb *msg = msgb_alloc(1024, "conn_req"); + struct osmo_scu_prim *prim; + + prim = (struct osmo_scu_prim *) msgb_put(msg, sizeof(*prim)); + osmo_prim_init(&prim->oph, SCCP_SAP_USER, + OSMO_SCU_PRIM_N_CONNECT, + PRIM_OP_REQUEST, msg); + /* Set SSN for calling and called addr */ + sccp_make_addr_pc_ssn(&prim->u.connect.called_addr, 2, SSN_RANAP); + sccp_make_addr_pc_ssn(&prim->u.connect.calling_addr, 1, SSN_RANAP); + prim->u.connect.sccp_class = 2; + prim->u.connect.conn_id = conn_id; + + return &prim->oph; +} + +int tx_conn_req(struct sua_link *link, uint32_t conn_id) +{ + struct osmo_prim_hdr *prim = make_conn_req(conn_id); + return osmo_osmo_sua_user_link_down(link, prim); +} + +struct osmo_prim_hdr * +make_dt1_req(uint32_t conn_id, const uint8_t *data, unsigned int len) +{ + struct msgb *msg = msgb_alloc(1024, "dt1"); + struct osmo_scu_prim *prim; + + prim = (struct osmo_scu_prim *) msgb_put(msg, sizeof(*prim)); + osmo_prim_init(&prim->oph, SCCP_SAP_USER, + OSMO_SCU_PRIM_N_DATA, + PRIM_OP_REQUEST, msg); + prim->u.data.conn_id = conn_id; + + msg->l2h = msgb_put(msg, len); + memcpy(msg->l2h, data, len); + + return &prim->oph; +} |