libosmo-sigtran  1.3.0.24-e7c8
Osmocom SIGTRAN library
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 /* legacy shim for name change */
141 #define OSMO_SCCP_SSN_SMLC_BSSAP OSMO_SCCP_SSN_SMLC_BSSAP_LE
142 
143 extern const struct value_string osmo_sccp_ssn_names[];
144 static inline const char *osmo_sccp_ssn_name(enum osmo_sccp_ssn val)
145 { return get_value_string(osmo_sccp_ssn_names, val); }
146 
147 struct osmo_sccp_gt {
148  uint8_t gti;
149  uint8_t tt;
150  uint32_t npi;
151  uint32_t nai;
152  char digits[32];
153 };
154 
156  uint32_t presence;
158  struct osmo_sccp_gt gt;
159  uint32_t pc;
160  uint32_t ssn;
161  union {
162  struct in_addr v4;
163  struct in6_addr v6;
164  } ip;
165  /* we don't do hostnames */
166 };
167 
168 /* OSMO_SCU_PRIM_N_CONNECT */
173  //struct osmo_sccp_qos_pars qos_pars;
174  uint32_t sccp_class;
175  uint32_t importance;
176  uint32_t conn_id;
177  /* user data */
178 };
179 
180 /* OSMO_SCU_PRIM_N_DATA / OSMO_SCU_PRIM_N_EXPEDITED_DATA */
182  uint32_t conn_id;
183  uint32_t importance;
184  /* user data */
185 };
186 
191 };
192 
193 /* OSMO_SCU_PRIM_N_DISCONNECT */
197  uint32_t cause;
198  uint32_t conn_id;
199  uint32_t importance;
200  /* user data */
201 };
202 
203 /* OSMO_SCU_PRIM_N_RESET */
206  uint32_t cause;
207  uint32_t conn_id;
208 };
209 
210 /* OSMO_SCU_PRIM_N_UNITDATA */
215  uint32_t return_option;
216  uint32_t importance;
217  /* user data */
218 };
219 
220 /* OSMO_SCU_PRIM_N_NOTICE */
224  uint32_t cause;
225  uint32_t importance;
226  /* user data */
227 };
228 
230  struct osmo_prim_hdr oph;
231  union {
233  struct osmo_scu_data_param data;
238  } u;
239 };
240 
241 #define msgb_scu_prim(msg) ((struct osmo_scu_prim *)(msg)->l1h)
242 
243 char *osmo_scu_prim_name(struct osmo_prim_hdr *oph);
244 
245 struct osmo_ss7_instance;
246 struct osmo_sccp_instance;
247 struct osmo_sccp_user;
248 
249 void osmo_sccp_vty_init(void);
250 
251 struct osmo_sccp_instance *
255 struct osmo_sccp_instance *osmo_sccp_get_sccp(const struct osmo_sccp_user *scu);
256 
257 void osmo_sccp_user_unbind(struct osmo_sccp_user *scu);
258 void osmo_sccp_user_set_priv(struct osmo_sccp_user *scu, void *priv);
259 void *osmo_sccp_user_get_priv(struct osmo_sccp_user *scu);
260 
261 struct osmo_sccp_user *
263  osmo_prim_cb prim_cb, uint16_t ssn, uint32_t pc);
264 
265 struct osmo_sccp_user *
266 osmo_sccp_user_bind(struct osmo_sccp_instance *inst, const char *name,
267  osmo_prim_cb prim_cb, uint16_t ssn);
268 struct osmo_sccp_user *
269 osmo_sccp_user_find(struct osmo_sccp_instance *inst, uint16_t ssn, uint32_t pc);
270 
271 int osmo_sccp_user_sap_down(struct osmo_sccp_user *scu, struct osmo_prim_hdr *oph);
272 int osmo_sccp_user_sap_down_nofree(struct osmo_sccp_user *scu, struct osmo_prim_hdr *oph);
273 
274 struct osmo_ss7_instance *
275 osmo_sccp_addr_by_name(struct osmo_sccp_addr *dest_addr,
276  const char *name);
277 
278 const char *osmo_sccp_name_by_addr(const struct osmo_sccp_addr *addr);
279 
280 void osmo_sccp_local_addr_by_instance(struct osmo_sccp_addr *dest_addr,
281  const struct osmo_sccp_instance *inst,
282  uint32_t ssn);
283 
284 bool osmo_sccp_check_addr(struct osmo_sccp_addr *addr, uint32_t presence);
285 int osmo_sccp_addr_cmp(const struct osmo_sccp_addr *a, const struct osmo_sccp_addr *b, uint32_t presence_criteria);
286 int osmo_sccp_addr_ri_cmp(const struct osmo_sccp_addr *a, const struct osmo_sccp_addr *b);
287 int osmo_sccp_gt_cmp(const struct osmo_sccp_gt *a, const struct osmo_sccp_gt *b);
288 
289 const char *osmo_sccp_user_name(struct osmo_sccp_user *scu);
void * osmo_sccp_user_get_priv(struct osmo_sccp_user *scu)
Definition: sccp_user.c:163
osmo_scu_prim_type
SCCP-User primitives as per Q.711.
Definition: sccp_sap.h:32
@ OSMO_SCU_PRIM_N_CONNECT
Definition: sccp_sap.h:34
@ OSMO_SCU_PRIM_N_NOTICE
Definition: sccp_sap.h:42
@ OSMO_SCU_PRIM_N_INFORM
Definition: sccp_sap.h:39
@ OSMO_SCU_PRIM_N_RESET
Definition: sccp_sap.h:38
@ OSMO_SCU_PRIM_N_UNITDATA
Definition: sccp_sap.h:41
@ OSMO_SCU_PRIM_N_PCSTATE
Definition: sccp_sap.h:46
@ OSMO_SCU_PRIM_N_EXPEDITED_DATA
Definition: sccp_sap.h:36
@ OSMO_SCU_PRIM_N_STATE
Definition: sccp_sap.h:45
@ OSMO_SCU_PRIM_N_DISCONNECT
Definition: sccp_sap.h:37
@ OSMO_SCU_PRIM_N_DATA
Definition: sccp_sap.h:35
@ OSMO_SCU_PRIM_N_COORD
Definition: sccp_sap.h:44
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:806
osmo_sccp_npi
Definition: sccp_sap.h:83
@ OSMO_SCCP_NPI_F69_TELEX
Definition: sccp_sap.h:88
@ OSMO_SCCP_NPI_E214_ISDN_MOBILE
Definition: sccp_sap.h:91
@ OSMO_SCCP_NPI_GEERIC
Definition: sccp_sap.h:86
@ OSMO_SCCP_NPI_E210_MARITIME
Definition: sccp_sap.h:89
@ OSMO_SCCP_NPI_X121_DATA
Definition: sccp_sap.h:87
@ OSMO_SCCP_NPI_E212_LAND
Definition: sccp_sap.h:90
@ OSMO_SCCP_NPI_E164_ISDN
Definition: sccp_sap.h:85
@ OSMO_SCCP_NPI_UNKNOWN
Definition: sccp_sap.h:84
@ OSMO_SCCP_NPI_PRIVATE
Definition: sccp_sap.h:92
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:1720
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:127
void osmo_sccp_user_set_priv(struct osmo_sccp_user *scu, void *priv)
Definition: sccp_user.c:158
osmo_sccp_originator
Definition: sccp_sap.h:187
@ OSMO_SCCP_ORIG_NS_USER
Definition: sccp_sap.h:189
@ OSMO_SCCP_ORIG_NS_PROVIDER
Definition: sccp_sap.h:188
@ OSMO_SCCP_ORIG_UNDEFINED
Definition: sccp_sap.h:190
const char * osmo_sccp_user_name(struct osmo_sccp_user *scu)
Compose a human readable string to describe the SCCP user's connection.
Definition: sccp_user.c:445
void osmo_sccp_instance_destroy(struct osmo_sccp_instance *inst)
Definition: sccp_user.c:245
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:284
static const char * osmo_sccp_routing_ind_name(enum osmo_sccp_routing_ind val)
Definition: sccp_sap.h:65
osmo_sccp_gti
Definition: sccp_sap.h:70
@ OSMO_SCCP_GTI_TT_NPL_ENC_NAI
Definition: sccp_sap.h:75
@ OSMO_SCCP_GTI_NAI_ONLY
Definition: sccp_sap.h:72
@ OSMO_SCCP_GTI_TT_ONLY
Definition: sccp_sap.h:73
@ OSMO_SCCP_GTI_TT_NPL_ENC
Definition: sccp_sap.h:74
@ OSMO_SCCP_GTI_NO_GT
Definition: sccp_sap.h:71
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:327
osmo_sccp_routing_ind
Definition: sccp_sap.h:57
@ OSMO_SCCP_RI_GT
Definition: sccp_sap.h:59
@ OSMO_SCCP_RI_NONE
Definition: sccp_sap.h:58
@ OSMO_SCCP_RI_SSN_PC
Definition: sccp_sap.h:60
@ OSMO_SCCP_RI_SSN_IP
Definition: sccp_sap.h:61
const struct value_string osmo_sccp_ssn_names[]
Definition: sccp_sap.c:108
void osmo_sccp_vty_init(void)
Definition: sccp_vty.c:256
const struct value_string osmo_sccp_routing_ind_names[]
Definition: sccp_sap.c:91
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:1777
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:139
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:220
osmo_sccp_ssn
Definition: sccp_sap.h:106
@ OSMO_SCCP_SSN_BSC_BSSAP_LE
Definition: sccp_sap.h:133
@ OSMO_SCCP_SSN_ISUP
Definition: sccp_sap.h:109
@ OSMO_SCCP_SSN_RES_INTL
Definition: sccp_sap.h:119
@ OSMO_SCCP_SSN_MSC_BSSAP_LE
Definition: sccp_sap.h:134
@ OSMO_SCCP_SSN_HLR
Definition: sccp_sap.h:112
@ OSMO_SCCP_SSN_SGSN_MAP
Definition: sccp_sap.h:129
@ OSMO_SCCP_SSN_VLR
Definition: sccp_sap.h:113
@ OSMO_SCCP_SSN_RANAP
Definition: sccp_sap.h:123
@ OSMO_SCCP_SSN_gsmSCF_MAP
Definition: sccp_sap.h:127
@ OSMO_SCCP_SSN_MSC
Definition: sccp_sap.h:114
@ OSMO_SCCP_SSN_GMLC_MAP
Definition: sccp_sap.h:125
@ OSMO_SCCP_SSN_BSSAP
Definition: sccp_sap.h:137
@ OSMO_SCCP_SSN_ISDN_SS
Definition: sccp_sap.h:118
@ OSMO_SCCP_SSN_SMLC_BSSAP_LE
Definition: sccp_sap.h:135
@ OSMO_SCCP_SSN_MAP
Definition: sccp_sap.h:111
@ OSMO_SCCP_SSN_GGSN_MAP
Definition: sccp_sap.h:130
@ OSMO_SCCP_SSN_EIR
Definition: sccp_sap.h:115
@ OSMO_SCCP_SSN_CAP
Definition: sccp_sap.h:126
@ OSMO_SCCP_SSN_TC_TEST
Definition: sccp_sap.h:121
@ OSMO_SCCP_SSN_RNSAP
Definition: sccp_sap.h:124
@ OSMO_SCCP_SSN_PCAP
Definition: sccp_sap.h:132
@ OSMO_SCCP_SSN_AUC
Definition: sccp_sap.h:116
@ OSMO_SCCP_SSN_OMAP
Definition: sccp_sap.h:110
@ OSMO_SCCP_SSN_BISDN
Definition: sccp_sap.h:120
@ OSMO_SCCP_SSN_BSS_OAM
Definition: sccp_sap.h:136
@ OSMO_SCCP_SSN_SIWF_MAP
Definition: sccp_sap.h:128
@ OSMO_SCCP_SSN_MGMT
Definition: sccp_sap.h:108
osmo_sccp_nai
Definition: sccp_sap.h:96
@ OSMO_SCCP_NAI_SUBSCR
Definition: sccp_sap.h:98
@ OSMO_SCCP_NAI_INTL
Definition: sccp_sap.h:101
@ OSMO_SCCP_NAI_UNKNOWN
Definition: sccp_sap.h:97
@ OSMO_SCCP_NAI_RES_NAT_USE
Definition: sccp_sap.h:99
@ OSMO_SCCP_NAI_NATL
Definition: sccp_sap.h:100
static const char * osmo_sccp_gti_name(enum osmo_sccp_gti val)
Definition: sccp_sap.h:79
static const char * osmo_sccp_ssn_name(enum osmo_sccp_ssn val)
Definition: sccp_sap.h:144
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:80
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:264
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:1259
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:349
const struct value_string osmo_sccp_gti_names[]
Definition: sccp_sap.c:99
void osmo_sccp_user_unbind(struct osmo_sccp_user *scu)
Unbind a given SCCP user.
Definition: sccp_user.c:148
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:1277
char * osmo_scu_prim_name(struct osmo_prim_hdr *oph)
Definition: sccp_sap.c:46
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:816
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:409
Definition: sccp_sap.h:155
uint32_t pc
Definition: sccp_sap.h:159
struct in_addr v4
Definition: sccp_sap.h:162
union osmo_sccp_addr::@29 ip
uint32_t ssn
Definition: sccp_sap.h:160
enum osmo_sccp_routing_ind ri
Definition: sccp_sap.h:157
struct osmo_sccp_gt gt
Definition: sccp_sap.h:158
uint32_t presence
Definition: sccp_sap.h:156
struct in6_addr v6
Definition: sccp_sap.h:163
Definition: sccp_sap.h:147
uint8_t gti
Definition: sccp_sap.h:148
uint32_t nai
Definition: sccp_sap.h:151
uint32_t npi
Definition: sccp_sap.h:150
char digits[32]
Definition: sccp_sap.h:152
uint8_t tt
Definition: sccp_sap.h:149
Definition: sccp_internal.h:41
struct osmo_ss7_instance * ss7
Definition: sccp_internal.h:52
void * priv
Definition: sccp_internal.h:53
Definition: sccp_internal.h:60
struct osmo_sccp_instance * inst
pointer back to SCCP instance
Definition: sccp_internal.h:64
uint32_t pc
Definition: sccp_internal.h:70
uint16_t ssn
SSN and/or point code to which we are bound.
Definition: sccp_internal.h:69
char * name
human-readable name of this user
Definition: sccp_internal.h:66
osmo_prim_cb prim_cb
Definition: sccp_internal.h:76
Definition: sccp_sap.h:169
struct osmo_sccp_addr calling_addr
Definition: sccp_sap.h:171
struct osmo_sccp_addr responding_addr
Definition: sccp_sap.h:172
uint32_t sccp_class
Definition: sccp_sap.h:174
uint32_t importance
Definition: sccp_sap.h:175
struct osmo_sccp_addr called_addr
Definition: sccp_sap.h:170
uint32_t conn_id
Definition: sccp_sap.h:176
Definition: sccp_sap.h:181
uint32_t importance
Definition: sccp_sap.h:183
uint32_t conn_id
Definition: sccp_sap.h:182
Definition: sccp_sap.h:194
uint32_t conn_id
Definition: sccp_sap.h:198
enum osmo_sccp_originator originator
Definition: sccp_sap.h:195
uint32_t importance
Definition: sccp_sap.h:199
struct osmo_sccp_addr responding_addr
Definition: sccp_sap.h:196
uint32_t cause
Definition: sccp_sap.h:197
Definition: sccp_sap.h:221
struct osmo_sccp_addr called_addr
Definition: sccp_sap.h:222
uint32_t cause
Definition: sccp_sap.h:224
uint32_t importance
Definition: sccp_sap.h:225
struct osmo_sccp_addr calling_addr
Definition: sccp_sap.h:223
Definition: sccp_sap.h:229
struct osmo_prim_hdr oph
Definition: sccp_sap.h:230
struct osmo_scu_notice_param notice
Definition: sccp_sap.h:237
struct osmo_scu_unitdata_param unitdata
Definition: sccp_sap.h:236
struct osmo_scu_disconn_param disconnect
Definition: sccp_sap.h:234
struct osmo_scu_connect_param connect
Definition: sccp_sap.h:232
struct osmo_scu_data_param data
Definition: sccp_sap.h:233
struct osmo_scu_reset_param reset
Definition: sccp_sap.h:235
union osmo_scu_prim::@30 u
Definition: sccp_sap.h:204
uint32_t conn_id
Definition: sccp_sap.h:207
uint32_t cause
Definition: sccp_sap.h:206
enum osmo_sccp_originator originator
Definition: sccp_sap.h:205
Definition: sccp_sap.h:211
uint32_t return_option
Definition: sccp_sap.h:215
uint32_t in_sequence_control
Definition: sccp_sap.h:214
struct osmo_sccp_addr called_addr
Definition: sccp_sap.h:212
struct osmo_sccp_addr calling_addr
Definition: sccp_sap.h:213
uint32_t importance
Definition: sccp_sap.h:216
Definition: osmo_ss7.h:71
struct osmo_sccp_instance * sccp
Definition: osmo_ss7.h:90
char * name
Definition: osmo_ss7.h:94