Lines Matching defs:handle

196 bt_activate(pcap_t* handle)
198 struct pcap_bt *handlep = handle->priv;
206 if (sscanf(handle->opt.device, BT_IFACE"%d", &dev_id) != 1)
208 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
210 handle->opt.device);
222 if (handle->snapshot <= 0 || handle->snapshot > MAXIMUM_SNAPLEN)
223 handle->snapshot = MAXIMUM_SNAPLEN;
226 handle->bufsize = BT_CTRL_SIZE+sizeof(pcap_bluetooth_h4_header)+handle->snapshot;
227 handle->linktype = DLT_BLUETOOTH_HCI_H4_WITH_PHDR;
229 handle->read_op = bt_read_linux;
230 handle->inject_op = bt_inject_linux;
231 handle->setfilter_op = pcapint_install_bpf_program; /* no kernel filtering */
232 handle->setdirection_op = bt_setdirection_linux;
233 handle->set_datalink_op = NULL; /* can't change data link type */
234 handle->getnonblock_op = pcapint_getnonblock_fd;
235 handle->setnonblock_op = pcapint_setnonblock_fd;
236 handle->stats_op = bt_stats_linux;
240 handle->fd = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
241 if (handle->fd < 0) {
242 pcapint_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
247 handle->buffer = malloc(handle->bufsize);
248 if (!handle->buffer) {
249 pcapint_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
255 if (setsockopt(handle->fd, SOL_HCI, HCI_DATA_DIR, &opt, sizeof(opt)) < 0) {
256 pcapint_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
262 if (setsockopt(handle->fd, SOL_HCI, HCI_TIME_STAMP, &opt, sizeof(opt)) < 0) {
263 pcapint_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
273 if (setsockopt(handle->fd, SOL_HCI, HCI_FILTER, &flt, sizeof(flt)) < 0) {
274 pcapint_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
286 if (bind(handle->fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
287 pcapint_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
292 if (handle->opt.rfmon) {
300 if (handle->opt.buffer_size != 0) {
304 if (setsockopt(handle->fd, SOL_SOCKET, SO_RCVBUF,
305 &handle->opt.buffer_size,
306 sizeof(handle->opt.buffer_size)) == -1) {
307 pcapint_fmt_errmsg_for_errno(handle->errbuf,
313 handle->selectable_fd = handle->fd;
317 pcapint_cleanup_live_common(handle);
322 bt_read_linux(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_char *user)
333 pktd = (u_char *)handle->buffer + BT_CTRL_SIZE;
336 iv.iov_len = handle->snapshot;
341 msg.msg_control = handle->buffer;
346 if (handle->break_loop)
348 handle->break_loop = 0;
351 ret = recvmsg(handle->fd, &msg, 0);
359 pcapint_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
383 switch (handle->direction) {
402 if (handle->fcode.bf_insns == NULL ||
403 pcapint_filter(handle->fcode.bf_insns, pktd, pkth.len, pkth.caplen)) {
411 bt_inject_linux(pcap_t *handle, const void *buf _U_, int size _U_)
413 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
420 bt_stats_linux(pcap_t *handle, struct pcap_stat *stats)
422 struct pcap_bt *handlep = handle->priv;
430 ret = ioctl(handle->fd, HCIGETDEVINFO, (void *)&dev_info);
434 pcapint_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,