libosmo-sigtran  2.3.0
Osmocom SIGTRAN library
ss7_asp.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "config.h"
4 
5 #include <stdint.h>
6 #include <osmocom/core/linuxlist.h>
7 #include <osmocom/core/fsm.h>
8 #include <osmocom/core/msgb.h>
9 #include <osmocom/core/tdef.h>
10 #include <osmocom/netif/stream.h>
11 
13 
14 #include "ss7_asp_peer.h"
15 #include "ss7_internal.h"
16 
17 /***********************************************************************
18  * SS7 Application Server Processes
19  ***********************************************************************/
20 
21 struct osmo_ss7_instance;
22 
24  /* Submit primitives M3UA -> LM:
25  * oph: {sap: XUA_SAP_LM, prim: enum osmo_xlm_prim_type},
26  * cb_data: (struct osmo_ss7_asp *)
27  */
28  osmo_prim_cb prim_cb;
29  void (*free_func)(struct osmo_xua_layer_manager *lm);
30  void *priv;
31 };
33 
35  /* 0 kept unused on purpose since it's handled specially by osmo_fsm */
36  SS7_ASP_XUA_T_ACK = 1, /* RFC3868 & RFC4666 timer T(ack) */
37  SS7_ASP_XUA_T_BEAT, /* RFC3868 & RFC4666 timer T(beat) */
38  /* This must remain the last item: */
40 };
41 extern const struct value_string ss7_asp_xua_timer_names[];
42 extern const struct osmo_tdef ss7_asp_xua_timer_defaults[SS7_ASP_XUA_TIMERS_LEN];
43 /* According to SUA RFC3868 Section 8, M3UA RFC4666 Section 4.3.4.1 */
44 #define SS7_ASP_XUA_DEFAULT_T_ACK_SEC 2
45 /* According to SUA RFC3868 Section 8 */
46 #define SS7_ASP_XUA_DEFAULT_T_BEAT_SEC 30
47 
53 };
54 
55 struct osmo_ss7_asp {
57  struct llist_head list;
58  struct llist_head assoc_as_list; /* list of struct ss7_as_asp_assoc */
59  unsigned int num_assoc_as; /* amount of ss7_as_asp_assoc/ss7_as in as_list */
60 
62 
64  struct osmo_fsm_inst *fi;
65 
68  struct llist_head siblings;
69 
71  struct osmo_stream_cli *client;
72  struct osmo_stream_srv *server;
74  char *sock_name;
75 
76  /* Peer's ASP Identifier, as received during ASPUP (SG/IPSP) and ASPUP ACK (IPSP),
77  * and transmitted during NOTIFY. */
78  uint32_t remote_asp_id;
80 
81  /* Layer Manager to which we talk */
83 
86 
89 
91  struct rate_ctr_group *ctrg;
92 
94  struct msgb *pending_msg;
95 
96  /* IPA proto ASP specific fields. */
97  struct {
98  /* Incoming IPA PDUs have no SLS field, hence a potentially
99  * unique one within AS is assigned to this ASP and applied
100  * manually when received. */
101  uint8_t sls:4;
103  } ipa;
104 
105 #ifdef WITH_TCAP_LOADSHARING
106  struct {
107  bool enabled;
108  } tcap;
109 #endif /* WITH_TCAP_LOADSHARING */
110 
111  struct {
112  char *name;
113  char *description;
115  struct {
117  bool shutdown:1;
119  bool blocked:1;
121  bool is_server;
122  enum osmo_ss7_asp_role role;
125  /* Used internally by "asp" node to figure out if "no shutdown"
126  * was done explicitly, in order to avoid automatic asp
127  * reconfiguring/restart at go_parent().
128  * Can be dropped in the future once we make sure everybody uses
129  * "[no] shutdown" explicitly in cfg files. */
131 
132  /* Local ASP Identifier transmitted during ASPUP (ASP/IPSP) and ASPUP ACK (IPSP),
133  * and received during NOTIFY.
134  * "The optional ASP Identifier parameter contains a unique value
135  * that is locally significant among the ASPs that support an AS". */
136  uint32_t local_asp_id;
138 
139  struct osmo_ss7_asp_peer local;
140  struct osmo_ss7_asp_peer remote;
141  uint8_t ip_dscp;
142  uint8_t qos_class;
143  uint32_t quirks;
144 
145  /* Whether to Tx xUA DAUD during ASP activation when in ASP role. */
146  bool daud_act;
147 
148  /* T_defs used by the default_lm: */
149  struct osmo_tdef *T_defs_xua;
150 
151  /* T_defs used by the default_lm: */
152  struct osmo_tdef *T_defs_lm;
153 
154  struct {
162  uint16_t max_init_timeo_value; /* ms */
164 
165  struct {
171  int keepalive_time_value; /* seconds */
172  int keepalive_intvl_value; /* seconds */
174  unsigned int user_timeout_value; /* milliseconds */
175  } tcp;
176 
179  } cfg;
180 };
181 
182 struct osmo_ss7_asp *ss7_asp_alloc(struct osmo_ss7_instance *inst, const char *name,
183  uint16_t remote_port, uint16_t local_port,
186 bool ss7_asp_is_started(const struct osmo_ss7_asp *asp);
187 int ss7_asp_get_fd(const struct osmo_ss7_asp *asp);
188 int ss7_asp_disconnect_stream(struct osmo_ss7_asp *asp);
189 
190 int ss7_asp_apply_tcp_pars(const struct osmo_ss7_asp *asp);
191 int ss7_asp_apply_peer_primary_address(const struct osmo_ss7_asp *asp);
192 int ss7_asp_apply_primary_address(const struct osmo_ss7_asp *asp);
193 int ss7_asp_apply_new_local_address(const struct osmo_ss7_asp *asp, unsigned int loc_idx);
194 int ss7_asp_apply_drop_local_address(const struct osmo_ss7_asp *asp, unsigned int loc_idx);
195 int ss7_asp_apply_ip_dscp(const struct osmo_ss7_asp *asp);
196 
197 void ss7_asp_set_blocked(struct osmo_ss7_asp *asp, bool blocked);
200 
201 unsigned int ss7_asp_get_all_rctx(const struct osmo_ss7_asp *asp, uint32_t *rctx, unsigned int rctx_size,
202  const struct osmo_ss7_as *excl_as);
203 unsigned int ss7_asp_get_all_rctx_be(const struct osmo_ss7_asp *asp, uint32_t *rctx, unsigned int rctx_size,
204  const struct osmo_ss7_as *excl_as);
205 struct osmo_ss7_as *ss7_asp_find_as_by_rctx(const struct osmo_ss7_asp *asp, uint32_t rctx);
206 struct osmo_ss7_as *ss7_asp_get_first_as(const struct osmo_ss7_asp *asp);
207 
208 int ss7_asp_determine_traf_mode(const struct osmo_ss7_asp *asp);
209 bool ss7_asp_check_remote_asp_id_unique(const struct osmo_ss7_asp *asp, uint32_t remote_asp_id);
210 
211 #define LOGPASP(asp, subsys, level, fmt, args ...) \
212  _LOGSS7((asp)->inst, subsys, level, "ASP(%s) " fmt, (asp)->cfg.name, ## args)
osmo_ss7_asp_protocol
Definition: osmo_ss7.h:157
osmo_ss7_asp_role
Definition: osmo_ss7.h:243
struct osmo_ss7_as * ss7_asp_get_first_as(const struct osmo_ss7_asp *asp)
Definition: ss7_asp.c:1635
int ss7_asp_determine_traf_mode(const struct osmo_ss7_asp *asp)
Definition: ss7_asp.c:1649
bool ss7_asp_is_started(const struct osmo_ss7_asp *asp)
Definition: ss7_asp.c:988
int ss7_asp_apply_primary_address(const struct osmo_ss7_asp *asp)
Definition: ss7_asp.c:437
ss7_asp_xua_timer
Definition: ss7_asp.h:34
@ SS7_ASP_XUA_TIMERS_LEN
Definition: ss7_asp.h:39
@ SS7_ASP_XUA_T_ACK
Definition: ss7_asp.h:36
@ SS7_ASP_XUA_T_BEAT
Definition: ss7_asp.h:37
struct osmo_xua_layer_manager * xua_layer_manager_default_alloc(struct osmo_ss7_asp *asp)
Definition: xua_default_lm_fsm.c:668
ss7_asp_ctr
Definition: ss7_asp.h:48
@ SS7_ASP_CTR_PKT_TX_TOTAL
Definition: ss7_asp.h:52
@ SS7_ASP_CTR_PKT_RX_NI_MISMATCH
Definition: ss7_asp.h:51
@ SS7_ASP_CTR_PKT_RX_UNKNOWN
Definition: ss7_asp.h:50
@ SS7_ASP_CTR_PKT_RX_TOTAL
Definition: ss7_asp.h:49
void ss7_asp_restart_after_reconfigure(struct osmo_ss7_asp *asp)
Definition: ss7_asp.c:1571
void ss7_asp_set_blocked(struct osmo_ss7_asp *asp, bool blocked)
Definition: ss7_asp.c:1556
int ss7_asp_apply_peer_primary_address(const struct osmo_ss7_asp *asp)
Definition: ss7_asp.c:395
struct osmo_ss7_as * ss7_asp_find_as_by_rctx(const struct osmo_ss7_asp *asp, uint32_t rctx)
Find Application Server associated to ASP by given routing context.
Definition: ss7_asp.c:1622
int ss7_asp_get_fd(const struct osmo_ss7_asp *asp)
Get the fd of a given ASP.
Definition: ss7_asp.c:1542
int ss7_asp_disconnect_stream(struct osmo_ss7_asp *asp)
Definition: ss7_asp.c:883
const struct osmo_tdef ss7_asp_xua_timer_defaults[SS7_ASP_XUA_TIMERS_LEN]
Definition: ss7_asp.c:122
bool ss7_asp_check_remote_asp_id_unique(const struct osmo_ss7_asp *asp, uint32_t remote_asp_id)
Definition: ss7_asp.c:1670
int ss7_asp_apply_new_local_address(const struct osmo_ss7_asp *asp, unsigned int loc_idx)
Definition: ss7_asp.c:334
int ss7_asp_apply_tcp_pars(const struct osmo_ss7_asp *asp)
Definition: ss7_asp.c:325
unsigned int ss7_asp_get_all_rctx(const struct osmo_ss7_asp *asp, uint32_t *rctx, unsigned int rctx_size, const struct osmo_ss7_as *excl_as)
Definition: ss7_asp.c:1612
int ss7_asp_apply_drop_local_address(const struct osmo_ss7_asp *asp, unsigned int loc_idx)
Definition: ss7_asp.c:356
const struct value_string ss7_asp_xua_timer_names[]
Definition: ss7_asp.c:132
int ss7_asp_apply_ip_dscp(const struct osmo_ss7_asp *asp)
Definition: ss7_asp.c:378
unsigned int ss7_asp_get_all_rctx_be(const struct osmo_ss7_asp *asp, uint32_t *rctx, unsigned int rctx_size, const struct osmo_ss7_as *excl_as)
Definition: ss7_asp.c:1605
void ss7_asp_xua_layer_manager_start(struct osmo_ss7_asp *asp)
Definition: ss7_asp.c:714
struct osmo_ss7_asp * ss7_asp_alloc(struct osmo_ss7_instance *inst, const char *name, uint16_t remote_port, uint16_t local_port, int trans_proto, enum osmo_ss7_asp_protocol proto)
Definition: ss7_asp.c:736
bool ss7_asp_set_default_peer_hosts(struct osmo_ss7_asp *asp)
Definition: ss7_asp.c:576
Definition: ss7_as.h:105
Definition: ss7_asp_peer.h:11
Definition: ss7_asp.h:55
enum osmo_ss7_asp_role role
Definition: ss7_asp.h:122
char * sock_name
pre-formatted human readable local/remote socket name
Definition: ss7_asp.h:74
uint32_t local_asp_id
Definition: ss7_asp.h:136
bool role_set_by_vty
Definition: ss7_asp.h:123
int keepalive_time_value
Definition: ss7_asp.h:171
struct osmo_ss7_asp::@27 cfg
struct osmo_ss7_asp_peer remote
Definition: ss7_asp.h:140
bool max_attempts_present
Definition: ss7_asp.h:157
bool explicit_shutdown_state_by_vty_since_node_enter
Definition: ss7_asp.h:130
bool max_instreams_present
Definition: ss7_asp.h:156
struct osmo_tdef * T_defs_lm
Definition: ss7_asp.h:152
struct osmo_fsm_inst * fi
ASP FSM.
Definition: ss7_asp.h:64
uint16_t max_attempts_value
Definition: ss7_asp.h:161
struct osmo_tdef * T_defs_xua
Definition: ss7_asp.h:149
uint16_t max_instreams_value
Definition: ss7_asp.h:160
unsigned int num_assoc_as
Definition: ss7_asp.h:59
struct llist_head list
entry in osmo_ss7_instance::asp_list
Definition: ss7_asp.h:57
uint8_t sls
Definition: ss7_asp.h:101
bool local_asp_id_present
Definition: ss7_asp.h:137
enum osmo_ss7_asp_protocol proto
Definition: ss7_asp.h:114
struct osmo_ss7_instance * inst
Definition: ss7_asp.h:61
struct osmo_ss7_asp::@27::@28 adm_state
bool num_ostreams_present
Definition: ss7_asp.h:155
uint32_t remote_asp_id
Definition: ss7_asp.h:78
struct osmo_ss7_asp::@26 ipa
struct osmo_stream_srv * server
Definition: ss7_asp.h:72
uint8_t ip_dscp
Definition: ss7_asp.h:141
uint32_t quirks
Definition: ss7_asp.h:143
bool simple_client_allocated
Were we allocated by "simple client" support?
Definition: ss7_asp.h:88
int keepalive_probes_value
Definition: ss7_asp.h:173
bool blocked
SCP association, but reject ASP-ACTIVE.
Definition: ss7_asp.h:119
bool sls_assigned
Definition: ss7_asp.h:102
struct osmo_stream_cli * client
osmo_stream / libosmo-netif handles
Definition: ss7_asp.h:71
struct osmo_ss7_asp::@27::@29 sctp_init
bool trans_role_set_by_vty
Definition: ss7_asp.h:124
struct osmo_xua_server * xua_server
osmo_xua_server over which we were established
Definition: ss7_asp.h:67
struct osmo_xua_layer_manager * lm
Definition: ss7_asp.h:82
struct osmo_ss7_asp_peer local
Definition: ss7_asp.h:139
bool is_server
Definition: ss7_asp.h:121
int keepalive_intvl_value
Definition: ss7_asp.h:172
bool user_timeout_present
Definition: ss7_asp.h:170
unsigned int user_timeout_value
Definition: ss7_asp.h:174
bool daud_act
Definition: ss7_asp.h:146
bool dyn_allocated
Were we dynamically allocated.
Definition: ss7_asp.h:85
bool max_init_timeo_present
Definition: ss7_asp.h:158
char * name
Definition: ss7_asp.h:112
bool keepalive_probes_present
Definition: ss7_asp.h:169
bool keepalive_time_present
Definition: ss7_asp.h:167
bool keepalive_intvl_present
Definition: ss7_asp.h:168
bool shutdown
no SCTP association with peer
Definition: ss7_asp.h:117
uint8_t qos_class
Definition: ss7_asp.h:142
struct msgb * pending_msg
Pending message for non-blocking IPA read.
Definition: ss7_asp.h:94
struct osmo_ss7_asp::@27::@30 tcp
uint16_t num_ostreams_value
Definition: ss7_asp.h:159
int trans_proto
The underlaying transport protocol (one of IPPROTO_*)
Definition: ss7_asp.h:178
struct llist_head assoc_as_list
Definition: ss7_asp.h:58
char * description
Definition: ss7_asp.h:113
bool keepalive_enable
Definition: ss7_asp.h:166
bool remote_asp_id_present
Definition: ss7_asp.h:79
struct rate_ctr_group * ctrg
Rate Counter Group.
Definition: ss7_asp.h:91
struct llist_head siblings
Definition: ss7_asp.h:68
uint16_t max_init_timeo_value
Definition: ss7_asp.h:162
Definition: ss7_instance.h:47
Definition: ss7_asp.h:23
osmo_prim_cb prim_cb
Definition: ss7_asp.h:28
void * priv
Definition: ss7_asp.h:30
void(* free_func)(struct osmo_xua_layer_manager *lm)
Definition: ss7_asp.h:29
Definition: ss7_xua_srv.h:18