libpcap

Vlan id is set to 0 when TPACKET_V2 is used

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 05:55:33
问题 I have a problem about the usage of this TPACKET_V2 . My problem is that after setting of this type of packet on socket, when I try to receive some packets I can't read the vlan id from the packet (of course from the header of the packet) the vlan_tci is ever 0. Now I'm using open suse sp1 and when I run my program on sless sp2 I 'm able to get the vlan id with the same program that doesn't work on sless sp1 but the weird thing is that tcpdump is able to get the vlan id (on this sless) and

pcap_lookupnet returns incorrect IP address

我是研究僧i 提交于 2019-12-02 04:53:33
Following example code from the libpcap documentation yields the following code which should report the IP address of the given interface (eth0 in this case) [Error checking omitted for brevity] #include <stdio.h> #include <pcap.h> #include <arpa/inet.h> int main(int argc, char *argv[]) { char errbuf[PCAP_ERRBUF_SIZE]; bpf_u_int32 mask; bpf_u_int32 ip; struct in_addr ip_addr; /* Find the properties for the device */ pcap_lookupnet("eth0", &ip, &mask, errbuf); ip_addr.s_addr = ip; printf("IP Address: %s\n", inet_ntoa(ip_addr)); return 0; } However, this results in 192.168.1.0, rather than the

Vlan id is set to 0 when TPACKET_V2 is used

痴心易碎 提交于 2019-12-02 00:12:53
I have a problem about the usage of this TPACKET_V2 . My problem is that after setting of this type of packet on socket, when I try to receive some packets I can't read the vlan id from the packet (of course from the header of the packet) the vlan_tci is ever 0. Now I'm using open suse sp1 and when I run my program on sless sp2 I 'm able to get the vlan id with the same program that doesn't work on sless sp1 but the weird thing is that tcpdump is able to get the vlan id (on this sless) and tcpdump set the TPACKET_V2 (so this means that TPACKET_2 is supported) My simple project is based on

安装升级libpcap至1.9.0

百般思念 提交于 2019-12-01 19:50:13
不看别人的是不会装的,装过就忘了,所以记在这里 1、首先安装或者升级glibc 2.17 CentOS 6.x 如何升级 glibc 2.17 2、然后安装flex yum -y install flex 3、然后安装bison yum -y install bison 4、安装完成后验证 你可以看其他人的方法,直接编写c,还有一个简单方法,再安装tcpdump yum -y install tcpdump 安装完成后,使用如下命令查看安装或者升级了的libpcap版本 tcpdump --version 来源: https://www.cnblogs.com/lizhaoxian/p/11715373.html

Passing an argument on libpcap pcap_loop() callback

旧城冷巷雨未停 提交于 2019-12-01 19:17:21
Because I would like to make some tests with the libpcap and a small C program, I am trying to pass a structure from main() to got_packet(). After reading the libpcap tutorial, I had found this: The prototype for pcap_loop() is below: int pcap_loop(pcap_t *p, int cnt, pcap_handler callback, u_char *user) The last argument is useful in some applications, but many times is simply set as NULL. Suppose we have arguments of our own that we wish to send to our callback function, in addition to the arguments that pcap_loop() sends. This is where we do it. Obviously, you must typecast to a u_char

packet data intercept and modification

时光毁灭记忆、已成空白 提交于 2019-12-01 13:56:17
I'd like to be able to intercept/ modify data in tcp flow, on the side of tcp client. Examples for pcap show how to parse tcp packet header/ payload. But suppose, i want to modify packet payload before tcp client reads it, or drop the packet entirely. How can i do that with pcap capure? As above, you can't do interception/modification with pcap. For this you need one of the following OS-dependent techniques: Linux : libnetfilter_queue + iptables MacOS , FreeBSD : divert sockets + ipfw Windows : WinPkFilter (commercial), WinDivert (LGPL), or write your own NDIS IM or WFP call-out driver. (usual

Can libpcap be compiled for iPhone/armv6?

牧云@^-^@ 提交于 2019-12-01 12:55:52
Trying to compile a basic program which uses pcap.h. I've set up the environment on my Mac OSX box which uses the iPhone 3.1.3 SDK for an iPhone 3GS. I've also installed libpcap to ~/libpcap so I can tell gcc where to look for the headers using the -I flag. However, it fails with an ld warning saying the file is not of the required architecture. I'm compiling with the following line: /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -I /Users/abnev/libpcap/include -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.3.sdk -o pcap pcap.c -lpcap

requirement of root privileges for libpcap functions

懵懂的女人 提交于 2019-12-01 11:37:55
The pcap_lookupdev() fills in the errbuf variable when run as non-root user, while the same functions returns the value of the first available network interface when run as root. Is this access disabled by the OS or the library. I think it is the OS. What is the right answer? This is not a homework question In general, when it comes to accessing files, devices and other services provided by the OS, access models in Unix (and, thus, Linux) are implemented in the OS. Userspace programs are expected to just try whatever they want to do and gracefully handle any error condition by e.g. informing

Can libpcap be compiled for iPhone/armv6?

扶醉桌前 提交于 2019-12-01 11:10:36
问题 Trying to compile a basic program which uses pcap.h. I've set up the environment on my Mac OSX box which uses the iPhone 3.1.3 SDK for an iPhone 3GS. I've also installed libpcap to ~/libpcap so I can tell gcc where to look for the headers using the -I flag. However, it fails with an ld warning saying the file is not of the required architecture. I'm compiling with the following line: /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -I /Users/abnev/libpcap/include -arch armv6

Asynchronous libpcap: losing packets?

拈花ヽ惹草 提交于 2019-12-01 05:47:33
I have a program that sends a set of TCP SYN packets to a host (using raw sockets) and uses libpcap (with a filter) to obtain the responses. I'm trying to implement this in an asynchronous I/O framework, but it seems that libpcap is missing some of the responses (namely the first packets of a series when it takes less than 100 microseconds between the TCP SYN and the response). The pcap handle is setup like this: pcap_t* pcap = pcap_open_live(NULL, -1, false, -1, errorBuffer); pcap_setnonblock(pcap, true, errorBuffer); Then I add a filter (contained on the filterExpression string): struct bpf