1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Error compiling when included tcp_var.h

Discussion in 'FreeBSD Development' started by mix_room, Nov 25, 2011.

  1. mix_room

    mix_room Member

    Messages:
    592
    Thanks Received:
    44
    I am attempting to include /usr/include/netinet/tcp_var.h. When compiling, there are errors thrown. The errors seem to indicate that there is an error with tcp_var.h
    Since this file is a system file I am assuming that I am doing something wrong.

    I am using gmake.

    Attached is the last line which fails.
    Code:
    libtool: compile:  c++ -DHAVE_CONFIG_H -I. -I.. -I/usr/local/include -I/usr/local -O2 -pipe \... 
    -fno-strict-aliasing -MT libboblight_la-tcpsocket.lo -MD -MP -MF .deps/libboblight_la-tcpsocket.Tpo -c util/tcpsocket.cpp  -fPIC -DPIC -o .libs/libboblight_la-tcpsocket.o
    In file included from util/tcpsocket.cpp:28:
    /usr/include/netinet/tcp_var.h:51: error: expected ';' before 'tqe_q'
    /usr/include/netinet/tcp_var.h:56: error: expected constructor, destructor, or type conversion before '(' token
    /usr/include/netinet/tcp_var.h:67: error: expected ';' before 'scblink'
    /usr/include/netinet/tcp_var.h:102: error: field 't_segq' has incomplete type
    /usr/include/netinet/tcp_var.h:184: error: 'sackhole_head' has not been declared
    /usr/include/netinet/tcp_var.h:184: error: expected ';' before 'snd_holes'
    /usr/include/netinet/tcp_var.h:318: error: expected ';' before 'tw_2msl'
    


    Does anyone have a hint what might be wrong?

    Attached tcp_var.h to make it easier:
    Code:
     49 /* TCP segment queue entry */
     50 struct tseg_qent {
     51         LIST_ENTRY(tseg_qent) tqe_q;
     52         int     tqe_len;                /* TCP segment data length */
     53         struct  tcphdr *tqe_th;         /* a pointer to tcp header */
     54         struct  mbuf    *tqe_m;         /* mbuf contains packet */
     55 };
     56 LIST_HEAD(tsegqe_head, tseg_qent);
     57
    ...
     67         TAILQ_ENTRY(sackhole) scblink;  /* scoreboard linkage */
    ...
    101 struct tcpcb {
    102         struct  tsegqe_head t_segq;     /* segment reassembly queue */
    103         void    *t_pspare[2];           /* new reassembly queue */
    104         int     t_segqlen;              /* segment reassembly queue length */
    105         int     t_dupacks;              /* consecutive dup acks recd */
    106
    ...
    182 /* SACK related state */
    183         int     snd_numholes;           /* number of holes seen by sender */
    184         TAILQ_HEAD(sackhole_head, sackhole) snd_holes;
    185                                         /* SACK scoreboard (sorted) */
    ...
    318         TAILQ_ENTRY(tcptw) tw_2msl;
    


    It looks as though it fails whenever a function is called. Is this the error? And how would I solve it?
     
  2. doena

    doena New Member

    Messages:
    16
    Thanks Received:
    0
    Are you sure that you want to use kernel-code/header in userspace?
     
  3. mix_room

    mix_room Member

    Messages:
    592
    Thanks Received:
    44
    Not at all. But this was the only file I found in /usr/include or /usr/local/include that had the definitions which I needed.

    I didn't write the code, its part of my trying to port boblight, as indicated by the rest of the threads I've been spamming yesterday and today.
     
  4. mix_room

    mix_room Member

    Messages:
    592
    Thanks Received:
    44
    Is there a problem that this is a header-file for C while the remainder of the code is written in C++? The same errors are thrown when I attempt to compiles a skeleton code using both /usr/bin/c++,/usr/bin/gcc and /usr/bin/g++

    Code:
    #include <netinet/tcp_var.h>
    
    using namespace std;
    
    int main() {
            return 0;
    }
    


    (A bunch of other errors regarding u_long not being a type are thrown aswell, I'm guessing these are included in sometype of sys.h that is not included)
     
  5. mix_room

    mix_room Member

    Messages:
    592
    Thanks Received:
    44
    Perhaps I should rather ask on the mailing lists.
    Which would be the correct list to ask on?

    EDIT: I filed a PR instead.
     
  6. mix_room

    mix_room Member

    Messages:
    592
    Thanks Received:
    44
    In reply to my PR submission I received the following email:

    Code:
    > Most networking headers have _many_ undocumented prerequisites.
    > tcp_var.h itself is is not really documented, so you just have to know
    > what its prerequisites are and shouldn't expect it to work for C++.
    > You have to be a networking person or use trial and error to know the
    > prerequisites. (In 2004, tcp_var.h was not mentioned in any man page.
    > Now it is mentioned in siftr.4 and hhook.9, and these references are
    > only usable for human readers of tcp_var.h. hhook.9 has a synopsis
    > that can't possibly work due to missing prerequisites for the 1 header
    > that it satisifies, despite massive pollution internal to this header.)
    >
    > When I stopped policing prerequisites in 1999, minimal prerequisites
    > for <netinet/tcp_var.h> were
    >
    > #include <sys/types.h>
    > #include <netinet/in.h>
    > #include <netinet/in_systm.h>
    > #include <netinet/ip_var.h>
    > #include <netinet/tcp.h>
    >
    > in that order. These were found by trial and error (many trials and
    > many errors for each file tested. The trials included complete tests
    > of subsets to find a minimum that worked for a range of compilers and
    > compiler options, and incomplete tests of ordering). These still work,
    > at least with gcc and normal compiler options. They happen to work
    > for C++ too.
    >
    > $SENDER
    


    The errors no longer appear in the minimal test file. Haven't had a chance to try the more complex code.