title: No member named 'source' in 'udphdr'
body: <p>I am trying to install <a href="http://nsrg.louisiana.edu/project/ntmaps/output/palmtree.html" rel="nofollow">palmtree</a> and I followed every step but when I run make, I obtained the following error:</p>
  
  <pre><code>Building file: ../src/tools/palmtree/PalmTree.cpp
  Invoking: GCC C++ Compiler
  g++ -O3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"src/tools/palmtree/PalmTree.d" -MT"src/tools/palmtree/PalmTree.d" -o"src/tools/palmtree/PalmTree.o" "../src/tools/palmtree/PalmTree.cpp"
  Finished building: ../src/tools/palmtree/PalmTree.cpp
  
  Building file: ../src/tools/Tool.cpp
  Invoking: GCC C++ Compiler
  g++ -O3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"src/tools/Tool.d" -MT"src/tools/Tool.d" -o"src/tools/Tool.o" "../src/tools/Tool.cpp"
  Finished building: ../src/tools/Tool.cpp
  
  Building file: ../src/prober/udp/DirectUDPProber.cpp
  Invoking: GCC C++ Compiler
  g++ -O3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"src/prober/udp/DirectUDPProber.d" -MT"src/prober/udp/DirectUDPProber.d" -o"src/prober/udp/DirectUDPProber.o" "../src/prober/udp/DirectUDPProber.cpp"
  ../src/prober/udp/DirectUDPProber.cpp:201:8: error: no member named 'source' in 'udphdr'
           udp-&gt;source=htons(srcPort_16);
           ~~~  ^
  ../src/prober/udp/DirectUDPProber.cpp:202:8: error: no member named 'dest' in 'udphdr'
           udp-&gt;dest=htons(dstPort_16);
           ~~~  ^
  ../src/prober/udp/DirectUDPProber.cpp:203:8: error: no member named 'len' in 'udphdr'
           udp-&gt;len=htons(DirectProber::MINIMUM_UDP_HEADER_LENGTH + DirectProber::DEFAULT_UDP_RANDOM_DATA_LENGTH + DirectProber::ATTENTION_MESSAGE.length());//the length must be udp_header length + data length.
           ~~~  ^
  ../src/prober/udp/DirectUDPProber.cpp:204:8: error: no member named 'check' in 'udphdr'
           udp-&gt;check=0x0;
           ~~~  ^
  ../src/prober/udp/DirectUDPProber.cpp:225:25: error: no member named 'len' in 'udphdr'
           memcpy(pseudo, &amp;(udp-&gt;len), 2);
                            ~~~  ^
  ../src/prober/udp/DirectUDPProber.cpp:233:8: error: no member named 'check' in 'udphdr'
           udp-&gt;check=DirectProber::calculateInternetChecksum((uint16_t *)pseudoBuffer, pseudoBufferLength);
           ~~~  ^
  ../src/prober/udp/DirectUDPProber.cpp:406:20: error: member access into incomplete type 'struct icmphdr'
                          tmpChecksum=icmp-&gt;checksum;
                                          ^
  ../src/prober/udp/DirectUDPProber.cpp:402:11: note: forward declaration of 'icmphdr'
                          struct icmphdr * icmp=(struct icmphdr *)(buffer + (ip-&gt;ip_hl)*4);
                                 ^
  ../src/prober/udp/DirectUDPProber.cpp:407:8: error: member access into incomplete type 'struct icmphdr'
                          icmp-&gt;checksum=0x0;//before computing checksum, the sum field must be zero
                              ^
  ../src/prober/udp/DirectUDPProber.cpp:402:11: note: forward declaration of 'icmphdr'
                          struct icmphdr * icmp=(struct icmphdr *)(buffer + (ip-&gt;ip_hl)*4);
                                 ^
  ../src/prober/udp/DirectUDPProber.cpp:415:8: error: member access into incomplete type 'struct icmphdr'
                          icmp-&gt;checksum=tmpChecksum;
                              ^
  ../src/prober/udp/DirectUDPProber.cpp:402:11: note: forward declaration of 'icmphdr'
                          struct icmphdr * icmp=(struct icmphdr *)(buffer + (ip-&gt;ip_hl)*4);
                                 ^
  ../src/prober/udp/DirectUDPProber.cpp:420:11: error: member access into incomplete type 'struct icmphdr'
                          if(icmp-&gt;type==DirectProber::ICMP_TYPE_TIME_EXCEEDED || icmp-&gt;type == DirectProber::ICMP_TYPE_DESTINATION_UNREACHABLE){
                                 ^
  ../src/prober/udp/DirectUDPProber.cpp:402:11: note: forward declaration of 'icmphdr'
                          struct icmphdr * icmp=(struct icmphdr *)(buffer + (ip-&gt;ip_hl)*4);
                                 ^
  ../src/prober/udp/DirectUDPProber.cpp:439:25: error: no member named 'source' in 'udphdr'
                                                  ntohs(payloadudp-&gt;source)==srcPort_16 &amp;&amp;
                                                        ~~~~~~~~~~  ^
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sys/_endian.h:132:39: note: expanded from macro 'ntohs'
  #define ntohs(x)        __DARWIN_OSSwapInt16(x)
                                               ^
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libkern/_OSByteOrder.h:72:40: note: expanded from macro '__DARWIN_OSSwapInt16'
      ((__uint16_t)(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt16(x) : _OSSwapInt16(x)))
                                         ^
  ../src/prober/udp/DirectUDPProber.cpp:439:25: error: no member named 'source' in 'udphdr'
                                                  ntohs(payloadudp-&gt;source)==srcPort_16 &amp;&amp;
                                                        ~~~~~~~~~~  ^
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sys/_endian.h:132:39: note: expanded from macro 'ntohs'
  #define ntohs(x)        __DARWIN_OSSwapInt16(x)
                                               ^
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libkern/_OSByteOrder.h:72:71: note: expanded from macro '__DARWIN_OSSwapInt16'
      ((__uint16_t)(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt16(x) : _OSSwapInt16(x)))
                                                                        ^
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libkern/_OSByteOrder.h:44:34: note: expanded from macro '__DARWIN_OSSwapConstInt16'
      ((__uint16_t)((((__uint16_t)(x) &amp; 0xff00) &gt;&gt; 8) | \
                                   ^
  ../src/prober/udp/DirectUDPProber.cpp:439:25: error: no member named 'source' in 'udphdr'
                                                  ntohs(payloadudp-&gt;source)==srcPort_16 &amp;&amp;
                                                        ~~~~~~~~~~  ^
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sys/_endian.h:132:39: note: expanded from macro 'ntohs'
  #define ntohs(x)        __DARWIN_OSSwapInt16(x)
                                               ^
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libkern/_OSByteOrder.h:72:71: note: expanded from macro '__DARWIN_OSSwapInt16'
      ((__uint16_t)(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt16(x) : _OSSwapInt16(x)))
                                                                        ^
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libkern/_OSByteOrder.h:45:32: note: expanded from macro '__DARWIN_OSSwapConstInt16'
                  (((__uint16_t)(x) &amp; 0x00ff) &lt;&lt; 8)))
                                 ^
  ../src/prober/udp/DirectUDPProber.cpp:439:25: error: no member named 'source' in 'udphdr'
                                                  ntohs(payloadudp-&gt;source)==srcPort_16 &amp;&amp;
                                                        ~~~~~~~~~~  ^
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sys/_endian.h:132:39: note: expanded from macro 'ntohs'
  #define ntohs(x)        __DARWIN_OSSwapInt16(x)
                                               ^
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libkern/_OSByteOrder.h:72:89: note: expanded from macro '__DARWIN_OSSwapInt16'
      ((__uint16_t)(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt16(x) : _OSSwapInt16(x)))
                                                                                          ^
  ../src/prober/udp/DirectUDPProber.cpp:440:25: error: no member named 'dest' in 'udphdr'
                                                  ntohs(payloadudp-&gt;dest)==dstPort_16){
                                                        ~~~~~~~~~~  ^
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sys/_endian.h:132:39: note: expanded from macro 'ntohs'
  #define ntohs(x)        __DARWIN_OSSwapInt16(x)
                                               ^
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libkern/_OSByteOrder.h:72:40: note: expanded from macro '__DARWIN_OSSwapInt16'
      ((__uint16_t)(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt16(x) : _OSSwapInt16(x)))
                                         ^
  ../src/prober/udp/DirectUDPProber.cpp:440:25: error: no member named 'dest' in 'udphdr'
                                                  ntohs(payloadudp-&gt;dest)==dstPort_16){
                                                        ~~~~~~~~~~  ^
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sys/_endian.h:132:39: note: expanded from macro 'ntohs'
  #define ntohs(x)        __DARWIN_OSSwapInt16(x)
                                               ^
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libkern/_OSByteOrder.h:72:71: note: expanded from macro '__DARWIN_OSSwapInt16'
      ((__uint16_t)(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt16(x) : _OSSwapInt16(x)))
                                                                        ^
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libkern/_OSByteOrder.h:44:34: note: expanded from macro '__DARWIN_OSSwapConstInt16'
      ((__uint16_t)((((__uint16_t)(x) &amp; 0xff00) &gt;&gt; 8) | \
                                   ^
  ../src/prober/udp/DirectUDPProber.cpp:440:25: error: no member named 'dest' in 'udphdr'
                                                  ntohs(payloadudp-&gt;dest)==dstPort_16){
                                                        ~~~~~~~~~~  ^
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sys/_endian.h:132:39: note: expanded from macro 'ntohs'
  #define ntohs(x)        __DARWIN_OSSwapInt16(x)
                                               ^
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libkern/_OSByteOrder.h:72:71: note: expanded from macro '__DARWIN_OSSwapInt16'
      ((__uint16_t)(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt16(x) : _OSSwapInt16(x)))
                                                                        ^
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libkern/_OSByteOrder.h:45:32: note: expanded from macro '__DARWIN_OSSwapConstInt16'
                  (((__uint16_t)(x) &amp; 0x00ff) &lt;&lt; 8)))
                                 ^
  ../src/prober/udp/DirectUDPProber.cpp:440:25: error: no member named 'dest' in 'udphdr'
                                                  ntohs(payloadudp-&gt;dest)==dstPort_16){
                                                        ~~~~~~~~~~  ^
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sys/_endian.h:132:39: note: expanded from macro 'ntohs'
  #define ntohs(x)        __DARWIN_OSSwapInt16(x)
                                               ^
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libkern/_OSByteOrder.h:72:89: note: expanded from macro '__DARWIN_OSSwapInt16'
      ((__uint16_t)(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt16(x) : _OSSwapInt16(x)))
                                                                                          ^
  ../src/prober/udp/DirectUDPProber.cpp:456:81: error: member access into incomplete type 'struct icmphdr'
                                                                  return buildProbeRecord(REQTime, dst, rplyAddress, TTL, ip-&gt;ip_ttl, icmp-&gt;type, icmp-&gt;code,  ntohs(ip-&gt;ip_id), payloadip-&gt;ip_ttl, RRarray,RRarrayLength);
                                                                                                                                          ^
  ../src/prober/udp/DirectUDPProber.cpp:402:11: note: forward declaration of 'icmphdr'
                          struct icmphdr * icmp=(struct icmphdr *)(buffer + (ip-&gt;ip_hl)*4);
                                 ^
  fatal error: too many errors emitted, stopping now [-ferror-limit=]
  20 errors generated.
  make: *** [src/prober/udp/DirectUDPProber.o] Error 1
  </code></pre>
  
  <p>I understand that I need to change something within ../src/prober/udp/DirectUDPProber.cpp, I assume that the type is defined within: 
  <code>#include &lt;netinet/udp.h&gt;</code> I used locate to find <code>netinet/udp.h</code> it gave: </p>
  
  <pre><code>(1) /Applications/MATLAB_R2015a.app/polyspace/verifier/cxx/include/include-libc/netinet/ip_icmp.h
  (2) /Applications/MATLAB_R2016a.app/polyspace/verifier/cxx/include/include-libc/netinet/ip_icmp.h
  (3) /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/include/netinet/ip_icmp.h
  (4) /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/netinet/ip_icmp.h
  (5) /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/netinet/ip_icmp.h
  (6) /Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/usr/include/netinet/ip_icmp.h
  (7) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/netinet/ip_icmp.h
  (8) /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdk/MacOSX.sdk/usr/include/netinet/ip_icmp.h
  (9) /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdk/iPhoneSimulator.sdk/usr/include/netinet/ip_icmp.h
  </code></pre>
  
  <p>I looked at the 3rd one and the 8th one, and indeed they have only:</p>
  
  <pre><code>struct udphdr {
      u_short uh_sport;       /* source port */
      u_short uh_dport;       /* destination port */
      u_short uh_ulen;        /* udp length */
      u_short uh_sum;         /* udp checksum */
  };
  </code></pre>
  
  <p>While the matlab link has:</p>
  
  <pre><code>/* UDP header as specified by RFC 768, August 1980. */
  #ifdef __FAVOR_BSD
  
  struct udphdr
  {
    u_int16_t uh_sport;       /* source port */
    u_int16_t uh_dport;       /* destination port */
    u_int16_t uh_ulen;        /* udp length */
    u_int16_t uh_sum;     /* udp checksum */
  };
  
  #else
  
  struct udphdr
  {
    u_int16_t source;
    u_int16_t dest;
    u_int16_t len;
    u_int16_t check;
  };
  #endif
  </code></pre>
  
  <p>What should I do? they mention that I should have pthread library, but I could not find much information.</p>
  
  <p>Thank you for your help.</p>
  
  <p>Antoine</p>