spandsp  3.0.0
private/v150_1.h
1 /*
2  * SpanDSP - a series of DSP components for telephony
3  *
4  * private/v150_1.h - An implementation of V.150.1.
5  *
6  * Written by Steve Underwood <steveu@coppice.org>
7  *
8  * Copyright (C) 2022 Steve Underwood
9  *
10  * All rights reserved.
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License version 2, as
14  * published by the Free Software Foundation.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  */
25 
26 #if !defined(_SPANDSP_PRIVATE_V150_1_H_)
27 #define _SPANDSP_PRIVATE_V150_1_H_
28 
29 /*
30  telephone network
31  ^
32  |
33  |
34  v
35  +-----------------------------------+
36  | |
37  | Signal processing entity (SPE) |
38  | |
39  +-----------------------------------+
40  | ^
41  | |
42  Signal list 1 | | Signal list 2
43  | |
44  v |
45  +-----------------------------------+ Signal list 5 +-----------------------------------+
46  | | ----------------------->| |
47  | SSE protocol state machine (P) | | Gateway state machine (s,s') |
48  | |<------------------------| |
49  +-----------------------------------+ Signal list 6 +-----------------------------------+
50  | ^
51  | |
52  Signal list 3 | | Signal list 4
53  | |
54  v |
55  +-----------------------------------+
56  | |
57  | IP network processor |
58  | |
59  +-----------------------------------+
60  ^
61  |
62  |
63  v
64  IP network
65 */
66 
67 enum V150_1_SIGNAL_e
68 {
69  /* Signal list 1 - SPE to SSE protocol state engine */
70 
71  /* SPE has detected 2100Hz tone for a duration less than 50ms */
72  V150_1_SIGNAL_TONE_2100HZ = 1,
73  /* SPE has detected 2225Hz tone for a duration less than 50ms */
74  V150_1_SIGNAL_TONE_2225HZ,
75  /* SPE has verified presence of V.25 ANS type answer tone */
76  V150_1_SIGNAL_ANS,
77  /* SPE has detected a 180-degree phase reversal in a verified ANS type answer tone */
78  V150_1_SIGNAL_ANS_PR,
79  /* SPE has verified presence of V.8 ANSam type answer tone */
80  V150_1_SIGNAL_ANSAM,
81  /* SPE has detected a 180-degree phase reversal in a verified ANSam type answer tone */
82  V150_1_SIGNAL_ANSAM_PR,
83  /* SPE has detected a V.8 CI signal */
84  V150_1_SIGNAL_CI,
85  /* SPE has detected a V.8 CM signal */
86  V150_1_SIGNAL_CM,
87  /* SPE has detected a V.8 JM signal */
88  V150_1_SIGNAL_JM,
89  /* SPE has detected a V.21 low channel signal */
90  V150_1_SIGNAL_V21_LOW,
91  /* SPE has detected a V.21 high channel signal */
92  V150_1_SIGNAL_V21_HIGH,
93  /* SPE has detected a V.23 low channel signal */
94  V150_1_SIGNAL_V23_LOW,
95  /* SPE has detected a V.23 high channel signal */
96  V150_1_SIGNAL_V23_HIGH,
97  /* SPE has detected a V.22bis scrambled binary one's signal */
98  V150_1_SIGNAL_SB1,
99  /* SPE has detected a V.22bis unscrambled binary one's signal */
100  V150_1_SIGNAL_USB1,
101  /* SPE has detected a V.22bis S1 signal */
102  V150_1_SIGNAL_S1,
103  /* SPE has detected a V.32/V.32bis AA signal */
104  V150_1_SIGNAL_AA,
105  /* SPE has detected a V.32/V.32bis AC signal */
106  V150_1_SIGNAL_AC,
107  /* Call discrimination time-out */
108  V150_1_SIGNAL_CALL_DISCRIMINATION_TIMEOUT,
109  /* SPE has detected an unknown or unsupported signal */
110  V150_1_SIGNAL_UNKNOWN,
111  /* SPE has detected silence */
112  V150_1_SIGNAL_SILENCE,
113  /* SPE has initiated an abort request */
114  V150_1_SIGNAL_ABORT,
115 
116  /* Signal list 2 - SSE protocol state engine to SPE */
117 
118  /* SPE requested to generate a V.25 ANS type answer tone signal */
119  V150_1_SIGNAL_ANS_GEN,
120  /* SPE requested to generate a V.25 ANS type answer tone signal with 180-degree phase reversals every 450 ms */
121  V150_1_SIGNAL_ANS_PR_GEN,
122  /* SPE requested to generate a V.8 ANSam type answer tone signal */
123  V150_1_SIGNAL_ANSAM_GEN,
124  /* SPE requested to generate a V.8 ANSam type answer tone signal with 180-degree phase reversals every 450 ms */
125  V150_1_SIGNAL_ANSAM_PR_GEN,
126  /* SPE requested to generate a 2225Hz tone */
127  V150_1_SIGNAL_2225HZ_GEN,
128  /* SPE requested to prevent any modem signal to be output to the telephony side of the gateway */
129  V150_1_SIGNAL_CONCEAL_MODEM,
130  /* SPE requested to block 2100Hz tone */
131  V150_1_SIGNAL_BLOCK_2100HZ_TONE,
132  /* SPE requested to enable automode function */
133  V150_1_SIGNAL_AUTOMODE_ENABLE,
134 
135  /* Signal list 3 - SSE protocol state engine to IP network */
136 
137  /* Send audio state with reason code */
138  V150_1_SIGNAL_AUDIO_GEN,
139  /* Send facsimile relay state with reason code */
140  V150_1_SIGNAL_FAX_RELAY_GEN,
141  /* Send indeterminate state with reason code */
142  V150_1_SIGNAL_INDETERMINATE_GEN,
143  /* Send modem relay state with reason code */
144  V150_1_SIGNAL_MODEM_RELAY_GEN,
145  /* Send text relay state with reason code */
146  V150_1_SIGNAL_TEXT_RELAY_GEN,
147  /* Send VBD state with reason code */
148  V150_1_SIGNAL_VBD_GEN,
149  /* Send RFC4733 ANS event */
150  V150_1_SIGNAL_RFC4733_ANS_GEN,
151  /* Send RFC4733 ANS with phase reversals event */
152  V150_1_SIGNAL_RFC4733_ANS_PR_GEN,
153  /* Send RFC4733 ANSam event */
154  V150_1_SIGNAL_RFC4733_ANSAM_GEN,
155  /* Send RFC4733 ANSam with phase reversals event */
156  V150_1_SIGNAL_RFC4733_ANSAM_PR_GEN,
157  /* Send RFC4733 tone */
158  V150_1_SIGNAL_RFC4733_TONE_GEN,
159 
160  /* Signal list 4 - IP network to SSE protocol state engine */
161 
162  /* Audio state detected with reason code */
163  V150_1_SIGNAL_AUDIO,
164  /* Facsimile relay state detected with reason code */
165  V150_1_SIGNAL_FAX_RELAY,
166  /* Indeterminate state detected with reason code */
167  V150_1_SIGNAL_INDETERMINATE,
168  /* Modem relay state detected with reason code */
169  V150_1_SIGNAL_MODEM_RELAY,
170  /* Text relay state detected with reason code */
171  V150_1_SIGNAL_TEXT_RELAY,
172  /* VBD state detected with reason code */
173  V150_1_SIGNAL_VBD,
174  /* An RFC4733 ANS event detected with reason code */
175  V150_1_SIGNAL_RFC4733_ANS,
176  /* An RFC4733 ANS with phase reversals event detected */
177  V150_1_SIGNAL_RFC4733_ANS_PR,
178  /* An RFC4733 ANSam event detected */
179  V150_1_SIGNAL_RFC4733_ANSAM,
180  /* An RFC4733 ANSam with phase reversals event detected */
181  V150_1_SIGNAL_RFC4733_ANSAM_PR,
182  /* An RFC4733 tone detected */
183  V150_1_SIGNAL_RFC4733_TONE,
184 
185  /* Lists 5 and 6 have the same contents */
186  /* Signal list 5 - SSE protocol state engine to gateway */
187  /* Signal list 6 - Gateway to SSE protocol state engine */
188 
189  /* Audio state */
190  V150_1_SIGNAL_AUDIO_STATE,
191  /* Facsimile relay state */
192  V150_1_SIGNAL_FAX_RELAY_STATE,
193  /* Indeterminate state */
194  V150_1_SIGNAL_INDETERMINATE_STATE,
195  /* Modem relay state */
196  V150_1_SIGNAL_MODEM_RELAY_STATE,
197  /* Text relay state */
198  V150_1_SIGNAL_TEXT_RELAY_STATE,
199  /* VBD state */
200  V150_1_SIGNAL_VBD_STATE,
201 
202  /* Signal not listed in V.150.1 */
203  V150_1_SIGNAL_CALL_DISCRIMINATION_TIMER_EXPIRED
204 };
205 
206 typedef struct
207 {
208  v150_1_cdscselect_t cdscselect;
209  v150_1_modem_relay_gateway_type_t modem_relay_gateway_type;
210 
211  bool v42_lapm_supported;
212  /* Annex A was removed from the V.42 spec. in 2002, so it won't be supported. */
213  bool v42_annex_a_supported;
214  bool v42bis_supported;
215  bool v44_supported;
216  bool mnp5_supported;
217 
218  int ecp;
219  bool necrxch_option;
220  bool ecrxch_option;
221  bool xid_profile_exchange_supported;
222  bool asymmetric_data_types_supported;
223  bool dlci_supported;
224  bool i_raw_bit_supported;
225  bool i_char_stat_supported;
226  bool i_char_dyn_supported;
227  bool i_frame_supported;
228  bool i_octet_cs_supported;
229  bool i_char_stat_cs_supported;
230  bool i_char_dyn_cs_supported;
231 
232  bool i_raw_bit_available;
233  bool i_frame_available;
234  bool i_octet_with_dlci_available;
235  bool i_octet_without_dlci_available;
236  bool i_char_stat_available;
237  bool i_char_dyn_available;
238  bool i_octet_cs_available;
239  bool i_char_stat_cs_available;
240  bool i_char_dyn_cs_available;
241 
242  uint16_t compression_tx_dictionary_size;
243  uint16_t compression_rx_dictionary_size;
244  uint8_t compression_tx_string_length;
245  uint8_t compression_rx_string_length;
246  uint16_t compression_tx_history_size;
247  uint16_t compression_rx_history_size;
248 
249  bool jm_category_id_seen[16];
250  uint16_t jm_category_info[16];
251 
252  uint16_t v42bis_p0; /* directions */
253  uint16_t v42bis_p1; /* codewords */
254  uint16_t v42bis_p2; /* string size */
255  uint16_t v44_c0; /* capability */
256  uint16_t v44_p0; /* directions */
257  uint16_t v44_p1t; /* tx_dictionary_size */
258  uint16_t v44_p1r; /* rx_dictionary_size */
259  uint16_t v44_p2t; /* tx_string_size */
260  uint16_t v44_p2r; /* rx_string_size */
261  uint16_t v44_p3t; /* tx_history_size */
262  uint16_t v44_p3r; /* rx_history_size */
263 
264  uint16_t selected_compression_direction;
265  uint16_t selected_compression;
266  uint16_t selected_error_correction;
267 
268  /* Data link connection identifier */
269  uint16_t dlci;
270 
271  /* Sequence number for the information packets which contain a transmitted character sequence number */
272  uint16_t octet_cs_next_seq_no;
273  /* The data format for asynchronous data characters - data bits, parity and stop bits */
274  uint8_t data_format_code;
275 
276  /* Selected modulation scheme */
277  uint16_t selmod;
278  /* Transmit symbol rate enable */
279  bool txsen;
280  /* Receive symbol rate enable */
281  bool rxsen;
282  /* Transmit data signalling rate */
283  uint16_t tdsr;
284  /* Receive data signalling rate */
285  uint16_t rdsr;
286  /* Physical layer transmitter symbol rate */
287  uint16_t txsr;
288  /* Physical layer receiver symbol rate */
289  uint16_t rxsr;
290 
291  bool busy;
292 
293  int sprt_subsession_id;
294  uint8_t sprt_payload_type;
295 
296  int connection_state;
297  int cleardown_reason;
299 
301 {
302  v150_1_rx_data_handler_t rx_data_handler;
303  void *rx_data_handler_user_data;
304  v150_1_rx_status_report_handler_t rx_status_report_handler;
305  void *rx_status_report_user_data;
306  v150_1_spe_signal_handler_t spe_signal_handler;
307  void *spe_signal_handler_user_data;
308  v150_1_timer_handler_t timer_handler;
309  void *timer_user_data;
310 
311  v150_1_cdscselect_t cdscselect;
312  /* True if RFC4733 is preferred */
313  bool rfc4733_preferred;
314  int call_discrimination_timeout;
315 
316  /* The current media state of the local node (i.e., the value that will be sent to the remote
317  node in the event field of an SSE message) */
318  uint8_t local_media_state; /* See V.150.1 C.4.3.1 */
319  /* The last known media state of the remote node, as known by the local node (i.e. the value
320  that will be sent to the remote node in the remote media state field of an SSE extension
321  field with explicit acknowledgement) */
322  uint8_t remote_media_state; /* See V.150.1 C.4.3.1 */
323  /* The last known mode of the local node known by the remote node, as known by the local node
324  (i.e., the value that was received from the remote node in the remote media state field of
325  an SSE extension field with explicit acknowledgement) */
326  uint8_t remote_ack; /* See V.150.1 C.4.3.1 */
327 
328  struct
329  {
330  v150_1_near_far_t parms;
331 
332  int8_t info_msg_preferences[10];
333 
334  /* The maximum packet lengths we may generate. These vary with the channel number when using SPRT
335  as the transport. So, we hold a length for each SPRT protocol channel ID. */
336  int max_payload_bytes[SPRT_CHANNELS];
337 
338  /* The channel to be used for info packets */
339  uint16_t info_stream_channel;
340  /* The message ID to be used for info packets */
341  uint16_t info_stream_msg_id;
342  } near;
343  struct
344  {
345  v150_1_near_far_t parms;
346 
347  int break_source;
348  int break_type;
349  int break_duration;
350  } far;
351  int joint_connection_state;
352 
353  v150_1_sse_state_t sse;
354  sprt_state_t sprt;
355 
356  span_timestamp_t latest_timer;
357  span_timestamp_t call_discrimination_timer;
358  span_timestamp_t sse_timer;
359  span_timestamp_t sprt_timer;
360  /*! \brief Error and flow logging control */
362 };
363 
364 #endif
365 /*- End of file ------------------------------------------------------------*/
Definition: private/sprt.h:95
Definition: private/v150_1_sse.h:31
Definition: private/v150_1.h:206
Definition: private/logging.h:33
Definition: private/v150_1.h:300
logging_state_t logging
Error and flow logging control.
Definition: private/v150_1.h:361