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