libosmo-sigtran  1.6.0.17-bd92
Osmocom SIGTRAN library
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
sccp_sap.h
Go to the documentation of this file.
1 #pragma once
2 
3 /* SCCP User SAP description */
4 
5 /* (C) 2015-2017 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 General Public License as published by
10  * the Free Software Foundation; either version 2 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 General Public License for more details.
17  *
18  * You should have received a copy of the GNU 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>
26 
27 #include <netinet/in.h>
28 
29 /* detailed coding of primitives at the SAP_SCCP_USER */
30 
33  /* connection oriented, 6.1.1 */
40  /* connectionless, 6.2.2 */
43  /* management */
47 };
48 
49 #define OSMO_SCCP_ADDR_T_GT 0x0001 /* global title */
50 #define OSMO_SCCP_ADDR_T_PC 0x0002 /* signalling point code */
51 #define OSMO_SCCP_ADDR_T_SSN 0x0004 /* subsystem number */
52 #define OSMO_SCCP_ADDR_T_IPv4 0x0008
53 #define OSMO_SCCP_ADDR_T_IPv6 0x0010
54 #define OSMO_SCCP_ADDR_T_MASK 0x001f
55 
56 /* Q.713 3.4.1 + RFC 3868 3.10.2.3 */
62 };
63 
64 extern const struct value_string osmo_sccp_routing_ind_names[];
65 static inline const char *osmo_sccp_routing_ind_name(enum osmo_sccp_routing_ind val)
66 { return get_value_string(osmo_sccp_routing_ind_names, val); }
67 
68 
69 /* Q.713 3.4.1 + RFC 3868 3.10.2.3 */
76 };
77 
78 extern const struct value_string osmo_sccp_gti_names[];
79 static inline const char *osmo_sccp_gti_name(enum osmo_sccp_gti val)
80 { return get_value_string(osmo_sccp_gti_names, val); }
81 
82 /* RFC 3868 3.10.2.3 */
93 };
94 
95 /* Q.713 3.4.2.3.1 + RFC 3868 3.10.2.3 */
102  /* 5.. 255: Spare */
103 };
104 
105 /* Q.713 3.4.2.2 */
107  /* globally standardised for GSM/UMTS: 1-31 */
117  /* Q.713 */
122  /* national network SSN for wihin and between GSM/UMTS: 129-150 */
131  /* national network SSN within GSM/UMTS: 32-128 + 151-254 */
138 };
139 
140 /* Q.711 6.3.2.2.5 Signalling point status */
145 };
146 /* Q.711 6.3.2.2.6 Remote SCCP status */
153 };
154 
155 /* legacy shim for name change */
156 #define OSMO_SCCP_SSN_SMLC_BSSAP OSMO_SCCP_SSN_SMLC_BSSAP_LE
157 
158 extern const struct value_string osmo_sccp_ssn_names[];
159 static inline const char *osmo_sccp_ssn_name(enum osmo_sccp_ssn val)
160 { return get_value_string(osmo_sccp_ssn_names, val); }
161 
162 struct osmo_sccp_gt {
163  uint8_t gti;
164  uint8_t tt;
165  uint32_t npi;
166  uint32_t nai;
167  char digits[32];
168 };
169 
171  uint32_t presence;
173  struct osmo_sccp_gt gt;
174  uint32_t pc;
175  uint32_t ssn;
176  union {
177  struct in_addr v4;
178  struct in6_addr v6;
179  } ip;
180  /* we don't do hostnames */
181 };
182 
183 /* OSMO_SCU_PRIM_N_CONNECT */
185  struct osmo_sccp_addr called_addr;
186  struct osmo_sccp_addr calling_addr;
187  struct osmo_sccp_addr responding_addr;
188  //struct osmo_sccp_qos_pars qos_pars;
189  uint32_t sccp_class;
190  uint32_t importance;
191  uint32_t conn_id;
192  /* user data */
193 };
194 
195 /* OSMO_SCU_PRIM_N_DATA / OSMO_SCU_PRIM_N_EXPEDITED_DATA */
197  uint32_t conn_id;
198  uint32_t importance;
199  /* user data */
200 };
201 
206 };
207 
208 /* OSMO_SCU_PRIM_N_DISCONNECT */
210  enum osmo_sccp_originator originator;
211  struct osmo_sccp_addr responding_addr;
212  uint32_t cause;
213  uint32_t conn_id;
214  uint32_t importance;
215  /* user data */
216 };
217 
218 /* OSMO_SCU_PRIM_N_RESET */
220  enum osmo_sccp_originator originator;
221  uint32_t cause;
222  uint32_t conn_id;
223 };
224 
225 /* OSMO_SCU_PRIM_N_UNITDATA */
227  struct osmo_sccp_addr called_addr;
228  struct osmo_sccp_addr calling_addr;
230  uint32_t return_option;
231  uint32_t importance;
232  /* user data */
233 };
234 
235 /* OSMO_SCU_PRIM_N_NOTICE */
237  struct osmo_sccp_addr called_addr;
238  struct osmo_sccp_addr calling_addr;
239  uint32_t cause;
240  uint32_t importance;
241  /* user data */
242 };
243 
244 /* OSMO_SCU_PRIM_N_STATE */
246  uint32_t affected_pc;
247  uint32_t affected_ssn;
248  bool user_in_service; /* true: UIS; false: UOS */
250 };
251 
252 /* OSMO_ASCU_PRIM_N_PCSTATE */
254  uint32_t affected_pc;
256  enum osmo_sccp_sp_status sp_status;
257  enum osmo_sccp_rem_sccp_status remote_sccp_status;
258 };
259 
261  struct osmo_prim_hdr oph;
262  union {
263  struct osmo_scu_connect_param connect;
265  struct osmo_scu_disconn_param disconnect;
266  struct osmo_scu_reset_param reset;
267  struct osmo_scu_unitdata_param unitdata;
268  struct osmo_scu_notice_param notice;
269  struct osmo_scu_state_param state;
270  struct osmo_scu_pcstate_param pcstate;
271  } u;
272 };
273 
274 #define msgb_scu_prim(msg) ((struct osmo_scu_prim *)(msg)->l1h)
275 
276 char *osmo_scu_prim_name(const struct osmo_prim_hdr *oph);
277 
278 struct osmo_ss7_instance;
279 struct osmo_sccp_instance;
280 struct osmo_sccp_user;
281 
282 void osmo_sccp_vty_init(void);
283 
287 struct osmo_sccp_instance *osmo_sccp_get_sccp(const struct osmo_sccp_user *scu);
288 
289 void osmo_sccp_user_unbind(struct osmo_sccp_user *scu);
290 void osmo_sccp_user_set_priv(struct osmo_sccp_user *scu, void *priv);
291 void *osmo_sccp_user_get_priv(struct osmo_sccp_user *scu);
292 
294  osmo_prim_cb prim_cb, uint16_t ssn, uint32_t pc);
295 
296 struct osmo_sccp_user *osmo_sccp_user_bind(struct osmo_sccp_instance *inst, const char *name,
297  osmo_prim_cb prim_cb, uint16_t ssn);
298 struct osmo_sccp_user *osmo_sccp_user_find(struct osmo_sccp_instance *inst, uint16_t ssn, uint32_t pc);
299 
300 int osmo_sccp_user_sap_down(struct osmo_sccp_user *scu, struct osmo_prim_hdr *oph);
301 int osmo_sccp_user_sap_down_nofree(struct osmo_sccp_user *scu, struct osmo_prim_hdr *oph);
302 
303 struct osmo_ss7_instance *osmo_sccp_addr_by_name(struct osmo_sccp_addr *dest_addr, const char *name);
304 int osmo_sccp_addr_by_name_local(struct osmo_sccp_addr *dest_addr, const char *name,
305  const struct osmo_ss7_instance *inst);
306 
307 const char *osmo_sccp_name_by_addr(const struct osmo_sccp_addr *addr);
308 
309 void osmo_sccp_local_addr_by_instance(struct osmo_sccp_addr *dest_addr,
310  const struct osmo_sccp_instance *inst,
311  uint32_t ssn);
312 
313 bool osmo_sccp_check_addr(struct osmo_sccp_addr *addr, uint32_t presence);
314 int osmo_sccp_addr_cmp(const struct osmo_sccp_addr *a, const struct osmo_sccp_addr *b, uint32_t presence_criteria);
315 int osmo_sccp_addr_ri_cmp(const struct osmo_sccp_addr *a, const struct osmo_sccp_addr *b);
316 int osmo_sccp_gt_cmp(const struct osmo_sccp_gt *a, const struct osmo_sccp_gt *b);
317 
318 const char *osmo_sccp_user_name(struct osmo_sccp_user *scu);
Definition: sccp_sap.h:41
Definition: sccp_sap.h:85
Definition: sccp_sap.h:45
Definition: sccp_sap.h:136
Definition: sccp_sap.h:42
Definition: sccp_sap.h:75
Definition: sccp_sap.h:58
Definition: sccp_sap.h:116
uint32_t return_option
Definition: sccp_sap.h:230
void osmo_sccp_user_unbind(struct osmo_sccp_user *scu)
Unbind a given SCCP user.
Definition: sccp_user.c:149
int osmo_sccp_gt_cmp(const struct osmo_sccp_gt *a, const struct osmo_sccp_gt *b)
Compare two SCCP Global Titles.
Definition: sccp_user.c:335
int osmo_sccp_addr_cmp(const struct osmo_sccp_addr *a, const struct osmo_sccp_addr *b, uint32_t presence_criteria)
Compare two SCCP addresses by given presence criteria.
Definition: sccp_user.c:357
Definition: sccp_sap.h:119
Definition: sccp_sap.h:84
int osmo_sccp_addr_ri_cmp(const struct osmo_sccp_addr *a, const struct osmo_sccp_addr *b)
Compare the routing information of two SCCP addresses.
Definition: sccp_user.c:417
int osmo_sccp_addr_by_name_local(struct osmo_sccp_addr *dest_addr, const char *name, const struct osmo_ss7_instance *inst)
Lookup an SCCP address from the addressbook of a specific instance by its name.
Definition: osmo_ss7_vty.c:1360
uint32_t conn_id
Definition: sccp_sap.h:197
struct osmo_sccp_instance * osmo_sccp_instance_create(struct osmo_ss7_instance *ss7, void *priv)
create a SCCP Instance and register it as user with SS7 inst
Definition: sccp_user.c:221
int osmo_sccp_user_sap_down(struct osmo_sccp_user *scu, struct osmo_prim_hdr *oph)
Main entrance function for primitives from SCCP User.
Definition: sccp_scoc.c:1914
Definition: sccp_sap.h:184
Definition: sccp_sap.h:44
Definition: sccp_sap.h:113
Definition: sccp_sap.h:100
Definition: sccp_sap.h:226
Definition: sccp_sap.h:46
Definition: sccp_sap.h:129
uint32_t presence
Definition: sccp_sap.h:171
char * name
human-readable name of this user
Definition: sccp_internal.h:67
Definition: sccp_sap.h:125
Definition: sccp_sap.h:114
Definition: sccp_sap.h:150
static const char * osmo_sccp_gti_name(enum osmo_sccp_gti val)
Definition: sccp_sap.h:79
Definition: sccp_sap.h:91
Definition: sccp_sap.h:132
uint32_t conn_id
Definition: sccp_sap.h:191
osmo_scu_prim_type
SCCP-User primitives as per Q.711.
Definition: sccp_sap.h:32
Definition: sccp_sap.h:120
bool osmo_sccp_check_addr(struct osmo_sccp_addr *addr, uint32_t presence)
check whether a given SCCP-Address is consistent.
Definition: sccp_user.c:292
static const char * osmo_sccp_ssn_name(enum osmo_sccp_ssn val)
Definition: sccp_sap.h:159
void osmo_sccp_local_addr_by_instance(struct osmo_sccp_addr *dest_addr, const struct osmo_sccp_instance *inst, uint32_t ssn)
derive a basic local SCCP-Address from a given SCCP instance.
Definition: sccp_user.c:272
uint16_t ssn
SSN and/or point code to which we are bound.
Definition: sccp_internal.h:70
Definition: sccp_internal.h:42
Definition: sccp_sap.h:260
Definition: sccp_sap.h:108
uint32_t pc
Definition: sccp_sap.h:174
osmo_sccp_rem_sccp_status
Definition: sccp_sap.h:147
Definition: sccp_sap.h:60
uint32_t cause
Definition: sccp_sap.h:239
Definition: sccp_sap.h:97
osmo_prim_cb prim_cb
Definition: sccp_internal.h:77
uint32_t affected_pc
Definition: sccp_sap.h:254
Definition: sccp_sap.h:152
int osmo_sccp_user_sap_down_nofree(struct osmo_sccp_user *scu, struct osmo_prim_hdr *oph)
Main entrance function for primitives from SCCP User.
Definition: sccp_scoc.c:1857
struct osmo_sccp_user * osmo_sccp_user_bind_pc(struct osmo_sccp_instance *inst, const char *name, osmo_prim_cb prim_cb, uint16_t ssn, uint32_t pc)
Bind a given SCCP User to a given SSN+PC.
Definition: sccp_user.c:128
Definition: sccp_sap.h:148
uint32_t importance
Definition: sccp_sap.h:240
void * priv
Definition: sccp_internal.h:54
osmo_sccp_gti
Definition: sccp_sap.h:70
Definition: sccp_sap.h:101
Definition: sccp_sap.h:123
Definition: sccp_sap.h:87
Definition: sccp_sap.h:36
Definition: sccp_sap.h:135
uint32_t importance
Definition: sccp_sap.h:198
Definition: sccp_sap.h:203
uint8_t gti
Definition: sccp_sap.h:163
Definition: sccp_sap.h:205
Definition: sccp_sap.h:99
bool user_in_service
Definition: sccp_sap.h:248
struct osmo_sccp_instance * inst
pointer back to SCCP instance
Definition: sccp_internal.h:65
Definition: sccp_sap.h:124
Definition: sccp_sap.h:151
osmo_sccp_originator
Definition: sccp_sap.h:202
uint32_t conn_id
Definition: sccp_sap.h:222
void osmo_sccp_user_set_priv(struct osmo_sccp_user *scu, void *priv)
Definition: sccp_user.c:159
const char * osmo_sccp_name_by_addr(const struct osmo_sccp_addr *addr)
Reverse lookup the lookup-name of a specified SCCP address.
Definition: osmo_ss7_vty.c:1378
void osmo_sccp_vty_init(void)
Definition: sccp_vty.c:256
struct osmo_ss7_instance * osmo_sccp_get_ss7(const struct osmo_sccp_instance *sccp)
get the SS7 instance that is related to the given SCCP instance
Definition: sccp_user.c:822
uint32_t nai
Definition: sccp_sap.h:166
uint32_t affected_ssn
Definition: sccp_sap.h:247
osmo_sccp_ssn
Definition: sccp_sap.h:106
uint32_t npi
Definition: sccp_sap.h:165
Definition: sccp_sap.h:88
Definition: sccp_sap.h:110
Definition: sccp_sap.h:111
uint32_t conn_id
Definition: sccp_sap.h:213
Definition: sccp_sap.h:142
Definition: sccp_sap.h:115
Definition: sccp_sap.h:253
Definition: sccp_sap.h:34
Definition: sccp_sap.h:127
uint32_t restricted_importance_level
Definition: sccp_sap.h:255
const struct value_string osmo_sccp_ssn_names[]
Definition: sccp_sap.c:108
Definition: sccp_internal.h:61
Definition: sccp_sap.h:126
Definition: sccp_sap.h:144
struct osmo_sccp_instance * osmo_sccp_get_sccp(const struct osmo_sccp_user *scu)
get the SCCP instance that is related to the given sccp user
Definition: sccp_user.c:832
Definition: sccp_sap.h:143
struct osmo_ss7_instance * ss7
Definition: sccp_internal.h:53
Definition: sccp_sap.h:89
Definition: sccp_sap.h:128
Definition: sccp_sap.h:134
Definition: sccp_sap.h:118
char digits[32]
Definition: sccp_sap.h:167
Definition: sccp_sap.h:98
Definition: sccp_sap.h:112
osmo_sccp_routing_ind
Definition: sccp_sap.h:57
const struct value_string osmo_sccp_gti_names[]
Definition: sccp_sap.c:99
char * name
Definition: osmo_ss7.h:96
void osmo_sccp_instance_destroy(struct osmo_sccp_instance *inst)
Definition: sccp_user.c:253
Definition: sccp_sap.h:72
uint32_t ssn_multiplicity_ind
Definition: sccp_sap.h:249
const char * osmo_sccp_user_name(struct osmo_sccp_user *scu)
Compose a human readable string to describe the SCCP user&#39;s connection.
Definition: sccp_user.c:453
char * osmo_scu_prim_name(const struct osmo_prim_hdr *oph)
Definition: sccp_sap.c:46
uint32_t importance
Definition: sccp_sap.h:214
Definition: sccp_sap.h:121
struct osmo_sccp_user * osmo_sccp_user_bind(struct osmo_sccp_instance *inst, const char *name, osmo_prim_cb prim_cb, uint16_t ssn)
Bind a given SCCP User to a given SSN (at any PC)
Definition: sccp_user.c:140
Definition: sccp_sap.h:204
Definition: sccp_sap.h:170
Definition: sccp_sap.h:245
osmo_sccp_nai
Definition: sccp_sap.h:96
Definition: sccp_sap.h:162
Definition: sccp_sap.h:74
Definition: sccp_sap.h:39
struct osmo_ss7_instance * osmo_sccp_addr_by_name(struct osmo_sccp_addr *dest_addr, const char *name)
Lookup an SCCP address from the addressbook by its name.
Definition: osmo_ss7_vty.c:1338
uint32_t cause
Definition: sccp_sap.h:212
Definition: sccp_sap.h:236
struct osmo_sccp_instance * sccp
Definition: osmo_ss7.h:92
const struct value_string osmo_sccp_routing_ind_names[]
Definition: sccp_sap.c:91
Definition: sccp_sap.h:86
Definition: sccp_sap.h:61
uint8_t data[0]
Definition: xua_types.h:72
static const char * osmo_sccp_routing_ind_name(enum osmo_sccp_routing_ind val)
Definition: sccp_sap.h:65
Definition: osmo_ss7.h:73
Definition: sccp_sap.h:59
uint32_t importance
Definition: sccp_sap.h:231
uint32_t cause
Definition: sccp_sap.h:221
Definition: sccp_sap.h:137
osmo_sccp_npi
Definition: sccp_sap.h:83
Definition: sccp_sap.h:130
Definition: sccp_sap.h:209
uint32_t pc
Definition: sccp_internal.h:71
Definition: sccp_sap.h:35
Definition: sccp_sap.h:37
void * osmo_sccp_user_get_priv(struct osmo_sccp_user *scu)
Definition: sccp_user.c:164
uint32_t sccp_class
Definition: sccp_sap.h:189
struct osmo_sccp_user * osmo_sccp_user_find(struct osmo_sccp_instance *inst, uint16_t ssn, uint32_t pc)
Find a SCCP User registered for given PC+SSN or SSN only.
Definition: sccp_user.c:81
uint32_t affected_pc
Definition: sccp_sap.h:246
osmo_sccp_sp_status
Definition: sccp_sap.h:141
Definition: sccp_sap.h:90
Definition: sccp_sap.h:196
Definition: sccp_sap.h:71
Definition: sccp_sap.h:219
uint32_t importance
Definition: sccp_sap.h:190
Definition: sccp_sap.h:109
uint32_t ssn
Definition: sccp_sap.h:175
uint32_t in_sequence_control
Definition: sccp_sap.h:229
Definition: sccp_sap.h:133
Definition: sccp_sap.h:92
Definition: sccp_sap.h:38
Definition: sccp_sap.h:73
uint8_t tt
Definition: sccp_sap.h:164