• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/libpcap-1.4.0/

Lines Matching defs:handle

205 int usb_mmap(pcap_t* handle)
207 int len = ioctl(handle->fd, MON_IOCQ_RING_SIZE);
211 handle->md.mmapbuflen = len;
212 handle->md.mmapbuf = mmap(0, handle->md.mmapbuflen, PROT_READ,
213 MAP_SHARED, handle->fd, 0);
214 return handle->md.mmapbuf != MAP_FAILED;
330 usb_activate(pcap_t* handle)
335 handle->bufsize = handle->snapshot;
336 handle->offset = 0;
337 handle->linktype = DLT_USB_LINUX;
339 handle->inject_op = usb_inject_linux;
340 handle->setfilter_op = install_bpf_program; /* no kernel filtering */
341 handle->setdirection_op = usb_setdirection_linux;
342 handle->set_datalink_op = NULL; /* can't change data link type */
343 handle->getnonblock_op = pcap_getnonblock_fd;
344 handle->setnonblock_op = pcap_setnonblock_fd;
347 if (sscanf(handle->opt.source, USB_IFACE"%d", &handle->md.ifindex) != 1)
349 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
350 "Can't get USB bus index from %s", handle->opt.source);
355 snprintf(full_path, USB_LINE_LEN, LINUX_USB_MON_DEV"%d", handle->md.ifindex);
356 handle->fd = open(full_path, O_RDONLY, 0);
357 if (handle->fd >= 0)
359 if (handle->opt.rfmon) {
363 close(handle->fd);
368 if (usb_mmap(handle)) {
369 handle->linktype = DLT_USB_LINUX_MMAPPED;
370 handle->stats_op = usb_stats_linux_bin;
371 handle->read_op = usb_read_linux_mmap;
372 handle->cleanup_op = usb_cleanup_linux_mmap;
373 probe_devices(handle->md.ifindex);
376 * "handle->fd" is a real file, so "select()" and
379 handle->selectable_fd = handle->fd;
384 handle->stats_op = usb_stats_linux_bin;
385 handle->read_op = usb_read_linux_bin;
386 probe_devices(handle->md.ifindex);
390 snprintf(full_path, USB_LINE_LEN, USB_TEXT_DIR"/%dt", handle->md.ifindex);
391 handle->fd = open(full_path, O_RDONLY, 0);
392 if (handle->fd < 0)
400 snprintf(full_path, USB_LINE_LEN, USB_TEXT_DIR_OLD"/%dt", handle->md.ifindex);
401 handle->fd = open(full_path, O_RDONLY, 0);
403 if (handle->fd < 0) {
405 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
411 if (handle->opt.rfmon) {
415 close(handle->fd);
419 handle->stats_op = usb_stats_linux;
420 handle->read_op = usb_read_linux;
424 * "handle->fd" is a real file, so "select()" and "poll()"
427 handle->selectable_fd = handle->fd;
431 handle->buffer = malloc(handle->bufsize);
432 if (!handle->buffer) {
433 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
435 close(handle->fd);
453 usb_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *user)
463 u_char * rawdata = handle->buffer;
465 pcap_usb_header* uhdr = (pcap_usb_header*)handle->buffer;
471 ret = read(handle->fd, line, USB_LINE_LEN - 1);
472 if (handle->break_loop)
474 handle->break_loop = 0;
483 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
484 "Can't read from fd %d: %s", handle->fd, strerror(errno));
496 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
503 uhdr->bus_id = handle->md.ifindex;
510 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
537 if (handle->direction == PCAP_D_OUT)
541 if (handle->direction == PCAP_D_IN)
562 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
586 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
604 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
623 while ((string[0] != 0) && (string[1] != 0) && (pkth.caplen < handle->snapshot))
636 if (pkth.caplen > handle->snapshot)
637 pkth.caplen = handle->snapshot;
639 if (handle->fcode.bf_insns == NULL ||
640 bpf_filter(handle->fcode.bf_insns, handle->buffer,
642 handle->md.packets_read++;
643 callback(user, &pkth, handle->buffer);
650 usb_inject_linux(pcap_t *handle, const void *buf, size_t size)
652 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "inject not supported on "
658 usb_stats_linux(pcap_t *handle, struct pcap_stat *stats)
666 snprintf(string, USB_LINE_LEN, USB_TEXT_DIR"/%ds", handle->md.ifindex);
676 snprintf(string, USB_LINE_LEN, USB_TEXT_DIR_OLD"/%ds", handle->md.ifindex);
680 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
695 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
727 stats->ps_recv = handle->md.packets_read;
741 usb_stats_linux_bin(pcap_t *handle, struct pcap_stat *stats)
745 ret = ioctl(handle->fd, MON_IOCG_STATS, &st);
748 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
749 "Can't read stats from fd %d:%s ", handle->fd, strerror(errno));
753 stats->ps_recv = handle->md.packets_read + st.queued;
764 usb_read_linux_bin(pcap_t *handle, int max_packets, pcap_handler callback, u_char *user)
769 int clen = handle->snapshot - sizeof(pcap_usb_header);
772 info.hdr = (pcap_usb_header*) handle->buffer;
773 info.data = handle->buffer + sizeof(pcap_usb_header);
778 ret = ioctl(handle->fd, MON_IOCX_GET, &info);
779 if (handle->break_loop)
781 handle->break_loop = 0;
790 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
791 "Can't read from fd %d: %s", handle->fd, strerror(errno));
805 if (handle->fcode.bf_insns == NULL ||
806 bpf_filter(handle->fcode.bf_insns, handle->buffer,
808 handle->md.packets_read++;
809 callback(user, &pkth, handle->buffer);
822 usb_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback, u_char *user)
832 max_clen = handle->snapshot - sizeof(pcap_usb_header);
848 ret = ioctl(handle->fd, MON_IOCX_MFETCH, &fetch);
849 if (handle->break_loop)
851 handle->break_loop = 0;
860 snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
861 "Can't mfetch fd %d: %s", handle->fd, strerror(errno));
869 hdr = (pcap_usb_header*) &handle->md.mmapbuf[vec[i]];
885 if (handle->fcode.bf_insns == NULL ||
886 bpf_filter(handle->fcode.bf_insns, (u_char*) hdr,
888 handle->md.packets_read++;
900 ioctl(handle->fd, MON_IOCH_MFLUSH, nflush);
905 usb_cleanup_linux_mmap(pcap_t* handle)
908 if (handle->md.mmapbuf != NULL) {
909 munmap(handle->md.mmapbuf, handle->md.mmapbuflen);
910 handle->md.mmapbuf = NULL;
912 pcap_cleanup_live_common(handle);