2

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..

trinity
  • 10,394
  • 15
  • 49
  • 67
  • 1
    Are these the first errors that occur, or are there others before them? Can you post the _entire_ output from the compiler? Also, look at the definition of `struct iphdr` in /usr/include/linux/ip.h to see if those members actually are defined. – Adam Liss Jan 09 '10 at 20:23
  • What is the actual file you are compiling. The compiler output says the file name is "tcp.c", not "sniffer_eth_ip_tcp.c". Furthermore, "sniffer_eth_ip_tcp.c" (as provided in that link) has only 268 lines. – R Samuel Klatchko Jan 09 '10 at 20:27
  • i've now posted the warnings too. what should i do to rectify.. ( tcp.c also had the same code ) – trinity Jan 10 '10 at 08:06

1 Answers1

3

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
  • 14,226
  • 3
  • 42
  • 60
  • +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. – wadesworld Jan 10 '10 at 08:07
  • 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 Jan 10 '10 at 08:49