remove sigtran code, now part of libosmo-sccp
This commit is contained in:
parent
269b8ac7ee
commit
38a4f32d58
|
@ -1,17 +0,0 @@
|
|||
LDADD := -ltalloc -lsctp $(shell pkg-config --libs libosmo-sccp) $(shell pkg-config --libs libosmocore) $(shell pkg-config --libs libosmo-netif)
|
||||
LDFLAGS += $(LDADD)
|
||||
CFLAGS += -Wall
|
||||
|
||||
all: sua_client_test sua_server_test
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -o $@ -c $^
|
||||
|
||||
sua_client_test: sccp_sap.o sua.o sua_client_test.o sua_test_common.o /usr/local/lib/libxua.a
|
||||
$(CC) $(LDFLAGS) -o $@ $^
|
||||
|
||||
sua_server_test: sccp_sap.o sua.o sua_server_test.o sua_test_common.o /usr/local/lib/libxua.a
|
||||
$(CC) $(LDFLAGS) -o $@ $^
|
||||
|
||||
clean:
|
||||
@rm *.o sua_client_test sua_server_test
|
|
@ -1,122 +0,0 @@
|
|||
/* RFC 3868 SUA SCCP User Adaption */
|
||||
|
||||
/* (C) 2012 by Harald Welte <laforge@gnumonks.org>
|
||||
%
|
||||
% All Rights Reserved
|
||||
%
|
||||
% This program is free software; you can redistribute it and/or modify
|
||||
% it under the terms of the GNU Affero General Public License as
|
||||
% published by the Free Software Foundation; either version 3 of the
|
||||
% License, or (at your option) any later version.
|
||||
%
|
||||
% This program is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU Affero General Public License
|
||||
% along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* FIXME: Move this to libosmocore osmocom/core/gsm/protocol/sua.h */
|
||||
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
#define SUA_PPID 4
|
||||
#define SUA_PORT 14001
|
||||
|
||||
/* 3.1.2 Message Classes */
|
||||
#define SUA_MSGC_MGMT 0
|
||||
#define SUA_MSGC_SNM 2
|
||||
#define SUA_MSGC_ASPSM 3
|
||||
#define SUA_MSGC_ASPTM 4
|
||||
#define SUA_MSGC_CL 7
|
||||
#define SUA_MSGC_CO 8
|
||||
#define SUA_MSGC_RKM 9
|
||||
|
||||
/* 3.1.3 Message Types */
|
||||
#define SUA_MGMT_ERR 0
|
||||
#define SUA_MGMT_NTFY 1
|
||||
|
||||
#define SUA_SNM_DUNA 1
|
||||
#define SUA_SNM_DAVA 2
|
||||
#define SUA_SNM_DAUD 3
|
||||
#define SUA_SNM_SCON 4
|
||||
#define SUA_SNM_DUPU 5
|
||||
#define SUA_SNM_DRST 6
|
||||
|
||||
#define SUA_ASPSM_UP 1
|
||||
#define SUA_ASPSM_DOWN 2
|
||||
#define SUA_ASPSM_BEAT 3
|
||||
#define SUA_ASPSM_UP_ACK 4
|
||||
#define SUA_ASPSM_DOWN_ACK 5
|
||||
#define SUA_ASPSM_BEAT_ACK 6
|
||||
|
||||
#define SUA_ASPTM_ACTIVE 1
|
||||
#define SUA_ASPTM_INACTIVE 2
|
||||
#define SUA_ASPTM_ACTIVE_ACK 3
|
||||
#define SUA_ASPTM_INACTIVE_ACK 4
|
||||
|
||||
#define SUA_RKM_REG_REQ 1
|
||||
#define SUA_RKM_REG_RSP 2
|
||||
#define SUA_RKM_DEREG_REQ 3
|
||||
#define SUA_RKM_DEREG_RSP 4
|
||||
|
||||
#define SUA_CL_CLDT 1
|
||||
#define SUA_CL_CLDR 2
|
||||
|
||||
#define SUA_CO_CORE 1
|
||||
#define SUA_CO_COAK 2
|
||||
#define SUA_CO_COREF 3
|
||||
#define SUA_CO_RELRE 4
|
||||
#define SUA_CO_RELCO 5
|
||||
#define SUA_CO_RESCO 6
|
||||
#define SUA_CO_RESRE 7
|
||||
#define SUA_CO_CODT 8
|
||||
#define SUA_CO_CODA 9
|
||||
#define SUA_CO_COERR 10
|
||||
#define SUA_CO_COIT 11
|
||||
|
||||
#define SUA_IEI_ROUTE_CTX 0x0006
|
||||
#define SUA_IEI_CORR_ID 0x0013
|
||||
#define SUA_IEI_REG_RESULT 0x0014
|
||||
#define SUA_IEI_DEREG_RESULT 0x0015
|
||||
|
||||
/* 3.10 SUA specific parameters */
|
||||
|
||||
#define SUA_IEI_S7_HOP_CTR 0x0101
|
||||
#define SUA_IEI_SRC_ADDR 0x0102
|
||||
#define SUA_IEI_DEST_ADDR 0x0103
|
||||
#define SUA_IEI_SRC_REF 0x0104
|
||||
#define SUA_IEI_DEST_REF 0x0105
|
||||
#define SUA_IEI_CAUSE 0x0106
|
||||
#define SUA_IEI_SEQ_NR 0x0107
|
||||
#define SUA_IEI_RX_SEQ_NR 0x0108
|
||||
#define SUA_IEI_ASP_CAPA 0x0109
|
||||
#define SUA_IEI_CREDIT 0x010A
|
||||
#define SUA_IEI_DATA 0x010B
|
||||
#define SUA_IEI_USER_CAUSE 0x010C
|
||||
#define SUA_IEI_NET_APPEARANCE 0x010D
|
||||
#define SUA_IEI_ROUTING_KEY 0x010E
|
||||
#define SUA_IEI_DRN 0x010F
|
||||
#define SUA_IEI_TID 0x0110
|
||||
#define SUA_IEI_SMI 0x0112
|
||||
#define SUA_IEI_IMPORTANCE 0x0113
|
||||
#define SUA_IEI_MSG_PRIO 0x0114
|
||||
#define SUA_IEI_PROTO_CLASS 0x0115
|
||||
#define SUA_IEI_SEQ_CTRL 0x0116
|
||||
#define SUA_IEI_SEGMENTATION 0x0117
|
||||
#define SUA_IEI_CONG_LEVEL 0x0118
|
||||
|
||||
#define SUA_IEI_GT 0x8001
|
||||
#define SUA_IEI_PC 0x8002
|
||||
#define SUA_IEI_SSN 0x8003
|
||||
#define SUA_IEI_IPv4 0x8004
|
||||
#define SUA_IEI_HOST 0x8005
|
||||
#define SUA_IEI_IPv6 0x8006
|
||||
|
||||
#define SUA_RI_GT 1
|
||||
#define SUA_RI_SSN_PC 2
|
||||
#define SUA_RI_HOST 3
|
||||
#define SUA_RI_SSN_IP 4
|
|
@ -1,43 +0,0 @@
|
|||
#include <string.h>
|
||||
#include <osmocom/core/utils.h>
|
||||
|
||||
#include "sccp_sap.h"
|
||||
|
||||
const struct value_string osmo_scu_prim_names[] = {
|
||||
{ OSMO_SCU_PRIM_N_CONNECT, "N-CONNECT" },
|
||||
{ OSMO_SCU_PRIM_N_DATA, "N-DATA" },
|
||||
{ OSMO_SCU_PRIM_N_EXPEDITED_DATA, "N-EXPEDITED-DATA" },
|
||||
{ OSMO_SCU_PRIM_N_DISCONNECT, "N-DISCONNECT" },
|
||||
{ OSMO_SCU_PRIM_N_RESET, "N-RESET" },
|
||||
{ OSMO_SCU_PRIM_N_INFORM, "N-INFORM" },
|
||||
{ OSMO_SCU_PRIM_N_UNITDATA, "N-UNITDATA" },
|
||||
{ OSMO_SCU_PRIM_N_NOTICE, "N-NOTICE" },
|
||||
/* management */
|
||||
{ OSMO_SCU_PRIM_N_COORD, "N-COORD" },
|
||||
{ OSMO_SCU_PRIM_N_STATE, "N-STATE" },
|
||||
{ OSMO_SCU_PRIM_N_PCSTATE, "N-PCSATE" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
const struct value_string osmo_prim_op_names[] = {
|
||||
{ PRIM_OP_REQUEST, "request" },
|
||||
{ PRIM_OP_RESPONSE, "response" },
|
||||
{ PRIM_OP_INDICATION, "indication" },
|
||||
{ PRIM_OP_CONFIRM, "confirm" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static char prim_name_buf[128];
|
||||
|
||||
char *osmo_sccp_prim_name(struct osmo_prim_hdr *oph)
|
||||
{
|
||||
const char *name = get_value_string(osmo_scu_prim_names, oph->primitive);
|
||||
|
||||
prim_name_buf[0] = '\0';
|
||||
strncpy(prim_name_buf, name, sizeof(prim_name_buf)-1);
|
||||
prim_name_buf[sizeof(prim_name_buf)-1] = '\0';
|
||||
name = get_value_string(osmo_prim_op_names, oph->operation);
|
||||
strncat(prim_name_buf, name, sizeof(prim_name_buf)-strlen(prim_name_buf)-2);
|
||||
|
||||
return prim_name_buf;
|
||||
}
|
|
@ -1,199 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
/* SCCP User SAP description */
|
||||
|
||||
/* (C) 2015 by Harald Welte <laforge@gnumonks.org>
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <osmocom/core/prim.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
/* FIXME: properly define this based on libosmocore */
|
||||
#define SCCP_SAP_USER 0x2342
|
||||
|
||||
/* detailed coding of primitives at the SAP_SCCP_USER */
|
||||
|
||||
/*! \brief SCCP-User primitives as per Q.711 */
|
||||
enum osmo_scu_prim_type {
|
||||
/* connection oriented, 6.1.1 */
|
||||
OSMO_SCU_PRIM_N_CONNECT,
|
||||
OSMO_SCU_PRIM_N_DATA,
|
||||
OSMO_SCU_PRIM_N_EXPEDITED_DATA,
|
||||
OSMO_SCU_PRIM_N_DISCONNECT,
|
||||
OSMO_SCU_PRIM_N_RESET,
|
||||
OSMO_SCU_PRIM_N_INFORM,
|
||||
/* connectionless, 6.2.2 */
|
||||
OSMO_SCU_PRIM_N_UNITDATA,
|
||||
OSMO_SCU_PRIM_N_NOTICE,
|
||||
/* management */
|
||||
OSMO_SCU_PRIM_N_COORD,
|
||||
OSMO_SCU_PRIM_N_STATE,
|
||||
OSMO_SCU_PRIM_N_PCSTATE,
|
||||
};
|
||||
|
||||
#define OSMO_SCCP_ADDR_T_GT 0x0001
|
||||
#define OSMO_SCCP_ADDR_T_PC 0x0002
|
||||
#define OSMO_SCCP_ADDR_T_SSN 0x0004
|
||||
#define OSMO_SCCP_ADDR_T_IPv4 0x0008
|
||||
#define OSMO_SCCP_ADDR_T_IPv6 0x0010
|
||||
|
||||
/* Q.713 3.4.1 + RFC 3868 3.10.2.3 */
|
||||
enum osmo_sccp_routing_ind {
|
||||
OSMO_SCCP_RI_GT,
|
||||
OSMO_SCCP_RI_SSN_PC,
|
||||
OSMO_SCCP_RI_SSN_IP,
|
||||
};
|
||||
|
||||
/* Q.713 3.4.1 + RFC 3868 3.10.2.3 */
|
||||
enum osmo_sccp_gti {
|
||||
OSMO_SCCP_GTI_NO_GT,
|
||||
OSMO_SCCP_GTI_NAI_ONLY,
|
||||
OSMO_SCCP_GTI_TT_ONLY,
|
||||
OSMO_SCCP_GTI_TT_NPL_ENC,
|
||||
OSMO_SCCP_GTI_TT_NPL_ENC_NAI,
|
||||
};
|
||||
|
||||
/* RFC 3868 3.10.2.3 */
|
||||
enum osmo_sccp_npi {
|
||||
OSMO_SCCP_NPI_UNKNOWN = 0,
|
||||
OSMO_SCCP_NPI_E164_ISDN = 1,
|
||||
OSMO_SCCP_NPI_GEERIC = 2,
|
||||
OSMO_SCCP_NPI_X121_DATA = 3,
|
||||
OSMO_SCCP_NPI_F69_TELEX = 4,
|
||||
OSMO_SCCP_NPI_E210_MARITIME = 5,
|
||||
OSMO_SCCP_NPI_E212_LAND = 6,
|
||||
OSMO_SCCP_NPI_E214_ISDN_MOBILE = 7,
|
||||
OSMO_SCCP_NPI_PRIVATE = 14,
|
||||
};
|
||||
|
||||
/* Q.713 3.4.2.3.1 + RFC 3868 3.10.2.3 */
|
||||
enum osmo_sccp_nai {
|
||||
OSMO_SCCP_NAI_UNKNOWN = 0,
|
||||
OSMO_SCCP_NAI_SUBSCR = 1,
|
||||
OSMO_SCCP_NAI_RES_NAT_USE = 2,
|
||||
OSMO_SCCP_NAI_NATL = 3,
|
||||
OSMO_SCCP_NAI_INTL = 4,
|
||||
/* 5.. 255: Spare */
|
||||
};
|
||||
|
||||
/* Q.713 3.4.2.2 */
|
||||
enum osmo_sccp_ssn {
|
||||
OSMO_SCCP_SSN_MGMT = 1,
|
||||
OSMO_SCCP_SSN_ISUP = 3,
|
||||
OSMO_SCCP_SSN_OMAP = 4,
|
||||
OSMO_SCCP_SSN_MAP = 5,
|
||||
OSMO_SCCP_SSN_HLR = 6,
|
||||
OSMO_SCCP_SSN_VLR = 7,
|
||||
OSMO_SCCP_SSN_MSC = 8,
|
||||
OSMO_SCCP_SSN_EIR = 9,
|
||||
OSMO_SCCP_SSN_AUC = 0x0a,
|
||||
OSMO_SCCP_SSN_ISDN_SS = 0x0b,
|
||||
OSMO_SCCP_SSN_RES_INTL = 0x0c,
|
||||
OSMO_SCCP_SSN_BISDN = 0x0d,
|
||||
OSMO_SCCP_SSN_TC_TEST = 0x0e,
|
||||
};
|
||||
|
||||
struct osmo_sccp_gt {
|
||||
uint8_t gti;
|
||||
uint8_t nr_digits;
|
||||
uint8_t tt;
|
||||
uint32_t npi;
|
||||
uint32_t nai;
|
||||
uint8_t digits[32];
|
||||
};
|
||||
|
||||
struct osmo_sccp_addr {
|
||||
uint32_t presence;
|
||||
struct osmo_sccp_gt gt;
|
||||
uint32_t pc;
|
||||
uint32_t ssn;
|
||||
union {
|
||||
struct in_addr v4;
|
||||
struct in6_addr v6;
|
||||
} ip;
|
||||
/* we don't do hostnames */
|
||||
};
|
||||
|
||||
/* OSMO_SCU_PRIM_N_CONNECT */
|
||||
struct osmo_scu_connect_param {
|
||||
struct osmo_sccp_addr called_addr;
|
||||
struct osmo_sccp_addr calling_addr;
|
||||
struct osmo_sccp_addr responding_addr;
|
||||
//struct osmo_sccp_qos_pars qos_pars;
|
||||
uint32_t sccp_class;
|
||||
uint32_t importance;
|
||||
uint32_t conn_id;
|
||||
/* user data */
|
||||
};
|
||||
|
||||
/* OSMO_SCU_PRIM_N_DATA / OSMO_SCU_PRIM_N_EXPEDITED_DATA */
|
||||
struct osmo_scu_data_param {
|
||||
uint32_t conn_id;
|
||||
uint32_t importance;
|
||||
/* user data */
|
||||
};
|
||||
|
||||
enum osmo_sccp_originator {
|
||||
OSMO_SCCP_ORIG_NS_PROVIDER,
|
||||
OSMO_SCCP_ORIG_NS_USER,
|
||||
OSMO_SCCP_ORIG_UNDEFINED,
|
||||
};
|
||||
|
||||
/* OSMO_SCU_PRIM_N_DISCONNECT */
|
||||
struct osmo_scu_disconn_param {
|
||||
enum osmo_sccp_originator originator;
|
||||
struct osmo_sccp_addr repsonding_addr;
|
||||
uint32_t cause;
|
||||
uint32_t conn_id;
|
||||
uint32_t importance;
|
||||
/* user data */
|
||||
};
|
||||
|
||||
/* OSMO_SCU_PRIM_N_RESET */
|
||||
struct osmo_scu_reset_param {
|
||||
enum osmo_sccp_originator originator;
|
||||
uint32_t cause;
|
||||
uint32_t conn_id;
|
||||
};
|
||||
|
||||
/* OSMO_SCU_PRIM_N_UNITDATA */
|
||||
struct osmo_scu_unitdata_param {
|
||||
struct osmo_sccp_addr called_addr;
|
||||
struct osmo_sccp_addr calling_addr;
|
||||
uint32_t in_sequence_control;
|
||||
uint32_t return_option;
|
||||
uint32_t importance;
|
||||
/* user data */
|
||||
};
|
||||
|
||||
struct osmo_scu_prim {
|
||||
struct osmo_prim_hdr oph;
|
||||
union {
|
||||
struct osmo_scu_connect_param connect;
|
||||
struct osmo_scu_data_param data;
|
||||
struct osmo_scu_disconn_param disconnect;
|
||||
struct osmo_scu_reset_param reset;
|
||||
struct osmo_scu_unitdata_param unitdata;
|
||||
} u;
|
||||
};
|
||||
|
||||
#define msgb_scu_prim(msg) ((struct osmo_scu_prim *)(msg)->l1h)
|
||||
|
||||
char *osmo_sccp_prim_name(struct osmo_prim_hdr *oph);
|
1431
sigtran/sua.c
1431
sigtran/sua.c
File diff suppressed because it is too large
Load Diff
|
@ -1,21 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <osmocom/core/prim.h>
|
||||
|
||||
struct osmo_sua_user;
|
||||
struct osmo_sua_link;
|
||||
|
||||
void osmo_sua_set_log_area(int area);
|
||||
|
||||
struct osmo_sua_user *osmo_sua_user_create(void *ctx, osmo_prim_cb prim_cb);
|
||||
void osmo_sua_user_destroy(struct osmo_sua_user *user);
|
||||
|
||||
int osmo_sua_server_listen(struct osmo_sua_user *user, const char *hostname, uint16_t port);
|
||||
|
||||
int osmo_sua_client_connect(struct osmo_sua_user *user, const char *hostname, uint16_t port);
|
||||
struct osmo_sua_link *osmo_sua_client_get_link(struct osmo_sua_user *user);
|
||||
|
||||
/* user hands us a SCCP-USER SAP primitive down into the stack */
|
||||
int osmo_sua_user_link_down(struct osmo_sua_link *link, struct osmo_prim_hdr *oph);
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
#include "sua_test_common.h"
|
||||
|
||||
struct osmo_sua_user *g_user;
|
||||
struct sua_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_sccp_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);
|
||||
xua_set_log_area(DXUA);
|
||||
|
||||
osmo_init_logging(&test_log_info);
|
||||
|
||||
g_user = osmo_sua_user_create(ctx, sccp_sap_up);
|
||||
|
||||
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,79 +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_sccp_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_sua_user *user;
|
||||
void *ctx = talloc_named_const(NULL, 1, "root");
|
||||
int rc;
|
||||
|
||||
osmo_sua_set_log_area(DSUA);
|
||||
xua_set_log_area(DXUA);
|
||||
|
||||
osmo_init_logging(&test_log_info);
|
||||
|
||||
user = osmo_sua_user_create(ctx, sccp_sap_up);
|
||||
|
||||
rc = osmo_sua_server_listen(user, "127.0.0.1", 2342);
|
||||
if (rc < 0) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
osmo_select_main(0);
|
||||
}
|
||||
}
|
|
@ -1,95 +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",
|
||||
},
|
||||
[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 osmo_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_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 osmo_sua_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,31 +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/vty/logging.h>
|
||||
|
||||
#include "sua.h"
|
||||
#include "sccp_sap.h"
|
||||
|
||||
|
||||
enum log_cat {
|
||||
DMAIN,
|
||||
DSUA,
|
||||
DXUA,
|
||||
};
|
||||
|
||||
extern const struct log_info test_log_info;
|
||||
|
||||
int tx_unitdata(struct osmo_sua_link *link);
|
||||
int tx_conn_req(struct osmo_sua_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