berthubert / simplomon

Very simple monitoring system with a single configuration file
MIT License
97 stars 12 forks source link

netmon.cc doesn't compile on FreeBSD - netinet differences #16

Open nreilly opened 3 months ago

nreilly commented 3 months ago

Compilation fails on FreeBSD in netmon.cc

[1/2] Compiling C++ object simplomon.p/netmon.cc.o
FAILED: simplomon.p/netmon.cc.o 
ccache c++ -Isimplomon.p -I. -I.. -Isubprojects/cpp-httplib-0.13.1 -I../subprojects/cpp-httplib-0.13.1 -Isubprojects/simplesockets -I../subprojects/simplesockets -I/usr/local/include -I/usr/local/include/lua53 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c++20 -O0 -g -pthread -DCPPHTTPLIB_OPENSSL_SUPPORT -DCPPHTTPLIB_ZLIB_SUPPORT -DCPPHTTPLIB_BROTLI_SUPPORT -MD -MQ simplomon.p/netmon.cc.o -MF simplomon.p/netmon.cc.o.d -o simplomon.p/netmon.cc.o -c ../netmon.cc
In file included from ../netmon.cc:6:
In file included from ../simplomon.hh:6:
In file included from ../notifiers.hh:3:
../sol/sol.hpp:14541:32: warning: unknown warning group '-Wmaybe-uninitialized', ignored [-Wunknown-warning-option]
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
                               ^
../sol/sol.hpp:17294:32: warning: unknown warning group '-Wmaybe-uninitialized', ignored [-Wunknown-warning-option]
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
                               ^
In file included from ../netmon.cc:10:
/usr/include/netinet/ip_icmp.h:110:14: error: field has incomplete type 'struct ip'
                        struct ip idi_ip;
                                  ^
/usr/include/netinet/ip_icmp.h:110:11: note: forward declaration of 'ip'
                        struct ip idi_ip;
                               ^
../netmon.cc:220:11: error: no member named 'type' in 'icmphdr'
    p.hdr.type = ICMP_ECHO;
    ~~~~~ ^
../netmon.cc:221:11: error: no member named 'un' in 'icmphdr'
    p.hdr.un.echo.id = id;
    ~~~~~ ^
../netmon.cc:222:11: error: no member named 'un' in 'icmphdr'
    p.hdr.un.echo.sequence = seq;
    ~~~~~ ^
../netmon.cc:229:11: error: no member named 'checksum' in 'icmphdr'
    p.hdr.checksum = 0;
    ~~~~~ ^
../netmon.cc:230:11: error: no member named 'checksum' in 'icmphdr'
    p.hdr.checksum = internetchecksum(&p, sizeof(p));
    ~~~~~ ^
../netmon.cc:251:73: error: member access into incomplete type 'struct iphdr'
    struct icmphdr* icmp = (struct icmphdr*) ((char*)packet.c_str() + ip->ihl*4);
                                                                        ^
../netmon.cc:250:12: note: forward declaration of 'iphdr'
    struct iphdr *ip = (iphdr*)packet.c_str();
           ^
../netmon.cc:253:16: error: no member named 'un' in 'icmphdr'
    id = icmp->un.echo.id;
         ~~~~  ^
../netmon.cc:254:17: error: no member named 'un' in 'icmphdr'
    seq = icmp->un.echo.sequence;
          ~~~~  ^
../netmon.cc:256:31: error: member access into incomplete type 'struct iphdr'
    payload = packet.substr(ip->ihl*4 + sizeof(icmp));
                              ^
../netmon.cc:250:12: note: forward declaration of 'iphdr'
    struct iphdr *ip = (iphdr*)packet.c_str();
           ^
2 warnings and 10 errors generated.
ninja: build stopped: subcommand failed.
nreilly commented 3 months ago

Last successful build was from 1875ec4afbc59d38e1683ed23af992c157aefb24

dch commented 3 months ago

@nreilly I'm working through the port, how do you actually get to this point with meson? Have I gotten this correct?

$ rm -rf _build
$ meson setup build
$ cd build
$ ninja
nreilly commented 3 months ago

@dch The below gets me to the compilation errors in netmon.cc with the current source:

# pkg install meson ninja lua53 cmake nlohmann-json sqlite3 pkgconf libfmt cpp-httplib
$ git clone https://github.com/berthubert/simplomon
$ cd simplomon
$ meson setup build --includedir /usr/local/include --libdir /usr/local/lib
$ meson compile -C build