Thread: Tcphdr there is not a member named

  1. #1
    Registered User
    Join Date
    Jan 2013
    Posts
    3

    Question Tcphdr there is not a member named

    I am writing an application for a school project to detect attackers from a pcap file. I find some example codes and want to compile them to inspect. When I want to compile them there is some errors

    Code:
    scandet.c: In function ‘void UpdateMap(map_t&, packetmap_t&, ip*, tcphdr*)’:
    scandet.c:82:9: error: ‘TH_SYN’ was not declared in this scope 
    scandet.c:82:27: error: ‘struct tcphdr’ has no member named ‘th_flags’ 
    scandet.c:82:42: error: ‘TH_ACK’ was not declared in this scope 
    scandet.c:82:60: error: ‘struct tcphdr’ has no member named ‘th_flags’ 
    scandet.c:84:92: error: ‘struct tcphdr’ has no member named ‘th_sport’ 
    scandet.c:84:118: error: ‘struct tcphdr’ has no member named ‘th_dport’ 
    scandet.c:84:138: error: ‘struct tcphdr’ has no member named ‘th_seq’ 
    scandet.c:91:82: error: ‘struct tcphdr’ has no member named ‘th_sport’ 
    scandet.c:91:108: error: ‘struct tcphdr’ has no member named ‘th_dport’ 
    scandet.c:103:34: error: ‘struct tcphdr’ has no member named ‘th_flags’ 
    scandet.c:103:66: error: ‘struct tcphdr’ has no member named ‘th_flags’ 
    scandet.c:104:91: error: ‘struct tcphdr’ has no member named ‘th_dport’ 
    scandet.c:104:117: error: ‘struct tcphdr’ has no member named ‘th_sport’ 
    scandet.c:104:137: error: ‘struct tcphdr’ has no member named ‘th_ack’ 
    scandet.c:107:82: error: ‘struct tcphdr’ has no member named ‘th_dport’ 
    scandet.c:107:108: error: ‘struct tcphdr’ has no member named ‘th_sport’ 
    make: *** [scandet.o] Error 1
    I am trying to compile code at http://github.com/zahanm/sec-project.../pp3/scandet.c . It is a solution to Stanford's CS155 Project 3 Part 2. I am using makefile provided at link. I searched internet and applied some solutions like defining _FAVOR_BSD and __USE_BSD. They don't worked. I am using Xubuntu 11.10. GCC version is 4.6.1, tcpdump version is 4.1.1 and libpcap version is 1.1.1.

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    The code in the file you linked scandet.c is C++; not C code.

    You might wish to compile it as C++.

    Tim S.
    Last edited by stahta01; 01-19-2013 at 03:22 PM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    Registered User
    Join Date
    Jan 2013
    Posts
    3
    Thanks but makefile uses g++ compiler.

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by khadgar View Post
    Thanks but makefile uses g++ compiler.
    Then this is not in the right sub-forum.
    There are three better ones.
    The ones I would pick from are Linux or Networking sub-forums.
    Linux Programming
    Networking/Device Communication
    Even the C++ sub-forum is better than this C sub-forum.

    You likely are using the two defines incorrectly or do NOT have a hybrid header (both Linux and BSD version of struct tcphdr).

    Tim S,
    Last edited by stahta01; 01-19-2013 at 06:40 PM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  5. #5
    Stoned Witch Barney McGrew's Avatar
    Join Date
    Oct 2012
    Location
    astaylea
    Posts
    420
    defining _FAVOR_BSD
    Check the header file. For me it's __FAVOR_BSD. Be sure to #define it before including netinet/tcp.h. In case you run into any other problems, be sure to link with the pcap library (eg. LDFLAGS='-lpcap' make scandet).

  6. #6
    Registered User
    Join Date
    Jan 2013
    Posts
    3
    Quote Originally Posted by Barney McGrew View Post
    Check the header file. For me it's __FAVOR_BSD. Be sure to #define it before including netinet/tcp.h. In case you run into any other problems, be sure to link with the pcap library (eg. LDFLAGS='-lpcap' make scandet).
    Defining __FAVOR_BSD worked now thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Error: structure XX has no member named YY
    By limp in forum C Programming
    Replies: 2
    Last Post: 04-07-2011, 04:52 PM
  2. Error: no member named 'whatever'
    By vileoxidation in forum C++ Programming
    Replies: 31
    Last Post: 10-09-2009, 08:12 PM
  3. Replies: 2
    Last Post: 04-22-2008, 12:07 PM
  4. Replies: 2
    Last Post: 04-19-2008, 12:06 AM
  5. Replies: 1
    Last Post: 04-17-2008, 07:45 PM