static int hci_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) { struct sock *sk = sock->sk; int err; BT_DBG("cmd %x arg %lx", cmd, arg); switch (cmd) { case HCIGETDEVLIST: return hci_get_dev_list(arg); case HCIGETDEVINFO: return hci_get_dev_info(arg); case HCIGETCONNLIST: return hci_get_conn_list(arg); case HCIDEVUP: if (!capable(CAP_NET_ADMIN)) return -EACCES; return hci_dev_open(arg); case HCIDEVDOWN: if (!capable(CAP_NET_ADMIN)) return -EACCES; return hci_dev_close(arg); case HCIDEVRESET: if (!capable(CAP_NET_ADMIN)) return -EACCES; return hci_dev_reset(arg); case HCIDEVRESTAT: if (!capable(CAP_NET_ADMIN)) return -EACCES; return hci_dev_reset_stat(arg); case HCISETSCAN: case HCISETAUTH: case HCISETENCRYPT: case HCISETPTYPE: case HCISETLINKPOL: case HCISETLINKMODE: case HCISETACLMTU: case HCISETSCOMTU: if (!capable(CAP_NET_ADMIN)) return -EACCES; return hci_dev_cmd(cmd, arg); case HCIINQUIRY: return hci_inquiry(arg); default: lock_sock(sk); err = hci_sock_bound_ioctl(sk, cmd, arg); release_sock(sk); return err; }; }
static int hci_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) { struct sock *sk = sock->sk; struct hci_dev *hdev = hci_pi(sk)->hdev; __u32 mode; DBG("cmd %x arg %lx", cmd, arg); switch (cmd) { case HCIGETINFO: return hci_dev_info(arg); case HCIGETDEVLIST: return hci_dev_list(arg); case HCIDEVUP: if (!capable(CAP_NET_ADMIN)) return -EACCES; return hci_dev_open(arg); case HCIDEVDOWN: if (!capable(CAP_NET_ADMIN)) return -EACCES; return hci_dev_close(arg); case HCIDEVRESET: if (!capable(CAP_NET_ADMIN)) return -EACCES; return hci_dev_reset(arg); case HCIRESETSTAT: if (!capable(CAP_NET_ADMIN)) return -EACCES; return hci_dev_reset_stat(arg); case HCISETSCAN: if (!capable(CAP_NET_ADMIN)) return -EACCES; return hci_dev_setscan(arg); case HCISETAUTH: if (!capable(CAP_NET_ADMIN)) return -EACCES; return hci_dev_setauth(arg); case HCISETRAW: if (!capable(CAP_NET_ADMIN)) return -EACCES; if (!hdev) return -EBADFD; if (arg) mode = HCI_RAW; else mode = HCI_NORMAL; return hci_dev_setmode(hdev, mode); case HCISETPTYPE: if (!capable(CAP_NET_ADMIN)) return -EACCES; return hci_dev_setptype(arg); case HCIINQUIRY: return hci_inquiry(arg); case HCIGETCONNLIST: return hci_conn_list(arg); default: return -EINVAL; }; }