views:

376

answers:

1

I ran a program ( the link is - http://www.security-freak.net/raw-sockets/sniffer_eth_ip_tcp.c ) in my fedora core 5. On compilation , i get the following errors :

[root@localhost ~]# gcc sniffer_eth_ip_tcp.c
    In file included from sniffer_eth_ip_tcp.c:12: /usr/include/linux/ip.h:97: error: expected specifier-qualifier-list before ‘uint8_t’
    In file included from /usr/include/linux/tcp.h:21,
                 from sniffer_eth_ip_tcp.c:13:
    /usr/include/asm/byteorder.h:6:2: warning: #warning using private kernel header; include   <endian.h> instead!
    sniffer_eth_ip_tcp.c: In function ‘ParseIpHeader’:
    sniffer_eth_ip_tcp.c:147: error: ‘struct iphdr’ has no member named ‘daddr’
    sniffer_eth_ip_tcp.c:148: error: ‘struct iphdr’ has no member named ‘saddr’
    sniffer_eth_ip_tcp.c: In function ‘ParseTcpHeader’:
    sniffer_eth_ip_tcp.c:185: error: ‘struct iphdr’ has no member named ‘protocol’
    sniffer_eth_ip_tcp.c:187: error: ‘struct iphdr’ has no member named ‘ihl’

But , the struct iphdr in the corresponding header file contains the above mentioned data members. can anyone please help..

+3  A: 

The only way to get that error is if the iphdr your program is referring to does not include those data members. So, search through all your includes, check for dup's, etc. (also, you can run the source through a precompile and find out EVERYTHING that has been included, that usually provides your answer)

[edit]
run cpp on your source to find out which header files are included (in which order). If you have a header with the wrong information included before the correct information, you will have a problem. In essence, only include the header files necessary to compile the program
[/edit]

KevinDTimm
+1 - the compiler isn't lying. If it says it can't find the members, it means the header you think is being included is not the one being included or something's getting redefined, etc.
Wade Williams
The first two lines < 1 error and 1 warning > are in header files linux/tcp.h and asm/byteorder.h. How do we correct them ?
trinity