Lines Matching full:handle
192 bt_activate(pcap_t* handle)
194 struct pcap_bt *handlep = handle->priv;
202 if (sscanf(handle->opt.device, BT_IFACE"%d", &dev_id) != 1)
204 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
206 handle->opt.device);
218 if (handle->snapshot <= 0 || handle->snapshot > MAXIMUM_SNAPLEN)
219 handle->snapshot = MAXIMUM_SNAPLEN;
222 handle->bufsize = BT_CTRL_SIZE+sizeof(pcap_bluetooth_h4_header)+handle->snapshot;
223 handle->linktype = DLT_BLUETOOTH_HCI_H4_WITH_PHDR;
225 handle->read_op = bt_read_linux;
226 handle->inject_op = bt_inject_linux;
227 handle->setfilter_op = pcapint_install_bpf_program; /* no kernel filtering */
228 handle->setdirection_op = bt_setdirection_linux;
229 handle->set_datalink_op = NULL; /* can't change data link type */
230 handle->getnonblock_op = pcapint_getnonblock_fd;
231 handle->setnonblock_op = pcapint_setnonblock_fd;
232 handle->stats_op = bt_stats_linux;
236 handle->fd = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
237 if (handle->fd < 0) {
238 pcapint_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
243 handle->buffer = malloc(handle->bufsize);
244 if (!handle->buffer) {
245 pcapint_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
251 if (setsockopt(handle->fd, SOL_HCI, HCI_DATA_DIR, &opt, sizeof(opt)) < 0) {
252 pcapint_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
258 if (setsockopt(handle->fd, SOL_HCI, HCI_TIME_STAMP, &opt, sizeof(opt)) < 0) {
259 pcapint_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
269 if (setsockopt(handle->fd, SOL_HCI, HCI_FILTER, &flt, sizeof(flt)) < 0) {
270 pcapint_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
282 if (bind(handle->fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
283 pcapint_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
288 if (handle->opt.rfmon) {
296 if (handle->opt.buffer_size != 0) {
300 if (setsockopt(handle->fd, SOL_SOCKET, SO_RCVBUF,
301 &handle->opt.buffer_size,
302 sizeof(handle->opt.buffer_size)) == -1) {
303 pcapint_fmt_errmsg_for_errno(handle->errbuf,
309 handle->selectable_fd = handle->fd;
313 pcapint_cleanup_live_common(handle);
318 bt_read_linux(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_char *user)
329 pktd = (u_char *)handle->buffer + BT_CTRL_SIZE;
332 iv.iov_len = handle->snapshot;
337 msg.msg_control = handle->buffer;
342 if (handle->break_loop)
344 handle->break_loop = 0;
347 ret = recvmsg(handle->fd, &msg, 0);
355 pcapint_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
379 switch (handle->direction) {
398 if (handle->fcode.bf_insns == NULL ||
399 pcapint_filter(handle->fcode.bf_insns, pktd, pkth.len, pkth.caplen)) {
407 bt_inject_linux(pcap_t *handle, const void *buf _U_, int size _U_)
409 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
416 bt_stats_linux(pcap_t *handle, struct pcap_stat *stats)
418 struct pcap_bt *handlep = handle->priv;
426 ret = ioctl(handle->fd, HCIGETDEVINFO, (void *)&dev_info);
430 pcapint_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,