blob: cd55ec2b3d220fb58b1661a2194ad9a4ff73de46 [file] [log] [blame]
Harald Welte283c7fd2015-12-21 23:35:56 +01001#pragma once
2
3/* SCCP User SAP description */
4
5/* (C) 2015 by Harald Welte <laforge@gnumonks.org>
6 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#include <stdint.h>
24#include <osmocom/core/prim.h>
25
26#include <netinet/in.h>
27
28#define SCCP_SAP_USER 0x2342
29
30/* detailed coding of primitives at the SAP_SCCP_USER */
31
32/*! \brief SCCP-User primitives as per Q.711 */
33enum osmo_scu_prim_type {
34 /* connection oriented, 6.1.1 */
35 OSMO_SCU_PRIM_N_CONNECT,
36 OSMO_SCU_PRIM_N_DATA,
37 OSMO_SCU_PRIM_N_EXPEDITED_DATA,
38 OSMO_SCU_PRIM_N_DISCONNECT,
39 OSMO_SCU_PRIM_N_RESET,
40 OSMO_SCU_PRIM_N_INFORM,
41 /* connectionless, 6.2.2 */
42 OSMO_SCU_PRIM_N_UNITDATA,
43 OSMO_SCU_PRIM_N_NOTICE,
44 /* management */
45 OSMO_SCU_PRIM_N_COORD,
46 OSMO_SCU_PRIM_N_STATE,
47 OSMO_SCU_PRIM_N_PCSTATE,
48};
49
50#define OSMO_SCCP_ADDR_T_GT 0x0001
51#define OSMO_SCCP_ADDR_T_PC 0x0002
52#define OSMO_SCCP_ADDR_T_SSN 0x0004
53#define OSMO_SCCP_ADDR_T_IPv4 0x0008
54#define OSMO_SCCP_ADDR_T_IPv6 0x0010
55
56/* Q.713 3.4.1 + RFC 3868 3.10.2.3 */
57enum osmo_sccp_routing_ind {
58 OSMO_SCCP_RI_GT,
59 OSMO_SCCP_RI_SSN_PC,
60 OSMO_SCCP_RI_SSN_IP,
61};
62
63/* Q.713 3.4.1 + RFC 3868 3.10.2.3 */
64enum osmo_sccp_gti {
65 OSMO_SCCP_GTI_NO_GT,
66 OSMO_SCCP_GTI_NAI_ONLY,
67 OSMO_SCCP_GTI_TT_ONLY,
68 OSMO_SCCP_GTI_TT_NPL_ENC,
69 OSMO_SCCP_GTI_TT_NPL_ENC_NAI,
70};
71
72/* RFC 3868 3.10.2.3 */
73enum osmo_sccp_npi {
74 OSMO_SCCP_NPI_UNKNOWN = 0,
75 OSMO_SCCP_NPI_E164_ISDN = 1,
76 OSMO_SCCP_NPI_GEERIC = 2,
77 OSMO_SCCP_NPI_X121_DATA = 3,
78 OSMO_SCCP_NPI_F69_TELEX = 4,
79 OSMO_SCCP_NPI_E210_MARITIME = 5,
80 OSMO_SCCP_NPI_E212_LAND = 6,
81 OSMO_SCCP_NPI_E214_ISDN_MOBILE = 7,
82 OSMO_SCCP_NPI_PRIVATE = 14,
83};
84
85/* Q.713 3.4.2.3.1 + RFC 3868 3.10.2.3 */
86enum osmo_sccp_nai {
87 OSMO_SCCP_NAI_UNKNOWN = 0,
88 OSMO_SCCP_NAI_SUBSCR = 1,
89 OSMO_SCCP_NAI_RES_NAT_USE = 2,
90 OSMO_SCCP_NAI_NATL = 3,
91 OSMO_SCCP_NAI_INTL = 4,
92 /* 5.. 255: Spare */
93};
94
95/* Q.713 3.4.2.2 */
96enum osmo_sccp_ssn {
97 OSMO_SCCP_SSN_MGMT = 1,
98 OSMO_SCCP_SSN_ISUP = 3,
99 OSMO_SCCP_SSN_OMAP = 4,
100 OSMO_SCCP_SSN_MAP = 5,
101 OSMO_SCCP_SSN_HLR = 6,
102 OSMO_SCCP_SSN_VLR = 7,
103 OSMO_SCCP_SSN_MSC = 8,
104 OSMO_SCCP_SSN_EIR = 9,
105 OSMO_SCCP_SSN_AUC = 0x0a,
106 OSMO_SCCP_SSN_ISDN_SS = 0x0b,
107 OSMO_SCCP_SSN_RES_INTL = 0x0c,
108 OSMO_SCCP_SSN_BISDN = 0x0d,
109 OSMO_SCCP_SSN_TC_TEST = 0x0e,
110};
111
112struct osmo_sccp_gt {
113 uint8_t gti;
114 uint8_t nr_digits;
115 uint8_t tt;
116 uint32_t npi;
117 uint32_t nai;
118 uint8_t digits[32];
119};
120
121struct osmo_sccp_addr {
122 uint32_t presence;
123 struct osmo_sccp_gt gt;
124 uint32_t pc;
125 uint32_t ssn;
126 union {
127 struct in_addr v4;
128 struct in6_addr v6;
129 } ip;
130 /* we don't do hostnames */
131};
132
133/* OSMO_SCU_PRIM_N_CONNECT */
134struct osmo_scu_connect_param {
135 struct osmo_sccp_addr called_addr;
136 struct osmo_sccp_addr calling_addr;
137 struct osmo_sccp_addr responding_addr;
138 //struct osmo_sccp_qos_pars qos_pars;
139 uint32_t sccp_class;
140 uint32_t importance;
141 uint32_t conn_id;
142 /* user data */
143};
144
145/* OSMO_SCU_PRIM_N_DATA / OSMO_SCU_PRIM_N_EXPEDITED_DATA */
146struct osmo_scu_data_param {
147 uint32_t conn_id;
148 uint32_t importance;
149 /* user data */
150};
151
152enum osmo_sccp_originator {
153 OSMO_SCCP_ORIG_NS_PROVIDER,
154 OSMO_SCCP_ORIG_NS_USER,
155 OSMO_SCCP_ORIG_UNDEFINED,
156};
157
158/* OSMO_SCU_PRIM_N_DISCONNECT */
159struct osmo_scu_disconn_param {
160 enum osmo_sccp_originator originator;
161 struct osmo_sccp_addr repsonding_addr;
162 uint32_t cause;
163 uint32_t conn_id;
164 uint32_t importance;
165 /* user data */
166};
167
168/* OSMO_SCU_PRIM_N_RESET */
169struct osmo_scu_reset_param {
170 enum osmo_sccp_originator originator;
171 uint32_t cause;
172 uint32_t conn_id;
173};
174
175/* OSMO_SCU_PRIM_N_UNITDATA */
176struct osmo_scu_unitdata_param {
177 struct osmo_sccp_addr called_addr;
178 struct osmo_sccp_addr calling_addr;
179 uint32_t in_sequence_control;
180 uint32_t return_option;
181 uint32_t importance;
182 /* user data */
183};
184
185struct osmo_scu_prim {
186 struct osmo_prim_hdr oph;
187 union {
188 struct osmo_scu_connect_param connect;
189 struct osmo_scu_data_param data;
190 struct osmo_scu_disconn_param disconnect;
191 struct osmo_scu_reset_param reset;
192 struct osmo_scu_unitdata_param unitdata;
193 } u;
194};
195
196#define msgb_scu_prim(msg) ((struct osmo_scu_prim *)(msg)->l1h)
197
198char *osmo_sccp_prim_name(struct osmo_prim_hdr *oph);