spandsp 3.0.0
v150_1_sse.h
1/*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * v150_1_sse.h - An implementation of the state signaling events (SSE),
5 * protocol defined in V.150.1 Annex C, less the packet
6 * exchange part
7 *
8 * Written by Steve Underwood <steveu@coppice.org>
9 *
10 * Copyright (C) 2022 Steve Underwood
11 *
12 * All rights reserved.
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2, as
16 * published by the Free Software Foundation.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 */
27
28#if !defined(_SPANDSP_V150_1_SSE_H_)
29#define _SPANDSP_V150_1_SSE_H_
30
31//typedef int (*v150_1_sse_tx_packet_handler_t) (void *user_data, bool repeat, const uint8_t pkt[], int len);
32
33//typedef int (*v150_1_sse_status_handler_t) (void *user_data, int status);
34
35/* V.150.1 C.4.1 */
36#define V150_1_SSE_DEFAULT_REPETITIONS 3
37#define V150_1_SSE_DEFAULT_REPETITION_INTERVAL 20000
38
39/* V.150.1 C.4.3.1 */
40#define V150_1_SSE_DEFAULT_ACK_N0 3
41#define V150_1_SSE_DEFAULT_ACK_T0 10000
42#define V150_1_SSE_DEFAULT_ACK_T1 300000
43
44/* V.150.1 C.5.4.1 */
45#define V150_1_SSE_DEFAULT_RECOVERY_N 5
46#define V150_1_SSE_DEFAULT_RECOVERY_T1 1000000
47#define V150_1_SSE_DEFAULT_RECOVERY_T2 1000000
48
49/* Table 12/V.150.1 plus amendments - SSE RIC codes for MoIP and ToIP (as per 15.2.1/V.151) */
50enum v150_1_sse_moip_ric_code_e
51{
52 /* Additional info: Available modulation modes as indicated in the CM sequence (Format is defined in Table 13) */
53 V150_1_SSE_MOIP_RIC_V8_CM = 1,
54 /* Additional info: Available modulation modes as indicated in the JM sequence (Format is defined in Table 13) */
55 V150_1_SSE_MOIP_RIC_V8_JM = 2,
56 /* Additional info: None */
57 V150_1_SSE_MOIP_RIC_V32BIS_AA = 3,
58 /* Additional info: None */
59 V150_1_SSE_MOIP_RIC_V32BIS_AC = 4,
60 /* Additional info: None */
61 V150_1_SSE_MOIP_RIC_V22BIS_USB1 = 5,
62 /* Additional info: None */
63 V150_1_SSE_MOIP_RIC_V22BIS_SB1 = 6,
64 /* Additional info: None */
65 V150_1_SSE_MOIP_RIC_V22BIS_S1 = 7,
66 /* Additional info: None */
67 V150_1_SSE_MOIP_RIC_V21_CH2 = 8,
68 /* Additional info: None */
69 V150_1_SSE_MOIP_RIC_V21_CH1 = 9,
70 /* Additional info: None */
71 V150_1_SSE_MOIP_RIC_V23_HIGH_CHANNEL = 10,
72 /* Additional info: None */
73 V150_1_SSE_MOIP_RIC_V23_LOW_CHANNEL = 11,
74 /* Additional info: None */
75 V150_1_SSE_MOIP_RIC_TONE_2225HZ = 12,
76 /* Additional info: None */
77 V150_1_SSE_MOIP_RIC_V21_CH2_HDLC_FLAGS = 13,
78 /* Additional info: None */
79 V150_1_SSE_MOIP_RIC_INDETERMINATE_SIGNAL = 14,
80 /* Additional info: None */
81 V150_1_SSE_MOIP_RIC_SILENCE = 15,
82 /* Additional info: None */
83 V150_1_SSE_MOIP_RIC_CNG = 16,
84 /* Additional info: None */
85 V150_1_SSE_MOIP_RIC_VOICE = 17,
86 /* Additional info: The timeout event (Format is defined in Table 14) */
87 V150_1_SSE_MOIP_RIC_TIMEOUT = 18,
88 /* Additional info: None */
89 V150_1_SSE_MOIP_RIC_P_STATE_TRANSITION = 19,
90 /* Additional info: Reason for clear down (Format is defined in Table 15) */
91 V150_1_SSE_MOIP_RIC_CLEARDOWN = 20,
92 /* Additional info: None */
93 V150_1_SSE_MOIP_RIC_ANS_CED = 21,
94 /* Additional info: None */
95 V150_1_SSE_MOIP_RIC_ANSAM = 22,
96 /* Additional info: None */
97 V150_1_SSE_MOIP_RIC_ANS_PR = 23,
98 /* Additional info: None */
99 V150_1_SSE_MOIP_RIC_ANSAM_PR = 24,
100 /* Additional info: None */
101 V150_1_SSE_MOIP_RIC_V92_QC1A = 25,
102 /* Additional info: None */
103 V150_1_SSE_MOIP_RIC_V92_QC1D = 26,
104 /* Additional info: None */
105 V150_1_SSE_MOIP_RIC_V92_QC2A = 27,
106 /* Additional info: None */
107 V150_1_SSE_MOIP_RIC_V92_QC2D = 28,
108 /* Additional info: None */
109 V150_1_SSE_MOIP_RIC_V8BIS_CRE = 29,
110 /* Additional info: None */
111 V150_1_SSE_MOIP_RIC_V8BIS_CRD = 30,
112 /* Additional info: None */
113 V150_1_SSE_MOIP_RIC_TIA825A_45_45BPS = 31,
114 /* Additional info: None */
115 V150_1_SSE_MOIP_RIC_TIA825A_50BPS = 32,
116 /* Additional info: None */
117 V150_1_SSE_MOIP_RIC_EDT = 33,
118 /* Additional info: None */
119 V150_1_SSE_MOIP_RIC_BELL103 = 34,
120 /* Additional info: None */
121 V150_1_SSE_MOIP_RIC_V21_TEXT_TELEPHONE = 35,
122 /* Additional info: None */
123 V150_1_SSE_MOIP_RIC_V23_MINITEL = 36,
124 /* Additional info: None */
125 V150_1_SSE_MOIP_RIC_V18_TEXT_TELEPHONE = 37,
126 /* Additional info: None */
127 V150_1_SSE_MOIP_RIC_V18_DTMF_TEXT_RELAY = 38,
128 /* Additional info: None */
129 V150_1_SSE_MOIP_RIC_CTM = 39,
130 V150_1_SSE_MOIP_RIC_VENDOR_MIN = 128,
131 V150_1_SSE_MOIP_RIC_VENDOR_MAX = 255
132};
133
134/* Annex F/T.38 - SSE RIC codes for FoIP */
135enum v150_1_sse_foip_ric_code_e
136{
137 /* Additional info: Available modulation modes as indicated in the CM sequence (Format is defined in Table 13) */
138 V150_1_SSE_FOIP_RIC_V21_FLAGS = 1,
139 /* Additional info: Available modulation modes as indicated in the JM sequence (Format is defined in Table 13) */
140 V150_1_SSE_FOIP_RIC_V8_CM = 2,
141 /* Additional info: None */
142 V150_1_SSE_FOIP_RIC_P_STATE_TRANSITION = 19
143};
144
145/* Table 13/V.150.1 - CM and JM additional information format in SSE payloads */
146enum v150_1_sse_moip_ric_info_v8_cm_code_e
147{
148 V150_1_SSE_MOIP_RIC_INFO_V8_CM_PCM_MODE = 0x8000,
149 V150_1_SSE_MOIP_RIC_INFO_V8_CM_V34_DUPLEX = 0x4000,
150 V150_1_SSE_MOIP_RIC_INFO_V8_CM_V34_HALF_DUPLEX = 0x2000,
151 V150_1_SSE_MOIP_RIC_INFO_V8_CM_V32BIS = 0x1000,
152 V150_1_SSE_MOIP_RIC_INFO_V8_CM_V22BIS = 0x0800,
153 V150_1_SSE_MOIP_RIC_INFO_V8_CM_V17 = 0x0400,
154 V150_1_SSE_MOIP_RIC_INFO_V8_CM_V29 = 0x0200,
155 V150_1_SSE_MOIP_RIC_INFO_V8_CM_V27TER = 0x0100,
156 V150_1_SSE_MOIP_RIC_INFO_V8_CM_V26TER = 0x0080,
157 V150_1_SSE_MOIP_RIC_INFO_V8_CM_V26BIS = 0x0040,
158 V150_1_SSE_MOIP_RIC_INFO_V8_CM_V23_DUPLEX = 0x0020,
159 V150_1_SSE_MOIP_RIC_INFO_V8_CM_V23_HALF_DUPLEX = 0x0010,
160 V150_1_SSE_MOIP_RIC_INFO_V8_CM_V21 = 0x0008,
161 V150_1_SSE_MOIP_RIC_INFO_V8_CM_V90_V92_ANALOGUE = 0x0004,
162 V150_1_SSE_MOIP_RIC_INFO_V8_CM_V90_V92_DIGITAL = 0x0002,
163 V150_1_SSE_MOIP_RIC_INFO_V8_CM_V91 = 0x0001
164};
165
166/* Table 14/V.150.1 - SSE timeout reason code definitions in SSE payload */
167enum v150_1_sse_moip_ric_info_v8_timeout_reason_code_e
168{
169 V150_1_SSE_MOIP_RIC_INFO_TIMEOUT_NULL = 0,
170 V150_1_SSE_MOIP_RIC_INFO_TIMEOUT_CALL_DISCRIMINATION_TIMEOUT = 1,
171 V150_1_SSE_MOIP_RIC_INFO_TIMEOUT_IP_TLP = 2,
172 V150_1_SSE_MOIP_RIC_INFO_TIMEOUT_SSE_EXPLICIT_ACK_TIMEOUT = 3
173};
174
175/* Table 28/V.150.1 - SSE cleardown reason code definitions in SSE payload */
176enum v150_1_sse_moip_ric_info_v8_cleardown_reason_code_e
177{
178 V150_1_SSE_MOIP_RIC_INFO_CLEARDOWN_UNKNOWN = 0,
179 V150_1_SSE_MOIP_RIC_INFO_CLEARDOWN_PHYSICAL_LAYER_RELEASE = 1,
180 V150_1_SSE_MOIP_RIC_INFO_CLEARDOWN_LINK_LAYER_DISCONNECT = 2,
181 V150_1_SSE_MOIP_RIC_INFO_CLEARDOWN_COMPRESSION_DISCONNECT = 3,
182 V150_1_SSE_MOIP_RIC_INFO_CLEARDOWN_ABORT = 4,
183 V150_1_SSE_MOIP_RIC_INFO_CLEARDOWN_ON_HOOK = 5,
184 V150_1_SSE_MOIP_RIC_INFO_CLEARDOWN_NETWORK_LAYER_TERMINATION = 6,
185 V150_1_SSE_MOIP_RIC_INFO_CLEARDOWN_ADMINISTRATIVE = 7
186};
187
188/* V.150.1 C.4 */
189enum v150_1_sse_reliability_option_e
190{
191 /* There are no reliability measures in use. */
192 V150_1_SSE_RELIABILITY_NONE = 0,
193 /* Simple SSE repetition as defined in C.4.1. This option is not declared at call
194 establishment time. As the default option, it is used if one of the remaining two
195 options is not declared. Note that it is permissible to set the number of
196 transmissions to one (no redundancy). */
197 V150_1_SSE_RELIABILITY_BY_REPETITION = 1,
198 /* Use of RFC 2198-based redundancy for SSEs (see C.4.2). This must be explicitly
199 declared at call establishment. */
200 V150_1_SSE_RELIABILITY_BY_RFC2198 = 2,
201 /* Explicit acknowledgement of SSEs (see C.4.3). This scheme is based on the
202 inclusion, in an SSE message, of the value of the endpoint's or gateway's
203 rmt_mode variable, which indicates its view of the remote media state.
204 Additionally, a gateway or endpoint may force the other end to respond
205 with an SSE by setting the Forced Response (F) bit. To be used, this option
206 must be explicitly declared by both ends at call establishment time. */
207 V150_1_SSE_RELIABILITY_BY_EXPLICIT_ACK = 3
208};
209
210enum v150_1_sse_status_e
211{
212 V150_1_SSE_STATUS_V8_CM_RECEIVED = 10,
213 V150_1_SSE_STATUS_V8_JM_RECEIVED = 11,
214 V150_1_SSE_STATUS_AA_RECEIVED = 12,
215 V150_1_SSE_STATUS_V8_CM_RECEIVED_FAX = 13,
216 V150_1_SSE_STATUS_V8_JM_RECEIVED_FAX = 14,
217 V150_1_SSE_STATUS_AA_RECEIVED_FAX = 15,
218 V150_1_SSE_STATUS_CLEARDOWN = 16
219};
220
221typedef struct v150_1_sse_state_s v150_1_sse_state_t;
222
223#if defined(__cplusplus)
224extern "C" {
225#endif
226
227SPAN_DECLARE(const char *) v150_1_sse_media_state_to_str(int state);
228
229SPAN_DECLARE(const char *) v150_1_sse_moip_ric_to_str(int ric);
230
231SPAN_DECLARE(const char *) v150_1_sse_timeout_reason_to_str(int reason);
232
233SPAN_DECLARE(const char *) v150_1_sse_cleardown_reason_to_str(int reason);
234
235SPAN_DECLARE(const char *) v150_1_sse_status_to_str(int status);
236
237/*! Receive an SSE packet, broken out of an RTP stream.
238 \brief Receive an SSE packet.
239 \param s V.150.1 SSE context.
240 \param seq_no
241 \param timestamp
242 \param pkt
243 \param len */
244SPAN_DECLARE(int) v150_1_rx_sse_packet(v150_1_state_t *s,
245 uint16_t seq_no,
246 uint32_t timestamp,
247 const uint8_t pkt[],
248 int len);
249
250/*! Transmit an SSE packet, for insertion into an RTP packet. This is normally needed by an
251 application.
252 \brief Transmit an SSE packet.
253 \param s V.150.1 SSE context.
254 \param event
255 \param ric
256 \param ricinfo */
257SPAN_DECLARE(int) v150_1_tx_sse_packet(v150_1_state_t *s, int event, int ric, int ricinfo);
258
259/*! Select one of the reliability schemes from V.150.1/C.4.
260 \brief Select one of the reliability schemes from V.150.1/C.4.
261 \param s V.150.1 SSE context.
262 \param method The chosen method.
263 \param parm1 maximum transmissions.
264 \param parm2 delay between transmissions, or T0, in microseconds.
265 \param parm3 T1, in microseconds.
266 \return 0 for Ok, else negative. */
267SPAN_DECLARE(int) v150_1_set_sse_reliability_method(v150_1_state_t *s,
268 enum v150_1_sse_reliability_option_e method,
269 int parm1,
270 int parm2,
271 int parm3);
272
273#if defined(__cplusplus)
274}
275#endif
276#endif
277/*- End of file ------------------------------------------------------------*/
Definition private/v150_1_sse.h:32