blob: 89d92a9d1bb99a70e5e9f3a66edb986018646583 [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
Harald Welte70e84ab2015-12-21 23:50:36 +010028/* FIXME: properly define this based on libosmocore */
Harald Welte283c7fd2015-12-21 23:35:56 +010029#define SCCP_SAP_USER 0x2342
30
31/* detailed coding of primitives at the SAP_SCCP_USER */
32
33/*! \brief SCCP-User primitives as per Q.711 */
34enum osmo_scu_prim_type {
35 /* connection oriented, 6.1.1 */
36 OSMO_SCU_PRIM_N_CONNECT,
37 OSMO_SCU_PRIM_N_DATA,
38 OSMO_SCU_PRIM_N_EXPEDITED_DATA,
39 OSMO_SCU_PRIM_N_DISCONNECT,
40 OSMO_SCU_PRIM_N_RESET,
41 OSMO_SCU_PRIM_N_INFORM,
42 /* connectionless, 6.2.2 */
43 OSMO_SCU_PRIM_N_UNITDATA,
44 OSMO_SCU_PRIM_N_NOTICE,
45 /* management */
46 OSMO_SCU_PRIM_N_COORD,
47 OSMO_SCU_PRIM_N_STATE,
48 OSMO_SCU_PRIM_N_PCSTATE,
49};
50
51#define OSMO_SCCP_ADDR_T_GT 0x0001
52#define OSMO_SCCP_ADDR_T_PC 0x0002
53#define OSMO_SCCP_ADDR_T_SSN 0x0004
54#define OSMO_SCCP_ADDR_T_IPv4 0x0008
55#define OSMO_SCCP_ADDR_T_IPv6 0x0010
56
57/* Q.713 3.4.1 + RFC 3868 3.10.2.3 */
58enum osmo_sccp_routing_ind {
59 OSMO_SCCP_RI_GT,
60 OSMO_SCCP_RI_SSN_PC,
61 OSMO_SCCP_RI_SSN_IP,
62};
63
64/* Q.713 3.4.1 + RFC 3868 3.10.2.3 */
65enum osmo_sccp_gti {
66 OSMO_SCCP_GTI_NO_GT,
67 OSMO_SCCP_GTI_NAI_ONLY,
68 OSMO_SCCP_GTI_TT_ONLY,
69 OSMO_SCCP_GTI_TT_NPL_ENC,
70 OSMO_SCCP_GTI_TT_NPL_ENC_NAI,
71};
72
73/* RFC 3868 3.10.2.3 */
74enum osmo_sccp_npi {
75 OSMO_SCCP_NPI_UNKNOWN = 0,
76 OSMO_SCCP_NPI_E164_ISDN = 1,
77 OSMO_SCCP_NPI_GEERIC = 2,
78 OSMO_SCCP_NPI_X121_DATA = 3,
79 OSMO_SCCP_NPI_F69_TELEX = 4,
80 OSMO_SCCP_NPI_E210_MARITIME = 5,
81 OSMO_SCCP_NPI_E212_LAND = 6,
82 OSMO_SCCP_NPI_E214_ISDN_MOBILE = 7,
83 OSMO_SCCP_NPI_PRIVATE = 14,
84};
85
86/* Q.713 3.4.2.3.1 + RFC 3868 3.10.2.3 */
87enum osmo_sccp_nai {
88 OSMO_SCCP_NAI_UNKNOWN = 0,
89 OSMO_SCCP_NAI_SUBSCR = 1,
90 OSMO_SCCP_NAI_RES_NAT_USE = 2,
91 OSMO_SCCP_NAI_NATL = 3,
92 OSMO_SCCP_NAI_INTL = 4,
93 /* 5.. 255: Spare */
94};
95
96/* Q.713 3.4.2.2 */
97enum osmo_sccp_ssn {
98 OSMO_SCCP_SSN_MGMT = 1,
99 OSMO_SCCP_SSN_ISUP = 3,
100 OSMO_SCCP_SSN_OMAP = 4,
101 OSMO_SCCP_SSN_MAP = 5,
102 OSMO_SCCP_SSN_HLR = 6,
103 OSMO_SCCP_SSN_VLR = 7,
104 OSMO_SCCP_SSN_MSC = 8,
105 OSMO_SCCP_SSN_EIR = 9,
106 OSMO_SCCP_SSN_AUC = 0x0a,
107 OSMO_SCCP_SSN_ISDN_SS = 0x0b,
108 OSMO_SCCP_SSN_RES_INTL = 0x0c,
109 OSMO_SCCP_SSN_BISDN = 0x0d,
110 OSMO_SCCP_SSN_TC_TEST = 0x0e,
111};
112
113struct osmo_sccp_gt {
114 uint8_t gti;
115 uint8_t nr_digits;
116 uint8_t tt;
117 uint32_t npi;
118 uint32_t nai;
119 uint8_t digits[32];
120};
121
122struct osmo_sccp_addr {
123 uint32_t presence;
124 struct osmo_sccp_gt gt;
125 uint32_t pc;
126 uint32_t ssn;
127 union {
128 struct in_addr v4;
129 struct in6_addr v6;
130 } ip;
131 /* we don't do hostnames */
132};
133
134/* OSMO_SCU_PRIM_N_CONNECT */
135struct osmo_scu_connect_param {
136 struct osmo_sccp_addr called_addr;
137 struct osmo_sccp_addr calling_addr;
138 struct osmo_sccp_addr responding_addr;
139 //struct osmo_sccp_qos_pars qos_pars;
140 uint32_t sccp_class;
141 uint32_t importance;
142 uint32_t conn_id;
143 /* user data */
144};
145
146/* OSMO_SCU_PRIM_N_DATA / OSMO_SCU_PRIM_N_EXPEDITED_DATA */
147struct osmo_scu_data_param {
148 uint32_t conn_id;
149 uint32_t importance;
150 /* user data */
151};
152
153enum osmo_sccp_originator {
154 OSMO_SCCP_ORIG_NS_PROVIDER,
155 OSMO_SCCP_ORIG_NS_USER,
156 OSMO_SCCP_ORIG_UNDEFINED,
157};
158
159/* OSMO_SCU_PRIM_N_DISCONNECT */
160struct osmo_scu_disconn_param {
161 enum osmo_sccp_originator originator;
162 struct osmo_sccp_addr repsonding_addr;
163 uint32_t cause;
164 uint32_t conn_id;
165 uint32_t importance;
166 /* user data */
167};
168
169/* OSMO_SCU_PRIM_N_RESET */
170struct osmo_scu_reset_param {
171 enum osmo_sccp_originator originator;
172 uint32_t cause;
173 uint32_t conn_id;
174};
175
176/* OSMO_SCU_PRIM_N_UNITDATA */
177struct osmo_scu_unitdata_param {
178 struct osmo_sccp_addr called_addr;
179 struct osmo_sccp_addr calling_addr;
180 uint32_t in_sequence_control;
181 uint32_t return_option;
182 uint32_t importance;
183 /* user data */
184};
185
186struct osmo_scu_prim {
187 struct osmo_prim_hdr oph;
188 union {
189 struct osmo_scu_connect_param connect;
190 struct osmo_scu_data_param data;
191 struct osmo_scu_disconn_param disconnect;
192 struct osmo_scu_reset_param reset;
193 struct osmo_scu_unitdata_param unitdata;
194 } u;
195};
196
197#define msgb_scu_prim(msg) ((struct osmo_scu_prim *)(msg)->l1h)
198
199char *osmo_sccp_prim_name(struct osmo_prim_hdr *oph);