Ignore files generated in the dependency checks.
[libpri-bristuff.git] / libpri.h
blobcf52d35304e1da786a58e34dfad8c7aea6676986
1 /*
2 * libpri: An implementation of Primary Rate ISDN
4 * Written by Mark Spencer <markster@digium.com>
6 * Copyright (C) 2001, Digium, Inc.
7 * All Rights Reserved.
8 * Copyright (C) 2003-2006 Junghanns.NET GmbH
9 * Klaus-Peter Junghanns <kpj@junghanns.net>
13 * See http://www.asterisk.org for more information about
14 * the Asterisk project. Please do not directly contact
15 * any of the maintainers of this project for assistance;
16 * the project provides a web site, mailing lists and IRC
17 * channels for your use.
19 * This program is free software, distributed under the terms of
20 * the GNU General Public License Version 2 as published by the
21 * Free Software Foundation. See the LICENSE file included with
22 * this program for more details.
25 #ifndef _LIBPRI_H
26 #define _LIBPRI_H
28 /* Node types */
29 #define PRI_NETWORK 1 /* PTP modes, default for PRI */
30 #define PRI_CPE 2
31 #define BRI_NETWORK_PTMP 3 /* PTMP modes, default for BRI */
32 #define BRI_CPE_PTMP 4
33 #define BRI_NETWORK 5 /* PTP modes */
34 #define BRI_CPE 6
36 /* Debugging */
37 #define PRI_DEBUG_Q921_RAW (1 << 0) /* Show raw HDLC frames */
38 #define PRI_DEBUG_Q921_DUMP (1 << 1) /* Show each interpreted Q.921 frame */
39 #define PRI_DEBUG_Q921_STATE (1 << 2) /* Debug state machine changes */
40 #define PRI_DEBUG_CONFIG (1 << 3) /* Display error events on stdout */
41 #define PRI_DEBUG_Q931_DUMP (1 << 5) /* Show interpreted Q.931 frames */
42 #define PRI_DEBUG_Q931_STATE (1 << 6) /* Debug Q.931 state machine changes */
43 #define PRI_DEBUG_Q931_ANOMALY (1 << 7) /* Show unexpected events */
44 #define PRI_DEBUG_APDU (1 << 8) /* Debug of APDU components such as ROSE */
45 #define PRI_DEBUG_AOC (1 << 9) /* Debug of Advice of Charge ROSE Messages */
47 #define PRI_DEBUG_ALL (0xffff) /* Everything */
49 /* Switch types */
50 #define PRI_SWITCH_UNKNOWN 0
51 #define PRI_SWITCH_NI2 1 /* National ISDN 2 */
52 #define PRI_SWITCH_DMS100 2 /* DMS 100 */
53 #define PRI_SWITCH_LUCENT5E 3 /* Lucent 5E */
54 #define PRI_SWITCH_ATT4ESS 4 /* AT&T 4ESS */
55 #define PRI_SWITCH_EUROISDN_E1 5 /* Standard EuroISDN (CTR4, ETSI 300-102) */
56 #define PRI_SWITCH_EUROISDN_T1 6 /* T1 EuroISDN variant (ETSI 300-102) */
57 #define PRI_SWITCH_NI1 7 /* National ISDN 1 */
58 #define PRI_SWITCH_GR303_EOC 8 /* GR-303 Embedded Operations Channel */
59 #define PRI_SWITCH_GR303_TMC 9 /* GR-303 Timeslot Management Channel */
60 #define PRI_SWITCH_QSIG 10 /* QSIG Switch */
61 /* Switchtypes 11 - 20 are reserved for internal use */
64 /* PRI D-Channel Events */
65 #define PRI_EVENT_DCHAN_UP 1 /* D-channel is up */
66 #define PRI_EVENT_DCHAN_DOWN 2 /* D-channel is down */
67 #define PRI_EVENT_RESTART 3 /* B-channel is restarted */
68 #define PRI_EVENT_CONFIG_ERR 4 /* Configuration Error Detected */
69 #define PRI_EVENT_RING 5 /* Incoming call */
70 #define PRI_EVENT_HANGUP 6 /* Call got hung up */
71 #define PRI_EVENT_RINGING 7 /* Call is ringing (alerting) */
72 #define PRI_EVENT_ANSWER 8 /* Call has been answered */
73 #define PRI_EVENT_HANGUP_ACK 9 /* Call hangup has been acknowledged */
74 #define PRI_EVENT_RESTART_ACK 10 /* Restart complete on a given channel */
75 #define PRI_EVENT_FACNAME 11 /* Caller*ID Name received on Facility */
76 #define PRI_EVENT_INFO_RECEIVED 12 /* Additional info (keypad) received */
77 #define PRI_EVENT_PROCEEDING 13 /* When we get CALL_PROCEEDING or PROGRESS */
78 #define PRI_EVENT_SETUP_ACK 14 /* When we get SETUP_ACKNOWLEDGE */
79 #define PRI_EVENT_HANGUP_REQ 15 /* Requesting the higher layer to hangup */
80 #define PRI_EVENT_NOTIFY 16 /* Notification received */
81 #define PRI_EVENT_PROGRESS 17 /* When we get CALL_PROCEEDING or PROGRESS */
82 #define PRI_EVENT_KEYPAD_DIGIT 18 /* When we receive during ACTIVE state */
83 #define PRI_EVENT_HOLD_REQ 19 /* R */
84 #define PRI_EVENT_RETRIEVE_REQ 20
85 #define PRI_EVENT_SUSPEND_REQ 21 /* park */
86 #define PRI_EVENT_RESUME_REQ 22 /* unpark */
87 #define PRI_EVENT_DISPLAY_RECEIVED 23
88 #define PRI_EVENT_FACILITY 24 /* Facility */
90 /* Simple states */
91 #define PRI_STATE_DOWN 0
92 #define PRI_STATE_UP 1
94 #define PRI_PROGRESS_MASK
96 /* Progress indicator values */
97 #define PRI_PROG_CALL_NOT_E2E_ISDN (1 << 0)
98 #define PRI_PROG_CALLED_NOT_ISDN (1 << 1)
99 #define PRI_PROG_CALLER_NOT_ISDN (1 << 2)
100 #define PRI_PROG_INBAND_AVAILABLE (1 << 3)
101 #define PRI_PROG_DELAY_AT_INTERF (1 << 4)
102 #define PRI_PROG_INTERWORKING_WITH_PUBLIC (1 << 5)
103 #define PRI_PROG_INTERWORKING_NO_RELEASE (1 << 6)
104 #define PRI_PROG_INTERWORKING_NO_RELEASE_PRE_ANSWER (1 << 7)
105 #define PRI_PROG_INTERWORKING_NO_RELEASE_POST_ANSWER (1 << 8)
106 #define PRI_PROG_CALLER_RETURNED_TO_ISDN (1 << 9)
108 /* Numbering plan identifier */
109 #define PRI_NPI_UNKNOWN 0x0
110 #define PRI_NPI_E163_E164 0x1
111 #define PRI_NPI_X121 0x3
112 #define PRI_NPI_F69 0x4
113 #define PRI_NPI_NATIONAL 0x8
114 #define PRI_NPI_PRIVATE 0x9
115 #define PRI_NPI_RESERVED 0xF
117 /* Type of number */
118 #define PRI_TON_UNKNOWN 0x0
119 #define PRI_TON_INTERNATIONAL 0x1
120 #define PRI_TON_NATIONAL 0x2
121 #define PRI_TON_NET_SPECIFIC 0x3
122 #define PRI_TON_SUBSCRIBER 0x4
123 #define PRI_TON_ABBREVIATED 0x6
124 #define PRI_TON_RESERVED 0x7
126 /* Redirection reasons */
127 #define PRI_REDIR_UNKNOWN 0x0
128 #define PRI_REDIR_FORWARD_ON_BUSY 0x1
129 #define PRI_REDIR_FORWARD_ON_NO_REPLY 0x2
130 #define PRI_REDIR_DEFLECTION 0x3
131 #define PRI_REDIR_DTE_OUT_OF_ORDER 0x9
132 #define PRI_REDIR_FORWARDED_BY_DTE 0xA
133 #define PRI_REDIR_UNCONDITIONAL 0xF
135 /* Dialing plan */
136 #define PRI_INTERNATIONAL_ISDN 0x11
137 #define PRI_NATIONAL_ISDN 0x21
138 #define PRI_LOCAL_ISDN 0x41
139 #define PRI_PRIVATE 0x49
140 #define PRI_UNKNOWN 0x0
142 /* Presentation */
143 #define PRES_ALLOWED_USER_NUMBER_NOT_SCREENED 0x00
144 #define PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN 0x01
145 #define PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN 0x02
146 #define PRES_ALLOWED_NETWORK_NUMBER 0x03
147 #define PRES_PROHIB_USER_NUMBER_NOT_SCREENED 0x20
148 #define PRES_PROHIB_USER_NUMBER_PASSED_SCREEN 0x21
149 #define PRES_PROHIB_USER_NUMBER_FAILED_SCREEN 0x22
150 #define PRES_PROHIB_NETWORK_NUMBER 0x23
151 #define PRES_NUMBER_NOT_AVAILABLE 0x43
153 /* Causes for disconnection */
154 #define PRI_CAUSE_UNALLOCATED 1
155 #define PRI_CAUSE_NO_ROUTE_TRANSIT_NET 2 /* !Q.SIG */
156 #define PRI_CAUSE_NO_ROUTE_DESTINATION 3
157 #define PRI_CAUSE_CHANNEL_UNACCEPTABLE 6
158 #define PRI_CAUSE_CALL_AWARDED_DELIVERED 7 /* !Q.SIG */
159 #define PRI_CAUSE_NORMAL_CLEARING 16
160 #define PRI_CAUSE_USER_BUSY 17
161 #define PRI_CAUSE_NO_USER_RESPONSE 18
162 #define PRI_CAUSE_NO_ANSWER 19
163 #define PRI_CAUSE_CALL_REJECTED 21
164 #define PRI_CAUSE_NUMBER_CHANGED 22
165 #define PRI_CAUSE_DESTINATION_OUT_OF_ORDER 27
166 #define PRI_CAUSE_INVALID_NUMBER_FORMAT 28
167 #define PRI_CAUSE_FACILITY_REJECTED 29 /* !Q.SIG */
168 #define PRI_CAUSE_RESPONSE_TO_STATUS_ENQUIRY 30
169 #define PRI_CAUSE_NORMAL_UNSPECIFIED 31
170 #define PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION 34
171 #define PRI_CAUSE_NETWORK_OUT_OF_ORDER 38 /* !Q.SIG */
172 #define PRI_CAUSE_NORMAL_TEMPORARY_FAILURE 41
173 #define PRI_CAUSE_SWITCH_CONGESTION 42 /* !Q.SIG */
174 #define PRI_CAUSE_ACCESS_INFO_DISCARDED 43 /* !Q.SIG */
175 #define PRI_CAUSE_REQUESTED_CHAN_UNAVAIL 44
176 #define PRI_CAUSE_PRE_EMPTED 45 /* !Q.SIG */
177 #define PRI_CAUSE_FACILITY_NOT_SUBSCRIBED 50 /* !Q.SIG */
178 #define PRI_CAUSE_OUTGOING_CALL_BARRED 52 /* !Q.SIG */
179 #define PRI_CAUSE_INCOMING_CALL_BARRED 54 /* !Q.SIG */
180 #define PRI_CAUSE_BEARERCAPABILITY_NOTAUTH 57
181 #define PRI_CAUSE_BEARERCAPABILITY_NOTAVAIL 58
182 #define PRI_CAUSE_SERVICEOROPTION_NOTAVAIL 63 /* Q.SIG */
183 #define PRI_CAUSE_BEARERCAPABILITY_NOTIMPL 65
184 #define PRI_CAUSE_CHAN_NOT_IMPLEMENTED 66 /* !Q.SIG */
185 #define PRI_CAUSE_FACILITY_NOT_IMPLEMENTED 69 /* !Q.SIG */
186 #define PRI_CAUSE_INVALID_CALL_REFERENCE 81
187 #define PRI_CAUSE_IDENTIFIED_CHANNEL_NOTEXIST 82 /* Q.SIG */
188 #define PRI_CAUSE_INCOMPATIBLE_DESTINATION 88
189 #define PRI_CAUSE_INVALID_MSG_UNSPECIFIED 95 /* !Q.SIG */
190 #define PRI_CAUSE_MANDATORY_IE_MISSING 96
191 #define PRI_CAUSE_MESSAGE_TYPE_NONEXIST 97
192 #define PRI_CAUSE_WRONG_MESSAGE 98
193 #define PRI_CAUSE_IE_NONEXIST 99
194 #define PRI_CAUSE_INVALID_IE_CONTENTS 100
195 #define PRI_CAUSE_WRONG_CALL_STATE 101
196 #define PRI_CAUSE_RECOVERY_ON_TIMER_EXPIRE 102
197 #define PRI_CAUSE_MANDATORY_IE_LENGTH_ERROR 103 /* !Q.SIG */
198 #define PRI_CAUSE_PROTOCOL_ERROR 111
199 #define PRI_CAUSE_INTERWORKING 127 /* !Q.SIG */
201 /* Transmit capabilities */
202 #define PRI_TRANS_CAP_SPEECH 0x0
203 #define PRI_TRANS_CAP_DIGITAL 0x08
204 #define PRI_TRANS_CAP_RESTRICTED_DIGITAL 0x09
205 #define PRI_TRANS_CAP_3_1K_AUDIO 0x10
206 #define PRI_TRANS_CAP_7K_AUDIO 0x11 /* Depriciated ITU Q.931 (05/1998)*/
207 #define PRI_TRANS_CAP_DIGITAL_W_TONES 0x11
208 #define PRI_TRANS_CAP_VIDEO 0x18
210 #define PRI_LAYER_1_ITU_RATE_ADAPT 0x21
211 #define PRI_LAYER_1_ULAW 0x22
212 #define PRI_LAYER_1_ALAW 0x23
213 #define PRI_LAYER_1_G721 0x24
214 #define PRI_LAYER_1_G722_G725 0x25
215 #define PRI_LAYER_1_H223_H245 0x26
216 #define PRI_LAYER_1_NON_ITU_ADAPT 0x27
217 #define PRI_LAYER_1_V120_RATE_ADAPT 0x28
218 #define PRI_LAYER_1_X31_RATE_ADAPT 0x29
221 /* Intermediate rates for V.110 */
222 #define PRI_INT_RATE_8K 1
223 #define PRI_INT_RATE_16K 2
224 #define PRI_INT_RATE_32K 3
227 /* Rate adaption for bottom 5 bits of rateadaption */
228 #define PRI_RATE_USER_RATE_MASK 0x1F
229 #define PRI_RATE_ADAPT_UNSPEC 0x00
230 #define PRI_RATE_ADAPT_0K6 0x01
231 #define PRI_RATE_ADAPT_1K2 0x02
232 #define PRI_RATE_ADAPT_2K4 0x03
233 #define PRI_RATE_ADAPT_3K6 0x04
234 #define PRI_RATE_ADAPT_4K8 0x05
235 #define PRI_RATE_ADAPT_7K2 0x06
236 #define PRI_RATE_ADAPT_8K 0x07
237 #define PRI_RATE_ADAPT_9K6 0x08
238 #define PRI_RATE_ADAPT_14K4 0x09
239 #define PRI_RATE_ADAPT_16K 0x0A
240 #define PRI_RATE_ADAPT_19K2 0x0B
241 #define PRI_RATE_ADAPT_32K 0x0C
242 #define PRI_RATE_ADAPT_38K4 0x0D
243 #define PRI_RATE_ADAPT_48K 0x0E
244 #define PRI_RATE_ADAPT_56K 0x0F
245 #define PRI_RATE_ADAPT_57K6 0x12
246 #define PRI_RATE_ADAPT_28K8 0x13
247 #define PRI_RATE_ADAPT_24K 0x14
248 #define PRI_RATE_ADAPT_0K1345 0x15
249 #define PRI_RATE_ADAPT_0K1 0x16
250 #define PRI_RATE_ADAPT_0K075_1K2 0x17
251 #define PRI_RATE_ADAPT_1K2_0K075 0x18
252 #define PRI_RATE_ADAPT_0K05 0x19
253 #define PRI_RATE_ADAPT_0K075 0x1A
254 #define PRI_RATE_ADAPT_0K110 0x1B
255 #define PRI_RATE_ADAPT_0K150 0x1C
256 #define PRI_RATE_ADAPT_0K200 0x1D
257 #define PRI_RATE_ADAPT_0K300 0x1E
258 #define PRI_RATE_ADAPT_12K 0x1F
260 /* in-band negotiation flag for rateadaption bit 5 */
261 #define PRI_RATE_ADAPT_NEGOTIATION_POSS 0x20
263 /* async flag for rateadaption bit 6 */
264 #define PRI_RATE_ADAPT_ASYNC 0x40
266 /* Notifications */
267 #define PRI_NOTIFY_USER_SUSPENDED 0x00 /* User suspended */
268 #define PRI_NOTIFY_USER_RESUMED 0x01 /* User resumed */
269 #define PRI_NOTIFY_BEARER_CHANGE 0x02 /* Bearer service change (DSS1) */
270 #define PRI_NOTIFY_ASN1_COMPONENT 0x03 /* ASN.1 encoded component (DSS1) */
271 #define PRI_NOTIFY_COMPLETION_DELAY 0x04 /* Call completion delay */
272 #define PRI_NOTIFY_CONF_ESTABLISHED 0x42 /* Conference established */
273 #define PRI_NOTIFY_CONF_DISCONNECTED 0x43 /* Conference disconnected */
274 #define PRI_NOTIFY_CONF_PARTY_ADDED 0x44 /* Other party added */
275 #define PRI_NOTIFY_CONF_ISOLATED 0x45 /* Isolated */
276 #define PRI_NOTIFY_CONF_REATTACHED 0x46 /* Reattached */
277 #define PRI_NOTIFY_CONF_OTHER_ISOLATED 0x47 /* Other party isolated */
278 #define PRI_NOTIFY_CONF_OTHER_REATTACHED 0x48 /* Other party reattached */
279 #define PRI_NOTIFY_CONF_OTHER_SPLIT 0x49 /* Other party split */
280 #define PRI_NOTIFY_CONF_OTHER_DISCONNECTED 0x4a /* Other party disconnected */
281 #define PRI_NOTIFY_CONF_FLOATING 0x4b /* Conference floating */
282 #define PRI_NOTIFY_WAITING_CALL 0x60 /* Call is waiting call */
283 #define PRI_NOTIFY_DIVERSION_ACTIVATED 0x68 /* Diversion activated (DSS1) */
284 #define PRI_NOTIFY_TRANSFER_ALERTING 0x69 /* Call transfer, alerting */
285 #define PRI_NOTIFY_TRANSFER_ACTIVE 0x6a /* Call transfer, active */
286 #define PRI_NOTIFY_REMOTE_HOLD 0x79 /* Remote hold */
287 #define PRI_NOTIFY_REMOTE_RETRIEVAL 0x7a /* Remote retrieval */
288 #define PRI_NOTIFY_CALL_DIVERTING 0x7b /* Call is diverting */
290 #define PRI_COPY_DIGITS_CALLED_NUMBER
292 /* Network Specific Facilities (AT&T) */
293 #define PRI_NSF_NONE -1
294 #define PRI_NSF_SID_PREFERRED 0xB1
295 #define PRI_NSF_ANI_PREFERRED 0xB2
296 #define PRI_NSF_SID_ONLY 0xB3
297 #define PRI_NSF_ANI_ONLY 0xB4
298 #define PRI_NSF_CALL_ASSOC_TSC 0xB9
299 #define PRI_NSF_NOTIF_CATSC_CLEARING 0xBA
300 #define PRI_NSF_OPERATOR 0xB5
301 #define PRI_NSF_PCCO 0xB6
302 #define PRI_NSF_SDN 0xE1
303 #define PRI_NSF_TOLL_FREE_MEGACOM 0xE2
304 #define PRI_NSF_MEGACOM 0xE3
305 #define PRI_NSF_ACCUNET 0xE6
306 #define PRI_NSF_LONG_DISTANCE_SERVICE 0xE7
307 #define PRI_NSF_INTERNATIONAL_TOLL_FREE 0xE8
308 #define PRI_NSF_ATT_MULTIQUEST 0xF0
309 #define PRI_NSF_CALL_REDIRECTION_SERVICE 0xF7
311 #ifdef RELAX_TRB
312 #define PRI_RELAX_TRB
313 #endif
315 typedef struct q921_call q921_call;
316 typedef struct q931_call q931_call;
318 typedef struct pri_event_generic {
319 /* Events with no additional information fall in this category */
320 int e;
321 int tei;
322 } pri_event_generic;
324 typedef struct pri_event_error {
325 int e;
326 char err[256];
327 } pri_event_error;
329 typedef struct pri_event_restart {
330 int e;
331 int channel;
332 } pri_event_restart;
334 typedef struct pri_event_ringing {
335 int e;
336 int channel;
337 int cref;
338 int progress;
339 int progressmask;
340 char useruserinfo[260]; /* User->User info */
341 q931_call *call;
342 } pri_event_ringing;
344 typedef struct pri_event_answer {
345 int e;
346 int channel;
347 int tei; /* belongs to this tei */
348 int cref;
349 int progress;
350 int progressmask;
351 char useruserinfo[260]; /* User->User info */
352 q931_call *call;
353 } pri_event_answer;
355 typedef struct pri_event_facname {
356 int e;
357 char callingname[256];
358 char callingnum[256];
359 int channel;
360 int cref;
361 q931_call *call;
362 } pri_event_facname;
364 #define PRI_CALLINGPLANANI
365 #define PRI_CALLINGPLANRDNIS
366 typedef struct pri_event_ring {
367 int e;
368 int channel; /* Channel requested */
369 int callingpres; /* Presentation of Calling CallerID */
370 int callingpresuser; /* Presentation of Calling CallerID */
371 int callingplan; /* Dialing plan of Calling entity */
372 int callingplanuser; /* Dialing plan of Calling entity */
373 int callingplanani; /* Dialing plan of Calling entity ANI */
374 char callingnum[256]; /* Calling number, network provided */
375 char callingani[256]; /* Calling number, user provided */
376 char callingname[256]; /* Calling name (if provided) */
377 int calledplan; /* Dialing plan of Called number */
378 int ani2; /* ANI II */
379 char callednum[256]; /* Called number */
380 char redirectingnum[256]; /* Redirecting number */
381 char redirectingname[256]; /* Redirecting name */
382 int redirectingreason; /* Reason for redirect */
383 int callingplanrdnis; /* Dialing plan of Redirecting Number */
384 char useruserinfo[260]; /* User->User info */
385 int flexible; /* Are we flexible with our channel selection? */
386 int cref; /* Call Reference Number */
387 int ctype; /* Call type (see PRI_TRANS_CAP_* */
388 int layer1; /* User layer 1 */
389 int complete; /* Have we seen "Complete" i.e. no more number? */
390 q931_call *call; /* Opaque call pointer */
391 int tei; /* belongs to this tei */
392 char callingsubaddr[256]; /* Calling parties subaddress */
393 int progress;
394 int progressmask;
395 char origcalledname[256];
396 char origcallednum[256];
397 int callingplanorigcalled; /* Dialing plan of Originally Called Number */
398 int origredirectingreason;
399 char lowlayercompat[16];
400 char highlayercompat[4];
401 } pri_event_ring;
403 typedef struct pri_event_hangup {
404 int e;
405 int channel; /* Channel requested */
406 int cause;
407 int cref;
408 int tei;
409 int inband_progress;
410 q931_call *call; /* Opaque call pointer */
411 long aoc_units; /* Advise of Charge number of charged units */
412 char useruserinfo[260]; /* User->User info */
413 } pri_event_hangup;
415 typedef struct pri_event_restart_ack {
416 int e;
417 int channel;
418 } pri_event_restart_ack;
420 #define PRI_PROGRESS_CAUSE
421 typedef struct pri_event_proceeding {
422 int e;
423 int channel;
424 int cref;
425 int progress;
426 int progressmask;
427 int cause;
428 q931_call *call;
429 } pri_event_proceeding;
431 typedef struct pri_event_setup_ack {
432 int e;
433 int channel;
434 q931_call *call;
435 } pri_event_setup_ack;
437 typedef struct pri_event_notify {
438 int e;
439 int channel;
440 int info;
441 } pri_event_notify;
443 typedef struct pri_event_keypad_digit {
444 int e;
445 int channel;
446 q931_call *call;
447 char digits[64];
448 } pri_event_keypad_digit;
450 typedef struct pri_event_hold_req {
451 int e;
452 int channel;
453 int cref;
454 int tei;
455 q931_call *call;
456 } pri_event_hold_req;
458 /* euroisdn faciltiy fun */
459 typedef struct pri_event_facility_req {
460 int e;
461 int channel;
462 int cref;
463 int tei;
464 int operation;
465 char forwardnum[256]; /* Redirection destination */
466 q931_call *call;
467 } pri_event_facility_req;
469 typedef struct pri_event_retrieve_req {
470 int e;
471 int channel;
472 int cref;
473 int tei;
474 q931_call *call;
475 } pri_event_retrieve_req;
477 typedef struct pri_event_suspend_req {
478 int e;
479 int channel;
480 int cref;
481 int tei;
482 q931_call *call;
483 char callid[10];
484 } pri_event_suspend_req;
486 typedef struct pri_event_resume_req {
487 int e;
488 int channel;
489 int cref;
490 int tei;
491 q931_call *call;
492 char callid[10];
493 } pri_event_resume_req;
495 typedef struct pri_event_display {
496 int e;
497 int channel;
498 int cref;
499 q931_call *call;
500 char text[256];
501 } pri_event_display;
504 typedef union {
505 int e;
506 pri_event_generic gen; /* Generic view */
507 pri_event_restart restart; /* Restart view */
508 pri_event_error err; /* Error view */
509 pri_event_facname facname; /* Caller*ID Name on Facility */
510 pri_event_facility_req facility; /* sservices */
511 pri_event_ring ring; /* Ring */
512 pri_event_hangup hangup; /* Hang up */
513 pri_event_ringing ringing; /* Ringing */
514 pri_event_answer answer; /* Answer */
515 pri_event_restart_ack restartack; /* Restart Acknowledge */
516 pri_event_proceeding proceeding; /* Call proceeding & Progress */
517 pri_event_setup_ack setup_ack; /* SETUP_ACKNOWLEDGE structure */
518 pri_event_notify notify; /* Notification */
519 pri_event_hold_req hold_req;
520 pri_event_retrieve_req retrieve_req;
521 pri_event_suspend_req suspend_req;
522 pri_event_resume_req resume_req;
523 pri_event_display display;
524 pri_event_keypad_digit digit; /* Digits that come during a call */
525 } pri_event;
527 struct pri;
528 struct pri_sr;
530 #define PRI_IO_FUNCS
531 /* Type declaration for callbacks to read or write a HDLC frame as below */
532 typedef int (*pri_io_cb)(struct pri *pri, void *buf, int buflen);
534 /* Create a D-channel on a given file descriptor. The file descriptor must be a
535 channel operating in HDLC mode with FCS computed by the fd's driver. Also it
536 must be NON-BLOCKING! Frames received on the fd should include FCS. Nodetype
537 must be one of PRI_NETWORK or PRI_CPE. switchtype should be PRI_SWITCH_* */
538 extern struct pri *pri_new(int fd, int nodetype, int switchtype, int span);
540 extern void pri_shutdown(struct pri *pri);
542 /* Create D-channel just as above with user defined I/O callbacks and data */
543 extern struct pri *pri_new_cb(int fd, int nodetype, int switchtype, pri_io_cb io_read, pri_io_cb io_write, void *userdata);
545 /* Retrieve the user data associated with the D channel */
546 extern void *pri_get_userdata(struct pri *pri);
548 /* Set the user data associated with the D channel */
549 extern void pri_set_userdata(struct pri *pri, void *userdata);
551 /* Set Network Specific Facility for PRI */
552 extern void pri_set_nsf(struct pri *pri, int nsf);
554 /* Set debug parameters on PRI -- see above debug definitions */
555 extern void pri_set_debug(struct pri *pri, int debug);
557 /* Get debug parameters on PRI -- see above debug definitions */
558 extern int pri_get_debug(struct pri *pri);
560 #define PRI_FACILITY_ENABLE
561 /* Enable transmission support of Facility IEs on the pri */
562 extern void pri_facility_enable(struct pri *pri);
564 /* Set file descriptor for debugging to a file */
565 extern void pri_set_debug_fd(struct pri *pri, int fd);
567 /* Run PRI on the given D-channel, taking care of any events that
568 need to be handled. If block is set, it will block until an event
569 occurs which needs to be handled */
570 extern pri_event *pri_dchannel_run(struct pri *pri, int block);
572 /* Check for an outstanding event on the PRI */
573 pri_event *pri_check_event(struct pri *pri);
575 /* Give a name to a given event ID */
576 extern char *pri_event2str(int id);
578 /* Give a name to a node type */
579 extern char *pri_node2str(int id);
581 /* Give a name to a switch type */
582 extern char *pri_switch2str(int id);
584 /* Print an event */
585 extern void pri_dump_event(struct pri *pri, pri_event *e);
587 /* Turn presentation into a string */
588 extern char *pri_pres2str(int pres);
590 /* Turn numbering plan into a string */
591 extern char *pri_plan2str(int plan);
593 /* Turn cause into a string */
594 extern char *pri_cause2str(int cause);
596 /* Acknowledge a call and place it on the given channel. Set info to non-zero if there
597 is in-band data available on the channel */
598 extern int pri_acknowledge(struct pri *pri, q931_call *call, int channel, int info);
600 /* Send a digit in overlap mode */
601 extern int pri_information(struct pri *pri, q931_call *call, char digit);
603 #define PRI_KEYPAD_FACILITY_TX
604 /* Send a keypad facility string of digits */
605 extern int pri_keypad_facility(struct pri *pri, q931_call *call, char *digits);
607 /* Send a INFO msg with display ie */
608 extern int pri_information_display(struct pri *pri, q931_call *call, char *display);
610 /* add a display ie to a call, so it can be sent with the next message */
611 extern int pri_add_display(struct pri *pri, q931_call *call, char *display);
613 /* Answer the incomplete(call without called number) call on the given channel.
614 Set non-isdn to non-zero if you are not connecting to ISDN equipment */
615 extern int pri_need_more_info(struct pri *pri, q931_call *call, int channel, int nonisdn);
617 /* Answer the call on the given channel (ignored if you called acknowledge already).
618 Set non-isdn to non-zero if you are not connecting to ISDN equipment */
619 extern int pri_answer(struct pri *pri, q931_call *call, int channel, int nonisdn);
621 extern int pri_deflect(struct pri *pri, q931_call *call, char *destination);
623 /* Ack a HOLD_REQ */
624 extern int pri_hold_acknowledge(struct pri *pri, q931_call *call);
626 /* Reject a HOLD_REQ */
627 extern int pri_hold_reject(struct pri *pri, q931_call *call);
629 /* Ack a RETRIEVE_REQ */
630 extern int pri_retrieve_acknowledge(struct pri *pri, q931_call *call, int channel);
632 /* Reject a RETRIEVE_REQ */
633 extern int pri_retrieve_reject(struct pri *pri, q931_call *call);
635 /* Ack a SUSPEND_REQ */
636 extern int pri_suspend_acknowledge(struct pri *pri, q931_call *call, char *display);
638 /* Reject a SUSPEND_REQ */
639 extern int pri_suspend_reject(struct pri *pri, q931_call *call, char *display);
641 /* Reject a RESUME_REQ */
642 extern int pri_resume_reject(struct pri *pri, q931_call *call, char *display);
644 /* Ack a RESUME_REQ */
645 extern int pri_resume_acknowledge(struct pri *pri, q931_call *call, int channel, char *display);
647 /* Send a Facility Message */
648 extern int pri_facility(struct pri *pri, q931_call *call, int operation, char *arguments);
650 /* Set CRV reference for GR-303 calls */
653 #undef pri_release
654 #undef pri_disconnect
656 /* backwards compatibility for those who don't use asterisk with libpri */
657 #define pri_release(a,b,c) \
658 pri_hangup(a,b,c, -1)
660 #define pri_disconnect(a,b,c) \
661 pri_hangup(a,b,c, -1)
663 /* Hangup a call */
664 #define PRI_HANGUP
665 extern int pri_hangup(struct pri *pri, q931_call *call, int cause, int aocunits);
667 #define PRI_DESTROYCALL
668 extern void pri_destroycall(struct pri *pri, q931_call *call);
670 #define PRI_RESTART
671 extern int pri_restart(struct pri *pri);
673 extern int pri_reset(struct pri *pri, int channel);
675 /* Create a new call */
676 extern q931_call *pri_new_call(struct pri *pri);
678 /* Retrieve CRV reference for GR-303 calls. Returns >0 on success. */
679 extern int pri_get_crv(struct pri *pri, q931_call *call, int *callmode);
681 /* Retrieve CRV reference for GR-303 calls. CRV must be >0, call mode should be 0 */
682 extern int pri_set_crv(struct pri *pri, q931_call *call, int crv, int callmode);
684 /* How long until you need to poll for a new event */
685 extern struct timeval *pri_schedule_next(struct pri *pri);
687 /* Run any pending schedule events */
688 extern pri_event *pri_schedule_run(struct pri *pri);
689 extern pri_event *pri_schedule_run_tv(struct pri *pri, const struct timeval *now);
691 extern int pri_call(struct pri *pri, q931_call *c, int transmode, int channel,
692 int exclusive, int nonisdn, char *caller, int callerplan, char *callername, int callerpres,
693 char *called,int calledplan, int ulayer1);
695 extern struct pri_sr *pri_sr_new(void);
696 extern void pri_sr_free(struct pri_sr *sr);
698 extern int pri_sr_set_channel(struct pri_sr *sr, int channel, int exclusive, int nonisdn);
699 extern int pri_sr_set_bearer(struct pri_sr *sr, int transmode, int userl1, char *llc);
700 extern int pri_sr_set_called(struct pri_sr *sr, char *called, int calledplan, int complete);
701 extern int pri_sr_set_caller(struct pri_sr *sr, char *caller, char *callername, int callerplan, int callerpres);
702 extern int pri_sr_set_redirecting(struct pri_sr *sr, char *num, int plan, int pres, int reason);
703 #define PRI_USER_USER_TX
704 /* Set the user user field. Warning! don't send binary data accross this field */
705 extern void pri_sr_set_useruser(struct pri_sr *sr, const char *userchars);
707 extern void pri_call_set_useruser(q931_call *sr, const char *userchars);
709 extern int pri_setup(struct pri *pri, q931_call *call, struct pri_sr *req);
711 /* Set a call has a call indpendent signalling connection (i.e. no bchan) */
712 extern int pri_sr_set_connection_call_independent(struct pri_sr *req);
714 /* Send an MWI indication to a remote location. If activate is non zero, activates, if zero, decativates */
715 extern int pri_mwi_activate(struct pri *pri, q931_call *c, char *caller, int callerplan, char *callername, int callerpres, char *called, int calledplan);
717 /* Send an MWI deactivate request to a remote location */
718 extern int pri_mwi_deactivate(struct pri *pri, q931_call *c, char *caller, int callerplan, char *callername, int callerpres, char *called, int calledplan);
720 #define PRI_2BCT
721 /* Attempt to pass the channels back to the NET side if compatable and
722 * suscribed. Sometimes called 2 bchannel transfer (2BCT) */
723 int pri_channel_bridge(q931_call *call1, q931_call *call2);
725 /* Override message and error stuff */
726 #define PRI_NEW_SET_API
727 extern void pri_set_message(void (*__pri_error)(char *, int span));
728 extern void pri_set_error(void (*__pri_error)(char *, int span));
730 /* Set overlap mode */
731 #define PRI_SET_OVERLAPDIAL
732 extern void pri_set_overlapdial(struct pri *pri,int state);
734 #define PRI_DUMP_INFO_STR
735 extern char *pri_dump_info_str(struct pri *pri);
737 /* Get file descriptor */
738 extern int pri_fd(struct pri *pri);
740 #define PRI_PROGRESS
741 /* Send call proceeding */
742 extern int pri_progress(struct pri *pri, q931_call *c, int channel, int info);
744 #define PRI_PROCEEDING_FULL
745 /* Send call proceeding */
746 extern int pri_proceeding(struct pri *pri, q931_call *c, int channel, int info);
748 /* Enable inband progress when a DISCONNECT is received */
749 void pri_set_inbanddisconnect(struct pri *pri, unsigned int enable);
751 /* Enslave a PRI to another, so they share the same call list
752 (and maybe some timers) */
753 extern void pri_enslave(struct pri *master, struct pri *slave);
755 #define PRI_GR303_SUPPORT
756 #define PRI_ENSLAVE_SUPPORT
757 #define PRI_SETUP_CALL
758 #define PRI_RECEIVE_SUBADDR
759 #define PRI_REDIRECTING_REASON
760 #define PRI_AOC_UNITS
761 #define PRI_ANI
763 /* Send notification */
764 extern int pri_notify(struct pri *pri, q931_call *c, int channel, int info);
766 /* Get/Set PRI Timers */
767 #define PRI_GETSET_TIMERS
768 extern int pri_set_timer(struct pri *pri, int timer, int value);
769 extern int pri_get_timer(struct pri *pri, int timer);
770 extern int pri_timer2idx(char *timer);
772 #define PRI_MAX_TIMERS 32
774 #define PRI_TIMER_N200 0 /* Maximum numer of q921 retransmissions */
775 #define PRI_TIMER_N201 1 /* Maximum numer of octets in an information field */
776 #define PRI_TIMER_N202 2 /* Maximum numer of transmissions of the TEI identity request message */
777 #define PRI_TIMER_K 3 /* Maximum number of outstanding I-frames */
779 #define PRI_TIMER_T200 4 /* time between SABME's */
780 #define PRI_TIMER_T201 5 /* minimum time between retransmissions of the TEI Identity check messages */
781 #define PRI_TIMER_T202 6 /* minimum time between transmission of TEI Identity request messages */
782 #define PRI_TIMER_T203 7 /* maxiumum time without exchanging packets */
784 #define PRI_TIMER_T300 8
785 #define PRI_TIMER_T301 9 /* maximum time to respond to an ALERT */
786 #define PRI_TIMER_T302 10
787 #define PRI_TIMER_T303 11 /* maximum time to wait after sending a SETUP without a response */
788 #define PRI_TIMER_T304 12
789 #define PRI_TIMER_T305 13
790 #define PRI_TIMER_T306 14
791 #define PRI_TIMER_T307 15
792 #define PRI_TIMER_T308 16
793 #define PRI_TIMER_T309 17
794 #define PRI_TIMER_T310 18 /* maximum time between receiving a CALLPROCEEDING and receiving a ALERT/CONNECT/DISCONNECT/PROGRESS */
795 #define PRI_TIMER_T313 19
796 #define PRI_TIMER_T314 20
797 #define PRI_TIMER_T316 21 /* maximum time between transmitting a RESTART and receiving a RESTART ACK */
798 #define PRI_TIMER_T317 22
799 #define PRI_TIMER_T318 23
800 #define PRI_TIMER_T319 24
801 #define PRI_TIMER_T320 25
802 #define PRI_TIMER_T321 26
803 #define PRI_TIMER_T322 27
805 /* Get PRI version */
806 const char *pri_get_version(void);
808 #endif