예제 #1
0
파일: hci_sock.c 프로젝트: nhanh0/hah
static int hci_sock_create(struct socket *sock, int protocol)
{
	struct sock *sk;

	DBG("sock %p", sock);

	if (sock->type != SOCK_RAW)
		return -ESOCKTNOSUPPORT;

	sock->ops = &hci_sock_ops;

	if (!(sk = sk_alloc(PF_BLUETOOTH, GFP_KERNEL, 1)))
		return -ENOMEM;

	sock->state = SS_UNCONNECTED;
	sock_init_data(sock, sk);

	memset(&sk->protinfo, 0, sizeof(struct hci_pinfo));
	sk->destruct = NULL;
	sk->protocol = protocol;
	sk->state    = BT_OPEN;

	/* Initialize filter */
	hci_pi(sk)->filter.type_mask  = (1<<HCI_EVENT_PKT);
	hci_pi(sk)->filter.event_mask[0] = ~0L;
	hci_pi(sk)->filter.event_mask[1] = ~0L;

	bluez_sock_link(&hci_sk_list, sk);

	MOD_INC_USE_COUNT;

	return 0;
}
static int hci_sock_create(struct socket *sock, int protocol)
{
	struct sock *sk;

	BT_DBG("sock %p", sock);

	if (sock->type != SOCK_RAW)
		return -ESOCKTNOSUPPORT;

	sock->ops = &hci_sock_ops;

	if (!(sk = sk_alloc(PF_BLUETOOTH, GFP_KERNEL, 1)))
		return -ENOMEM;

	sock->state = SS_UNCONNECTED;
	sock_init_data(sock, sk);

	memset(&sk->protinfo, 0, sizeof(struct hci_pinfo));
	sk->destruct = NULL;
	sk->protocol = protocol;
	sk->state    = BT_OPEN;

	bluez_sock_link(&hci_sk_list, sk);

	MOD_INC_USE_COUNT;
	return 0;
}
예제 #3
0
static struct sock *l2cap_sock_alloc(struct socket *sock, int proto, int prio)
{
	struct sock *sk;

	if (!(sk = sk_alloc(PF_BLUETOOTH, prio, 1)))
		return NULL;

	bluez_sock_init(sock, sk);
	
	sk->zapped   = 0;

	sk->destruct = l2cap_sock_destruct;
	sk->sndtimeo = L2CAP_CONN_TIMEOUT;

	sk->protocol = proto;
	sk->state    = BT_OPEN;

	l2cap_sock_init_timer(sk);

	bluez_sock_link(&l2cap_sk_list, sk);

	MOD_INC_USE_COUNT;
	return sk;
}