Lines Matching full:handle
187 bt_activate(pcap_t* handle)
189 struct pcap_bt *handlep = handle->priv;
197 if (sscanf(handle->opt.source, BT_IFACE"%d", &dev_id) != 1)
199 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
201 handle->opt.source);
206 handle->bufsize = handle->snapshot+BT_CTRL_SIZE+sizeof(pcap_bluetooth_h4_header);
207 handle->offset = BT_CTRL_SIZE;
208 handle->linktype = DLT_BLUETOOTH_HCI_H4_WITH_PHDR;
210 handle->read_op = bt_read_linux;
211 handle->inject_op = bt_inject_linux;
212 handle->setfilter_op = install_bpf_program; /* no kernel filtering */
213 handle->setdirection_op = bt_setdirection_linux;
214 handle->set_datalink_op = NULL; /* can't change data link type */
215 handle->getnonblock_op = pcap_getnonblock_fd;
216 handle->setnonblock_op = pcap_setnonblock_fd;
217 handle->stats_op = bt_stats_linux;
221 handle->fd = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
222 if (handle->fd < 0) {
223 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
228 handle->buffer = malloc(handle->bufsize);
229 if (!handle->buffer) {
230 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't allocate dump buffer: %s",
236 if (setsockopt(handle->fd, SOL_HCI, HCI_DATA_DIR, &opt, sizeof(opt)) < 0) {
237 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
243 if (setsockopt(handle->fd, SOL_HCI, HCI_TIME_STAMP, &opt, sizeof(opt)) < 0) {
244 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
254 if (setsockopt(handle->fd, SOL_HCI, HCI_FILTER, &flt, sizeof(flt)) < 0) {
255 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
267 if (bind(handle->fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
268 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
274 if (handle->opt.rfmon) {
282 if (handle->opt.buffer_size != 0) {
286 if (setsockopt(handle->fd, SOL_SOCKET, SO_RCVBUF,
287 &handle->opt.buffer_size,
288 sizeof(handle->opt.buffer_size)) == -1) {
289 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
295 handle->selectable_fd = handle->fd;
299 pcap_cleanup_live_common(handle);
304 bt_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *user)
313 bthdr = (pcap_bluetooth_h4_header*) &handle->buffer[handle->offset];
314 iv.iov_base = &handle->buffer[handle->offset+sizeof(pcap_bluetooth_h4_header)];
315 iv.iov_len = handle->snapshot;
320 msg.msg_control = handle->buffer;
321 msg.msg_controllen = handle->offset;
325 ret = recvmsg(handle->fd, &msg, 0);
326 if (handle->break_loop)
328 handle->break_loop = 0;
334 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
356 if ((in && (handle->direction == PCAP_D_OUT)) ||
357 ((!in) && (handle->direction == PCAP_D_IN)))
363 if (handle->fcode.bf_insns == NULL ||
364 bpf_filter(handle->fcode.bf_insns, &handle->buffer[handle->offset],
366 callback(user, &pkth, &handle->buffer[handle->offset]);
373 bt_inject_linux(pcap_t *handle, const void *buf, size_t size)
375 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "inject not supported on "
382 bt_stats_linux(pcap_t *handle, struct pcap_stat *stats)
384 struct pcap_bt *handlep = handle->priv;
392 ret = ioctl(handle->fd, HCIGETDEVINFO, (void *)&dev_info);
396 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,