1/* 2 * pcap-linux.c: Packet capture interface to the Linux kernel 3 * 4 * Copyright (c) 2000 Torsten Landschoff <torsten@debian.org> 5 * Sebastian Krahmer <krahmer@cs.uni-potsdam.de> 6 * 7 * License: BSD 8 * --- 152 unchanged lines hidden (view full) --- 161#ifdef PCAP_SUPPORT_BT 162#include "pcap-bt-linux.h" 163#endif 164 165#ifdef PCAP_SUPPORT_CAN 166#include "pcap-can-linux.h" 167#endif 168 |
169#if PCAP_SUPPORT_CANUSB 170#include "pcap-canusb-linux.h" 171#endif 172 |
173#ifdef PCAP_SUPPORT_NETFILTER 174#include "pcap-netfilter-linux.h" 175#endif 176 177/* 178 * If PF_PACKET is defined, we can use {SOCK_RAW,SOCK_DGRAM}/PF_PACKET 179 * sockets rather than SOCK_PACKET sockets. 180 * --- 236 unchanged lines hidden (view full) --- 417#endif /* HAVE_SNF_API */ 418 419#ifdef PCAP_SUPPORT_BT 420 if (strstr(device, "bluetooth")) { 421 return bt_create(device, ebuf); 422 } 423#endif 424 |
425#if PCAP_SUPPORT_CANUSB 426 if (strstr(device, "canusb")) { 427 return canusb_create(device, ebuf); 428 } 429#endif 430 |
431#ifdef PCAP_SUPPORT_CAN |
432 if ((strncmp(device, "can", 3) == 0 && isdigit(device[3])) || 433 (strncmp(device, "vcan", 4) == 0 && isdigit(device[4]))) { |
434 return can_create(device, ebuf); 435 } 436#endif 437 438#ifdef PCAP_SUPPORT_USB 439 if (strstr(device, "usbmon")) { 440 return usb_create(device, ebuf); 441 } --- 1863 unchanged lines hidden (view full) --- 2305#ifdef PCAP_SUPPORT_NETFILTER 2306 /* 2307 * Add netfilter devices. 2308 */ 2309 if (netfilter_platform_finddevs(alldevsp, errbuf) < 0) 2310 return (-1); 2311#endif 2312 |
2313#if PCAP_SUPPORT_CANUSB 2314 if (canusb_platform_finddevs(alldevsp, errbuf) < 0) 2315 return (-1); 2316#endif 2317 |
2318 return (0); 2319} 2320 2321/* 2322 * Attach the given BPF code to the packet capture device. 2323 */ 2324static int 2325pcap_setfilter_linux_common(pcap_t *handle, struct bpf_program *filter, --- 3088 unchanged lines hidden (view full) --- 5414 if (p->k >= SLL_HDR_LEN) { 5415 /* 5416 * It's within the link-layer payload; that starts at an 5417 * offset of 0, as far as the kernel packet filter is 5418 * concerned, so subtract the length of the link-layer 5419 * header. 5420 */ 5421 p->k -= SLL_HDR_LEN; |
5422 } else if (p->k == 0) { 5423 /* 5424 * It's the packet type field; map it to the special magic 5425 * kernel offset for that field. 5426 */ 5427 p->k = SKF_AD_OFF + SKF_AD_PKTTYPE; |
5428 } else if (p->k == 14) { 5429 /* 5430 * It's the protocol field; map it to the special magic 5431 * kernel offset for that field. 5432 */ 5433 p->k = SKF_AD_OFF + SKF_AD_PROTOCOL; |
5434 } else if ((bpf_int32)(p->k) > 0) { |
5435 /* 5436 * It's within the header, but it's not one of those 5437 * fields; we can't do that in the kernel, so punt 5438 * to userland. 5439 */ 5440 return -1; 5441 } 5442 return 0; --- 119 unchanged lines hidden --- |