Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / sys / net / i4b / capi / capi_msgs.h
1 /*
2  * Copyright (c) 2001 Cubical Solutions Ltd. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23  * SUCH DAMAGE.
24  *
25  * capi/capi_msgs.h     The CAPI i4b message and handler declarations.
26  *
27  * $FreeBSD: src/sys/i4b/capi/capi_msgs.h,v 1.1.2.1 2001/08/10 14:08:34 obrien Exp $
28  * $DragonFly: src/sys/net/i4b/capi/capi_msgs.h,v 1.2 2003/06/17 04:28:39 dillon Exp $
29  */
30
31 #ifndef _I4B_CAPI_MSGS_H_
32 #define _I4B_CAPI_MSGS_H_
33
34 /* CAPI commands */
35
36 #define CAPI_ALERT                   0x01
37 #define CAPI_CONNECT                 0x02
38 #define CAPI_CONNECT_ACTIVE          0x03
39 #define CAPI_CONNECT_B3              0x82
40 #define CAPI_CONNECT_B3_ACTIVE       0x83
41 #define CAPI_CONNECT_B3_T90_ACTIVE   0x88
42 #define CAPI_DATA_B3                 0x86
43 #define CAPI_DISCONNECT_B3           0x84
44 #define CAPI_DISCONNECT              0x04
45 #define CAPI_FACILITY                0x80
46 #define CAPI_INFO                    0x08
47 #define CAPI_LISTEN                  0x05
48 #define CAPI_MANUFACTURER            0xff
49 #define CAPI_RESET_B3                0x87
50 #define CAPI_SELECT_B_PROTOCOL       0x41
51
52 /* CAPI subcommands */
53
54 #define CAPI_REQ                     0x80
55 #define CAPI_CONF                    0x81
56 #define CAPI_IND                     0x82
57 #define CAPI_RESP                    0x83
58
59 /* CAPI combined commands */
60
61 #define CAPICMD(cmd,subcmd)          (((subcmd)<<8)|(cmd))
62
63 #define CAPI_DISCONNECT_REQ          CAPICMD(CAPI_DISCONNECT,CAPI_REQ)
64 #define CAPI_DISCONNECT_CONF         CAPICMD(CAPI_DISCONNECT,CAPI_CONF)
65 #define CAPI_DISCONNECT_IND          CAPICMD(CAPI_DISCONNECT,CAPI_IND)
66 #define CAPI_DISCONNECT_RESP         CAPICMD(CAPI_DISCONNECT,CAPI_RESP)
67
68 #define CAPI_ALERT_REQ               CAPICMD(CAPI_ALERT,CAPI_REQ)
69 #define CAPI_ALERT_CONF              CAPICMD(CAPI_ALERT,CAPI_CONF)
70
71 #define CAPI_CONNECT_REQ             CAPICMD(CAPI_CONNECT,CAPI_REQ)
72 #define CAPI_CONNECT_CONF            CAPICMD(CAPI_CONNECT,CAPI_CONF)
73 #define CAPI_CONNECT_IND             CAPICMD(CAPI_CONNECT,CAPI_IND)
74 #define CAPI_CONNECT_RESP            CAPICMD(CAPI_CONNECT,CAPI_RESP)
75
76 #define CAPI_CONNECT_ACTIVE_REQ      CAPICMD(CAPI_CONNECT_ACTIVE,CAPI_REQ)
77 #define CAPI_CONNECT_ACTIVE_CONF     CAPICMD(CAPI_CONNECT_ACTIVE,CAPI_CONF)
78 #define CAPI_CONNECT_ACTIVE_IND      CAPICMD(CAPI_CONNECT_ACTIVE,CAPI_IND)
79 #define CAPI_CONNECT_ACTIVE_RESP     CAPICMD(CAPI_CONNECT_ACTIVE,CAPI_RESP)
80
81 #define CAPI_SELECT_B_PROTOCOL_REQ   CAPICMD(CAPI_SELECT_B_PROTOCOL,CAPI_REQ)
82 #define CAPI_SELECT_B_PROTOCOL_CONF  CAPICMD(CAPI_SELECT_B_PROTOCOL,CAPI_CONF)
83
84 #define CAPI_CONNECT_B3_REQ          CAPICMD(CAPI_CONNECT_B3,CAPI_REQ)
85 #define CAPI_CONNECT_B3_CONF         CAPICMD(CAPI_CONNECT_B3,CAPI_CONF)
86 #define CAPI_CONNECT_B3_IND          CAPICMD(CAPI_CONNECT_B3,CAPI_IND)
87 #define CAPI_CONNECT_B3_RESP         CAPICMD(CAPI_CONNECT_B3,CAPI_RESP)
88
89 #define CAPI_CONNECT_B3_ACTIVE_REQ   CAPICMD(CAPI_CONNECT_B3_ACTIVE,CAPI_REQ)
90 #define CAPI_CONNECT_B3_ACTIVE_CONF  CAPICMD(CAPI_CONNECT_B3_ACTIVE,CAPI_CONF)
91 #define CAPI_CONNECT_B3_ACTIVE_IND   CAPICMD(CAPI_CONNECT_B3_ACTIVE,CAPI_IND)
92 #define CAPI_CONNECT_B3_ACTIVE_RESP  CAPICMD(CAPI_CONNECT_B3_ACTIVE,CAPI_RESP)
93
94 #define CAPI_CONNECT_B3_T90_ACTIVE_IND CAPICMD(CAPI_CONNECT_B3_T90_ACTIVE,CAPI_IND)
95 #define CAPI_CONNECT_B3_T90_ACTIVE_RESP CAPICMD(CAPI_CONNECT_B3_T90_ACTIVE,CAPI_RESP)
96
97 #define CAPI_DATA_B3_REQ             CAPICMD(CAPI_DATA_B3,CAPI_REQ)
98 #define CAPI_DATA_B3_CONF            CAPICMD(CAPI_DATA_B3,CAPI_CONF)
99 #define CAPI_DATA_B3_IND             CAPICMD(CAPI_DATA_B3,CAPI_IND)
100 #define CAPI_DATA_B3_RESP            CAPICMD(CAPI_DATA_B3,CAPI_RESP)
101
102 #define CAPI_DISCONNECT_B3_REQ       CAPICMD(CAPI_DISCONNECT_B3,CAPI_REQ)
103 #define CAPI_DISCONNECT_B3_CONF      CAPICMD(CAPI_DISCONNECT_B3,CAPI_CONF)
104 #define CAPI_DISCONNECT_B3_IND       CAPICMD(CAPI_DISCONNECT_B3,CAPI_IND)
105 #define CAPI_DISCONNECT_B3_RESP      CAPICMD(CAPI_DISCONNECT_B3,CAPI_RESP)
106
107 #define CAPI_RESET_B3_REQ            CAPICMD(CAPI_RESET_B3,CAPI_REQ)
108 #define CAPI_RESET_B3_CONF           CAPICMD(CAPI_RESET_B3,CAPI_CONF)
109 #define CAPI_RESET_B3_IND            CAPICMD(CAPI_RESET_B3,CAPI_IND)
110 #define CAPI_RESET_B3_RESP           CAPICMD(CAPI_RESET_B3,CAPI_RESP)
111
112 #define CAPI_LISTEN_REQ              CAPICMD(CAPI_LISTEN,CAPI_REQ)
113 #define CAPI_LISTEN_CONF             CAPICMD(CAPI_LISTEN,CAPI_CONF)
114
115 #define CAPI_MANUFACTURER_REQ        CAPICMD(CAPI_MANUFACTURER,CAPI_REQ)
116 #define CAPI_MANUFACTURER_CONF       CAPICMD(CAPI_MANUFACTURER,CAPI_CONF)
117 #define CAPI_MANUFACTURER_IND        CAPICMD(CAPI_MANUFACTURER,CAPI_IND)
118 #define CAPI_MANUFACTURER_RESP       CAPICMD(CAPI_MANUFACTURER,CAPI_RESP)
119
120 #define CAPI_FACILITY_REQ            CAPICMD(CAPI_FACILITY,CAPI_REQ)
121 #define CAPI_FACILITY_CONF           CAPICMD(CAPI_FACILITY,CAPI_CONF)
122 #define CAPI_FACILITY_IND            CAPICMD(CAPI_FACILITY,CAPI_IND)
123 #define CAPI_FACILITY_RESP           CAPICMD(CAPI_FACILITY,CAPI_RESP)
124
125 #define CAPI_INFO_REQ                CAPICMD(CAPI_INFO,CAPI_REQ)
126 #define CAPI_INFO_CONF               CAPICMD(CAPI_INFO,CAPI_CONF)
127 #define CAPI_INFO_IND                CAPICMD(CAPI_INFO,CAPI_IND)
128 #define CAPI_INFO_RESP               CAPICMD(CAPI_INFO,CAPI_RESP)
129
130 /* CAPI message access helpers */
131
132 /*
133  * CAPI message header:
134  * word   Length
135  * word   ApplId
136  * byte   Command
137  * byte   Subcommand
138  * word   MsgId
139  *
140  * Note that in the following, Controller/PLCI/NCCI is coded as follows:
141  * bits 0..6 = controller, bit 7 = ext/int, bits 8..15 = PLCI, and
142  * bits 16..31 = NCCI value.
143  *
144  * ALERT_REQ, 01 80:
145  * dword  PLCI
146  * struct Additional Info
147  *
148  * ALERT_CONF, 01 81:
149  * dword  PLCI
150  * word   Info (0 = OK, other = cause)
151  *
152  * CONNECT_REQ, 02 80:
153  * dword  controller
154  * word   CIP
155  * struct Called party number
156  * struct Calling party number
157  * struct Called party subaddress
158  * struct Calling party subaddress
159  * struct Bearer Capability
160  * struct Low Layer Compatibility
161  * struct High Layer Compatibility
162  * struct Additional Info
163  *
164  * CONNECT_CONF, 02 81:
165  * dword  PLCI
166  * word   Info (0 = OK, other = cause)
167  *
168  * CONNECT_IND, 02 82:
169  * dword  PLCI
170  * word   CIP
171  * struct Called party number
172  * struct Calling party number
173  * struct Called party subaddress
174  * struct Calling party subaddress
175  * struct Bearer Capability
176  * struct Low Layer Compatibility
177  * struct High Layer Compatibility
178  * struct Additional Info
179  * struct Second Calling party number
180  *
181  * CONNECT_RESP, 02 83:
182  * dword  PLCI
183  * word   Reject (0 = accept, 1 = ignore, 2 = reject/normal clearing)
184  * struct B protocol
185  * struct Connected number
186  * struct Connected subaddress
187  * struct Low Layer Compatibility
188  * struct Additional Info
189  *
190  * CONNECT_ACTIVE_IND, 03 82:
191  * dword  PLCI
192  * struct Connected number
193  * struct Connected subaddress
194  * struct Low Layer Compatibility
195  *
196  * CONNECT_ACTIVE_RESP, 03 83:
197  * dword  PLCI
198  *
199  * CONNECT_B3_REQ, 82 80:
200  * dword  PLCI
201  * struct NCPI
202  *
203  * CONNECT_B3_CONF, 82 81:
204  * dword  NCCI
205  * word   Info (0 = connected, other = cause)
206  *
207  * CONNECT_B3_IND, 82 82:
208  * dword  NCCI
209  * struct NCPI
210  *
211  * CONNECT_B3_RESP, 82 83:
212  * dword  NCCI
213  * word   Reject (0 = accept, 2 = reject/normal clearing)
214  * struct NCPI
215  *
216  * CONNECT_B3_ACTIVE_IND, 83 82:
217  * dword  NCCI
218  * struct NCPI
219  *
220  * CONNECT_B3_ACTIVE_RESP, 83  83:
221  * dword  NCCI
222  *
223  * DATA_B3_REQ, 86 80:
224  * dword  NCCI
225  * dword  Data pointer
226  * word   Data length
227  * word   Data handle (packet id)
228  * word   Flags (02 = more)
229  *
230  * DATA_B3_CONF, 86 81:
231  * dword  NCCI
232  * word   Data handle (packet id)
233  * word   Info (0 = OK, other = cause)
234  *
235  * DATA_B3_IND, 86 82:
236  * dword  NCCI
237  * dword  Data pointer
238  * word   Data length
239  * word   Data handle (packet id)
240  * word   Flags (02 = more)
241  *
242  * DATA_B3_RESP, 86 83:
243  * dword  NCCI
244  * word   Data handle (packet id)
245  *
246  * DISCONNECT_B3_REQ, 84 80:
247  * dword  NCCI
248  * struct NCPI
249  *
250  * DISCONNECT_B3_CONF, 84 81:
251  * dword  NCCI
252  * word   Info (0 = OK, other = cause)
253  *
254  * DISCONNECT_B3_IND, 84 82:
255  * dword  NCCI
256  * word   Reason
257  * struct NCPI
258  *
259  * DISCONNECT_B3_RESP, 84 83:
260  * dword  NCCI
261  *
262  * DISCONNECT_REQ, 04 80:
263  * dword  PLCI
264  * struct Additional Info
265  *
266  * DISCONNECT_CONF, 04 81:
267  * dword  PLCI
268  * word   Info (0 = OK, other = cause)
269  *
270  * DISCONNECT_IND, 04 82:
271  * dword  PLCI
272  * word   Reason
273  *
274  * DISCONNECT_RESP, 04 83:
275  * dword  PLCI
276  *
277  * LISTEN_REQ, 05 80:
278  * dword  Controller
279  * dword  Info mask (bits 0..9 used)
280  * dword  CIP Mask (bit 0 = any match)
281  * dword  CIP Mask 2 (bit 0 = any match)
282  * struct Calling party number
283  * struct Calling party subaddress
284  *
285  * LISTEN_CONF, 05 81:
286  * dword  Controller
287  * word   Info (0 = OK, other = cause)
288  *
289  * INFO_REQ, 08 80:
290  * dword  Controller/PLCI
291  * struct Called party number
292  * struct Additional Info
293  *
294  * INFO_CONF, 08 81:
295  * dword  Controller/PLCI
296  * word   Info (0 = OK, other = cause)
297  *
298  * INFO_IND, 08 82:
299  * dword  Controller/PLCI
300  * word   Info number
301  * struct Info element
302  *
303  * INFO_RESP, 08 83:
304  * dword  Controller/PLCI
305  */
306
307 #define CAPIMSG_LEN(msg)             (msg[0]|(msg[1]<<8))
308 #define CAPIMSG_DATALEN(msg)         (msg[16]|(msg[17]<<8))
309
310 static __inline u_int8_t* capimsg_getu8(u_int8_t *msg, u_int8_t *val)
311 {
312     *val = *msg;
313     return (msg + 1);
314 }
315
316 static __inline u_int8_t* capimsg_getu16(u_int8_t *msg, u_int16_t *val)
317 {
318     *val = (msg[0]|(msg[1]<<8));
319     return (msg + 2);
320 }
321
322 static __inline u_int8_t* capimsg_getu32(u_int8_t *msg, u_int32_t *val)
323 {
324     *val = (msg[0]|(msg[1]<<8)|(msg[2]<<16)|(msg[3]<<24));
325     return (msg + 4);
326 }
327
328 static __inline u_int8_t* capimsg_setu8(u_int8_t *msg, u_int8_t val)
329 {
330     msg[0] = val;
331     return (msg + 1);
332 }
333
334 static __inline u_int8_t* capimsg_setu16(u_int8_t *msg, u_int16_t val)
335 {
336     msg[0] = (val & 0xff);
337     msg[1] = (val >> 8) & 0xff;
338     return (msg + 2);
339 }
340
341 static __inline u_int8_t* capimsg_setu32(u_int8_t *msg, u_int32_t val)
342 {
343     msg[0] = (val & 0xff);
344     msg[1] = (val >> 8) & 0xff;
345     msg[2] = (val >> 16) & 0xff;
346     msg[3] = (val >> 24) & 0xff;
347     return (msg + 4);
348 }
349
350 /*
351 //  CAPI message handlers called by higher layers
352 */
353
354 extern void capi_listen_req(capi_softc_t *sc, u_int32_t CIP);
355 extern void capi_alert_req(capi_softc_t *sc, call_desc_t *cd);
356 extern void capi_connect_req(capi_softc_t *sc, call_desc_t *cd);
357 extern void capi_connect_b3_req(capi_softc_t *sc, call_desc_t *cd);
358 extern void capi_connect_resp(capi_softc_t *sc, call_desc_t *cd);
359 extern void capi_data_b3_req(capi_softc_t *sc, int chan, struct mbuf *m);
360 extern void capi_disconnect_req(capi_softc_t *sc, call_desc_t *cd);
361
362 /*
363 //  CAPI message handlers called by the receive routine
364 */
365
366 extern void capi_listen_conf(capi_softc_t *sc, struct mbuf *m);
367 extern void capi_info_ind(capi_softc_t *sc, struct mbuf *m);
368 extern void capi_alert_conf(capi_softc_t *sc, struct mbuf *m);
369 extern void capi_connect_conf(capi_softc_t *sc, struct mbuf *m);
370 extern void capi_connect_active_ind(capi_softc_t *sc, struct mbuf *m);
371 extern void capi_connect_b3_conf(capi_softc_t *sc, struct mbuf *m);
372 extern void capi_connect_b3_active_ind(capi_softc_t *sc, struct mbuf *m);
373 extern void capi_connect_ind(capi_softc_t *sc, struct mbuf *m);
374 extern void capi_connect_b3_ind(capi_softc_t *sc, struct mbuf *m);
375 extern void capi_data_b3_conf(capi_softc_t *sc, struct mbuf *m);
376 extern void capi_data_b3_ind(capi_softc_t *sc, struct mbuf *m);
377 extern void capi_disconnect_conf(capi_softc_t *sc, struct mbuf *m);
378 extern void capi_disconnect_b3_ind(capi_softc_t *sc, struct mbuf *m);
379 extern void capi_disconnect_ind(capi_softc_t *sc, struct mbuf *m);
380
381 #endif /* _I4B_CAPI_MSGS_H_ */