1 /*
2  * libpri: An implementation of Primary Rate ISDN
3  *
4  * Written by Mark Spencer <markster@digium.com>
5  *
6  * Copyright (C) 2001, Digium, Inc.
7  * All Rights Reserved.
8  */
9 
10 /*
11  * See http://www.asterisk.org for more information about
12  * the Asterisk project. Please do not directly contact
13  * any of the maintainers of this project for assistance;
14  * the project provides a web site, mailing lists and IRC
15  * channels for your use.
16  *
17  * This program is free software, distributed under the terms of
18  * the GNU General Public License Version 2 as published by the
19  * Free Software Foundation. See the LICENSE file included with
20  * this program for more details.
21  *
22  * In addition, when this program is distributed with Asterisk in
23  * any form that would qualify as a 'combined work' or as a
24  * 'derivative work' (but not mere aggregation), you can redistribute
25  * and/or modify the combination under the terms of the license
26  * provided with that copy of Asterisk, instead of the license
27  * terms granted here.
28  */
29 
30 /*
31  * NOTE:
32  * All new global identifiers that are added to this file MUST be
33  * prefixed with PRI_ or pri_ to indicate that they are part of this
34  * library and to reduce potential naming conflicts.
35  */
36 
37 #ifndef _LIBPRI_H
38 #define _LIBPRI_H
39 
40 /* Node types */
41 #define PRI_NETWORK		1
42 #define PRI_CPE			2
43 
44 /* Debugging */
45 #define PRI_DEBUG_Q921_RAW		(1 << 0)	/* Show raw HDLC frames */
46 #define PRI_DEBUG_Q921_DUMP		(1 << 1)	/* Show each interpreted Q.921 frame */
47 #define PRI_DEBUG_Q921_STATE 	(1 << 2)	/* Debug state machine changes */
48 #define PRI_DEBUG_CONFIG		(1 << 3) 	/* Display error events on stdout */
49 #define PRI_DEBUG_Q931_DUMP		(1 << 5)	/* Show interpreted Q.931 frames */
50 #define PRI_DEBUG_Q931_STATE	(1 << 6)	/* Debug Q.931 state machine changes */
51 #define	PRI_DEBUG_Q931_ANOMALY 	(1 << 7)	/* Show unexpected events */
52 #define PRI_DEBUG_APDU			(1 << 8)	/* Debug of APDU components such as ROSE */
53 #define PRI_DEBUG_AOC			(1 << 9)	/* Debug of Advice of Charge ROSE Messages */
54 #define PRI_DEBUG_CC			(1 << 10)	/* Debug call-completion. */
55 
56 #define PRI_DEBUG_ALL			(0xffff)	/* Everything */
57 
58 /* Switch types */
59 #define PRI_SWITCH_UNKNOWN 		0
60 #define PRI_SWITCH_NI2	   		1	/* National ISDN 2 */
61 #define PRI_SWITCH_DMS100		2	/* DMS 100 */
62 #define PRI_SWITCH_LUCENT5E		3	/* Lucent 5E */
63 #define PRI_SWITCH_ATT4ESS		4	/* AT&T 4ESS */
64 #define PRI_SWITCH_EUROISDN_E1		5	/* Standard EuroISDN (CTR4, ETSI 300-102) */
65 #define PRI_SWITCH_EUROISDN_T1		6	/* T1 EuroISDN variant (ETSI 300-102) */
66 #define PRI_SWITCH_NI1			7	/* National ISDN 1 */
67 #define PRI_SWITCH_GR303_EOC		8	/* GR-303 Embedded Operations Channel */
68 #define PRI_SWITCH_GR303_TMC		9	/* GR-303 Timeslot Management Channel */
69 #define PRI_SWITCH_QSIG			10	/* QSIG Switch */
70 /* Switchtypes 11 - 20 are reserved for internal use */
71 
72 
73 /* PRI D-Channel Events */
74 #define PRI_EVENT_DCHAN_UP		 1	/* D-channel is up */
75 #define PRI_EVENT_DCHAN_DOWN	 2	/* D-channel is down */
76 #define PRI_EVENT_RESTART		 3	/* B-channel is restarted */
77 #define PRI_EVENT_CONFIG_ERR 	 4	/* Configuration Error Detected */
78 #define PRI_EVENT_RING			 5	/* Incoming call (SETUP) */
79 #define PRI_EVENT_HANGUP		 6	/* Call got hung up (RELEASE/RELEASE_COMPLETE/other) */
80 #define PRI_EVENT_RINGING		 7	/* Call is ringing (ALERTING) */
81 #define PRI_EVENT_ANSWER		 8	/* Call has been answered (CONNECT) */
82 #define PRI_EVENT_HANGUP_ACK	 9	/* Call hangup has been acknowledged */
83 #define PRI_EVENT_RESTART_ACK	10	/* Restart complete on a given channel (RESTART_ACKNOWLEDGE) */
84 #define PRI_EVENT_FACNAME		11	/* Caller*ID Name received on Facility (DEPRECATED) */
85 #define PRI_EVENT_FACILITY		11	/* Facility received (FACILITY) */
86 #define PRI_EVENT_INFO_RECEIVED 12	/* Additional info (digits) received (INFORMATION) */
87 #define PRI_EVENT_PROCEEDING	13	/* When we get CALL_PROCEEDING */
88 #define PRI_EVENT_SETUP_ACK		14	/* When we get SETUP_ACKNOWLEDGE */
89 #define PRI_EVENT_HANGUP_REQ	15	/* Requesting the higher layer to hangup (DISCONNECT) */
90 #define PRI_EVENT_NOTIFY		16	/* Notification received (NOTIFY) */
91 #define PRI_EVENT_PROGRESS		17	/* When we get PROGRESS */
92 #define PRI_EVENT_KEYPAD_DIGIT	18	/* When we receive during ACTIVE state (INFORMATION) */
93 #define PRI_EVENT_SERVICE       19	/* SERVICE maintenance message */
94 #define PRI_EVENT_SERVICE_ACK   20	/* SERVICE maintenance acknowledgement message */
95 #define PRI_EVENT_HOLD			21	/* HOLD request received */
96 #define PRI_EVENT_HOLD_ACK		22	/* HOLD_ACKNOWLEDGE received */
97 #define PRI_EVENT_HOLD_REJ		23	/* HOLD_REJECT received */
98 #define PRI_EVENT_RETRIEVE		24	/* RETRIEVE request received */
99 #define PRI_EVENT_RETRIEVE_ACK	25	/* RETRIEVE_ACKNOWLEDGE received */
100 #define PRI_EVENT_RETRIEVE_REJ	26	/* RETRIEVE_REJECT received */
101 #define PRI_EVENT_CONNECT_ACK	27	/* CONNECT_ACKNOWLEDGE received */
102 
103 /* Simple states */
104 #define PRI_STATE_DOWN		0
105 #define PRI_STATE_UP		1
106 
107 #define PRI_PROGRESS_MASK
108 
109 /* Progress indicator values */
110 #define PRI_PROG_CALL_NOT_E2E_ISDN						(1 << 0)
111 #define PRI_PROG_CALLED_NOT_ISDN						(1 << 1)
112 #define PRI_PROG_CALLER_NOT_ISDN						(1 << 2)
113 #define PRI_PROG_INBAND_AVAILABLE						(1 << 3)
114 #define PRI_PROG_DELAY_AT_INTERF						(1 << 4)
115 #define PRI_PROG_INTERWORKING_WITH_PUBLIC				(1 << 5)
116 #define PRI_PROG_INTERWORKING_NO_RELEASE				(1 << 6)
117 #define PRI_PROG_INTERWORKING_NO_RELEASE_PRE_ANSWER		(1 << 7)
118 #define PRI_PROG_INTERWORKING_NO_RELEASE_POST_ANSWER	(1 << 8)
119 #define PRI_PROG_CALLER_RETURNED_TO_ISDN					(1 << 9)
120 
121 /* Numbering plan identifier */
122 #define PRI_NPI_UNKNOWN					0x0 /*!< Unknown numbering plan */
123 #define PRI_NPI_E163_E164				0x1 /*!< ISDN/telephony numbering plan (public) */
124 #define PRI_NPI_X121					0x3 /*!< Data numbering plan */
125 #define PRI_NPI_F69						0x4 /*!< Telex numbering plan */
126 #define PRI_NPI_NATIONAL				0x8 /*!< National standard numbering plan */
127 #define PRI_NPI_PRIVATE					0x9 /*!< Private numbering plan */
128 #define PRI_NPI_RESERVED				0xF /*!< Reserved for extension */
129 
130 /* Type of number */
131 #define PRI_TON_UNKNOWN					0x0
132 #define PRI_TON_INTERNATIONAL			0x1
133 #define PRI_TON_NATIONAL				0x2
134 #define PRI_TON_NET_SPECIFIC			0x3
135 #define PRI_TON_SUBSCRIBER				0x4
136 #define PRI_TON_ABBREVIATED				0x6
137 #define PRI_TON_RESERVED				0x7
138 
139 /* Redirection reasons */
140 #define PRI_REDIR_UNKNOWN				0x0
141 #define PRI_REDIR_FORWARD_ON_BUSY		0x1
142 #define PRI_REDIR_FORWARD_ON_NO_REPLY	0x2
143 #define PRI_REDIR_DEFLECTION			0x3
144 #define PRI_REDIR_DTE_OUT_OF_ORDER		0x9
145 #define PRI_REDIR_FORWARDED_BY_DTE		0xA
146 #define PRI_REDIR_UNCONDITIONAL			0xF
147 
148 /* Dialing plan */
149 #define PRI_INTERNATIONAL_ISDN		0x11
150 #define PRI_NATIONAL_ISDN			0x21
151 #define PRI_LOCAL_ISDN				0x41
152 #define PRI_PRIVATE					0x49
153 #define PRI_UNKNOWN					0x0
154 
155 /* Presentation */
156 #define PRI_PRES_NUMBER_TYPE				0x03
157 #define PRI_PRES_USER_NUMBER_UNSCREENED		0x00
158 #define PRI_PRES_USER_NUMBER_PASSED_SCREEN	0x01
159 #define PRI_PRES_USER_NUMBER_FAILED_SCREEN	0x02
160 #define PRI_PRES_NETWORK_NUMBER				0x03
161 
162 #define PRI_PRES_RESTRICTION				0x60
163 #define PRI_PRES_ALLOWED					0x00
164 #define PRI_PRES_RESTRICTED					0x20
165 #define PRI_PRES_UNAVAILABLE				0x40
166 #define PRI_PRES_RESERVED					0x60
167 
168 #define PRES_ALLOWED_USER_NUMBER_NOT_SCREENED \
169 	(PRI_PRES_ALLOWED | PRI_PRES_USER_NUMBER_UNSCREENED)
170 
171 #define PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN \
172 	(PRI_PRES_ALLOWED | PRI_PRES_USER_NUMBER_PASSED_SCREEN)
173 
174 #define PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN \
175 	(PRI_PRES_ALLOWED | PRI_PRES_USER_NUMBER_FAILED_SCREEN)
176 
177 #define PRES_ALLOWED_NETWORK_NUMBER	\
178 	(PRI_PRES_ALLOWED | PRI_PRES_NETWORK_NUMBER)
179 
180 #define PRES_PROHIB_USER_NUMBER_NOT_SCREENED \
181 	(PRI_PRES_RESTRICTED | PRI_PRES_USER_NUMBER_UNSCREENED)
182 
183 #define PRES_PROHIB_USER_NUMBER_PASSED_SCREEN \
184 	(PRI_PRES_RESTRICTED | PRI_PRES_USER_NUMBER_PASSED_SCREEN)
185 
186 #define PRES_PROHIB_USER_NUMBER_FAILED_SCREEN \
187 	(PRI_PRES_RESTRICTED | PRI_PRES_USER_NUMBER_FAILED_SCREEN)
188 
189 #define PRES_PROHIB_NETWORK_NUMBER \
190 	(PRI_PRES_RESTRICTED | PRI_PRES_NETWORK_NUMBER)
191 
192 #define PRES_NUMBER_NOT_AVAILABLE \
193 	(PRI_PRES_UNAVAILABLE | PRI_PRES_NETWORK_NUMBER)
194 
195 /* Reverse Charging Indication */
196 #define PRI_REVERSECHARGE_NONE      -1
197 #define PRI_REVERSECHARGE_REQUESTED  1
198 
199 /* Causes for disconnection (See Q.850) */
200 #define PRI_CAUSE_UNALLOCATED					1	/*!< Called number unassigned. */
201 #define PRI_CAUSE_NO_ROUTE_TRANSIT_NET			2	/* !Q.SIG */
202 #define PRI_CAUSE_NO_ROUTE_DESTINATION			3
203 #define PRI_CAUSE_CHANNEL_UNACCEPTABLE			6
204 #define PRI_CAUSE_CALL_AWARDED_DELIVERED		7	/* !Q.SIG */
205 #define PRI_CAUSE_NORMAL_CLEARING				16
206 #define PRI_CAUSE_USER_BUSY						17
207 #define PRI_CAUSE_NO_USER_RESPONSE				18
208 #define PRI_CAUSE_NO_ANSWER						19
209 #define PRI_CAUSE_CALL_REJECTED					21
210 #define PRI_CAUSE_NUMBER_CHANGED				22
211 #define PRI_CAUSE_NONSELECTED_USER_CLEARING		26
212 #define PRI_CAUSE_DESTINATION_OUT_OF_ORDER		27
213 #define PRI_CAUSE_INVALID_NUMBER_FORMAT			28
214 #define PRI_CAUSE_FACILITY_REJECTED				29	/* !Q.SIG */
215 #define PRI_CAUSE_RESPONSE_TO_STATUS_ENQUIRY	30
216 #define PRI_CAUSE_NORMAL_UNSPECIFIED			31
217 #define PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION		34
218 #define PRI_CAUSE_NETWORK_OUT_OF_ORDER			38	/* !Q.SIG */
219 #define PRI_CAUSE_NORMAL_TEMPORARY_FAILURE		41
220 #define PRI_CAUSE_SWITCH_CONGESTION				42	/* !Q.SIG */
221 #define PRI_CAUSE_ACCESS_INFO_DISCARDED			43	/* !Q.SIG */
222 #define PRI_CAUSE_REQUESTED_CHAN_UNAVAIL		44
223 #define PRI_CAUSE_PRE_EMPTED					45	/* !Q.SIG */
224 #define PRI_CAUSE_RESOURCE_UNAVAIL_UNSPECIFIED	47
225 #define PRI_CAUSE_FACILITY_NOT_SUBSCRIBED  		50	/* !Q.SIG */
226 #define PRI_CAUSE_OUTGOING_CALL_BARRED     		52	/* !Q.SIG */
227 #define PRI_CAUSE_INCOMING_CALL_BARRED     		54	/* !Q.SIG */
228 #define PRI_CAUSE_BEARERCAPABILITY_NOTAUTH		57
229 #define PRI_CAUSE_BEARERCAPABILITY_NOTAVAIL     58
230 #define PRI_CAUSE_SERVICEOROPTION_NOTAVAIL		63	/* Q.SIG */
231 #define PRI_CAUSE_BEARERCAPABILITY_NOTIMPL		65
232 #define PRI_CAUSE_CHAN_NOT_IMPLEMENTED     		66	/* !Q.SIG */
233 #define PRI_CAUSE_FACILITY_NOT_IMPLEMENTED      69	/* !Q.SIG */
234 #define PRI_CAUSE_INVALID_CALL_REFERENCE		81
235 #define PRI_CAUSE_IDENTIFIED_CHANNEL_NOTEXIST	82	/* Q.SIG */
236 #define PRI_CAUSE_INCOMPATIBLE_DESTINATION		88
237 #define PRI_CAUSE_INVALID_MSG_UNSPECIFIED  		95	/* !Q.SIG */
238 #define PRI_CAUSE_MANDATORY_IE_MISSING			96
239 #define PRI_CAUSE_MESSAGE_TYPE_NONEXIST			97
240 #define PRI_CAUSE_WRONG_MESSAGE					98
241 #define PRI_CAUSE_IE_NONEXIST					99
242 #define PRI_CAUSE_INVALID_IE_CONTENTS			100
243 #define PRI_CAUSE_WRONG_CALL_STATE				101
244 #define PRI_CAUSE_RECOVERY_ON_TIMER_EXPIRE		102
245 #define PRI_CAUSE_MANDATORY_IE_LENGTH_ERROR		103	/* !Q.SIG */
246 #define PRI_CAUSE_PROTOCOL_ERROR				111
247 #define PRI_CAUSE_INTERWORKING					127	/* !Q.SIG */
248 
249 /* Transmit capabilities */
250 #define PRI_TRANS_CAP_SPEECH					0x0
251 #define PRI_TRANS_CAP_DIGITAL					0x08
252 #define PRI_TRANS_CAP_RESTRICTED_DIGITAL		0x09
253 #define PRI_TRANS_CAP_3_1K_AUDIO				0x10
254 #define PRI_TRANS_CAP_7K_AUDIO					0x11	/* Depriciated ITU Q.931 (05/1998)*/
255 #define PRI_TRANS_CAP_DIGITAL_W_TONES			0x11
256 #define PRI_TRANS_CAP_VIDEO						0x18
257 
258 #define PRI_LAYER_1_ITU_RATE_ADAPT	0x21
259 #define PRI_LAYER_1_ULAW			0x22
260 #define PRI_LAYER_1_ALAW			0x23
261 #define PRI_LAYER_1_G721			0x24
262 #define PRI_LAYER_1_G722_G725		0x25
263 #define PRI_LAYER_1_H223_H245		0x26
264 #define PRI_LAYER_1_NON_ITU_ADAPT	0x27
265 #define PRI_LAYER_1_V120_RATE_ADAPT	0x28
266 #define PRI_LAYER_1_X31_RATE_ADAPT	0x29
267 
268 
269 /* Intermediate rates for V.110 */
270 #define PRI_INT_RATE_8K			1
271 #define PRI_INT_RATE_16K		2
272 #define PRI_INT_RATE_32K		3
273 
274 
275 /* Rate adaption for bottom 5 bits of rateadaption */
276 #define PRI_RATE_USER_RATE_MASK		0x1F
277 #define PRI_RATE_ADAPT_UNSPEC		0x00
278 #define PRI_RATE_ADAPT_0K6		0x01
279 #define PRI_RATE_ADAPT_1K2		0x02
280 #define PRI_RATE_ADAPT_2K4		0x03
281 #define PRI_RATE_ADAPT_3K6		0x04
282 #define PRI_RATE_ADAPT_4K8		0x05
283 #define PRI_RATE_ADAPT_7K2		0x06
284 #define PRI_RATE_ADAPT_8K		0x07
285 #define PRI_RATE_ADAPT_9K6		0x08
286 #define PRI_RATE_ADAPT_14K4		0x09
287 #define PRI_RATE_ADAPT_16K		0x0A
288 #define PRI_RATE_ADAPT_19K2		0x0B
289 #define PRI_RATE_ADAPT_32K		0x0C
290 #define PRI_RATE_ADAPT_38K4		0x0D
291 #define PRI_RATE_ADAPT_48K		0x0E
292 #define PRI_RATE_ADAPT_56K		0x0F
293 #define PRI_RATE_ADAPT_57K6		0x12
294 #define PRI_RATE_ADAPT_28K8		0x13
295 #define PRI_RATE_ADAPT_24K		0x14
296 #define PRI_RATE_ADAPT_0K1345		0x15
297 #define PRI_RATE_ADAPT_0K1		0x16
298 #define PRI_RATE_ADAPT_0K075_1K2	0x17
299 #define PRI_RATE_ADAPT_1K2_0K075	0x18
300 #define PRI_RATE_ADAPT_0K05		0x19
301 #define PRI_RATE_ADAPT_0K075		0x1A
302 #define PRI_RATE_ADAPT_0K110		0x1B
303 #define PRI_RATE_ADAPT_0K150		0x1C
304 #define PRI_RATE_ADAPT_0K200		0x1D
305 #define PRI_RATE_ADAPT_0K300		0x1E
306 #define PRI_RATE_ADAPT_12K		0x1F
307 
308 /* in-band negotiation flag for rateadaption bit 5 */
309 #define PRI_RATE_ADAPT_NEGOTIATION_POSS	0x20
310 
311 /* async flag for rateadaption bit 6 */
312 #define PRI_RATE_ADAPT_ASYNC		0x40
313 
314 /* Notifications */
315 #define PRI_NOTIFY_USER_SUSPENDED		0x00	/* User suspended (Q.931) (Call is placed on hold) */
316 #define PRI_NOTIFY_USER_RESUMED			0x01	/* User resumed (Q.931) (Call is taken off hold) */
317 #define PRI_NOTIFY_BEARER_CHANGE		0x02	/* Bearer service change (DSS1) */
318 #define PRI_NOTIFY_ASN1_COMPONENT		0x03	/* ASN.1 encoded component (DSS1) */
319 #define PRI_NOTIFY_COMPLETION_DELAY		0x04	/* Call completion delay */
320 #define PRI_NOTIFY_CONF_ESTABLISHED		0x42	/* Conference established */
321 #define PRI_NOTIFY_CONF_DISCONNECTED		0x43	/* Conference disconnected */
322 #define PRI_NOTIFY_CONF_PARTY_ADDED		0x44	/* Other party added */
323 #define PRI_NOTIFY_CONF_ISOLATED		0x45	/* Isolated */
324 #define PRI_NOTIFY_CONF_REATTACHED		0x46	/* Reattached */
325 #define PRI_NOTIFY_CONF_OTHER_ISOLATED		0x47	/* Other party isolated */
326 #define PRI_NOTIFY_CONF_OTHER_REATTACHED	0x48	/* Other party reattached */
327 #define PRI_NOTIFY_CONF_OTHER_SPLIT		0x49	/* Other party split */
328 #define PRI_NOTIFY_CONF_OTHER_DISCONNECTED	0x4a	/* Other party disconnected */
329 #define PRI_NOTIFY_CONF_FLOATING		0x4b	/* Conference floating */
330 #define PRI_NOTIFY_WAITING_CALL			0x60	/* Call is waiting call */
331 #define PRI_NOTIFY_DIVERSION_ACTIVATED		0x68	/* Diversion activated (DSS1) (cfu, cfb, cfnr) (EN 300 207-1 Section 7.2.1) */
332 #define PRI_NOTIFY_TRANSFER_ALERTING		0x69	/* Call transfer, alerting (EN 300 369-1 Section 7.2) */
333 #define PRI_NOTIFY_TRANSFER_ACTIVE		0x6a	/* Call transfer, active(answered) (EN 300 369-1 Section 7.2) */
334 #define PRI_NOTIFY_REMOTE_HOLD			0x79	/* Remote hold */
335 #define PRI_NOTIFY_REMOTE_RETRIEVAL		0x7a	/* Remote retrieval */
336 #define PRI_NOTIFY_CALL_DIVERTING		0x7b	/* Call is diverting (EN 300 207-1 Section 7.2.1) */
337 
338 #define PRI_COPY_DIGITS_CALLED_NUMBER
339 
340 /* Network Specific Facilities (AT&T) */
341 #define PRI_NSF_NONE                   -1
342 #define PRI_NSF_SID_PREFERRED          0xB1
343 #define PRI_NSF_ANI_PREFERRED          0xB2
344 #define PRI_NSF_SID_ONLY               0xB3
345 #define PRI_NSF_ANI_ONLY               0xB4
346 #define PRI_NSF_CALL_ASSOC_TSC         0xB9
347 #define PRI_NSF_NOTIF_CATSC_CLEARING   0xBA
348 #define PRI_NSF_OPERATOR               0xB5
349 #define PRI_NSF_PCCO                   0xB6
350 #define PRI_NSF_SDN                    0xE1
351 #define PRI_NSF_TOLL_FREE_MEGACOM      0xE2
352 #define PRI_NSF_MEGACOM                        0xE3
353 #define PRI_NSF_ACCUNET                        0xE6
354 #define PRI_NSF_LONG_DISTANCE_SERVICE  0xE7
355 #define PRI_NSF_INTERNATIONAL_TOLL_FREE        0xE8
356 #define PRI_NSF_ATT_MULTIQUEST         0xF0
357 #define PRI_NSF_CALL_REDIRECTION_SERVICE       0xF7
358 
359 typedef struct q931_call q931_call;
360 
361 /* Name character set enumeration values */
362 #define PRI_CHAR_SET_UNKNOWN				0
363 #define PRI_CHAR_SET_ISO8859_1				1
364 #define PRI_CHAR_SET_WITHDRAWN				2
365 #define PRI_CHAR_SET_ISO8859_2				3
366 #define PRI_CHAR_SET_ISO8859_3				4
367 #define PRI_CHAR_SET_ISO8859_4				5
368 #define PRI_CHAR_SET_ISO8859_5				6
369 #define PRI_CHAR_SET_ISO8859_7				7
370 #define PRI_CHAR_SET_ISO10646_BMPSTRING		8
371 #define PRI_CHAR_SET_ISO10646_UTF_8STRING	9
372 
373 /*! \brief Q.SIG name information. */
374 struct pri_party_name {
375 	/*! \brief TRUE if the name information is valid/present */
376 	int valid;
377 	/*!
378 	 * \brief Q.931 presentation-indicator encoded field
379 	 * \note Must tollerate the Q.931 screening-indicator field values being present.
380 	 */
381 	int presentation;
382 	/*!
383 	 * \brief Character set the name is using.
384 	 * \details
385 	 * unknown(0),
386 	 * iso8859-1(1),
387 	 * enum-value-withdrawn-by-ITU-T(2)
388 	 * iso8859-2(3),
389 	 * iso8859-3(4),
390 	 * iso8859-4(5),
391 	 * iso8859-5(6),
392 	 * iso8859-7(7),
393 	 * iso10646-BmpString(8),
394 	 * iso10646-utf-8String(9)
395 	 * \details
396 	 * Set to iso8859-1(1) if unsure what to use.
397 	 */
398 	int char_set;
399 	/*! \brief Name data with null terminator. */
400 	char str[64];
401 };
402 
403 struct pri_party_number {
404 	/*! \brief TRUE if the number information is valid/present */
405 	int valid;
406 	/*! \brief Q.931 presentation-indicator and screening-indicator encoded fields */
407 	int presentation;
408 	/*! \brief Q.931 Type-Of-Number and numbering-plan encoded fields */
409 	int plan;
410 	/*! \brief Number data with null terminator. */
411 	char str[64];
412 };
413 
414 /*!
415  * \note This structure is a place holder for possible future subaddress support
416  * to maintain ABI compatibility.
417  */
418 struct pri_party_subaddress {
419 	/*! \brief TRUE if the subaddress information is valid/present */
420 	int valid;
421 	/*!
422 	 * \brief Subaddress type.
423 	 * \details
424 	 * nsap(0),
425 	 * user_specified(2)
426 	 */
427 	int type;
428 	/*!
429 	 * \brief TRUE if odd number of address signals
430 	 * \note The odd/even indicator is used when the type of subaddress is
431 	 * user_specified and the coding is BCD.
432 	 */
433 	int odd_even_indicator;
434 	/*! \brief Length of the subaddress data */
435 	int length;
436 	/*!
437 	 * \brief Subaddress data with null terminator.
438 	 * \note The null terminator is a convenience only since the data could be
439 	 * BCD/binary and thus have a null byte as part of the contents.
440 	 */
441 	unsigned char data[32];
442 };
443 
444 /*! \brief Addressing information needed to identify an endpoint in a call. */
445 struct pri_party_address {
446 	/*! \brief Subscriber phone number */
447 	struct pri_party_number number;
448 	/*! \brief Subscriber subaddress */
449 	struct pri_party_subaddress subaddress;
450 };
451 
452 /*! \brief Information needed to identify an endpoint in a call. */
453 struct pri_party_id {
454 	/*! \brief Subscriber name */
455 	struct pri_party_name name;
456 	/*! \brief Subscriber phone number */
457 	struct pri_party_number number;
458 	/*! \brief Subscriber subaddress */
459 	struct pri_party_subaddress subaddress;
460 };
461 
462 /*! \brief Connected Line/Party information */
463 struct pri_party_connected_line {
464 	/*! Connected party ID */
465 	struct pri_party_id id;
466 };
467 
468 /*!
469  * \brief Redirecting Line information.
470  * \details
471  * RDNIS (Redirecting Directory Number Information Service)
472  * Where a call diversion or transfer was invoked.
473  */
474 struct pri_party_redirecting {
475 	/*! Who is redirecting the call (Sent to the party the call is redirected toward) */
476 	struct pri_party_id from;
477 	/*! Call is redirecting to a new party (Sent to the caller) */
478 	struct pri_party_id to;
479 	/*! Originally called party (in cases of multiple redirects) */
480 	struct pri_party_id orig_called;
481 	/*! Number of times the call was redirected */
482 	int count;
483 	/*! Original reason for redirect (in cases of multiple redirects) */
484 	int orig_reason;
485 	/*! Redirection reason */
486 	int reason;
487 };
488 
489 /*!
490  * \brief Information for rerouting/deflecting the call.
491  */
492 struct pri_rerouting_data {
493 	/*!
494 	 * \brief Updated caller-id information.
495 	 * \note The information may have been altered by procedure in the private network.
496 	 */
497 	struct pri_party_id caller;
498 	/*!
499 	 * \note
500 	 * deflection.to is the new called number and must always be present.
501 	 */
502 	struct pri_party_redirecting deflection;
503 	/*!
504 	 * \brief Diverting user subscription option to specify if caller is notified.
505 	 * \details
506 	 * noNotification(0),
507 	 * notificationWithoutDivertedToNr(1),
508 	 * notificationWithDivertedToNr(2),
509 	 * notApplicable(3) (Status only.)
510 	 */
511 	int subscription_option;
512 	/*! Invocation ID to use when sending a reply to the call rerouting/deflection request. */
513 	int invoke_id;
514 };
515 
516 /*
517  * NOTE:
518  * The code surrounded by STATUS_REQUEST_PLACE_HOLDER is not implemented.
519  * The STATUS_REQUEST_PLACE_HOLDER code will be made unconditional if support
520  * for the messages is ever needed (and gets written).
521  */
522 
523 /* Subcommands derived from supplementary services. */
524 #define PRI_SUBCMD_REDIRECTING				1	/*!< Redirecting information update */
525 #define PRI_SUBCMD_CONNECTED_LINE			2	/*!< Connected line information update */
526 #define PRI_SUBCMD_REROUTING				3	/*!< CallRerouting/CallDeflection received. */
527 #if defined(STATUS_REQUEST_PLACE_HOLDER)
528 #define PRI_SUBCMD_STATUS_REQ				4	/*!< Determine the status of the given party. */
529 #define PRI_SUBCMD_STATUS_REQ_RSP			5	/*!< Status request response */
530 #endif	/* defined(STATUS_REQUEST_PLACE_HOLDER) */
531 #define PRI_SUBCMD_CC_AVAILABLE				6	/*!< Indicate that CC is available */
532 #define PRI_SUBCMD_CC_REQ					7	/*!< CC activation request */
533 #define PRI_SUBCMD_CC_REQ_RSP				8	/*!< CC activation request response */
534 #define PRI_SUBCMD_CC_REMOTE_USER_FREE		9	/*!< Indicate that CC party B is available, party A is considered free. */
535 #define PRI_SUBCMD_CC_B_FREE				10	/*!< Indicate that CC party B is available, party A is considered busy. */
536 #define PRI_SUBCMD_CC_STATUS_REQ			11	/*!< Request/prod to receive updates of CC party A status */
537 #define PRI_SUBCMD_CC_STATUS_REQ_RSP		12	/*!< Requested update of CC party A status */
538 #define PRI_SUBCMD_CC_STATUS				13	/*!< Unsolicited update of CC party A status */
539 #define PRI_SUBCMD_CC_CALL					14	/*!< Indicate that this call is a CC callback */
540 #define PRI_SUBCMD_CC_CANCEL				15	/*!< Unsolicited indication that CC is canceled */
541 #define PRI_SUBCMD_CC_STOP_ALERTING			16	/*!< Indicate that someone else has responed to remote user free */
542 #define PRI_SUBCMD_TRANSFER_CALL			17	/*!< Request to transfer the specified calls together. */
543 #define PRI_SUBCMD_AOC_S					18	/*!< Advice Of Charge Start information (Rate list) */
544 #define PRI_SUBCMD_AOC_D					19	/*!< Advice Of Charge During information */
545 #define PRI_SUBCMD_AOC_E					20	/*!< Advice Of Charge End information */
546 #define PRI_SUBCMD_AOC_CHARGING_REQ			21	/*!< Advice Of Charge Request information */
547 #define PRI_SUBCMD_AOC_CHARGING_REQ_RSP		22	/*!< Advice Of Charge Request Response information */
548 #define PRI_SUBCMD_MCID_REQ					23	/*!< Malicious Call ID Request */
549 #define PRI_SUBCMD_MCID_RSP					24	/*!< Malicious Call ID Request response */
550 #define PRI_SUBCMD_DISPLAY_TEXT				25	/*!< Received display ie text */
551 
552 #if defined(STATUS_REQUEST_PLACE_HOLDER)
553 struct pri_subcmd_status_request {
554 	/*!
555 	 * \brief Invoke id in case there are multiple outstanding requests.
556 	 * \note Used to match any responses with the original invoke in case
557 	 * there are several requests active.
558 	 */
559 	int invoke_id;
560 	/*! \brief Party address requesting status about. */
561 	struct pri_party_address party;
562 };
563 #endif	/* defined(STATUS_REQUEST_PLACE_HOLDER) */
564 
565 #if defined(STATUS_REQUEST_PLACE_HOLDER)
566 struct pri_subcmd_status_request_rsp {
567 	/*!
568 	 * \brief Request id in case there are multiple outstanding requests.
569 	 * \note Used to match any responses with the request in case there
570 	 * are several requests active.
571 	 */
572 	int request_id;
573 	/*!
574 	 * \brief Response status to the status request.
575 	 * \details
576 	 * free(0),
577 	 * busy(1),
578 	 * incompatible(2)
579 	 * timeout(3),
580 	 */
581 	int status;
582 };
583 #endif	/* defined(STATUS_REQUEST_PLACE_HOLDER) */
584 
585 struct pri_subcmd_cc_id {
586 	/*! \brief Call-Completion record id */
587 	long cc_id;
588 };
589 
590 struct pri_subcmd_cc_request {
591 	/*! \brief Call-Completion record id */
592 	long cc_id;
593 	/*!
594 	 * \brief Mode of call-completion requested.
595 	 * \details
596 	 * ccbs(0),
597 	 * ccnr(1)
598 	 */
599 	int mode;
600 };
601 
602 struct pri_subcmd_cc_request_rsp {
603 	/*! \brief Call-Completion record id */
604 	long cc_id;
605 	/*!
606 	 * \brief Status of the requested call-completion activation.
607 	 * \details
608 	 * success(0),
609 	 * timeout(1),
610 	 * error(2),
611 	 * reject(3)
612 	 */
613 	int status;
614 	/*!
615 	 * \brief Failure code that can be converted to a string to further
616 	 * explain the non-timeout failure.
617 	 * \note Valid when status is error or reject.
618 	 * \note Use pri_facility_error2str() to convert the error_code.
619 	 * \note Use pri_facility_reject2str() to convert the reject_code.
620 	 */
621 	int fail_code;
622 };
623 
624 struct pri_subcmd_cc_status {
625 	/*! \brief Call-Completion record id */
626 	long cc_id;
627 	/*!
628 	 * \brief Party A status.
629 	 * \details
630 	 * free(0),
631 	 * busy(1)
632 	 */
633 	int status;
634 };
635 
636 struct pri_subcmd_cc_cancel {
637 	/*! \brief Call-Completion record id */
638 	long cc_id;
639 	/*!
640 	 * \brief TRUE if the cc_id is for an agent.
641 	 * \note This is a convenience value so the upper layer can know which
642 	 * list it should search for the cc_id.
643 	 */
644 	int is_agent;
645 };
646 
647 struct pri_subcmd_transfer {
648 	/*! \brief Opaque call pointer for transfer with other call. */
649 	q931_call *call_1;
650 	/*! \brief Opaque call pointer for transfer with other call. */
651 	q931_call *call_2;
652 	/*! TRUE if call_1 is on hold. */
653 	int is_call_1_held;
654 	/*! TRUE if call_2 is on hold. */
655 	int is_call_2_held;
656 	/*! Invocation ID to use when sending a reply to the transfer request. */
657 	int invoke_id;
658 };
659 
660 /*! \brief What is being charged. */
661 enum PRI_AOC_CHARGED_ITEM {
662 	PRI_AOC_CHARGED_ITEM_NOT_AVAILABLE,
663 	PRI_AOC_CHARGED_ITEM_SPECIAL_ARRANGEMENT,
664 	PRI_AOC_CHARGED_ITEM_BASIC_COMMUNICATION,
665 	PRI_AOC_CHARGED_ITEM_CALL_ATTEMPT,
666 	PRI_AOC_CHARGED_ITEM_CALL_SETUP,
667 	PRI_AOC_CHARGED_ITEM_USER_USER_INFO,
668 	PRI_AOC_CHARGED_ITEM_SUPPLEMENTARY_SERVICE,
669 };
670 
671 /*! \brief Rate method being used. */
672 enum PRI_AOC_RATE_TYPE {
673 	PRI_AOC_RATE_TYPE_NOT_AVAILABLE,
674 	PRI_AOC_RATE_TYPE_FREE,
675 	PRI_AOC_RATE_TYPE_FREE_FROM_BEGINNING,
676 	PRI_AOC_RATE_TYPE_DURATION,
677 	PRI_AOC_RATE_TYPE_FLAT,
678 	PRI_AOC_RATE_TYPE_VOLUME,
679 	PRI_AOC_RATE_TYPE_SPECIAL_CODE,
680 };
681 
682 enum PRI_AOC_TIME_SCALE {
683 	PRI_AOC_TIME_SCALE_HUNDREDTH_SECOND,
684 	PRI_AOC_TIME_SCALE_TENTH_SECOND,
685 	PRI_AOC_TIME_SCALE_SECOND,
686 	PRI_AOC_TIME_SCALE_TEN_SECOND,
687 	PRI_AOC_TIME_SCALE_MINUTE,
688 	PRI_AOC_TIME_SCALE_HOUR,
689 	PRI_AOC_TIME_SCALE_DAY,
690 };
691 
692 struct pri_aoc_time {
693 	/*! LengthOfTimeUnit (Not valid if length is zero.) */
694 	long length;
695 	/*! \see enum PRI_AOC_TIME_SCALE */
696 	int scale;
697 };
698 
699 enum PRI_AOC_MULTIPLIER {
700 	PRI_AOC_MULTIPLIER_THOUSANDTH,
701 	PRI_AOC_MULTIPLIER_HUNDREDTH,
702 	PRI_AOC_MULTIPLIER_TENTH,
703 	PRI_AOC_MULTIPLIER_ONE,
704 	PRI_AOC_MULTIPLIER_TEN,
705 	PRI_AOC_MULTIPLIER_HUNDRED,
706 	PRI_AOC_MULTIPLIER_THOUSAND,
707 };
708 
709 struct pri_aoc_amount {
710 	long cost;
711 	/*! \see enum PRI_AOC_MULTIPLIER */
712 	int multiplier;
713 };
714 
715 struct pri_aoc_duration {
716 	struct pri_aoc_amount amount;
717 	struct pri_aoc_time time;
718 	/*! Not present if the granularity time is zero. */
719 	struct pri_aoc_time granularity;
720 	/*!
721 	 * \brief Charging interval type
722 	 * \details
723 	 * continuousCharging(0),
724 	 * stepFunction(1)
725 	 */
726 	int charging_type;
727 	/*! Name of currency involved.  Null terminated. */
728 	char currency[10 + 1];
729 };
730 
731 struct pri_aoc_flat {
732 	struct pri_aoc_amount amount;
733 	/*! Name of currency involved.  Null terminated. */
734 	char currency[10 + 1];
735 };
736 
737 enum PRI_AOC_VOLUME_UNIT {
738 	PRI_AOC_VOLUME_UNIT_OCTET,
739 	PRI_AOC_VOLUME_UNIT_SEGMENT,
740 	PRI_AOC_VOLUME_UNIT_MESSAGE,
741 };
742 
743 struct pri_aoc_volume {
744 	struct pri_aoc_amount amount;
745 	/*! \see enum PRI_AOC_VOLUME_UNIT */
746 	int unit;
747 	/*! Name of currency involved.  Null terminated. */
748 	char currency[10 + 1];
749 };
750 
751 struct pri_aoc_s_element {
752 	/*!
753 	 * \brief What is being charged.
754 	 * \see enum PRI_AOC_CHARGED_ITEM
755 	 */
756 	int chargeable;
757 	/*!
758 	 * \brief Rate method being used.
759 	 * \see enum PRI_AOC_RATE_TYPE
760 	 */
761 	int rate_type;
762 	/*! \brief Charge rate being applied. */
763 	union {
764 		struct pri_aoc_duration duration;
765 		struct pri_aoc_flat flat;
766 		struct pri_aoc_volume volume;
767 		int special;
768 	} rate;
769 };
770 
771 struct pri_subcmd_aoc_s {
772 	/*!
773 	 * \brief Number of items in the rate list.
774 	 * \note If the list is empty then the charging information is not available.
775 	 */
776 	int num_items;
777 	struct pri_aoc_s_element item[10];
778 };
779 
780 enum PRI_AOC_DE_CHARGE {
781 	PRI_AOC_DE_CHARGE_NOT_AVAILABLE,
782 	PRI_AOC_DE_CHARGE_FREE,
783 	PRI_AOC_DE_CHARGE_CURRENCY,
784 	PRI_AOC_DE_CHARGE_UNITS,
785 };
786 
787 struct pri_aoc_recorded_currency {
788 	struct pri_aoc_amount amount;
789 	/*! Name of currency involved.  Null terminated. */
790 	char currency[10 + 1];
791 };
792 
793 struct pri_aoc_units_element {
794 	/*! Number of units recorded. -1 if not available. */
795 	long number;
796 	/*! Type of unit recorded. -1 if not available. */
797 	int type;
798 };
799 
800 struct pri_aoc_recorded_units {
801 	int num_items;
802 	struct pri_aoc_units_element item[32];
803 };
804 
805 enum PRI_AOC_D_BILLING_ID {
806 	PRI_AOC_D_BILLING_ID_NOT_AVAILABLE,
807 	PRI_AOC_D_BILLING_ID_NORMAL,
808 	PRI_AOC_D_BILLING_ID_REVERSE,
809 	PRI_AOC_D_BILLING_ID_CREDIT_CARD,
810 };
811 struct pri_subcmd_aoc_d {
812 	/*!
813 	 * \brief What is being charged.
814 	 * \see enum PRI_AOC_DE_CHARGE
815 	 */
816 	int charge;
817 	/*!
818 	 * \brief Billing accumulation
819 	 * \details
820 	 * subTotal(0),
821 	 * total(1)
822 	 */
823 	int billing_accumulation;
824 	/*! \see enum PRI_AOC_D_BILLING_ID */
825 	int billing_id;
826 	union {
827 		/*! Recorded currency */
828 		struct pri_aoc_recorded_currency money;
829 		/*! Recorded units list */
830 		struct pri_aoc_recorded_units unit;
831 	} recorded;
832 };
833 
834 enum PRI_AOC_E_BILLING_ID {
835 	PRI_AOC_E_BILLING_ID_NOT_AVAILABLE,
836 	PRI_AOC_E_BILLING_ID_NORMAL,
837 	PRI_AOC_E_BILLING_ID_REVERSE,
838 	PRI_AOC_E_BILLING_ID_CREDIT_CARD,
839 	PRI_AOC_E_BILLING_ID_CALL_FORWARDING_UNCONDITIONAL,
840 	PRI_AOC_E_BILLING_ID_CALL_FORWARDING_BUSY,
841 	PRI_AOC_E_BILLING_ID_CALL_FORWARDING_NO_REPLY,
842 	PRI_AOC_E_BILLING_ID_CALL_DEFLECTION,
843 	PRI_AOC_E_BILLING_ID_CALL_TRANSFER,
844 };
845 
846 enum PRI_AOC_E_CHARGING_ASSOCIATION {
847 	PRI_AOC_E_CHARGING_ASSOCIATION_NOT_AVAILABLE,
848 	PRI_AOC_E_CHARGING_ASSOCIATION_NUMBER,
849 	PRI_AOC_E_CHARGING_ASSOCIATION_ID,
850 };
851 
852 struct pri_aoc_e_charging_association {
853 	union {
854 		/*! Charged number */
855 		struct pri_party_number number;
856 		/*! Charge identifier */
857 		int id;
858 	} charge;
859 	/*! \see enum PRI_AOC_E_CHARGING_ASSOCIATION */
860 	int charging_type;
861 };
862 
863 struct pri_subcmd_aoc_e {
864 	/*!
865 	 * \brief What is being charged.
866 	 * \see enum PRI_AOC_DE_CHARGE
867 	 */
868 	int charge;
869 	/*! \see enum PRI_AOC_E_BILLING_ID */
870 	int billing_id;
871 	union {
872 		/*! Recorded currency */
873 		struct pri_aoc_recorded_currency money;
874 		/*! Recorded units list */
875 		struct pri_aoc_recorded_units unit;
876 	} recorded;
877 	/*! Charging association. */
878 	struct pri_aoc_e_charging_association associated;
879 };
880 
881 enum PRI_AOC_REQ_RSP {
882 	/* Error Results */
883 	PRI_AOC_REQ_RSP_ERROR_NOT_IMPLEMENTED,
884 	PRI_AOC_REQ_RSP_ERROR_NOT_AVAILABLE,
885 	PRI_AOC_REQ_RSP_ERROR_TIMEOUT,
886 	PRI_AOC_REQ_RSP_ERROR_REJECT,
887 	/* generic error result all other errors are lumped into */
888 	PRI_AOC_REQ_RSP_ERROR,
889 
890 	/* AOC Results */
891 	PRI_AOC_REQ_RSP_CHARGING_INFO_FOLLOWS,
892 	PRI_AOC_REQ_RSP_CURRENCY_INFO_LIST,
893 	PRI_AOC_REQ_RSP_SPECIAL_ARR,
894 };
895 
896 enum PRI_AOC_REQUEST {
897 	PRI_AOC_REQUEST_S = (1 << 0),
898 	PRI_AOC_REQUEST_D = (1 << 1),
899 	PRI_AOC_REQUEST_E = (1 << 2),
900 };
901 
902 struct pri_subcmd_aoc_request_response {
903 	/*!
904 	 * \brief aoc_s data from response
905 	 */
906 	struct pri_subcmd_aoc_s aoc_s;
907 
908 	/*!
909 	 * \brief if the aoc_s msg is present, this will be set
910 	 */
911 	int valid_aoc_s;
912 
913 	/*!
914 	 * \brief What type of aoc was requested.
915 	 * \see enum PRI_AOC_REQUEST
916 	 */
917 	int charging_request;
918 
919 	/*!
920 	 * \brief response to the charging_request
921 	 * \see enum PRI_AOC_REQ_RSP
922 	 */
923 	int charging_response;
924 };
925 
926 struct pri_subcmd_aoc_request {
927 	/*!
928 	 * \brief What types of aoc are being requested.
929 	 * \see enum PRI_AOC_REQUEST
930 	 */
931 	int charging_request;
932 
933 	/*!
934 	 * \brief Value given by the initiating request.
935 	 */
936 	 int invoke_id;
937 };
938 
939 struct pri_subcmd_mcid_req {
940 	/*!
941 	 * \brief Information libpri knows about the malicious caller.
942 	 * \note For the convenience of the upper layer.  This information
943 	 * may be incomplete if the upper layer redacted some caller
944 	 * information because it was restricted.
945 	 */
946 	struct pri_party_id originator;
947 	/*! \brief Information libpri knows about the callee. */
948 	struct pri_party_id answerer;
949 };
950 
951 struct pri_subcmd_mcid_rsp {
952 	/*!
953 	 * \brief MCID request response status.
954 	 * \details
955 	 * success(0),
956 	 * timeout(1),
957 	 * error(2),
958 	 * reject(3)
959 	 */
960 	int status;
961 	/*!
962 	 * \brief Failure code that can be converted to a string to further
963 	 * explain the non-timeout failure.
964 	 * \note Valid when status is error or reject.
965 	 * \note Use pri_facility_error2str() to convert the error_code.
966 	 * \note Use pri_facility_reject2str() to convert the reject_code.
967 	 */
968 	int fail_code;
969 };
970 
971 struct pri_subcmd_display_txt {
972 	/*!
973 	 * \brief Character set the text is using.
974 	 * \details
975 	 * unknown(0),
976 	 * iso8859-1(1),
977 	 * enum-value-withdrawn-by-ITU-T(2)
978 	 * iso8859-2(3),
979 	 * iso8859-3(4),
980 	 * iso8859-4(5),
981 	 * iso8859-5(6),
982 	 * iso8859-7(7),
983 	 * iso10646-BmpString(8),
984 	 * iso10646-utf-8String(9)
985 	 */
986 	int char_set;
987 	/*!
988 	 * \brief Number of octets in the display message.
989 	 * \note Not including any added null terminator.
990 	 */
991 	int length;
992 	/*!
993 	 * \brief Display text data.
994 	 * \note Null terminated on receive.
995 	 * \note Does not need to be null terminated on send.
996 	 */
997 	char text[128];
998 };
999 
1000 struct pri_subcommand {
1001 	/*! PRI_SUBCMD_xxx defined values */
1002 	int cmd;
1003 	union {
1004 		/*! Reserve room for possible expansion to maintain ABI compatibility. */
1005 		char reserve_space[512];
1006 		struct pri_party_connected_line connected_line;
1007 		struct pri_party_redirecting redirecting;
1008 		struct pri_rerouting_data rerouting;
1009 #if defined(STATUS_REQUEST_PLACE_HOLDER)
1010 		struct pri_subcmd_status_request status_request;
1011 		struct pri_subcmd_status_request_rsp status_request_rsp;
1012 #endif	/* defined(STATUS_REQUEST_PLACE_HOLDER) */
1013 		struct pri_subcmd_cc_id cc_available;
1014 		struct pri_subcmd_cc_request cc_request;
1015 		struct pri_subcmd_cc_request_rsp cc_request_rsp;
1016 		struct pri_subcmd_cc_id cc_remote_user_free;
1017 		struct pri_subcmd_cc_id cc_b_free;
1018 		struct pri_subcmd_cc_id cc_stop_alerting;
1019 		struct pri_subcmd_cc_id cc_status_req;
1020 		struct pri_subcmd_cc_status cc_status_req_rsp;
1021 		struct pri_subcmd_cc_status cc_status;
1022 		struct pri_subcmd_cc_id cc_call;
1023 		struct pri_subcmd_cc_cancel cc_cancel;
1024 		struct pri_subcmd_transfer transfer;
1025 		struct pri_subcmd_aoc_request aoc_request;
1026 		struct pri_subcmd_aoc_request_response aoc_request_response;
1027 		struct pri_subcmd_aoc_s aoc_s;
1028 		struct pri_subcmd_aoc_d aoc_d;
1029 		struct pri_subcmd_aoc_e aoc_e;
1030 		struct pri_subcmd_mcid_req mcid_req;
1031 		struct pri_subcmd_mcid_rsp mcid_rsp;
1032 		struct pri_subcmd_display_txt display;
1033 	} u;
1034 };
1035 
1036 /* Max number of subcommands per event message */
1037 #define PRI_MAX_SUBCOMMANDS	8
1038 
1039 struct pri_subcommands {
1040 	int counter_subcmd;
1041 	struct pri_subcommand subcmd[PRI_MAX_SUBCOMMANDS];
1042 };
1043 
1044 
1045 /*
1046  * Event channel parameter encoding:
1047  * 3322 2222 2222 1111 1111 1100 0000 0000
1048  * 1098 7654 3210 9876 5432 1098 7654 3210
1049  * xxxx xxxx xxxx xEDC BBBBBBBBB AAAAAAAAA
1050  *
1051  * Bit field
1052  * A - B channel
1053  * B - Span (DS1) (0 - 127)
1054  * C - DS1 Explicit bit
1055  * D - D channel (cis_call) bit (status only)
1056  * E - Call is held bit (status only)
1057  *
1058  * B channel values:
1059  * 0     - No channel (ISDN uses for call waiting feature)
1060  * 1-127 - B channel #
1061  * 0xFF  - Any channel (Also if whole channel value is -1 in event)
1062  */
1063 
1064 
1065 typedef struct pri_event_generic {
1066 	/* Events with no additional information fall in this category */
1067 	int e;
1068 } pri_event_generic;
1069 
1070 typedef struct pri_event_error {
1071 	int e;
1072 	char err[256];
1073 } pri_event_error;
1074 
1075 typedef struct pri_event_restart {
1076 	int e;
1077 	int channel;
1078 } pri_event_restart;
1079 
1080 typedef struct pri_event_ringing {
1081 	int e;
1082 	int channel;
1083 	int cref;
1084 	int progress;
1085 	int progressmask;
1086 	q931_call *call;
1087 	char useruserinfo[260];		/* User->User info */
1088 	struct pri_subcommands *subcmds;
1089 } pri_event_ringing;
1090 
1091 typedef struct pri_event_answer {
1092 	int e;
1093 	int channel;
1094 	int cref;
1095 	int progress;
1096 	int progressmask;
1097 	q931_call *call;
1098 	char useruserinfo[260];		/* User->User info */
1099 	struct pri_subcommands *subcmds;
1100 } pri_event_answer;
1101 
1102 /*! Deprecated replaced by struct pri_event_facility. */
1103 typedef struct pri_event_facname {
1104 	int e;
1105 	char callingname[256];
1106 	char callingnum[256];
1107 	int channel;
1108 	int cref;
1109 	q931_call *call;
1110 	int callingpres;			/* Presentation of Calling CallerID */
1111 	int callingplan;			/* Dialing plan of Calling entity */
1112 } pri_event_facname;
1113 
1114 struct pri_event_facility {
1115 	int e;
1116 	char callingname[256];		/*!< Deprecated, preserved for struct pri_event_facname compatibility */
1117 	char callingnum[256];		/*!< Deprecated, preserved for struct pri_event_facname compatibility */
1118 	int channel;
1119 	int cref;
1120 	/*!
1121 	 * \brief Master call or normal call.
1122 	 * \note Call pointer known about by upper layer.
1123 	 * \note NULL if dummy call reference.
1124 	 */
1125 	q931_call *call;
1126 	int callingpres;			/*!< Presentation of Calling CallerID (Deprecated, preserved for struct pri_event_facname compatibility) */
1127 	int callingplan;			/*!< Dialing plan of Calling entity (Deprecated, preserved for struct pri_event_facname compatibility) */
1128 	struct pri_subcommands *subcmds;
1129 	q931_call *subcall;			/*!< Subcall to send any reply toward. */
1130 };
1131 
1132 #define PRI_CALLINGPLANANI
1133 #define PRI_CALLINGPLANRDNIS
1134 typedef struct pri_event_ring {
1135 	int e;
1136 	int channel;				/* Channel requested */
1137 	int callingpres;			/* Presentation of Calling CallerID */
1138 	int callingplanani;			/* Dialing plan of Calling entity ANI */
1139 	int callingplan;			/* Dialing plan of Calling entity */
1140 	char callingani[256];		/* Calling ANI */
1141 	char callingnum[256];		/* Calling number */
1142 	char callingname[256];		/* Calling name (if provided) */
1143 	int calledplan;				/* Dialing plan of Called number */
1144 	int ani2;                   /* ANI II */
1145 	char callednum[256];		/* Called number */
1146 	char redirectingnum[256];	/* Redirecting number */
1147 	char redirectingname[256];	/* Redirecting name */
1148 	int redirectingreason;		/* Reason for redirect */
1149 	int callingplanrdnis;			/* Dialing plan of Redirecting Number */
1150 	char useruserinfo[260];		/* User->User info */
1151 	int flexible;				/* Are we flexible with our channel selection? */
1152 	int cref;					/* Call Reference Number */
1153 	int ctype;					/* Call type (see PRI_TRANS_CAP_* */
1154 	int layer1;					/* User layer 1 */
1155 	int complete;				/* Have we seen "Complete" i.e. no more number? */
1156 	q931_call *call;			/* Opaque call pointer */
1157 	char callingsubaddr[256];	/* Calling parties subaddress, backwards compatibility */
1158 	int progress;
1159 	int progressmask;
1160 	char origcalledname[256];
1161 	char origcallednum[256];
1162 	int callingplanorigcalled;		/* Dialing plan of Originally Called Number */
1163 	int origredirectingreason;
1164 	int reversecharge;
1165 	struct pri_subcommands *subcmds;
1166 	struct pri_party_id calling;			/* Calling Party's info, initially subaddress' */
1167 	struct pri_party_subaddress called_subaddress;	/* Called party's subaddress */
1168 	char keypad_digits[64];		/* Keypad digits in the SETUP message. */
1169 } pri_event_ring;
1170 
1171 typedef struct pri_event_hangup {
1172 	int e;
1173 	int channel;				/* Channel requested */
1174 	int cause;
1175 	int cref;
1176 	q931_call *call;			/* Opaque call pointer of call hanging up. */
1177 	long aoc_units;				/* Advice of Charge number of charged units */
1178 	char useruserinfo[260];		/* User->User info */
1179 	struct pri_subcommands *subcmds;
1180 	/*!
1181 	 * \brief Opaque held call pointer for possible transfer to active call.
1182 	 * \note The call_held and call_active pointers must not be NULL if
1183 	 * transfer held call on disconnect is available.
1184 	 */
1185 	q931_call *call_held;
1186 	/*!
1187 	 * \brief Opaque active call pointer for possible transfer with held call.
1188 	 * \note The call_held and call_active pointers must not be NULL if
1189 	 * transfer held call on disconnect is available.
1190 	 */
1191 	q931_call *call_active;
1192 } pri_event_hangup;
1193 
1194 typedef struct pri_event_restart_ack {
1195 	int e;
1196 	int channel;
1197 } pri_event_restart_ack;
1198 
1199 #define PRI_PROGRESS_CAUSE
1200 typedef struct pri_event_proceeding {
1201 	int e;
1202 	int channel;
1203 	int cref;
1204 	int progress;
1205 	int progressmask;
1206 	int cause;
1207 	q931_call *call;
1208 	struct pri_subcommands *subcmds;
1209 } pri_event_proceeding;
1210 
1211 typedef struct pri_event_setup_ack {
1212 	int e;
1213 	int channel;
1214 	q931_call *call;
1215 	struct pri_subcommands *subcmds;
1216 	int progressmask;
1217 } pri_event_setup_ack;
1218 
1219 typedef struct pri_event_notify {
1220 	int e;
1221 	int channel;
1222 	int info;
1223 	struct pri_subcommands *subcmds;
1224 	q931_call *call;
1225 } pri_event_notify;
1226 
1227 typedef struct pri_event_keypad_digit {
1228 	int e;
1229 	int channel;
1230 	q931_call *call;
1231 	char digits[64];
1232 	struct pri_subcommands *subcmds;
1233 } pri_event_keypad_digit;
1234 
1235 typedef struct pri_event_service {
1236 	int e;
1237 	int channel;
1238 	int changestatus;
1239 } pri_event_service;
1240 
1241 typedef struct pri_event_service_ack {
1242 	int e;
1243 	int channel;
1244 	int changestatus;
1245 } pri_event_service_ack;
1246 
1247 struct pri_event_hold {
1248 	int e;
1249 	int channel;
1250 	q931_call *call;
1251 	struct pri_subcommands *subcmds;
1252 };
1253 
1254 struct pri_event_hold_ack {
1255 	int e;
1256 	int channel;
1257 	q931_call *call;
1258 	struct pri_subcommands *subcmds;
1259 };
1260 
1261 struct pri_event_hold_rej {
1262 	int e;
1263 	int channel;
1264 	q931_call *call;
1265 	int cause;
1266 	struct pri_subcommands *subcmds;
1267 };
1268 
1269 struct pri_event_retrieve {
1270 	int e;
1271 	int channel;
1272 	q931_call *call;
1273 	int flexible;				/* Are we flexible with our channel selection? */
1274 	struct pri_subcommands *subcmds;
1275 };
1276 
1277 struct pri_event_retrieve_ack {
1278 	int e;
1279 	int channel;
1280 	q931_call *call;
1281 	struct pri_subcommands *subcmds;
1282 };
1283 
1284 struct pri_event_retrieve_rej {
1285 	int e;
1286 	int channel;
1287 	q931_call *call;
1288 	int cause;
1289 	struct pri_subcommands *subcmds;
1290 };
1291 
1292 struct pri_event_connect_ack {
1293 	int e;
1294 	int channel;
1295 	q931_call *call;
1296 	struct pri_subcommands *subcmds;
1297 };
1298 
1299 typedef union {
1300 	int e;
1301 	pri_event_generic gen;		/* Generic view */
1302 	pri_event_restart restart;	/* Restart view */
1303 	pri_event_error	  err;		/* Error view */
1304 	pri_event_facname facname;	/* Caller*ID Name on Facility (Deprecated, use pri_event.facility) */
1305 	pri_event_ring	  ring;		/* Ring */
1306 	pri_event_hangup  hangup;	/* Hang up */
1307 	pri_event_ringing ringing;	/* Ringing */
1308 	pri_event_answer  answer;	/* Answer */
1309 	pri_event_restart_ack restartack;	/* Restart Acknowledge */
1310 	pri_event_proceeding  proceeding;	/* Call proceeding & Progress */
1311 	pri_event_setup_ack   setup_ack;	/* SETUP_ACKNOWLEDGE structure */
1312 	pri_event_notify notify;		/* Notification */
1313 	pri_event_keypad_digit digit;			/* Digits that come during a call */
1314 	pri_event_service service;				/* service message */
1315 	pri_event_service_ack service_ack;		/* service acknowledgement message */
1316 	struct pri_event_facility facility;
1317 	struct pri_event_hold hold;
1318 	struct pri_event_hold_ack hold_ack;
1319 	struct pri_event_hold_rej hold_rej;
1320 	struct pri_event_retrieve retrieve;
1321 	struct pri_event_retrieve_ack retrieve_ack;
1322 	struct pri_event_retrieve_rej retrieve_rej;
1323 	struct pri_event_connect_ack connect_ack;
1324 } pri_event;
1325 
1326 struct pri;
1327 struct pri_sr;
1328 
1329 #define PRI_IO_FUNCS
1330 /* Type declaration for callbacks to read or write a HDLC frame as below */
1331 typedef int (*pri_io_cb)(struct pri *pri, void *buf, int buflen);
1332 
1333 /* Create a D-channel on a given file descriptor.  The file descriptor must be a
1334    channel operating in HDLC mode with FCS computed by the fd's driver.  Also it
1335    must be NON-BLOCKING! Frames received on the fd should include FCS.  Nodetype
1336    must be one of PRI_NETWORK or PRI_CPE.  switchtype should be PRI_SWITCH_* */
1337 struct pri *pri_new(int fd, int nodetype, int switchtype);
1338 struct pri *pri_new_bri(int fd, int ptpmode, int nodetype, int switchtype);
1339 
1340 /* Create D-channel just as above with user defined I/O callbacks and data */
1341 struct pri *pri_new_cb(int fd, int nodetype, int switchtype, pri_io_cb io_read, pri_io_cb io_write, void *userdata);
1342 
1343 /* Create BRI D-channel just as above with user defined I/O callbacks and data */
1344 struct pri *pri_new_bri_cb(int fd, int ptpmode, int nodetype, int switchtype, pri_io_cb io_read, pri_io_cb io_write, void *userdata);
1345 
1346 /* Retrieve the user data associated with the D channel */
1347 void *pri_get_userdata(struct pri *pri);
1348 
1349 /* Set the user data associated with the D channel */
1350 void pri_set_userdata(struct pri *pri, void *userdata);
1351 
1352 /* Set Network Specific Facility for PRI */
1353 void pri_set_nsf(struct pri *pri, int nsf);
1354 
1355 /* Set debug parameters on PRI -- see above debug definitions */
1356 void pri_set_debug(struct pri *pri, int debug);
1357 
1358 /* Get debug parameters on PRI -- see above debug definitions */
1359 int pri_get_debug(struct pri *pri);
1360 
1361 #define PRI_FACILITY_ENABLE
1362 /* Enable transmission support of Facility IEs on the pri */
1363 void pri_facility_enable(struct pri *pri);
1364 
1365 /* Run PRI on the given D-channel, taking care of any events that
1366    need to be handled.  If block is set, it will block until an event
1367    occurs which needs to be handled */
1368 pri_event *pri_dchannel_run(struct pri *pri, int block);
1369 
1370 /* Check for an outstanding event on the PRI */
1371 pri_event *pri_check_event(struct pri *pri);
1372 
1373 /* Give a name to a given event ID */
1374 char *pri_event2str(int id);
1375 
1376 /* Give a name to a node type */
1377 char *pri_node2str(int id);
1378 
1379 /* Give a name to a switch type */
1380 char *pri_switch2str(int id);
1381 
1382 /* Print an event */
1383 void pri_dump_event(struct pri *pri, pri_event *e);
1384 
1385 /* Turn presentation into a string */
1386 char *pri_pres2str(int pres);
1387 
1388 /* Turn numbering plan into a string */
1389 char *pri_plan2str(int plan);
1390 
1391 /* Turn cause into a string */
1392 char *pri_cause2str(int cause);
1393 
1394 /*!
1395  * \brief Convert the given facility error code to a descriptive string.
1396  *
1397  * \param facility_error_code Error code to convert to a string.
1398  *
1399  * \return Descriptive error string.
1400  */
1401 const char *pri_facility_error2str(int facility_error_code);
1402 
1403 /*!
1404  * \brief Convert the given facility reject code to a descriptive string.
1405  *
1406  * \param facility_reject_code Error code to convert to a string.
1407  *
1408  * \return Descriptive reject string.
1409  */
1410 const char *pri_facility_reject2str(int facility_reject_code);
1411 
1412 /*!
1413  * \brief Send the ALERTING message.
1414  *
1415  * \param pri D channel controller.
1416  * \param call Q.931 call leg.
1417  * \param channel Encoded channel id to use.  If zero do not change channel id.
1418  * \param info Nonzero to include a progress ie indicating inband audio available (ie ringback).
1419  *
1420  * \retval 0 on success.
1421  * \retval -1 on error.
1422  */
1423 int pri_acknowledge(struct pri *pri, q931_call *call, int channel, int info);
1424 
1425 /* Send a digit in overlap mode */
1426 int pri_information(struct pri *pri, q931_call *call, char digit);
1427 
1428 #define PRI_KEYPAD_FACILITY_TX
1429 /* Send a keypad facility string of digits */
1430 int pri_keypad_facility(struct pri *pri, q931_call *call, const char *digits);
1431 
1432 /*!
1433  * \brief Send the SETUP_ACKNOWLEDGE message.
1434  *
1435  * \param pri D channel controller.
1436  * \param call Q.931 call leg.
1437  * \param channel Encoded channel id to use.  If zero do not change channel id.
1438  * \param nonisdn Nonzero to include a progress ie indicating non-end-to-end-ISDN.
1439  *
1440  * \retval 0 on success.
1441  * \retval -1 on error.
1442  */
1443 int pri_need_more_info(struct pri *pri, q931_call *call, int channel, int nonisdn);
1444 
1445 /*!
1446  * \brief Send the SETUP_ACKNOWLEDGE message.
1447  *
1448  * \param ctrl D channel controller.
1449  * \param call Q.931 call leg.
1450  * \param channel Encoded channel id to use.  If zero do not change channel id.
1451  * \param nonisdn Nonzero to include a progress ie indicating non-end-to-end-ISDN.
1452  * \param inband Nonzero to include a progress ie indicating inband audio available (ie dialtone).
1453  *
1454  * \retval 0 on success.
1455  * \retval -1 on error.
1456  */
1457 int pri_setup_ack(struct pri *ctrl, q931_call *call, int channel, int nonisdn, int inband);
1458 
1459 /*!
1460  * \brief Send the CONNECT message.
1461  *
1462  * \param pri D channel controller.
1463  * \param call Q.931 call leg.
1464  * \param channel Encoded channel id to use.  If zero do not change channel id.
1465  * \param nonisdn Nonzero to include a progress ie indicating non-end-to-end-ISDN.
1466  *
1467  * \retval 0 on success.
1468  * \retval -1 on error.
1469  */
1470 int pri_answer(struct pri *pri, q931_call *call, int channel, int nonisdn);
1471 
1472 /*!
1473  * \brief Send the manual CONNECT_ACKNOWLEDGE message.
1474  *
1475  * \param ctrl D channel controller.
1476  * \param call Q.931 call leg.
1477  * \param channel Selected channel to assign to the call waiting call.
1478  * Zero if do not include the channel id ie in the CONNECT_ACKNOWLEDGE message.
1479  *
1480  * \retval 0 on success.
1481  * \retval -1 on error.
1482  */
1483 int pri_connect_ack(struct pri *ctrl, q931_call *call, int channel);
1484 
1485 /*!
1486  * \brief Set the manual CONNECT_ACKNOWLEDGE message enable flag.
1487  *
1488  * \param ctrl D channel controller.
1489  * \param enable TRUE to enable manual CONNECT_ACKNOWLEDGE message feature.
1490  *
1491  * \return Nothing
1492  */
1493 void pri_connect_ack_enable(struct pri *ctrl, int enable);
1494 
1495 /*!
1496  * \brief Give connected line information to a call
1497  * \note Could be used instead of pri_sr_set_caller_party() before calling pri_setup().
1498  */
1499 int pri_connected_line_update(struct pri *pri, q931_call *call, const struct pri_party_connected_line *connected);
1500 
1501 /*!
1502  * \brief Give redirection information to a call
1503  * \note Could be used instead of pri_sr_set_redirecting_parties() before calling pri_setup().
1504  */
1505 int pri_redirecting_update(struct pri *pri, q931_call *call, const struct pri_party_redirecting *redirecting);
1506 
1507 /* Set CRV reference for GR-303 calls */
1508 
1509 
1510 #undef pri_release
1511 #undef pri_disconnect
1512 
1513 /* backwards compatibility for those who don't use asterisk with libpri */
1514 #define pri_release(a,b,c) \
1515 	pri_hangup(a,b,c)
1516 
1517 #define pri_disconnect(a,b,c) \
1518 	pri_hangup(a,b,c)
1519 
1520 /* Hangup a call */
1521 #define PRI_HANGUP
1522 int pri_hangup(struct pri *pri, q931_call *call, int cause);
1523 
1524 /*!
1525  * \brief Set the call hangup fix enable flag.
1526  *
1527  * \param ctrl D channel controller.
1528  * \param enable TRUE to follow Q.931 Section 5.3.2 call hangup better.
1529  * FALSE for legacy behaviour. (Default FALSE if not called.)
1530  *
1531  * \return Nothing
1532  */
1533 void pri_hangup_fix_enable(struct pri *ctrl, int enable);
1534 
1535 #define PRI_DESTROYCALL
1536 void pri_destroycall(struct pri *pri, q931_call *call);
1537 
1538 #define PRI_RESTART
1539 int pri_restart(struct pri *pri);
1540 
1541 int pri_reset(struct pri *pri, int channel);
1542 
1543 /* handle b-channel maintenance messages */
1544 extern int pri_maintenance_service(struct pri *pri, int span, int channel, int changestatus);
1545 
1546 /* Create a new call */
1547 q931_call *pri_new_call(struct pri *pri);
1548 
1549 /*!
1550  * \brief Deterimine if the given call control pointer is a dummy call.
1551  *
1552  * \retval TRUE if given call is a dummy call.
1553  * \retval FALSE otherwise.
1554  */
1555 int pri_is_dummy_call(q931_call *call);
1556 
1557 /* Retrieve CRV reference for GR-303 calls.  Returns >0 on success. */
1558 int pri_get_crv(struct pri *pri, q931_call *call, int *callmode);
1559 
1560 /* Retrieve CRV reference for GR-303 calls.  CRV must be >0, call mode should be 0 */
1561 int pri_set_crv(struct pri *pri, q931_call *call, int crv, int callmode);
1562 
1563 /* How long until you need to poll for a new event */
1564 struct timeval *pri_schedule_next(struct pri *pri);
1565 
1566 /* Run any pending schedule events */
1567 extern pri_event *pri_schedule_run(struct pri *pri);
1568 extern pri_event *pri_schedule_run_tv(struct pri *pri, const struct timeval *now);
1569 
1570 int pri_call(struct pri *pri, q931_call *c, int transmode, int channel,
1571     int exclusive, int nonisdn, char *caller, int callerplan, char *callername, int callerpres,
1572     char *called, int calledplan, int ulayer1);
1573 
1574 struct pri_sr *pri_sr_new(void);
1575 void pri_sr_free(struct pri_sr *sr);
1576 
1577 int pri_sr_set_channel(struct pri_sr *sr, int channel, int exclusive, int nonisdn);
1578 int pri_sr_set_bearer(struct pri_sr *sr, int transmode, int userl1);
1579 int pri_sr_set_called(struct pri_sr *sr, char *called, int calledplan, int complete);
1580 
1581 /*!
1582  * \brief Set the caller party ID information in the call SETUP record.
1583  *
1584  * \param sr New call SETUP record.
1585  * \param caller Caller party ID information to set.
1586  *
1587  * \return Nothing
1588  */
1589 void pri_sr_set_caller_party(struct pri_sr *sr, const struct pri_party_id *caller);
1590 /*! \note Use pri_sr_set_caller_party() instead to pass more precise caller information. */
1591 int pri_sr_set_caller(struct pri_sr *sr, char *caller, char *callername, int callerplan, int callerpres);
1592 
1593 /*!
1594  * \brief Set the calling subaddress information in the call SETUP record.
1595  *
1596  * \param sr New call SETUP record.
1597  * \param subaddress information to set.
1598  *
1599  * \return Nothing
1600  */
1601 void pri_sr_set_caller_subaddress(struct pri_sr *sr, const struct pri_party_subaddress *subaddress);
1602 
1603 /*!
1604  * \brief Set the called subaddress information in the call SETUP record.
1605  *
1606  * \param sr New call SETUP record.
1607  * \param subaddress information to set.
1608  *
1609  * \return Nothing
1610  */
1611 void pri_sr_set_called_subaddress(struct pri_sr *sr, const struct pri_party_subaddress *subaddress);
1612 
1613 /*!
1614  * \brief Set the redirecting information in the call SETUP record.
1615  *
1616  * \param sr New call SETUP record.
1617  * \param caller Redirecting information to set.
1618  *
1619  * \return Nothing
1620  */
1621 void pri_sr_set_redirecting_parties(struct pri_sr *sr, const struct pri_party_redirecting *redirecting);
1622 /*! \note Use pri_sr_set_redirecting_parties() instead to pass more precise redirecting information. */
1623 int pri_sr_set_redirecting(struct pri_sr *sr, char *num, int plan, int pres, int reason);
1624 
1625 /*!
1626  * \brief Set the keypad digits in the call SETUP record.
1627  *
1628  * \param sr New call SETUP record.
1629  * \param keypad_digits Keypad digits to send.
1630  *
1631  * \return Nothing
1632  */
1633 void pri_sr_set_keypad_digits(struct pri_sr *sr, const char *keypad_digits);
1634 
1635 #define PRI_USER_USER_TX
1636 /* Set the user user field.  Warning!  don't send binary data accross this field */
1637 void pri_sr_set_useruser(struct pri_sr *sr, const char *userchars);
1638 void pri_sr_set_reversecharge(struct pri_sr *sr, int requested);
1639 
1640 void pri_call_set_useruser(q931_call *sr, const char *userchars);
1641 
1642 int pri_setup(struct pri *pri, q931_call *call, struct pri_sr *req);
1643 
1644 /*!
1645  * \brief Set a call as a call indpendent signalling connection (i.e. no bchan)
1646  * \note Call will automaticlly disconnect after signalling sent.
1647  */
1648 int pri_sr_set_connection_call_independent(struct pri_sr *req);
1649 
1650 /*!
1651  * \brief Set a call as a call indpendent signalling connection (i.e. no bchan)
1652  * \note Call will stay connected until explicitly disconnected.
1653  */
1654 int pri_sr_set_no_channel_call(struct pri_sr *req);
1655 
1656 /* Send an MWI indication to a remote location.  If activate is non zero, activates, if zero, deactivates */
1657 int pri_mwi_activate(struct pri *pri, q931_call *c, char *caller, int callerplan, char *callername, int callerpres, char *called, int calledplan);
1658 
1659 /* Send an MWI deactivate request to a remote location */
1660 int pri_mwi_deactivate(struct pri *pri, q931_call *c, char *caller, int callerplan, char *callername, int callerpres, char *called, int calledplan);
1661 
1662 /*!
1663  * \brief Send a MWI indication on the specified D channel.
1664  *
1665  * \param ctrl D channel controller.
1666  * \param mailbox Party receiving notification.
1667  * \param basic_service Basic service enum (-1 if not present).
1668  * \param num_messages NumberOfMessages (-1 if not present).
1669  * \param caller_id Party leaving message (NULL if not present).
1670  * \param timestamp When message left. (Generalized Time format, NULL if not present)
1671  * \param message_reference Message reference number (-1 if not present).
1672  * \param message_status Message status: added(0), removed(1).
1673  *
1674  * \retval 0 on success.
1675  * \retval -1 on error.
1676  */
1677 int pri_mwi_indicate(struct pri *ctrl, const struct pri_party_id *mailbox,
1678 	int basic_service, int num_messages, const struct pri_party_id *caller_id,
1679 	const char *timestamp, int message_reference, int message_status);
1680 
1681 /*!
1682  * \brief Send a MWI indication on the specified D channel. (Take two)
1683  *
1684  * \param ctrl D channel controller.
1685  * \param mailbox Party receiving notification.
1686  * \param vm_id Voicemail system number (NULL if not present).
1687  * \param basic_service Basic service enum (-1 if not present).
1688  * \param num_messages NumberOfMessages (-1 if not present).
1689  * \param caller_id Party leaving message (NULL if not present).
1690  * \param timestamp When message left. (Generalized Time format, NULL if not present)
1691  * \param message_reference Message reference number (-1 if not present).
1692  * \param message_status Message status: added(0), removed(1).
1693  *
1694  * \retval 0 on success.
1695  * \retval -1 on error.
1696  */
1697 int pri_mwi_indicate_v2(struct pri *ctrl, const struct pri_party_id *mailbox,
1698 	const struct pri_party_id *vm_id, int basic_service, int num_messages,
1699 	const struct pri_party_id *caller_id, const char *timestamp, int message_reference,
1700 	int message_status);
1701 
1702 /* Set service message support flag */
1703 int pri_set_service_message_support(struct pri *pri, int supportflag);
1704 
1705 #define PRI_2BCT
1706 /* Attempt to pass the channels back to the NET side if compatable and
1707  * subscribed.  Sometimes called 2 bchannel transfer (2BCT) */
1708 int pri_channel_bridge(q931_call *call1, q931_call *call2);
1709 
1710 /* Override message and error stuff */
1711 #define PRI_NEW_SET_API
1712 void pri_set_message(void (*__pri_error)(struct pri *pri, char *));
1713 void pri_set_error(void (*__pri_error)(struct pri *pri, char *));
1714 
1715 /* Set overlap mode */
1716 #define PRI_SET_OVERLAPDIAL
1717 void pri_set_overlapdial(struct pri *pri,int state);
1718 
1719 /* QSIG logical channel mapping option, do not skip channel 16 */
1720 #define PRI_SET_CHAN_MAPPING_LOGICAL
1721 void pri_set_chan_mapping_logical(struct pri *pri, int state);
1722 
1723 #define PRI_DUMP_INFO_STR
1724 char *pri_dump_info_str(struct pri *pri);
1725 
1726 /* Get file descriptor */
1727 int pri_fd(struct pri *pri);
1728 
1729 #define PRI_PROGRESS
1730 /* Send progress */
1731 int pri_progress(struct pri *pri, q931_call *c, int channel, int info);
1732 
1733 /* Send progress with cause IE */
1734 int pri_progress_with_cause(struct pri *pri, q931_call *c, int channel, int info, int cause);
1735 
1736 #define PRI_PROCEEDING_FULL
1737 /*!
1738  * \brief Send the PROCEEDING message.
1739  *
1740  * \param pri D channel controller.
1741  * \param c Q.931 call leg.
1742  * \param channel Encoded channel id to use.  If zero do not change channel id.
1743  * \param info Nonzero to include a progress ie indicating inband audio available.
1744  *
1745  * \retval 0 on success.
1746  * \retval -1 on error.
1747  */
1748 int pri_proceeding(struct pri *pri, q931_call *c, int channel, int info);
1749 
1750 /* Enable inband progress when a DISCONNECT is received */
1751 void pri_set_inbanddisconnect(struct pri *pri, unsigned int enable);
1752 
1753 /* Enslave a PRI to another, so they share the same call list
1754    (and maybe some timers) */
1755 void pri_enslave(struct pri *master, struct pri *slave);
1756 
1757 /*!
1758  * \brief  Request AOC on call setup
1759  *
1760  * \param call setup struct to set charging request info on
1761  * \param charging request to set on setup struct
1762  *
1763  * \retval 0 on success
1764  * \retval -1 on failure
1765  */
1766 int pri_sr_set_aoc_charging_request(struct pri_sr *sr, int charging_request);
1767 
1768 /*!
1769  * \brief Send AOC Request Response to a request for AOC-S
1770  *
1771  * \param ctrl D channel controller.
1772  * \param call Q.931 call leg.
1773  * \param invoke_id for response message
1774  * \param aoc_s message for response
1775  *
1776  * \retval 0 on success
1777  * \retval -1 on failure
1778  */
1779 int pri_aoc_s_request_response_send(struct pri *ctrl, q931_call *call, int invoke_id, const struct pri_subcmd_aoc_s *aoc_s);
1780 
1781 /*!
1782  * \brief Send AOC Request Response to a request for AOC-D or AOC-E
1783  *
1784  * \param ctrl D channel controller.
1785  * \param call Q.931 call leg.
1786  * \param response in form of enum PRI_AOC_REQ_RSP
1787  * \param invoke_id for response message
1788  *
1789  * \retval 0 on success
1790  * \retval -1 on failure
1791  */
1792 int pri_aoc_de_request_response_send(struct pri *ctrl, q931_call *call, int response, int invoke_id);
1793 
1794 /*!
1795  * \brief Send AOC-S message.
1796  *
1797  * \param ctrl D channel controller.
1798  * \param call Q.931 call leg.
1799  * \param aoc_s message to send
1800  *
1801  * \retval 0 on success
1802  * \retval -1 on failure
1803  */
1804 int pri_aoc_s_send(struct pri *ctrl, q931_call *c, const struct pri_subcmd_aoc_s *aoc_s);
1805 
1806 /*!
1807  * \brief Send AOC-D message.
1808  *
1809  * \param ctrl D channel controller.
1810  * \param call Q.931 call leg.
1811  * \param aoc_d message to send
1812  *
1813  * \retval 0 on success
1814  * \retval -1 on failure
1815  */
1816 int pri_aoc_d_send(struct pri *ctrl, q931_call *c, const struct pri_subcmd_aoc_d *aoc_d);
1817 
1818 /*!
1819  * \brief Send AOC-E message.
1820  *
1821  * \param ctrl D channel controller.
1822  * \param call Q.931 call leg.
1823  * \param aoc_e message to send
1824  *
1825  * \retval 0 on success
1826  * \retval -1 on failure
1827  */
1828 int pri_aoc_e_send(struct pri *ctrl, q931_call *c, const struct pri_subcmd_aoc_e *aoc_e);
1829 
1830 #define PRI_GR303_SUPPORT
1831 #define PRI_ENSLAVE_SUPPORT
1832 #define PRI_SETUP_CALL
1833 #define PRI_RECEIVE_SUBADDR
1834 #define PRI_REDIRECTING_REASON
1835 #define PRI_AOC_UNITS
1836 #define PRI_ANI
1837 
1838 /* Send notification */
1839 int pri_notify(struct pri *pri, q931_call *c, int channel, int info);
1840 
1841 int pri_callrerouting_facility(struct pri *pri, q931_call *call, const char *dest, const char* original, const char* reason);
1842 
1843 /*!
1844  * \brief Set the call deflection/rerouting feature enable flag.
1845  *
1846  * \param ctrl D channel controller.
1847  * \param enable TRUE to enable call deflection/rerouting feature.
1848  *
1849  * \return Nothing
1850  */
1851 void pri_reroute_enable(struct pri *ctrl, int enable);
1852 
1853 /*!
1854  * \brief Send the CallRerouting/CallDeflection message.
1855  *
1856  * \param ctrl D channel controller.
1857  * \param call Q.931 call leg.
1858  * \param caller Call rerouting/deflecting updated caller data. (NULL if data not updated.)
1859  * \param deflection Call rerouting/deflecting redirection data.
1860  * \param subscription_option Diverting user subscription option to specify if caller is notified.
1861  *
1862  * \note
1863  * deflection->to is the new called number and must always be present.
1864  * \note
1865  * subscription option:
1866  * noNotification(0),
1867  * notificationWithoutDivertedToNr(1),
1868  * notificationWithDivertedToNr(2)
1869  *
1870  * \retval 0 on success.
1871  * \retval -1 on error.
1872  */
1873 int pri_reroute_call(struct pri *ctrl, q931_call *call, const struct pri_party_id *caller, const struct pri_party_redirecting *deflection, int subscription_option);
1874 
1875 enum PRI_REROUTING_RSP_CODE {
1876 	/*!
1877 	 * Rerouting invocation accepted and the network provider option
1878 	 * "served user call retention on invocation of diversion"
1879 	 * is "clear call on invocation".
1880 	 */
1881 	PRI_REROUTING_RSP_OK_CLEAR,
1882 	/*!
1883 	 * Rerouting invocation accepted and the network provider option
1884 	 * "served user call retention on invocation of diversion"
1885 	 * is "retain call until alerting begins at the deflected-to user".
1886 	 */
1887 	PRI_REROUTING_RSP_OK_RETAIN,
1888 	PRI_REROUTING_RSP_NOT_SUBSCRIBED,
1889 	PRI_REROUTING_RSP_NOT_AVAILABLE,
1890 	/*! Supplementary service interaction not allowed. */
1891 	PRI_REROUTING_RSP_NOT_ALLOWED,
1892 	PRI_REROUTING_RSP_INVALID_NUMBER,
1893 	/*! Deflection to prohibited number (e.g., operator, police, emergency). */
1894 	PRI_REROUTING_RSP_SPECIAL_SERVICE_NUMBER,
1895 	/*! Deflection to served user number. */
1896 	PRI_REROUTING_RSP_DIVERSION_TO_SELF,
1897 	PRI_REROUTING_RSP_MAX_DIVERSIONS_EXCEEDED,
1898 	PRI_REROUTING_RSP_RESOURCE_UNAVAILABLE,
1899 };
1900 
1901 /*!
1902  * \brief Send the CallRerouteing/CallDeflection response message.
1903  *
1904  * \param ctrl D channel controller.
1905  * \param call Q.931 call leg.
1906  * \param invoke_id Value given by the initiating request.
1907  * \param code The result to send.
1908  *
1909  * \retval 0 on success.
1910  * \retval -1 on error.
1911  */
1912 int pri_rerouting_rsp(struct pri *ctrl, q931_call *call, int invoke_id, enum PRI_REROUTING_RSP_CODE code);
1913 
1914 /*!
1915  * \brief Set the call transfer feature enable flag.
1916  *
1917  * \param ctrl D channel controller.
1918  * \param enable TRUE to enable call transfer feature.
1919  *
1920  * \return Nothing
1921  */
1922 void pri_transfer_enable(struct pri *ctrl, int enable);
1923 
1924 /*!
1925  * \brief Send the call transfer response message.
1926  *
1927  * \param ctrl D channel controller.
1928  * \param call Q.931 call leg.
1929  * \param invoke_id Value given by the initiating request.
1930  * \param is_successful TRUE if the transfer was successful.
1931  *
1932  * \retval 0 on success.
1933  * \retval -1 on error.
1934  */
1935 int pri_transfer_rsp(struct pri *ctrl, q931_call *call, int invoke_id, int is_successful);
1936 
1937 /*!
1938  * \brief Set the advice of charge events feature enable flag.
1939  *
1940  * \param ctrl D channel controller.
1941  * \param enable TRUE to enable AOC events feature.
1942  *
1943  * \return Nothing
1944  */
1945 void pri_aoc_events_enable(struct pri *ctrl, int enable);
1946 
1947 enum pri_layer2_persistence {
1948 	PRI_L2_PERSISTENCE_DEFAULT,
1949 	/*! Immediately bring layer 2 back up if the peer brings layer 2 down. */
1950 	PRI_L2_PERSISTENCE_KEEP_UP,
1951 	/*! Leave layer 2 down if the peer brings layer 2 down. */
1952 	PRI_L2_PERSISTENCE_LEAVE_DOWN,
1953 #if 0	/* Possible future option.  Would need to define how long to idle before dropping. */
1954 	/*! Drop layer 2 on D channel idle. */
1955 	PRI_L2_PERSISTENCE_IDLE_DROP,
1956 #endif
1957 };
1958 
1959 /*!
1960  * \brief Set the layer2 persistence option.
1961  *
1962  * \param ctrl D channel controller.
1963  * \param option Layer 2 persistence to apply.
1964  *
1965  * \note
1966  * Not all values are supported by all modes.
1967  *
1968  * \return Nothing
1969  */
1970 void pri_persistent_layer2_option(struct pri *ctrl, enum pri_layer2_persistence option);
1971 
1972 #define PRI_DISPLAY_OPTION_BLOCK		(1 << 0)	/*!< Do not pass display text. */
1973 #define PRI_DISPLAY_OPTION_NAME_INITIAL	(1 << 1)	/*!< Use display in SETUP/CONNECT for name. */
1974 #define PRI_DISPLAY_OPTION_NAME_UPDATE	(1 << 2)	/*!< Use display in FACILITY/NOTIFY for COLP name if appropriate. */
1975 #define PRI_DISPLAY_OPTION_TEXT			(1 << 3)	/*!< Pass arbitrary display text in INFORMATION messages during call. */
1976 
1977 /*!
1978  * \brief Set the display ie send policy options.
1979  *
1980  * \param ctrl D channel controller.
1981  * \param flags Option flags to apply.
1982  *
1983  * \note
1984  * If no flags set then legacy default behaviour.
1985  *
1986  * \note
1987  * Not all options are supported by all switches.
1988  *
1989  * \return Nothing
1990  */
1991 void pri_display_options_send(struct pri *ctrl, unsigned long flags);
1992 
1993 /*!
1994  * \brief Set the display ie receive policy options.
1995  *
1996  * \param ctrl D channel controller.
1997  * \param flags Option flags to apply.
1998  *
1999  * \note
2000  * If no flags set then legacy default behaviour.
2001  *
2002  * \note
2003  * Not all options are supported by all switches.
2004  *
2005  * \return Nothing
2006  */
2007 void pri_display_options_receive(struct pri *ctrl, unsigned long flags);
2008 
2009 /*!
2010  * \brief Send display text during a call.
2011  *
2012  * \param ctrl D channel controller.
2013  * \param call Q.931 call leg
2014  * \param display Display text to send.
2015  *
2016  * \retval 0 on success.
2017  * \retval -1 on error.
2018  */
2019 int pri_display_text(struct pri *ctrl, q931_call *call, const struct pri_subcmd_display_txt *display);
2020 
2021 /*!
2022  * \brief Set the call hold feature enable flag.
2023  *
2024  * \param ctrl D channel controller.
2025  * \param enable TRUE to enable call hold feature.
2026  *
2027  * \return Nothing
2028  */
2029 void pri_hold_enable(struct pri *ctrl, int enable);
2030 
2031 /*!
2032  * \brief Send the HOLD message.
2033  *
2034  * \param ctrl D channel controller.
2035  * \param call Q.931 call leg
2036  *
2037  * \retval 0 on success.
2038  * \retval -1 on error.
2039  */
2040 int pri_hold(struct pri *ctrl, q931_call *call);
2041 
2042 /*!
2043  * \brief Send the HOLD ACKNOWLEDGE message.
2044  *
2045  * \param ctrl D channel controller.
2046  * \param call Q.931 call leg
2047  *
2048  * \retval 0 on success.
2049  * \retval -1 on error.
2050  */
2051 int pri_hold_ack(struct pri *ctrl, q931_call *call);
2052 
2053 /*!
2054  * \brief Send the HOLD REJECT message.
2055  *
2056  * \param ctrl D channel controller.
2057  * \param call Q.931 call leg
2058  * \param cause Q.931 cause code for rejecting the hold request.
2059  *
2060  * \retval 0 on success.
2061  * \retval -1 on error.
2062  */
2063 int pri_hold_rej(struct pri *ctrl, q931_call *call, int cause);
2064 
2065 /*!
2066  * \brief Send the RETRIEVE message.
2067  *
2068  * \param ctrl D channel controller.
2069  * \param call Q.931 call leg
2070  * \param channel Encoded channel id to use.  If zero do not send channel id.
2071  *
2072  * \retval 0 on success.
2073  * \retval -1 on error.
2074  */
2075 int pri_retrieve(struct pri *ctrl, q931_call *call, int channel);
2076 
2077 /*!
2078  * \brief Send the RETRIEVE ACKNOWLEDGE message.
2079  *
2080  * \param ctrl D channel controller.
2081  * \param call Q.931 call leg
2082  * \param channel Encoded channel id to use.
2083  *
2084  * \retval 0 on success.
2085  * \retval -1 on error.
2086  */
2087 int pri_retrieve_ack(struct pri *ctrl, q931_call *call, int channel);
2088 
2089 /*!
2090  * \brief Send the RETRIEVE REJECT message.
2091  *
2092  * \param ctrl D channel controller.
2093  * \param call Q.931 call leg
2094  * \param cause Q.931 cause code for rejecting the retrieve request.
2095  *
2096  * \retval 0 on success.
2097  * \retval -1 on error.
2098  */
2099 int pri_retrieve_rej(struct pri *ctrl, q931_call *call, int cause);
2100 
2101 #if defined(STATUS_REQUEST_PLACE_HOLDER)
2102 int pri_status_req(struct pri *ctrl, int request_id, const struct pri_sr *req);
2103 void pri_status_req_rsp(struct pri *ctrl, int invoke_id, int status);
2104 #endif	/* defined(STATUS_REQUEST_PLACE_HOLDER) */
2105 
2106 /*!
2107  * \brief Set the Malicious Call ID feature enable flag.
2108  *
2109  * \param ctrl D channel controller.
2110  * \param enable TRUE to enable MCID feature.
2111  *
2112  * \return Nothing
2113  */
2114 void pri_mcid_enable(struct pri *ctrl, int enable);
2115 
2116 /*!
2117  * \brief Send the MCID request message.
2118  *
2119  * \param ctrl D channel controller.
2120  * \param call Q.931 call leg
2121  *
2122  * \retval 0 on success.  You should wait for a PRI_SUBCMD_MCID_RSP
2123  * to continue clearing the call if it was in progress.
2124  * \retval -1 on error.
2125  */
2126 int pri_mcid_req_send(struct pri *ctrl, q931_call *call);
2127 
2128 /*!
2129  * \brief Set the call completion feature enable flag.
2130  *
2131  * \param ctrl D channel controller.
2132  * \param enable TRUE to enable call completion feature.
2133  *
2134  * \return Nothing
2135  */
2136 void pri_cc_enable(struct pri *ctrl, int enable);
2137 
2138 /*!
2139  * \brief Set the PTMP NT call completion recall mode.
2140  *
2141  * \param ctrl D channel controller.
2142  * \param mode globalRecall(0), specificRecall(1)
2143  *
2144  * \return Nothing
2145  */
2146 void pri_cc_recall_mode(struct pri *ctrl, int mode);
2147 
2148 /*!
2149  * \brief Set the Q.SIG call completion signaling link retention mode.
2150  * (Requestor/Initiator/Originator/Party-A)
2151  *
2152  * \param ctrl D channel controller.
2153  * \param signaling_retention release(0), retain(1), do-not-care(2).
2154  *
2155  * \return Nothing
2156  */
2157 void pri_cc_retain_signaling_req(struct pri *ctrl, int signaling_retention);
2158 
2159 /*!
2160  * \brief Set the Q.SIG call completion signaling link retention mode.
2161  * (Responder/Answerer/Party-B)
2162  *
2163  * \param ctrl D channel controller.
2164  * \param signaling_retention release(0), retain(1).
2165  *
2166  * \return Nothing
2167  */
2168 void pri_cc_retain_signaling_rsp(struct pri *ctrl, int signaling_retention);
2169 
2170 long pri_cc_available(struct pri *ctrl, q931_call *call);
2171 int pri_cc_req(struct pri *ctrl, long cc_id, int mode);
2172 int pri_cc_req_rsp(struct pri *ctrl, long cc_id, int status);
2173 void pri_cc_remote_user_free(struct pri *ctrl, long cc_id);
2174 void pri_cc_b_free(struct pri *ctrl, long cc_id);
2175 void pri_cc_stop_alerting(struct pri *ctrl, long cc_id);
2176 void pri_cc_status_req(struct pri *ctrl, long cc_id);
2177 void pri_cc_status_req_rsp(struct pri *ctrl, long cc_id, int status);
2178 void pri_cc_status(struct pri *ctrl, long cc_id, int status);
2179 int pri_cc_call(struct pri *ctrl, long cc_id, q931_call *call, struct pri_sr *req);
2180 void pri_cc_cancel(struct pri *ctrl, long cc_id);
2181 
2182 /* Date/time ie send policy option values. */
2183 #define PRI_DATE_TIME_SEND_DEFAULT		0	/*!< Send date/time ie default. */
2184 #define PRI_DATE_TIME_SEND_NO			1	/*!< Send date/time ie never. */
2185 #define PRI_DATE_TIME_SEND_DATE			2	/*!< Send date/time ie date only. */
2186 #define PRI_DATE_TIME_SEND_DATE_HH		3	/*!< Send date/time ie date and hour. */
2187 #define PRI_DATE_TIME_SEND_DATE_HHMM	4	/*!< Send date/time ie date, hour, and minute. */
2188 #define PRI_DATE_TIME_SEND_DATE_HHMMSS	5	/*!< Send date/time ie date, hour, minute, and second. */
2189 
2190 /*!
2191  * \brief Set the date/time ie send policy option.
2192  *
2193  * \param ctrl D channel controller.
2194  * \param option Policy option to set.
2195  *
2196  * \note
2197  * Only valid in NT mode.
2198  *
2199  * \return Nothing
2200  */
2201 void pri_date_time_send_option(struct pri *ctrl, int option);
2202 
2203 /* Get/Set PRI Timers  */
2204 #define PRI_GETSET_TIMERS
2205 int pri_set_timer(struct pri *pri, int timer, int value);
2206 int pri_get_timer(struct pri *pri, int timer);
2207 int pri_timer2idx(const char *timer_name);
2208 
2209 /*! New configurable timers and counters must be added to the end of the list */
2210 enum PRI_TIMERS_AND_COUNTERS {
2211 	PRI_TIMER_N200,	/*!< Maximum numer of Q.921 retransmissions */
2212 	PRI_TIMER_N201,	/*!< Maximum numer of octets in an information field */
2213 	PRI_TIMER_N202,	/*!< Maximum numer of transmissions of the TEI identity request message */
2214 	PRI_TIMER_K,	/*!< Maximum number of outstanding I-frames */
2215 
2216 	PRI_TIMER_T200,	/*!< Time between SABME's */
2217 	PRI_TIMER_T201,	/*!< Minimum time between retransmissions of the TEI Identity check messages */
2218 	PRI_TIMER_T202,	/*!< Minimum time between transmission of TEI Identity request messages */
2219 	PRI_TIMER_T203,	/*!< Maximum time without exchanging packets */
2220 
2221 	PRI_TIMER_T300,
2222 	PRI_TIMER_T301,	/*!< Maximum time to respond to an ALERT */
2223 	PRI_TIMER_T302,
2224 	PRI_TIMER_T303,	/*!< Maximum time to wait after sending a SETUP without a response */
2225 	PRI_TIMER_T304,
2226 	PRI_TIMER_T305,	/*!< Wait for DISCONNECT acknowledge */
2227 	PRI_TIMER_T306,
2228 	PRI_TIMER_T307,
2229 	PRI_TIMER_T308,	/*!< Wait for RELEASE acknowledge */
2230 	PRI_TIMER_T309,	/*!< Time active calls can tollerate data link layer being down before clearing. */
2231 	PRI_TIMER_T310,	/*!< Maximum time between receiving a CALL_PROCEEDING and receiving a ALERT/CONNECT/DISCONNECT/PROGRESS */
2232 	PRI_TIMER_T313,	/*!< Wait for CONNECT acknowledge, CPE side only */
2233 	PRI_TIMER_T314,
2234 	PRI_TIMER_T316,	/*!< Time to wait for a RESTART ACK before retransmitting RESTART. (Timer enabled if greater than zero.) */
2235 	PRI_TIMER_T317,
2236 	PRI_TIMER_T318,
2237 	PRI_TIMER_T319,
2238 	PRI_TIMER_T320,
2239 	PRI_TIMER_T321,
2240 	PRI_TIMER_T322,
2241 
2242 	PRI_TIMER_TM20,	/*!< Maximum time awaiting XID response */
2243 	PRI_TIMER_NM20,	/*!< Number of XID retransmits */
2244 
2245 	PRI_TIMER_T_HOLD,	/*!< Maximum time to wait for HOLD request response. */
2246 	PRI_TIMER_T_RETRIEVE,	/*!< Maximum time to wait for RETRIEVE request response. */
2247 
2248 	PRI_TIMER_T_RESPONSE,	/*!< Maximum time to wait for a typical APDU response. */
2249 
2250 	PRI_TIMER_T_STATUS,		/*!< Max time to wait for all replies to check for compatible terminals */
2251 
2252 	PRI_TIMER_T_ACTIVATE,	/*!< Request supervision timeout. */
2253 	PRI_TIMER_T_DEACTIVATE,	/*!< Deactivate supervision timeout. */
2254 	PRI_TIMER_T_INTERROGATE,/*!< Interrogation supervision timeout. */
2255 
2256 	/* ETSI call-completion timers */
2257 	PRI_TIMER_T_RETENTION,	/*!< Max time to wait for user A to activate call-completion. */
2258 	PRI_TIMER_T_CCBS1,		/*!< T-STATUS timer equivalent for CC user A status. */
2259 	PRI_TIMER_T_CCBS2,		/*!< Max time the CCBS service will be active */
2260 	PRI_TIMER_T_CCBS3,		/*!< Max time to wait for user A to respond to user B availability. */
2261 	PRI_TIMER_T_CCBS4,		/*!< CC user B guard time before sending CC recall indication. */
2262 	PRI_TIMER_T_CCBS5,		/*!< Network B CCBS supervision timeout. */
2263 	PRI_TIMER_T_CCBS6,		/*!< Network A CCBS supervision timeout. */
2264 	PRI_TIMER_T_CCNR2,		/*!< Max time the CCNR service will be active */
2265 	PRI_TIMER_T_CCNR5,		/*!< Network B CCNR supervision timeout. */
2266 	PRI_TIMER_T_CCNR6,		/*!< Network A CCNR supervision timeout. */
2267 
2268 	/* Q.SIG call-completion timers */
2269 	PRI_TIMER_QSIG_CC_T1,	/*!< CC request supervision timeout. */
2270 	PRI_TIMER_QSIG_CCBS_T2,	/*!< CCBS supervision timeout. */
2271 	PRI_TIMER_QSIG_CCNR_T2,	/*!< CCNR supervision timeout. */
2272 	PRI_TIMER_QSIG_CC_T3,	/*!< Max time to wait for user A to respond to user B availability. */
2273 	PRI_TIMER_QSIG_CC_T4,	/*!< Path reservation supervision timeout. */
2274 
2275 	PRI_TIMER_T312,			/*!< Supervise broadcast SETUP message call reference retention. */
2276 	PRI_TIMER_N316,			/*!< Number of times to transmit RESTART before giving up if T316 enabled. */
2277 
2278 	/* Must be last in the enum list */
2279 	PRI_MAX_TIMERS
2280 };
2281 
2282 /* Get PRI version */
2283 const char *pri_get_version(void);
2284 
2285 #endif
2286