File Index
Files and directories
Sign in
FILE

capiutil.h

File preview with syntax highlighting.

linux-6.19.14/include/linux/isdn/capiutil.h C
 1/* $Id: capiutil.h,v 1.5.6.2 2001/09/23 22:24:33 kai Exp $
 2 *
 3 * CAPI 2.0 defines & types
 4 *
 5 * From CAPI 2.0 Development Kit AVM 1995 (msg.c)
 6 * Rewritten for Linux 1996 by Carsten Paeth <calle@calle.de>
 7 *
 8 * This software may be used and distributed according to the terms
 9 * of the GNU General Public License, incorporated herein by reference.
10 *
11 */
12
13#ifndef __CAPIUTIL_H__
14#define __CAPIUTIL_H__
15
16#include <asm/types.h>
17
18#define CAPIMSG_BASELEN		8
19#define CAPIMSG_U8(m, off)	(m[off])
20#define CAPIMSG_U16(m, off)	(m[off]|(m[(off)+1]<<8))
21#define CAPIMSG_U32(m, off)	(m[off]|(m[(off)+1]<<8)|(m[(off)+2]<<16)|(m[(off)+3]<<24))
22#define	CAPIMSG_LEN(m)		CAPIMSG_U16(m,0)
23#define	CAPIMSG_APPID(m)	CAPIMSG_U16(m,2)
24#define	CAPIMSG_COMMAND(m)	CAPIMSG_U8(m,4)
25#define	CAPIMSG_SUBCOMMAND(m)	CAPIMSG_U8(m,5)
26#define CAPIMSG_CMD(m)		(((m[4])<<8)|(m[5]))
27#define	CAPIMSG_MSGID(m)	CAPIMSG_U16(m,6)
28#define CAPIMSG_CONTROLLER(m)	(m[8] & 0x7f)
29#define CAPIMSG_CONTROL(m)	CAPIMSG_U32(m, 8)
30#define CAPIMSG_NCCI(m)		CAPIMSG_CONTROL(m)
31#define CAPIMSG_DATALEN(m)	CAPIMSG_U16(m,16) /* DATA_B3_REQ */
32
33static inline void capimsg_setu8(void *m, int off, __u8 val)
34{
35	((__u8 *)m)[off] = val;
36}
37
38static inline void capimsg_setu16(void *m, int off, __u16 val)
39{
40	((__u8 *)m)[off] = val & 0xff;
41	((__u8 *)m)[off+1] = (val >> 8) & 0xff;
42}
43
44static inline void capimsg_setu32(void *m, int off, __u32 val)
45{
46	((__u8 *)m)[off] = val & 0xff;
47	((__u8 *)m)[off+1] = (val >> 8) & 0xff;
48	((__u8 *)m)[off+2] = (val >> 16) & 0xff;
49	((__u8 *)m)[off+3] = (val >> 24) & 0xff;
50}
51
52#define	CAPIMSG_SETLEN(m, len)		capimsg_setu16(m, 0, len)
53#define	CAPIMSG_SETAPPID(m, applid)	capimsg_setu16(m, 2, applid)
54#define	CAPIMSG_SETCOMMAND(m,cmd)	capimsg_setu8(m, 4, cmd)
55#define	CAPIMSG_SETSUBCOMMAND(m, cmd)	capimsg_setu8(m, 5, cmd)
56#define	CAPIMSG_SETMSGID(m, msgid)	capimsg_setu16(m, 6, msgid)
57#define	CAPIMSG_SETCONTROL(m, contr)	capimsg_setu32(m, 8, contr)
58#define	CAPIMSG_SETDATALEN(m, len)	capimsg_setu16(m, 16, len)
59
60#endif				/* __CAPIUTIL_H__ */
~/ Read-only file preview.