2005-04-17 02:20:36 +04:00
/*
BNEP protocol definition for Linux Bluetooth stack ( BlueZ ) .
Copyright ( C ) 2002 Maxim Krasnyansky < maxk @ qualcomm . com >
2007-02-09 17:24:33 +03:00
2005-04-17 02:20:36 +04:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License , version 2 , as
published by the Free Software Foundation .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
*/
# ifndef _BNEP_H
# define _BNEP_H
# include <linux/types.h>
# include <linux/crc32.h>
# include <net/bluetooth/bluetooth.h>
2011-03-21 16:19:58 +03:00
/* Limits */
# define BNEP_MAX_PROTO_FILTERS 5
# define BNEP_MAX_MULTICAST_FILTERS 20
/* UUIDs */
# define BNEP_BASE_UUID 0x0000000000001000800000805F9B34FB
# define BNEP_UUID16 0x02
# define BNEP_UUID32 0x04
# define BNEP_UUID128 0x16
# define BNEP_SVC_PANU 0x1115
# define BNEP_SVC_NAP 0x1116
# define BNEP_SVC_GN 0x1117
/* Packet types */
# define BNEP_GENERAL 0x00
# define BNEP_CONTROL 0x01
# define BNEP_COMPRESSED 0x02
# define BNEP_COMPRESSED_SRC_ONLY 0x03
# define BNEP_COMPRESSED_DST_ONLY 0x04
/* Control types */
# define BNEP_CMD_NOT_UNDERSTOOD 0x00
# define BNEP_SETUP_CONN_REQ 0x01
# define BNEP_SETUP_CONN_RSP 0x02
# define BNEP_FILTER_NET_TYPE_SET 0x03
# define BNEP_FILTER_NET_TYPE_RSP 0x04
# define BNEP_FILTER_MULTI_ADDR_SET 0x05
# define BNEP_FILTER_MULTI_ADDR_RSP 0x06
/* Extension types */
# define BNEP_EXT_CONTROL 0x00
/* Response messages */
# define BNEP_SUCCESS 0x00
# define BNEP_CONN_INVALID_DST 0x01
# define BNEP_CONN_INVALID_SRC 0x02
# define BNEP_CONN_INVALID_SVC 0x03
# define BNEP_CONN_NOT_ALLOWED 0x04
# define BNEP_FILTER_UNSUPPORTED_REQ 0x01
# define BNEP_FILTER_INVALID_RANGE 0x02
# define BNEP_FILTER_INVALID_MCADDR 0x02
# define BNEP_FILTER_LIMIT_REACHED 0x03
# define BNEP_FILTER_DENIED_SECURITY 0x04
/* L2CAP settings */
# define BNEP_MTU 1691
# define BNEP_PSM 0x0f
# define BNEP_FLUSH_TO 0xffff
# define BNEP_CONNECT_TO 15
# define BNEP_FILTER_TO 15
/* Headers */
# define BNEP_TYPE_MASK 0x7f
# define BNEP_EXT_HEADER 0x80
2005-04-17 02:20:36 +04:00
struct bnep_setup_conn_req {
2011-03-21 16:19:58 +03:00
__u8 type ;
__u8 ctrl ;
__u8 uuid_size ;
__u8 service [ 0 ] ;
2010-06-03 14:21:52 +04:00
} __packed ;
2005-04-17 02:20:36 +04:00
struct bnep_set_filter_req {
2011-03-21 16:19:58 +03:00
__u8 type ;
__u8 ctrl ;
2006-11-08 11:27:57 +03:00
__be16 len ;
2011-03-21 16:19:58 +03:00
__u8 list [ 0 ] ;
2010-06-03 14:21:52 +04:00
} __packed ;
2005-04-17 02:20:36 +04:00
struct bnep_control_rsp {
2011-03-21 16:19:58 +03:00
__u8 type ;
__u8 ctrl ;
2006-11-08 11:27:57 +03:00
__be16 resp ;
2010-06-03 14:21:52 +04:00
} __packed ;
2005-04-17 02:20:36 +04:00
struct bnep_ext_hdr {
2011-03-21 16:19:58 +03:00
__u8 type ;
__u8 len ;
__u8 data [ 0 ] ;
2010-06-03 14:21:52 +04:00
} __packed ;
2005-04-17 02:20:36 +04:00
/* BNEP ioctl defines */
# define BNEPCONNADD _IOW('B', 200, int)
# define BNEPCONNDEL _IOW('B', 201, int)
# define BNEPGETCONNLIST _IOR('B', 210, int)
# define BNEPGETCONNINFO _IOR('B', 211, int)
struct bnep_connadd_req {
2011-03-21 16:19:58 +03:00
int sock ; /* Connected socket */
2005-04-17 02:20:36 +04:00
__u32 flags ;
__u16 role ;
2011-03-21 16:19:58 +03:00
char device [ 16 ] ; /* Name of the Ethernet device */
2005-04-17 02:20:36 +04:00
} ;
struct bnep_conndel_req {
__u32 flags ;
__u8 dst [ ETH_ALEN ] ;
} ;
struct bnep_conninfo {
__u32 flags ;
__u16 role ;
2007-02-09 17:24:33 +03:00
__u16 state ;
2005-04-17 02:20:36 +04:00
__u8 dst [ ETH_ALEN ] ;
char device [ 16 ] ;
} ;
struct bnep_connlist_req {
__u32 cnum ;
struct bnep_conninfo __user * ci ;
} ;
struct bnep_proto_filter {
__u16 start ;
__u16 end ;
} ;
int bnep_add_connection ( struct bnep_connadd_req * req , struct socket * sock ) ;
int bnep_del_connection ( struct bnep_conndel_req * req ) ;
int bnep_get_connlist ( struct bnep_connlist_req * req ) ;
int bnep_get_conninfo ( struct bnep_conninfo * ci ) ;
2011-03-21 16:19:58 +03:00
/* BNEP sessions */
2005-04-17 02:20:36 +04:00
struct bnep_session {
struct list_head list ;
2007-02-09 17:24:33 +03:00
2005-04-17 02:20:36 +04:00
unsigned int role ;
2007-02-09 17:24:33 +03:00
unsigned long state ;
unsigned long flags ;
2005-04-17 02:20:36 +04:00
atomic_t killed ;
struct ethhdr eh ;
struct msghdr msg ;
struct bnep_proto_filter proto_filter [ BNEP_MAX_PROTO_FILTERS ] ;
2008-11-30 14:17:28 +03:00
unsigned long long mc_filter ;
2007-02-09 17:24:33 +03:00
2005-04-17 02:20:36 +04:00
struct socket * sock ;
struct net_device * dev ;
} ;
void bnep_net_setup ( struct net_device * dev ) ;
int bnep_sock_init ( void ) ;
2008-03-06 05:47:40 +03:00
void bnep_sock_cleanup ( void ) ;
2005-04-17 02:20:36 +04:00
static inline int bnep_mc_hash ( __u8 * addr )
{
2011-03-21 16:19:58 +03:00
return crc32_be ( ~ 0 , addr , ETH_ALEN ) > > 26 ;
2005-04-17 02:20:36 +04:00
}
# endif