File: /usr/src/linux/include/net/bluetooth/bluetooth.h

1     /* 
2        BlueZ - Bluetooth protocol stack for Linux
3        Copyright (C) 2000-2001 Qualcomm Incorporated
4     
5        Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
6     
7        This program is free software; you can redistribute it and/or modify
8        it under the terms of the GNU General Public License version 2 as
9        published by the Free Software Foundation;
10     
11        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12        OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
14        IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
15        CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
16        WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
17        ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
18        OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19     
20        ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
21        COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
22        SOFTWARE IS DISCLAIMED.
23     */
24     
25     /*
26      *  $Id: bluetooth.h,v 1.6 2001/08/03 04:19:49 maxk Exp $
27      */
28     
29     #ifndef __BLUETOOTH_H
30     #define __BLUETOOTH_H
31     
32     #include <asm/types.h>
33     #include <asm/byteorder.h>
34     
35     #ifndef AF_BLUETOOTH
36     #define AF_BLUETOOTH	31
37     #define PF_BLUETOOTH	AF_BLUETOOTH
38     #endif
39     
40     #define BTPROTO_L2CAP   0
41     #define BTPROTO_HCI     1
42     
43     #define SOL_HCI     0
44     #define SOL_L2CAP   6
45     
46     /* Connection and socket states */
47     enum {
48     	BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */
49     	BT_OPEN,
50     	BT_BOUND,
51     	BT_LISTEN,
52     	BT_CONNECT,
53     	BT_CONFIG,
54     	BT_DISCONN,
55     	BT_CLOSED
56     };
57     
58     /* Endianness conversions */
59     #define htobs(a)	__cpu_to_le16(a)
60     #define htobl(a)	__cpu_to_le32(a)
61     #define btohs(a)	__le16_to_cpu(a)
62     #define btohl(a)	__le32_to_cpu(a)
63     
64     /* BD Address */
65     typedef struct {
66     	__u8 b[6];
67     } __attribute__((packed)) bdaddr_t;
68     
69     #define BDADDR_ANY ((bdaddr_t *)"\000\000\000\000\000")
70     
71     /* Copy, swap, convert BD Address */
72     static inline int bacmp(bdaddr_t *ba1, bdaddr_t *ba2)
73     {
74     	return memcmp(ba1, ba2, sizeof(bdaddr_t));
75     }
76     static inline void bacpy(bdaddr_t *dst, bdaddr_t *src)
77     {
78     	memcpy(dst, src, sizeof(bdaddr_t));
79     }
80     
81     void baswap(bdaddr_t *dst, bdaddr_t *src);
82     char *batostr(bdaddr_t *ba);
83     bdaddr_t *strtoba(char *str);
84     
85     int bterr(__u16 code);
86     
87     #endif /* __BLUETOOTH_H */
88