libosmo-sigtran 2.2.1.28-88af 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
12#include <osmocom/sigtran/osmo_ss7.h>
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
23 struct osmo_xua_layer_manager {
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};
32 struct osmo_xua_layer_manager *xua_layer_manager_default_alloc(struct osmo_ss7_asp *asp);
33
34 enum ss7_asp_xua_timer {
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: */
39 SS7_ASP_XUA_TIMERS_LEN
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
48 enum ss7_asp_ctr {
49 SS7_ASP_CTR_PKT_RX_TOTAL,
50 SS7_ASP_CTR_PKT_RX_UNKNOWN,
51 SS7_ASP_CTR_PKT_RX_NI_MISMATCH,
52 SS7_ASP_CTR_PKT_TX_TOTAL,
53};
54
55 struct osmo_ss7_asp {
57 struct llist_head list;
58 struct osmo_ss7_instance *inst;
59
61 struct osmo_fsm_inst *fi;
62
64 struct osmo_xua_server *xua_server;
65 struct llist_head siblings;
66
68 struct osmo_stream_cli *client;
69 struct osmo_stream_srv *server;
71 char *sock_name;
72
73 /* ASP Identifier for ASP-UP + NTFY, as received by the peer.
74 * (In IPA ASPs it's used internally to hold 4-bit SLS).
75 * FIXME: This should actually be stored in a AS-ASP relation, since it
76 * can be different per AS, see RFC4666 3.5.1
77 * "The optional ASP Identifier parameter contains a unique value that
78 * is locally significant among the ASPs that support an AS".
79 */
80 uint32_t remote_asp_id;
81 bool remote_asp_id_present;
82
83 /* Layer Manager to which we talk */
84 struct osmo_xua_layer_manager *lm;
85
87 bool dyn_allocated;
88
90 bool simple_client_allocated;
91
93 struct rate_ctr_group *ctrg;
94
96 struct msgb *pending_msg;
97
98 /* IPA proto ASP specific fields. */
99 struct {
100 /* Incoming IPA PDUs have no SLS field, hence a potentially
101 * unique one within AS is assigned to this ASP and applied
102 * manually when received. */
103 uint8_t sls:4;
104 bool sls_assigned;
105 } ipa;
106
107#ifdef WITH_TCAP_LOADSHARING
108 struct {
109 bool enabled;
110 } tcap;
111#endif /* WITH_TCAP_LOADSHARING */
112
113 struct {
114 char *name;
115 char *description;
116 enum osmo_ss7_asp_protocol proto;
117 enum osmo_ss7_asp_admin_state adm_state;
118 bool is_server;
119 enum osmo_ss7_asp_role role;
120 bool role_set_by_vty;
121 bool trans_role_set_by_vty;
122 /* Used internally by "asp" node to figure out if "no shutdown"
123 * was done explicitly, in order to avoid automatic asp
124 * reconfiguring/restart at go_parent().
125 * Can be dropped in the future once we make sure everybody uses
126 * "[no] shutdown" explicitly in cfg files. */
127 bool explicit_shutdown_state_by_vty_since_node_enter;
128
129 struct osmo_ss7_asp_peer local;
130 struct osmo_ss7_asp_peer remote;
131 uint8_t qos_class;
132 uint32_t quirks;
133
134 /* Whether to Tx xUA DAUD during ASP activation when in ASP role. */
135 bool daud_act;
136
137 /* T_defs used by the default_lm: */
138 struct osmo_tdef *T_defs_xua;
139
140 /* T_defs used by the default_lm: */
141 struct osmo_tdef *T_defs_lm;
142
143 struct {
144 bool num_ostreams_present;
145 bool max_instreams_present;
146 bool max_attempts_present;
147 bool max_init_timeo_present;
148 uint16_t num_ostreams_value;
149 uint16_t max_instreams_value;
150 uint16_t max_attempts_value;
151 uint16_t max_init_timeo_value; /* ms */
152 } sctp_init;
153
154 struct {
155 bool keepalive_enable;
156 bool keepalive_time_present;
157 bool keepalive_intvl_present;
158 bool keepalive_probes_present;
159 bool user_timeout_present;
160 int keepalive_time_value; /* seconds */
161 int keepalive_intvl_value; /* seconds */
162 int keepalive_probes_value;
163 unsigned int user_timeout_value; /* milliseconds */
164 } tcp;
165
167 int trans_proto;
168 } cfg;
169};
170
171 struct osmo_ss7_asp *ss7_asp_alloc(struct osmo_ss7_instance *inst, const char *name,
172 uint16_t remote_port, uint16_t local_port,
173 int trans_proto, enum osmo_ss7_asp_protocol proto);
174 bool ss7_asp_set_default_peer_hosts(struct osmo_ss7_asp *asp);
175 bool ss7_asp_is_started(const struct osmo_ss7_asp *asp);
176 int ss7_asp_get_fd(const struct osmo_ss7_asp *asp);
177 int ss7_asp_disconnect_stream(struct osmo_ss7_asp *asp);
178
179 int ss7_asp_apply_tcp_pars(const struct osmo_ss7_asp *asp);
180 int ss7_asp_apply_peer_primary_address(const struct osmo_ss7_asp *asp);
181 int ss7_asp_apply_primary_address(const struct osmo_ss7_asp *asp);
182 int ss7_asp_apply_new_local_address(const struct osmo_ss7_asp *asp, unsigned int loc_idx);
183 int ss7_asp_apply_drop_local_address(const struct osmo_ss7_asp *asp, unsigned int loc_idx);
184
185 void ss7_asp_restart_after_reconfigure(struct osmo_ss7_asp *asp);
186
187 unsigned int ss7_asp_get_all_rctx(const struct osmo_ss7_asp *asp, uint32_t *rctx, unsigned int rctx_size,
188 const struct osmo_ss7_as *excl_as);
189 unsigned int ss7_asp_get_all_rctx_be(const struct osmo_ss7_asp *asp, uint32_t *rctx, unsigned int rctx_size,
190 const struct osmo_ss7_as *excl_as);
191
192 int ss7_asp_determine_traf_mode(const struct osmo_ss7_asp *asp);
193
194#define LOGPASP(asp, subsys, level, fmt, args ...) \
195 _LOGSS7((asp)->inst, subsys, level, "ASP(%s) " fmt, (asp)->cfg.name, ## args)
osmo_ss7.h
osmo_ss7_asp_protocol
osmo_ss7_asp_protocol
Definition: osmo_ss7.h:157
osmo_ss7_asp_role
osmo_ss7_asp_role
Definition: osmo_ss7.h:253
osmo_ss7_asp_admin_state
osmo_ss7_asp_admin_state
Definition: osmo_ss7.h:243
ss7_asp_determine_traf_mode
int ss7_asp_determine_traf_mode(const struct osmo_ss7_asp *asp)
Definition: ss7_asp.c:1594
ss7_asp_is_started
bool ss7_asp_is_started(const struct osmo_ss7_asp *asp)
Definition: ss7_asp.c:974
ss7_asp_apply_primary_address
int ss7_asp_apply_primary_address(const struct osmo_ss7_asp *asp)
Definition: ss7_asp.c:425
ss7_asp_xua_timer
ss7_asp_xua_timer
Definition: ss7_asp.h:34
SS7_ASP_XUA_TIMERS_LEN
@ SS7_ASP_XUA_TIMERS_LEN
Definition: ss7_asp.h:39
SS7_ASP_XUA_T_ACK
@ SS7_ASP_XUA_T_ACK
Definition: ss7_asp.h:36
SS7_ASP_XUA_T_BEAT
@ SS7_ASP_XUA_T_BEAT
Definition: ss7_asp.h:37
ss7_asp_ctr
ss7_asp_ctr
Definition: ss7_asp.h:48
SS7_ASP_CTR_PKT_TX_TOTAL
@ SS7_ASP_CTR_PKT_TX_TOTAL
Definition: ss7_asp.h:52
SS7_ASP_CTR_PKT_RX_NI_MISMATCH
@ SS7_ASP_CTR_PKT_RX_NI_MISMATCH
Definition: ss7_asp.h:51
SS7_ASP_CTR_PKT_RX_UNKNOWN
@ SS7_ASP_CTR_PKT_RX_UNKNOWN
Definition: ss7_asp.h:50
SS7_ASP_CTR_PKT_RX_TOTAL
@ SS7_ASP_CTR_PKT_RX_TOTAL
Definition: ss7_asp.h:49
ss7_asp_restart_after_reconfigure
void ss7_asp_restart_after_reconfigure(struct osmo_ss7_asp *asp)
Definition: ss7_asp.c:1541
ss7_asp_apply_peer_primary_address
int ss7_asp_apply_peer_primary_address(const struct osmo_ss7_asp *asp)
Definition: ss7_asp.c:383
ss7_asp_get_fd
int ss7_asp_get_fd(const struct osmo_ss7_asp *asp)
Get the fd of a given ASP.
Definition: ss7_asp.c:1528
ss7_asp_disconnect_stream
int ss7_asp_disconnect_stream(struct osmo_ss7_asp *asp)
Definition: ss7_asp.c:868
ss7_asp_xua_timer_defaults
const struct osmo_tdef ss7_asp_xua_timer_defaults[SS7_ASP_XUA_TIMERS_LEN]
Definition: ss7_asp.c:121
xua_layer_manager_default_alloc
struct osmo_xua_layer_manager * xua_layer_manager_default_alloc(struct osmo_ss7_asp *asp)
Definition: xua_default_lm_fsm.c:431
ss7_asp_apply_new_local_address
int ss7_asp_apply_new_local_address(const struct osmo_ss7_asp *asp, unsigned int loc_idx)
Definition: ss7_asp.c:339
ss7_asp_apply_tcp_pars
int ss7_asp_apply_tcp_pars(const struct osmo_ss7_asp *asp)
Definition: ss7_asp.c:330
ss7_asp_get_all_rctx
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:1583
ss7_asp_apply_drop_local_address
int ss7_asp_apply_drop_local_address(const struct osmo_ss7_asp *asp, unsigned int loc_idx)
Definition: ss7_asp.c:361
ss7_asp_alloc
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:724
ss7_asp_xua_timer_names
const struct value_string ss7_asp_xua_timer_names[]
Definition: ss7_asp.c:130
ss7_asp_get_all_rctx_be
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:1576
ss7_asp_set_default_peer_hosts
bool ss7_asp_set_default_peer_hosts(struct osmo_ss7_asp *asp)
Definition: ss7_asp.c:564
ss7_asp_peer.h
ss7_internal.h
osmo_ss7_as
Definition: ss7_as.h:86
osmo_ss7_asp_peer
Definition: ss7_asp_peer.h:11
osmo_ss7_asp
Definition: ss7_asp.h:55
osmo_ss7_asp::role
enum osmo_ss7_asp_role role
Definition: ss7_asp.h:119
osmo_ss7_asp::sock_name
char * sock_name
pre-formatted human readable local/remote socket name
Definition: ss7_asp.h:71
osmo_ss7_asp::sctp_init
struct osmo_ss7_asp::@27::@28 sctp_init
osmo_ss7_asp::role_set_by_vty
bool role_set_by_vty
Definition: ss7_asp.h:120
osmo_ss7_asp::keepalive_time_value
int keepalive_time_value
Definition: ss7_asp.h:160
osmo_ss7_asp::cfg
struct osmo_ss7_asp::@27 cfg
osmo_ss7_asp::remote
struct osmo_ss7_asp_peer remote
Definition: ss7_asp.h:130
osmo_ss7_asp::max_attempts_present
bool max_attempts_present
Definition: ss7_asp.h:146
osmo_ss7_asp::explicit_shutdown_state_by_vty_since_node_enter
bool explicit_shutdown_state_by_vty_since_node_enter
Definition: ss7_asp.h:127
osmo_ss7_asp::max_instreams_present
bool max_instreams_present
Definition: ss7_asp.h:145
osmo_ss7_asp::T_defs_lm
struct osmo_tdef * T_defs_lm
Definition: ss7_asp.h:141
osmo_ss7_asp::fi
struct osmo_fsm_inst * fi
ASP FSM.
Definition: ss7_asp.h:61
osmo_ss7_asp::max_attempts_value
uint16_t max_attempts_value
Definition: ss7_asp.h:150
osmo_ss7_asp::T_defs_xua
struct osmo_tdef * T_defs_xua
Definition: ss7_asp.h:138
osmo_ss7_asp::max_instreams_value
uint16_t max_instreams_value
Definition: ss7_asp.h:149
osmo_ss7_asp::list
struct llist_head list
entry in osmo_ss7_instance::asp_list
Definition: ss7_asp.h:57
osmo_ss7_asp::sls
uint8_t sls
Definition: ss7_asp.h:103
osmo_ss7_asp::proto
enum osmo_ss7_asp_protocol proto
Definition: ss7_asp.h:116
osmo_ss7_asp::inst
struct osmo_ss7_instance * inst
Definition: ss7_asp.h:58
osmo_ss7_asp::num_ostreams_present
bool num_ostreams_present
Definition: ss7_asp.h:144
osmo_ss7_asp::remote_asp_id
uint32_t remote_asp_id
Definition: ss7_asp.h:80
osmo_ss7_asp::ipa
struct osmo_ss7_asp::@26 ipa
osmo_ss7_asp::server
struct osmo_stream_srv * server
Definition: ss7_asp.h:69
osmo_ss7_asp::quirks
uint32_t quirks
Definition: ss7_asp.h:132
osmo_ss7_asp::simple_client_allocated
bool simple_client_allocated
Were we allocated by "simple client" support?
Definition: ss7_asp.h:90
osmo_ss7_asp::keepalive_probes_value
int keepalive_probes_value
Definition: ss7_asp.h:162
osmo_ss7_asp::sls_assigned
bool sls_assigned
Definition: ss7_asp.h:104
osmo_ss7_asp::client
struct osmo_stream_cli * client
osmo_stream / libosmo-netif handles
Definition: ss7_asp.h:68
osmo_ss7_asp::trans_role_set_by_vty
bool trans_role_set_by_vty
Definition: ss7_asp.h:121
osmo_ss7_asp::adm_state
enum osmo_ss7_asp_admin_state adm_state
Definition: ss7_asp.h:117
osmo_ss7_asp::xua_server
struct osmo_xua_server * xua_server
osmo_xua_server over which we were established
Definition: ss7_asp.h:64
osmo_ss7_asp::lm
struct osmo_xua_layer_manager * lm
Definition: ss7_asp.h:84
osmo_ss7_asp::local
struct osmo_ss7_asp_peer local
Definition: ss7_asp.h:129
osmo_ss7_asp::is_server
bool is_server
Definition: ss7_asp.h:118
osmo_ss7_asp::tcp
struct osmo_ss7_asp::@27::@29 tcp
osmo_ss7_asp::keepalive_intvl_value
int keepalive_intvl_value
Definition: ss7_asp.h:161
osmo_ss7_asp::user_timeout_present
bool user_timeout_present
Definition: ss7_asp.h:159
osmo_ss7_asp::user_timeout_value
unsigned int user_timeout_value
Definition: ss7_asp.h:163
osmo_ss7_asp::daud_act
bool daud_act
Definition: ss7_asp.h:135
osmo_ss7_asp::dyn_allocated
bool dyn_allocated
Were we dynamically allocated.
Definition: ss7_asp.h:87
osmo_ss7_asp::max_init_timeo_present
bool max_init_timeo_present
Definition: ss7_asp.h:147
osmo_ss7_asp::name
char * name
Definition: ss7_asp.h:114
osmo_ss7_asp::keepalive_probes_present
bool keepalive_probes_present
Definition: ss7_asp.h:158
osmo_ss7_asp::keepalive_time_present
bool keepalive_time_present
Definition: ss7_asp.h:156
osmo_ss7_asp::keepalive_intvl_present
bool keepalive_intvl_present
Definition: ss7_asp.h:157
osmo_ss7_asp::qos_class
uint8_t qos_class
Definition: ss7_asp.h:131
osmo_ss7_asp::pending_msg
struct msgb * pending_msg
Pending message for non-blocking IPA read.
Definition: ss7_asp.h:96
osmo_ss7_asp::num_ostreams_value
uint16_t num_ostreams_value
Definition: ss7_asp.h:148
osmo_ss7_asp::trans_proto
int trans_proto
The underlaying transport protocol (one of IPPROTO_*)
Definition: ss7_asp.h:167
osmo_ss7_asp::description
char * description
Definition: ss7_asp.h:115
osmo_ss7_asp::keepalive_enable
bool keepalive_enable
Definition: ss7_asp.h:155
osmo_ss7_asp::remote_asp_id_present
bool remote_asp_id_present
Definition: ss7_asp.h:81
osmo_ss7_asp::ctrg
struct rate_ctr_group * ctrg
Rate Counter Group.
Definition: ss7_asp.h:93
osmo_ss7_asp::siblings
struct llist_head siblings
Definition: ss7_asp.h:65
osmo_ss7_asp::max_init_timeo_value
uint16_t max_init_timeo_value
Definition: ss7_asp.h:151
osmo_ss7_instance
Definition: ss7_instance.h:45
osmo_xua_layer_manager
Definition: ss7_asp.h:23
osmo_xua_layer_manager::prim_cb
osmo_prim_cb prim_cb
Definition: ss7_asp.h:28
osmo_xua_layer_manager::priv
void * priv
Definition: ss7_asp.h:30
osmo_xua_layer_manager::free_func
void(* free_func)(struct osmo_xua_layer_manager *lm)
Definition: ss7_asp.h:29
osmo_xua_server
Definition: ss7_xua_srv.h:18