Ignore files generated in the dependency checks.
[libpri-bristuff.git] / pri_q931.h
blob196720d8cd7c6190cda90f4be9bc711b4db722e8
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 _PRI_Q931_H
26 #define _PRI_Q931_H
28 typedef enum q931_state {
29 /* User states */
30 U0_NULL_STATE,
31 U1_CALL_INITIATED,
32 U2_OVERLAP_SENDING,
33 U3_OUTGOING_CALL_PROCEEDING,
34 U4_CALL_DELIVERED,
35 U6_CALL_PRESENT,
36 U7_CALL_RECEIVED,
37 U8_CONNECT_REQUEST,
38 U9_INCOMING_CALL_PROCEEDING,
39 U10_ACTIVE,
40 U11_DISCONNECT_REQUEST,
41 U12_DISCONNECT_INDICATION,
42 U15_SUSPEND_REQUEST,
43 U17_RESUME_REQUEST,
44 U19_RELEASE_REQUEST,
45 U25_OVERLAP_RECEIVING,
46 /* Network states */
47 N0_NULL_STATE,
48 N1_CALL_INITIATED,
49 N2_OVERLAP_SENDING,
50 N3_OUTGOING_CALL_PROCEEDING,
51 N4_CALL_DELIVERED,
52 N6_CALL_PRESENT,
53 N7_CALL_RECEIVED,
54 N8_CONNECT_REQUEST,
55 N9_INCOMING_CALL_PROCEEDING,
56 N10_ACTIVE,
57 N11_DISCONNECT_REQUEST,
58 N12_DISCONNECT_INDICATION,
59 N15_SUSPEND_REQUEST,
60 N17_RESUME_REQUEST,
61 N19_RELEASE_REQUEST,
62 N22_CALL_ABORT,
63 N25_OVERLAP_RECEIVING
64 } q931_state;
66 typedef enum q931_mode {
67 UNKNOWN_MODE,
68 CIRCUIT_MODE,
69 PACKET_MODE
70 } q931_mode;
72 typedef struct q931_h {
73 unsigned char raw[0];
74 u_int8_t pd; /* Protocol Discriminator */
75 #if __BYTE_ORDER == __BIG_ENDIAN
76 u_int8_t x0:4;
77 u_int8_t crlen:4;
78 #else
79 u_int8_t crlen:4;
80 u_int8_t x0:4;
81 #endif
82 u_int8_t contents[0];
83 u_int8_t crv[3];
84 } __attribute__ ((packed)) q931_h;
87 /* Message type header */
88 typedef struct q931_mh {
89 #if __BYTE_ORDER == __BIG_ENDIAN
90 u_int8_t f:1;
91 u_int8_t msg:7;
92 #else
93 u_int8_t msg:7;
94 u_int8_t f:1;
95 #endif
96 u_int8_t data[0];
97 } __attribute__ ((packed)) q931_mh;
99 /* Information element format */
100 typedef struct q931_ie {
101 u_int8_t ie;
102 u_int8_t len;
103 u_int8_t data[0];
104 } __attribute__ ((packed)) q931_ie;
106 #define Q931_RES_HAVEEVENT (1 << 0)
107 #define Q931_RES_INERRROR (1 << 1)
109 #define Q931_PROTOCOL_DISCRIMINATOR 0x08
110 #define GR303_PROTOCOL_DISCRIMINATOR 0x4f
112 /* Q.931 / National ISDN Message Types */
114 /* Call Establishment Messages */
115 #define Q931_ALERTING 0x01
116 #define Q931_CALL_PROCEEDING 0x02
117 #define Q931_CONNECT 0x07
118 #define Q931_CONNECT_ACKNOWLEDGE 0x0f
119 #define Q931_PROGRESS 0x03
120 #define Q931_SETUP 0x05
121 #define Q931_SETUP_ACKNOWLEDGE 0x0d
123 /* Call Disestablishment Messages */
124 #define Q931_DISCONNECT 0x45
125 #define Q931_RELEASE 0x4d
126 #define Q931_RELEASE_COMPLETE 0x5a
127 #define Q931_RESTART 0x46
128 #define Q931_RESTART_ACKNOWLEDGE 0x4e
130 /* Miscellaneous Messages */
131 #define Q931_STATUS 0x7d
132 #define Q931_STATUS_ENQUIRY 0x75
133 #define Q931_USER_INFORMATION 0x20
134 #define Q931_SEGMENT 0x60
135 #define Q931_CONGESTION_CONTROL 0x79
136 #define Q931_INFORMATION 0x7b
137 #define Q931_FACILITY 0x62
138 #define Q931_NOTIFY 0x6e
140 /* Call Management Messages */
141 #define Q931_HOLD 0x24
142 #define Q931_HOLD_ACKNOWLEDGE 0x28
143 #define Q931_HOLD_REJECT 0x30
144 #define Q931_RETRIEVE 0x31
145 #define Q931_RETRIEVE_ACKNOWLEDGE 0x33
146 #define Q931_RETRIEVE_REJECT 0x37
147 #define Q931_RESUME 0x26
148 #define Q931_RESUME_ACKNOWLEDGE 0x2e
149 #define Q931_RESUME_REJECT 0x22
150 #define Q931_SUSPEND 0x25
151 #define Q931_SUSPEND_ACKNOWLEDGE 0x2d
152 #define Q931_SUSPEND_REJECT 0x21
154 /* Maintenance messages (codeset 0 only) */
155 #define NATIONAL_SERVICE 0x0f
156 #define NATIONAL_SERVICE_ACKNOWLEDGE 0x07
158 /* Special codeset 0 IE */
159 #define NATIONAL_CHANGE_STATUS 0x1
161 /* Q.931 / National ISDN Information Elements */
162 #define Q931_LOCKING_SHIFT 0x90
163 #define Q931_NON_LOCKING_SHIFT 0x98
164 #define Q931_BEARER_CAPABILITY 0x04
165 #define Q931_CAUSE 0x08
166 #define Q931_CALL_STATE 0x14
167 #define Q931_CHANNEL_IDENT 0x18
168 #define Q931_PROGRESS_INDICATOR 0x1e
169 #define Q931_NETWORK_SPEC_FAC 0x20
170 #define Q931_INFORMATION_RATE 0x40
171 #define Q931_TRANSIT_DELAY 0x42
172 #define Q931_TRANS_DELAY_SELECT 0x43
173 #define Q931_BINARY_PARAMETERS 0x44
174 #define Q931_WINDOW_SIZE 0x45
175 #define Q931_PACKET_SIZE 0x46
176 #define Q931_CLOSED_USER_GROUP 0x47
177 #define Q931_REVERSE_CHARGE_INDIC 0x4a
178 #define Q931_CALLING_PARTY_NUMBER 0x6c
179 #define Q931_CALLING_PARTY_SUBADDR 0x6d
180 #define Q931_CALLED_PARTY_NUMBER 0x70
181 #define Q931_CALLED_PARTY_SUBADDR 0x71
182 #define Q931_REDIRECTING_NUMBER 0x74
183 #define Q931_REDIRECTING_SUBADDR 0x75
184 #define Q931_TRANSIT_NET_SELECT 0x78
185 #define Q931_RESTART_INDICATOR 0x79
186 #define Q931_LOW_LAYER_COMPAT 0x7c
187 #define Q931_HIGH_LAYER_COMPAT 0x7d
189 #define Q931_CODESET(x) ((x) << 8)
190 #define Q931_IE_CODESET(x) ((x) >> 8)
191 #define Q931_IE_IE(x) ((x) & 0xff)
192 #define Q931_FULL_IE(codeset, ie) (((codeset) << 8) | ((ie) & 0xff))
193 #define Q931_IE_MAX_LEN 257
195 // BRI+
196 #define Q931_COLP 0x4c
198 #define Q931_DISPLAY 0x28
199 #define Q931_IE_SEGMENTED_MSG 0x00
200 #define Q931_IE_CHANGE_STATUS 0x01
201 #define Q931_IE_ORIGINATING_LINE_INFO (0x01 | Q931_CODESET(6))
202 #define Q931_IE_CONNECTED_ADDR 0x0C
203 #define Q931_IE_CONNECTED_NUM 0x4C
204 #define Q931_IE_CALL_IDENTITY 0x10
205 #define Q931_IE_FACILITY 0x1c
206 #define Q931_IE_ENDPOINT_ID 0x26
207 #define Q931_IE_NOTIFY_IND 0x27
208 #define Q931_IE_TIME_DATE 0x29
209 #define Q931_IE_KEYPAD_FACILITY 0x2c
210 #define Q931_IE_CALL_STATUS 0x2d
211 #define Q931_IE_UPDATE 0x31
212 #define Q931_IE_INFO_REQUEST 0x32
213 #define Q931_IE_SIGNAL 0x34
214 #define Q931_IE_SWITCHHOOK 0x36
215 #define Q931_IE_GENERIC_DIGITS (0x37 | Q931_CODESET(6))
216 #define Q931_IE_FEATURE_ACTIVATE 0x38
217 #define Q931_IE_FEATURE_IND 0x39
218 #define Q931_IE_ORIGINAL_CALLED_NUMBER 0x73
219 #define Q931_IE_REDIRECTION_NUMBER 0x76
220 #define Q931_IE_REDIRECTION_SUBADDR 0x77
221 #define Q931_IE_USER_USER_FACILITY 0x7A
222 #define Q931_IE_USER_USER 0x7E
223 #define Q931_IE_ESCAPE_FOR_EXT 0x7F
225 #define Q931_IE_SPECIAL 0x02
228 /* Call state stuff */
229 #define Q931_CALL_STATE_NULL 0
230 #define Q931_CALL_STATE_CALL_INITIATED 1
231 #define Q931_CALL_STATE_OVERLAP_SENDING 2
232 #define Q931_CALL_STATE_OUTGOING_CALL_PROCEEDING 3
233 #define Q931_CALL_STATE_CALL_DELIVERED 4
234 #define Q931_CALL_STATE_CALL_PRESENT 6
235 #define Q931_CALL_STATE_CALL_RECEIVED 7
236 #define Q931_CALL_STATE_CONNECT_REQUEST 8
237 #define Q931_CALL_STATE_INCOMING_CALL_PROCEEDING 9
238 #define Q931_CALL_STATE_ACTIVE 10
239 #define Q931_CALL_STATE_DISCONNECT_REQUEST 11
240 #define Q931_CALL_STATE_DISCONNECT_INDICATION 12
241 #define Q931_CALL_STATE_SUSPEND_REQUEST 15
242 #define Q931_CALL_STATE_RESUME_REQUEST 17
243 #define Q931_CALL_STATE_RELEASE_REQUEST 19
244 #define Q931_CALL_STATE_OVERLAP_RECEIVING 25
245 #define Q931_CALL_STATE_RESTART_REQUEST 61
246 #define Q931_CALL_STATE_RESTART 62
249 /* EuroISDN */
250 #define Q931_SENDING_COMPLETE 0xa1
253 /* Q.SIG specific */
254 #define QSIG_IE_TRANSIT_COUNT 0x31
256 extern int q931_receive(struct pri *pri, q931_h *h, int len, int tei);
258 extern int q931_alerting(struct pri *pri, q931_call *call, int channel, int info);
260 extern int q931_call_progress(struct pri *pri, q931_call *call, int channel, int info);
262 extern int q931_notify(struct pri *pri, q931_call *call, int channel, int info);
264 extern int q931_call_proceeding(struct pri *pri, q931_call *call, int channel, int info);
266 extern int q931_setup_ack(struct pri *pri, q931_call *call, int channel, int nonisdn);
268 extern int q931_information(struct pri *pri, q931_call *call, char digit);
270 extern int q931_keypad_facility(struct pri *pri, q931_call *call, char *digits);
272 extern int q931_information_display(struct pri *pri, q931_call *call, char *display);
274 extern int q931_add_display(struct pri *pri, q931_call *call, char *display);
276 extern int q931_connect(struct pri *pri, q931_call *call, int channel, int nonisdn);
278 extern int q931_release(struct pri *pri, q931_call *call, int cause);
280 extern int q931_disconnect(struct pri *pri, q931_call *call, int cause);
282 extern int q931_hangup(struct pri *pri, q931_call *call, int cause);
284 extern int q921_hangup(struct pri *pri, q931_call *c, int tei);
286 extern int q921_handle_hangup(struct pri *pri, q931_call *c, int tei);
288 extern int q931_restart(struct pri *pri, int channel);
290 extern int q931_facility(struct pri *pri, q931_call *call);
292 extern int q931_call_getcrv(struct pri *pri, q931_call *call, int *callmode);
294 extern int q931_call_setcrv(struct pri *pri, q931_call *call, int crv, int callmode);
296 extern q931_call *q931_new_call(struct pri *pri);
298 extern int q931_setup(struct pri *pri, q931_call *c, struct pri_sr *req);
299 extern void q931_dump(struct pri *pri, q931_h *h, int len, int txrx);
301 extern void __q931_destroycall(struct pri *pri, q931_call *c);
303 extern int q931_hold_acknowledge(struct pri *pri, q931_call *c);
305 extern int q931_hold_reject(struct pri *pri, q931_call *c);
307 extern int q931_retrieve_acknowledge(struct pri *pri, q931_call *c, int channel);
309 extern int q931_retrieve_reject(struct pri *pri, q931_call *c);
311 extern int q931_suspend_acknowledge(struct pri *pri, q931_call *c, char *display);
313 extern int q931_suspend_reject(struct pri *pri, q931_call *c, char *display);
315 extern int q931_resume_reject(struct pri *pri, q931_call *c, char *display);
317 extern int q931_resume_acknowledge(struct pri *pri, q931_call *c, int channel, char *display);
319 extern void q931_dl_indication(struct pri *pri, int event);
321 #endif