remove tests/sigtran: it's not a test case
in tests/* we have unit tests that are run as part of the autotest suite during 'make check'. The code in tests/sigtran is an example, but not a test. As the API is changing anyway, let's remove it for now and re-introduce actual tests and examples after the changes in API required by the upcoming new SCCP core. Change-Id: Ie471a197856c875eb4987bf9858d757312de24fb
This commit is contained in:
parent
ee350893cf
commit
85e03de7d1
|
@ -66,7 +66,6 @@ AC_OUTPUT(
|
|||
tests/sccp/Makefile
|
||||
tests/mtp/Makefile
|
||||
tests/m2ua/Makefile
|
||||
tests/sigtran/Makefile
|
||||
tests/xua/Makefile
|
||||
tests/ss7/Makefile
|
||||
Makefile)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
SUBDIRS = xua sccp mtp m2ua sigtran ss7
|
||||
SUBDIRS = xua sccp mtp m2ua ss7
|
||||
|
||||
# The `:;' works around a Bash 3.2 bug when the output is not writeable.
|
||||
$(srcdir)/package.m4: $(top_srcdir)/configure.ac
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)
|
||||
AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS)
|
||||
|
||||
noinst_HEADERS = sua_test_common.h
|
||||
noinst_PROGRAMS = sua_server_test sua_client_test
|
||||
|
||||
sua_server_test_SOURCES = sua_server_test.c sua_test_common.c
|
||||
sua_server_test_LDADD = $(top_builddir)/src/libosmo-sigtran.la $(LIBOSMOCORE_LIBS) $(TALLOC_LIBS)
|
||||
|
||||
sua_client_test_SOURCES = sua_client_test.c sua_test_common.c
|
||||
sua_client_test_LDADD = $(top_builddir)/src/libosmo-sigtran.la $(LIBOSMOCORE_LIBS) $(TALLOC_LIBS)
|
|
@ -1,56 +0,0 @@
|
|||
#include "sua_test_common.h"
|
||||
|
||||
struct osmo_sccp_user *g_user;
|
||||
struct osmo_sccp_link *g_link;
|
||||
|
||||
static int sccp_sap_up(struct osmo_prim_hdr *oph, void *link)
|
||||
{
|
||||
struct osmo_scu_prim *prim = (struct osmo_scu_prim *) oph;
|
||||
struct osmo_prim_hdr *resp = NULL;
|
||||
uint8_t payload[] = { 0xa1, 0xa2, 0xa3 };
|
||||
|
||||
printf("sccp_sap_up(%s)\n", osmo_scu_prim_name(oph));
|
||||
|
||||
switch (OSMO_PRIM_HDR(oph)) {
|
||||
case OSMO_PRIM(OSMO_SCU_PRIM_N_CONNECT, PRIM_OP_CONFIRM):
|
||||
printf("N-CONNECT.ind(%u), issuing DATA.req\n",
|
||||
prim->u.connect.conn_id);
|
||||
resp = make_dt1_req(prim->u.connect.conn_id, payload, sizeof(payload));
|
||||
break;
|
||||
}
|
||||
|
||||
if (resp)
|
||||
osmo_sua_user_link_down(link, resp);
|
||||
|
||||
msgb_free(oph->msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
void *ctx = talloc_named_const(NULL, 1, "root");
|
||||
int rc;
|
||||
|
||||
osmo_sua_set_log_area(DSUA);
|
||||
|
||||
osmo_init_logging(&test_log_info);
|
||||
|
||||
g_user = osmo_sua_user_create(ctx, sccp_sap_up, NULL);
|
||||
|
||||
rc = osmo_sua_client_connect(g_user, "127.0.0.1", 2342);
|
||||
if (rc < 0) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
g_link = osmo_sua_client_get_link(g_user);
|
||||
|
||||
int i = 8000;
|
||||
|
||||
while (1) {
|
||||
if (i < 8010)
|
||||
tx_conn_req(g_link, i++);
|
||||
//tx_unitdata(g_link);
|
||||
osmo_select_main(0);
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
#include "sua_test_common.h"
|
||||
|
||||
struct osmo_prim_hdr *make_conn_resp(struct osmo_scu_connect_param *param)
|
||||
{
|
||||
struct msgb *msg = msgb_alloc(1024, "conn_resp");
|
||||
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_RESPONSE, msg);
|
||||
memcpy(&prim->u.connect, param, sizeof(prim->u.connect));
|
||||
return &prim->oph;
|
||||
}
|
||||
|
||||
static int sccp_sap_up(struct osmo_prim_hdr *oph, void *link)
|
||||
{
|
||||
struct osmo_scu_prim *prim = (struct osmo_scu_prim *) oph;
|
||||
struct osmo_prim_hdr *resp = NULL;
|
||||
const uint8_t payload[] = { 0xb1, 0xb2, 0xb3 };
|
||||
|
||||
printf("sccp_sap_up(%s)\n", osmo_scu_prim_name(oph));
|
||||
|
||||
switch (OSMO_PRIM_HDR(oph)) {
|
||||
case OSMO_PRIM(OSMO_SCU_PRIM_N_CONNECT, PRIM_OP_CONFIRM):
|
||||
/* confirmation of outbound connection */
|
||||
break;
|
||||
case OSMO_PRIM(OSMO_SCU_PRIM_N_CONNECT, PRIM_OP_INDICATION):
|
||||
/* indication of new inbound connection request*/
|
||||
printf("N-CONNECT.ind(X->%u)\n", prim->u.connect.conn_id);
|
||||
resp = make_conn_resp(&prim->u.connect);
|
||||
break;
|
||||
case OSMO_PRIM(OSMO_SCU_PRIM_N_DISCONNECT, PRIM_OP_INDICATION):
|
||||
/* indication of disconnect */
|
||||
printf("N-DISCONNECT.ind(%u)\n", prim->u.disconnect.conn_id);
|
||||
break;
|
||||
case OSMO_PRIM(OSMO_SCU_PRIM_N_DATA, PRIM_OP_INDICATION):
|
||||
/* connection-oriented data received */
|
||||
printf("N-DATA.ind(%u, %s)\n", prim->u.data.conn_id,
|
||||
osmo_hexdump(msgb_l2(oph->msg), msgb_l2len(oph->msg)));
|
||||
resp = make_dt1_req(prim->u.data.conn_id, payload, sizeof(payload));
|
||||
break;
|
||||
case OSMO_PRIM(OSMO_SCU_PRIM_N_UNITDATA, PRIM_OP_INDICATION):
|
||||
/* connection-oriented data received */
|
||||
printf("N-UNITDATA.ind(%s)\n",
|
||||
osmo_hexdump(msgb_l2(oph->msg), msgb_l2len(oph->msg)));
|
||||
tx_unitdata(link);
|
||||
break;
|
||||
}
|
||||
|
||||
if (resp)
|
||||
osmo_sua_user_link_down(link, resp);
|
||||
|
||||
msgb_free(oph->msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct osmo_sccp_user *user;
|
||||
void *ctx = talloc_named_const(NULL, 1, "root");
|
||||
int rc;
|
||||
|
||||
osmo_sua_set_log_area(DSUA);
|
||||
|
||||
osmo_init_logging(&test_log_info);
|
||||
|
||||
user = osmo_sua_user_create(ctx, sccp_sap_up, NULL);
|
||||
|
||||
rc = osmo_sua_server_listen(user, "127.0.0.1", 2342);
|
||||
if (rc < 0) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
osmo_select_main(0);
|
||||
}
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
#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",
|
||||
},
|
||||
};
|
||||
|
||||
const struct log_info test_log_info = {
|
||||
.cat = log_cat,
|
||||
.num_cat = ARRAY_SIZE(log_cat),
|
||||
};
|
||||
|
||||
int tx_unitdata(struct osmo_sccp_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_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;
|
||||
}
|
||||
|
||||
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, OSMO_SCCP_SSN_RANAP);
|
||||
sccp_make_addr_pc_ssn(&prim->u.connect.calling_addr, 1, OSMO_SCCP_SSN_RANAP);
|
||||
prim->u.connect.sccp_class = 2;
|
||||
prim->u.connect.conn_id = conn_id;
|
||||
|
||||
return &prim->oph;
|
||||
}
|
||||
|
||||
int tx_conn_req(struct osmo_sccp_link *link, uint32_t conn_id)
|
||||
{
|
||||
struct osmo_prim_hdr *prim = make_conn_req(conn_id);
|
||||
return 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;
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <osmocom/core/select.h>
|
||||
#include <osmocom/core/prim.h>
|
||||
#include <osmocom/core/talloc.h>
|
||||
#include <osmocom/core/logging.h>
|
||||
#include <osmocom/core/application.h>
|
||||
#include <osmocom/vty/logging.h>
|
||||
|
||||
#include <osmocom/sigtran/sua.h>
|
||||
#include <osmocom/sigtran/sccp_sap.h>
|
||||
|
||||
|
||||
enum log_cat {
|
||||
DMAIN,
|
||||
DSUA,
|
||||
DXUA,
|
||||
};
|
||||
|
||||
extern const struct log_info test_log_info;
|
||||
|
||||
int tx_unitdata(struct osmo_sccp_link *link);
|
||||
int tx_conn_req(struct osmo_sccp_link *link, uint32_t conn_id);
|
||||
|
||||
struct osmo_prim_hdr *make_conn_req(uint32_t conn_id);
|
||||
struct osmo_prim_hdr *make_dt1_req(uint32_t conn_id, const uint8_t *data, unsigned int len);
|
Loading…
Reference in New Issue