aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom/sigtran
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2015-12-22 22:22:23 +0100
committerHarald Welte <laforge@gnumonks.org>2015-12-22 23:03:41 +0100
commitbf49cc1c0074055cecbf8346e41455d5c7bb0a71 (patch)
tree3f355e9af03d1a1c301a71af46e4bfc4e411babd /include/osmocom/sigtran
parent46c2945af2f7d6741fdba7185241845f1d2c7421 (diff)
Import SUA (SCCP User Adaptation) and SCCP User SAP
... this code originates from the osmo-iuh repository, but is now part of a new shared libosmo-sigtran.so library generated in this repository.
Diffstat (limited to 'include/osmocom/sigtran')
-rw-r--r--include/osmocom/sigtran/Makefile.am5
-rw-r--r--include/osmocom/sigtran/m2ua_types.h255
-rw-r--r--include/osmocom/sigtran/m3ua_types.h128
-rw-r--r--include/osmocom/sigtran/protocol/sua.h120
-rw-r--r--include/osmocom/sigtran/sccp_sap.h199
-rw-r--r--include/osmocom/sigtran/sua.h21
-rw-r--r--include/osmocom/sigtran/xua_msg.h53
-rw-r--r--include/osmocom/sigtran/xua_types.h45
8 files changed, 826 insertions, 0 deletions
diff --git a/include/osmocom/sigtran/Makefile.am b/include/osmocom/sigtran/Makefile.am
new file mode 100644
index 0000000..538a249
--- /dev/null
+++ b/include/osmocom/sigtran/Makefile.am
@@ -0,0 +1,5 @@
+sigtran_HEADERS = m3ua_types.h xua_types.h xua_msg.h m2ua_types.h sccp_sap.h sua.h
+sigtrandir = $(includedir)/osmocom/sigtran
+
+sigtran_prot_HEADERS = protocol/sua.h
+sigtran_protdir = $(includedir)/osmocom/sigtran/protocol
diff --git a/include/osmocom/sigtran/m2ua_types.h b/include/osmocom/sigtran/m2ua_types.h
new file mode 100644
index 0000000..7184f54
--- /dev/null
+++ b/include/osmocom/sigtran/m2ua_types.h
@@ -0,0 +1,255 @@
+#ifndef m2ua_types_h
+#define m2ua_types_h
+
+/**
+ * Types found in the M2UA RFC 3331
+ */
+
+#include <stdint.h>
+
+#define M2UA_VERSION 1
+#define M2UA_SPARE 0
+
+enum {
+ M2UA_CLS_MGMT, /* Management (MGMT) Message [IUA/M2UA/M3UA/SUA] */
+ M2UA_CLS_TRANS, /* Transfer Messages [M3UA] */
+ M2UA_CLS_SSNM, /* SS7 Signalling Network Management (SSNM) Messages [M3UA/SUA] */
+ M2UA_CLS_ASPSM, /* ASP State Maintenance (ASPSM) Messages [IUA/M2UA/M3UA/SUA] */
+ M2UA_CLS_ASPTM, /* ASP Traffic Maintenance (ASPTM) Messages [IUA/M2UA/M3UA/SUA] */
+ M2UA_CLS_QPTM, /* Q.921/Q.931 Boundary Primitives Transport (QPTM) */
+ M2UA_CLS_MAUP, /* MTP2 User Adaptation (MAUP) Messages [M2UA] */
+ M2UA_CLS_SUA_LESS, /* Connectionless Messages [SUA] */
+ M2UA_CLS_SUA_CONN, /* Connection-Oriented Messages [SUA] */
+ M2UA_CLS_RKM, /* Routing Key Management (RKM) Messages (M3UA) */
+ M2UA_CLS_IIM, /* Interface Identifier Management (IIM) Messages (M2UA) */
+};
+
+/**
+ * MTP2 User Adaption = MAUP messages
+ */
+enum {
+ M2UA_MAUP_RESERVED, /* Reserved */
+ M2UA_MAUP_DATA, /* Data */
+ M2UA_MAUP_EST_REQ, /* Establish Request */
+ M2UA_MAUP_EST_CON, /* Establish Confirm */
+ M2UA_MAUP_REL_REQ, /* Release Request */
+ M2UA_MAUP_REL_CON, /* Release Confirm */
+ M2UA_MAUP_REL_IND, /* Release Indication */
+ M2UA_MAUP_STATE_REQ, /* State Request */
+ M2UA_MAUP_STATE_CON, /* State Confirm */
+ M2UA_MAUP_STATE_IND, /* State Indication */
+ M2UA_MAUP_RETR_REQ, /* Data Retrieval Request */
+ M2UA_MAUP_D_RETR_CON, /* Data Retrieval Confirm */
+ M2UA_MAUP_D_RETR_IND, /* Data Retrieval Indication */
+ M2UA_MAUP_D_RETR_COMPL, /* Data Retrieval Complete Indication */
+ M2UA_MAUP_CONG_IND, /* Congestion Indication */
+ M2UA_MAUP_DATA_ACK, /* Data Acknowledge */
+};
+
+/**
+ * Application Server Process State Maintaenance (ASPSM) messages
+ */
+enum {
+ M2UA_ASPSM_RESERVED, /* Reserved */
+ M2UA_ASPSM_UP, /* ASP Up (UP) */
+ M2UA_ASPSM_DOWN, /* ASP Down (DOWN) */
+ M2UA_ASPSM_BEAT, /* Heartbeat (BEAT) */
+ M2UA_ASPSM_UP_ACK, /* ASP Up Ack (UP ACK) */
+ M2UA_ASPSM_DOWN_ACK, /* ASP Down Ack (DOWN ACK) */
+ M2UA_ASPSM_BEAT_ACK, /* Heartbeat Ack (BEAT ACK) */
+};
+
+/**
+ * Application Server Process Traffic Maintaenance (ASPTM) messages.
+ */
+enum {
+ M2UA_ASPTM_RESERVED, /* Reserved */
+ M2UA_ASPTM_ACTIV, /* ASP Active (ACTIVE) */
+ M2UA_ASPTM_INACTIV, /* ASP Inactive (INACTIVE) */
+ M2UA_ASPTM_ACTIV_ACK, /* ASP Active Ack (ACTIVE ACK) */
+ M2UA_ASPTM_INACTIV_ACK, /* ASP Inactive Ack (INACTIVE ACK) */
+};
+
+/**
+ * Management (MGMT) messages
+ */
+enum {
+ M2UA_MGMT_ERROR, /* Error (ERR) */
+ M2UA_MGMT_NTFY, /* Notify (NTFY) */
+};
+
+/**
+ * Interface Identifier Management (IIM) Messages
+ */
+enum {
+ M2UA_IIM_RESERVED, /* Reserved */
+ M2UA_IIM_REG_REQ, /* Registration Request (REG REQ) */
+ M2UA_IIM_REG_RSP, /* Registration Response (REG RSP) */
+ M2UA_IIM_DEREG_REQ, /* Deregistration Request (DEREG REQ) */
+ M2UA_IIM_DEREG_RSP, /* Deregistration Response (DEREG RSP) */
+};
+
+/**
+ * Tag Values for M2UA
+ */
+enum {
+ __m2ua_tag_start = 767,
+
+ M2UA_TAG_DATA, /* Protocol Data 1 */
+ M2UA_TAG_DATA_TTC, /* Protocol Data 2 (TTC) */
+ M2UA_TAG_STATE_REQ, /* State Request */
+ M2UA_TAG_STATE_EVENT, /* State Event */
+ M2UA_TAG_CONG_STATUS, /* Congestion Status */
+ M2UA_TAG_DISC_STATUS, /* Discard Status */
+ M2UA_TAG_ACTION, /* Action */
+ M2UA_TAG_SEQ_NO, /* Sequence Number */
+ M2UA_TAG_RETR_RES, /* Retrieval Result */
+ M2UA_TAG_LNK_KEY, /* Link Key */
+ M2UA_TAG_L_LNK_KEY_ID, /* Local-LK-Identifier */
+ M2UA_TAG_SDT, /* Signalling Data Terminal (SDT) Identifier */
+ M2UA_TAG_SDL, /* Signalling Data Link (SDL) Identifier */
+ M2UA_TAG_REG_RES, /* Registration Result */
+ M2UA_TAG_RES_STATUS, /* Registration Status */
+ M2UA_TAG_DEREG_RES, /* De-Registration Result */
+ M2UA_TAG_DEREG_STATUS, /* De-Registration Status */
+};
+
+/**
+ * 3.3.1.5 State Request
+ */
+enum {
+ M2UA_STATUS_LPO_SET, /* Request local processor outage */
+ M2UA_STATUS_LPO_CLEAR, /* Request local processor outage recovered */
+ M2UA_STATUS_EMER_SET, /* Request emergency alignment */
+ M2UA_STATUS_EMER_CLEAR, /* Request normal alignment (cancel emergency) */
+ M2UA_STATUS_FLUSH_BUFFERS, /* Flush or clear receive, transmit and retransmit queues */
+ M2UA_STATUS_CONTINUE, /* Continue or Resume */
+ M2UA_STATUS_CLEAR_RTB, /* Clear the retransmit queue */
+ M2UA_STATUS_AUDIT, /* Audit state of link */
+ M2UA_STATUS_CONG_CLEAR, /* Congestion cleared */
+ M2UA_STATUS_CONG_ACCEPT, /* Congestion accept */
+ M2UA_STATUS_CONG_DISCARD, /* Congestion discard */
+};
+
+/**
+ * 3.3.1.7 State Indication
+ */
+enum {
+ __m2ua_event_dummy,
+ M2UA_EVENT_RPO_ENTER, /* Remote entered processor outage */
+ M2UA_EVENT_RPO_EXIT, /* Remote exited processor outage */
+ M2UA_EVENT_LPO_ENTER, /* Link entered processor outage */
+ M2UA_EVENT_LPO_EXIT, /* Link exited processor outage */
+};
+
+/**
+ * 3.3.1.8 Congestion Indication
+ */
+enum {
+ M2UA_LEVEL_NONE, /* No congestion */
+ M2UA_LEVEL_1, /* Congestion Level 1 */
+ M2UA_LEVEL_2, /* Congestion Level 2 */
+ M2UA_LEVEL_3, /* Congestion Level 3 */
+};
+
+/**
+ * 3.3.1.9 Retrieval Request
+ */
+enum {
+ M2UA_ACTION_RTRV_BSN, /* Retrieve the backward sequence number */
+ M2UA_ACTION_RTRV_MSGS, /* Retrieve the PDUs from the transmit and retransmit queues. */
+};
+
+/**
+ * 3.3.1.10 Retrieval Confirm
+ */
+enum {
+ M2UA_RESULT_SUCCESS, /* Action successful */
+ M2UA_RESULT_FAILURE, /* Action failed */
+};
+
+/**
+ * 3.3.2.7 ASP Active (ASPAC)
+ */
+enum {
+ M2UA_TRA_OVERRIDE = 1, /* Override */
+ M2UA_TRA_LOAD_SHARE = 2, /* Load-share */
+ M2UA_TRA_BROADCAST = 3, /* Broadcast */
+};
+
+/**
+ * 3.3.3.1 Error (ERR)
+ */
+enum {
+ __m2ua_err_unused,
+ M2UA_ERR_INV_VER, /* Invalid Version */
+ M2UA_ERR_INV_INT_IDENT, /* Invalid Interface Identifier */
+ M2UA_ERR_UNS_MSG_CLASS, /* Unsupported Message Class */
+ M2UA_ERR_UNS_MSG_TYPE, /* Unsupported Message Type */
+ M2UA_ERR_UNS_TRA_MODE, /* Unsupported Traffic Handling Mode */
+ M2UA_ERR_UNE_MSG, /* Unexpected Message */
+ M2UA_ERR_PROTO_ERROR, /* Protocol Error */
+ M2UA_ERR_UNS_INT_IDENT_T, /* Unsupported Interface Identifier Type */
+ M2UA_ERR_INV_STR_IDENT, /* Invalid Stream Identifier */
+ M2UA_ERR_UNUSED1, /* Unused in M2UA */
+ M2UA_ERR_UNUSED2, /* Unused in M2UA */
+ M2UA_ERR_UNUSED3, /* Unused in M2UA */
+ M2UA_ERR_REFUSED, /* Refused - Management Blocking */
+ M2UA_ERR_ASP_IDENT_REQ, /* ASP Identifier Required */
+ M2UA_ERR_INV_ASP_IDENT, /* Invalid ASP Identifier */
+ M2UA_ERR_ASP_ACT_FOR_IDENT, /* ASP Active for Interface Identifier(s) */
+ M2UA_ERR_INV_PARAM_VAL, /* Invalid Parameter Value */
+ M2UA_ERR_PARAM_FIELD_ERR, /* Parameter Field Error */
+ M2UA_ERR_UNEXP_PARAM, /* Unexpected Parameter */
+ M2UA_ERR_UNUSED4, /* Unused in M2UA */
+ M2UA_ERR_UNUSED5, /* Unused in M2UA */
+ M2UA_ERR_MISSING_PARAM, /* Missing Parameter */
+};
+
+/**
+ * 3.3.3.2 Notify (NTFY)
+ */
+enum {
+ M2UA_STP_AS_STATE_CHG = 1, /* Application Server state change (AS_State_Change) */
+ M2UA_STP_OTHER = 2, /* Other */
+};
+
+enum {
+ /* this is for M2UA_STP_AS_STATE_CHG */
+ M2UA_STP_AS_INACTIVE = 2, /* Application Server Inactive (AS_Inactive) */
+ M2UA_STP_AS_ACTIVE = 3, /* Application Server Active (AS_Active) */
+ M2UA_STP_AS_PENDING = 4, /* Application Server Pending (AS_Pending) */
+
+ /* this is for the other */
+ M2UA_STP_O_INSUFF_ASP_RES = 1, /* Insufficient ASP resources active in AS */
+ M2UA_STP_O_ALT_ASP_ACTIVR = 2, /* Alternate ASP Active */
+ M2UA_STP_O_ASP_FAILURE = 3, /* ASP Failure */
+};
+
+/**
+ * 3.3.4.3 Registration Response (REG RSP)
+ */
+enum {
+ M2UA_REG_SUCC, /* Successfully Registered */
+ M2UA_REG_ERR_UNK, /* Error - Unknown */
+ M2UA_REG_ERR_INV_SDLI, /* Error - Invalid SDLI */
+ M2UA_REG_ERR_INV_SDTI, /* Error - Invalid SDTI */
+ M2UA_REG_ERR_INV_LNK_KEY, /* Error - Invalid Link Key */
+ M2UA_REG_ERR_PERM_DENIED, /* Error - Permission Denied */
+ M2UA_REG_ERR_OVERLAP_KEY, /* Error - Overlapping (Non-unique) Link Key */
+ M2UA_REG_ERR_LNK_KEY_NOT_PROV, /* Error - Link Key not Provisioned */
+ M2UA_REG_ERR_INSUFF_RES, /* Error - Insufficient Resources */
+};
+
+/**
+ * 3.3.4.4 De-Registration Response (DEREG RSP)
+ */
+enum {
+ M2UA_DEREG_SUCC, /* Successfully De-registered */
+ M2UA_DEREG_ERR_UNK, /* Error - Unknown */
+ M2UA_DEREG_ERR_INV_IDENT, /* Error - Invalid Interface Identifier */
+ M2UA_DEREG_ERR_PERM_DENIED, /* Error - Permission Denied */
+ M2UA_DEREG_ERR_NOT_REG, /* Error - Not Registered */
+};
+
+#endif
diff --git a/include/osmocom/sigtran/m3ua_types.h b/include/osmocom/sigtran/m3ua_types.h
new file mode 100644
index 0000000..c8e62b4
--- /dev/null
+++ b/include/osmocom/sigtran/m3ua_types.h
@@ -0,0 +1,128 @@
+#pragma once
+
+/**
+ * Types found in the M3UA RFC 4666
+ */
+
+#include <stdint.h>
+
+
+#define M3UA_VERSION 1
+
+enum {
+ M3UA_CLS_MGMT, /* Management (MGMT) Message [IUA/M2UA/M3UA/SUA] */
+ M3UA_CLS_TRANS, /* Transfer Messages [M3UA] */
+ M3UA_CLS_SSNM, /* SS7 Signalling Network Management (SSNM) Messages [M3UA/SUA] */
+ M3UA_CLS_ASPSM, /* ASP State Maintenance (ASPSM) Messages [IUA/M2UA/M3UA/SUA] */
+ M3UA_CLS_ASPTM, /* ASP Traffic Maintenance (ASPTM) Messages [IUA/M2UA/M3UA/SUA] */
+ M3UA_CLS_RESERVED1, /* Reserved for Other SIGTRAN Adaptation Layers */
+ M3UA_CLS_RESERVED2, /* Reserved for Other SIGTRAN Adaptation Layers */
+ M3UA_CLS_RESERVED3, /* Reserved for Other SIGTRAN Adaptation Layers */
+ M3UA_CLS_RESERVED4, /* Reserved for Other SIGTRAN Adaptation Layers */
+ M3UA_CLS_RKM, /* Routing Key Management (RKM) Messages (M3UA) */
+};
+
+/**
+ * Management (MGMT) messages
+ */
+enum {
+ M3UA_MGMT_ERROR, /* Error (ERR) */
+ M3UA_MGMT_NTFY, /* Notify (NTFY) */
+};
+
+/**
+ * Transfer Messages
+ */
+enum {
+ M3UA_TRANS_RESERVED, /* Reserved */
+ M3UA_TRANS_DATA, /* Payload Data (DATA) */
+};
+
+/**
+ * SS7 Signalling Network Management (SSNM) Messages
+ */
+enum {
+ M3UA_SSNM_RESERVED, /* Reserved */
+ M3UA_SSNM_DUNA, /* Destination Unavailable (DUNA) */
+ M3UA_SSNM_DAVA, /* Destination Available (DAVA) */
+ M3UA_SSNM_DAUD, /* Destination State Audit (DAUD) */
+ M3UA_SSNM_SCON, /* Signalling Congestion (SCON) */
+ M3UA_SSNM_DUPU, /* Destination User Part Unavailable (DUPU) */
+ M3UA_SSNM_DRST, /* Destination Restricted (DRST) */
+};
+
+/**
+ * Application Server Process State Maintaenance (ASPSM) messages
+ */
+enum {
+ M3UA_ASPSM_RESERVED, /* Reserved */
+ M3UA_ASPSM_UP, /* ASP Up (UP) */
+ M3UA_ASPSM_DOWN, /* ASP Down (DOWN) */
+ M3UA_ASPSM_BEAT, /* Heartbeat (BEAT) */
+ M3UA_ASPSM_UP_ACK, /* ASP Up Ack (UP ACK) */
+ M3UA_ASPSM_DOWN_ACK, /* ASP Down Ack (DOWN ACK) */
+ M3UA_ASPSM_BEAT_ACK, /* Heartbeat Ack (BEAT ACK) */
+};
+
+/**
+ * Application Server Process Traffic Maintaenance (ASPTM) messages.
+ */
+enum {
+ M3UA_ASPTM_RESERVED, /* Reserved */
+ M3UA_ASPTM_ACTIV, /* ASP Active (ACTIVE) */
+ M3UA_ASPTM_INACTIV, /* ASP Inactive (INACTIVE) */
+ M3UA_ASPTM_ACTIV_ACK, /* ASP Active Ack (ACTIVE ACK) */
+ M3UA_ASPTM_INACTIV_ACK, /* ASP Inactive Ack (INACTIVE ACK) */
+};
+
+/**
+ * Routing Key Management (RKM) Messages
+ */
+enum {
+ M3UA_RKM_RESERVED, /* Reserved */
+ M3UA_RKM_REG_REQ, /* Registration Request (REG REQ) */
+ M3UA_RKM_REG_RSP, /* Registration Response (REG RSP) */
+ M3UA_RKM_DEREG_REQ, /* Deregistration Request (DEREG REQ) */
+ M3UA_RKM_DEREG_RSP, /* Deregistration Response (DEREG RSP) */
+};
+
+/**
+ * Tag Values for M3UA
+ */
+enum {
+ M3UA_TAG_NET_APPEAR = 0x0200, /* Network Appearance */
+ M3UA_TAG_RESERVED1, /* Reserved */
+ M3UA_TAG_RESERVED2, /* Reserved */
+ M3UA_TAG_RESERVED3, /* Reserved */
+ M3UA_TAG_USER_CAUSE, /* User/Cause */
+ M3UA_TAG_CONGEST_IND, /* Congestion Indications */
+ M3UA_TAG_CONCERN_DEST, /* Concerned Destination */
+ M3UA_TAG_ROUTING_KEY, /* Routing Key */
+ M3UA_TAG_REG_RESULT, /* Registration Result */
+ M3UA_TAG_DEREG_RESULT, /* Deregistration Result */
+ M3UA_TAG_LOCAL_ROUT_KEY_IDENT, /* Local Routing Key Identifier */
+ M3UA_TAG_DEST_PC, /* Destination Point Code */
+ M3UA_TAG_SERV_IND, /* Service Indicators */
+ M3UA_TAG_RESERVED4, /* Reserved */
+ M3UA_TAG_ORIG_PC_LIST, /* Originating Point Code List */
+ M3UA_TAG_RESERVED5, /* Reserved */
+ M3UA_TAG_PROTO_DATA, /* Protocol Data */
+ M3UA_TAG_RESERVED6, /* Reserved */
+ M3UA_TAG_REG_STATUS, /* Registration Status */
+ M3UA_TAG_DEREG_STATUS, /* Deregistration Status */
+};
+
+
+/**
+ * Protocol data for transport messages. This is
+ * replacing the MTP L3 header
+ */
+struct m3ua_protocol_data {
+ uint32_t opc;
+ uint32_t dpc;
+ uint8_t si;
+ uint8_t ni;
+ uint8_t mp;
+ uint8_t sls;
+ uint8_t data[0];
+} __attribute__((packed));
diff --git a/include/osmocom/sigtran/protocol/sua.h b/include/osmocom/sigtran/protocol/sua.h
new file mode 100644
index 0000000..864a2df
--- /dev/null
+++ b/include/osmocom/sigtran/protocol/sua.h
@@ -0,0 +1,120 @@
+/* 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/>.
+ */
+
+#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
diff --git a/include/osmocom/sigtran/sccp_sap.h b/include/osmocom/sigtran/sccp_sap.h
new file mode 100644
index 0000000..fb42cee
--- /dev/null
+++ b/include/osmocom/sigtran/sccp_sap.h
@@ -0,0 +1,199 @@
+#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_scu_prim_name(struct osmo_prim_hdr *oph);
diff --git a/include/osmocom/sigtran/sua.h b/include/osmocom/sigtran/sua.h
new file mode 100644
index 0000000..2aa99f4
--- /dev/null
+++ b/include/osmocom/sigtran/sua.h
@@ -0,0 +1,21 @@
+#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);
+
diff --git a/include/osmocom/sigtran/xua_msg.h b/include/osmocom/sigtran/xua_msg.h
new file mode 100644
index 0000000..9cc8632
--- /dev/null
+++ b/include/osmocom/sigtran/xua_msg.h
@@ -0,0 +1,53 @@
+/* Routines for generating and parsing messages */
+/* (C) 2011 by Holger Hans Peter Freyther <zecke@selfish.org>
+ *
+ * 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/>.
+ *
+ */
+#pragma once
+
+#include "xua_types.h"
+
+#include <osmocom/core/linuxlist.h>
+
+struct msgb;
+
+struct xua_msg {
+ struct xua_common_hdr hdr;
+
+ struct llist_head headers;
+};
+
+struct xua_msg_part {
+ struct llist_head entry;
+
+ uint16_t tag;
+ uint16_t len;
+ uint8_t *dat;
+
+ /* TODO: keep small data in the struct for perf reasons */
+};
+
+
+struct xua_msg *xua_msg_alloc(void);
+void xua_msg_free(struct xua_msg *msg);
+
+int xua_msg_add_data(struct xua_msg *msg, uint16_t tag, uint16_t len, uint8_t *dat);
+
+struct xua_msg_part *xua_msg_find_tag(struct xua_msg *msg, uint16_t tag);
+
+struct xua_msg *xua_from_msg(const int version, uint16_t len, uint8_t *data);
+struct msgb *xua_to_msg(const int version, struct xua_msg *msg);
+
+void xua_set_log_area(int log_area);
diff --git a/include/osmocom/sigtran/xua_types.h b/include/osmocom/sigtran/xua_types.h
new file mode 100644
index 0000000..6568283
--- /dev/null
+++ b/include/osmocom/sigtran/xua_types.h
@@ -0,0 +1,45 @@
+#pragma once
+
+#include <stdint.h>
+
+/**
+ * Common tag values used by all user adaption layers
+ */
+enum {
+ MUA_TAG_RESERVED, /* Reserved */
+ MUA_TAG_IDENT_INT, /* Interface Identifier (Integer) (M2UA) */
+ MUA_TAG_UNUSED1, /* Unused */
+ MUA_TAG_IDENT_TEXT, /* Interface Identifier (Text) (M2UA) */
+ MUA_TAG_INFO, /* Info String */
+ MUA_TAG_UNUSED2, /* Unused */
+ MUA_TAG_ROUTING_CTX, /* Routing Context (M3UA) */
+ MUA_TAG_DIAG_INF, /* Diagnostic Information */
+ MUA_TAG_IDENT_RANGE, /* Interface Identifier (Integer Range) */
+ MUA_TAG_BEAT_DATA, /* Heartbeat Data */
+ MUA_TAG_UNUSED4, /* Unused */
+ MUA_TAG_TRA_MODE, /* Traffic Mode Type */
+ MUA_TAG_ERR_CODE, /* Error Code */
+ MUA_TAG_STATUS, /* Status Type/Information */
+ MUA_TAG_UNUSED5, /* Unused */
+ MUA_TAG_UNUSED6, /* Unused */
+ MUA_TAG_UNUSED7, /* Unused */
+ MUA_TAG_ASP_IDENT, /* ASP Identifier */
+ MUA_TAG_AFF_PC, /* Affected Point Code (M3UA) */
+ MUA_TAG_CORREL_ID, /* Correlation Id */
+};
+
+struct xua_common_hdr {
+ uint8_t version;
+ uint8_t spare;
+ uint8_t msg_class;
+ uint8_t msg_type;
+ uint32_t msg_length;
+ uint8_t data[0];
+} __attribute__((packed));
+
+
+struct xua_parameter_hdr {
+ uint16_t tag;
+ uint16_t len;
+ uint8_t data[0];
+} __attribute__((packed));