[nmsg-dev] nmsg 0.6.8 patch for OSX

Robert Edmonds edmonds at isc.org
Mon Aug 16 19:04:57 UTC 2010

Matt Thompson wrote:
> I've attached a patch against nmsg 0.6.8 to fix compilation on OSX.
> This may be required for other BSD systems as well if they lack
> struct icmphdr in netinet/ip_icmp.h.
> This compiles fine on at least Debian Linux since Linux also defines
> the BSD style struct icmp.
> I replaced sizeof(struct icmphdr) with offsetof(struct icmp,
> icmp_dun) and changed autoconf/check_net.m4 to check for struct icmp
> rather than icmphdr.

i think the amount of autoconf / #ifdef crap required to get these
structure definitions right across multiple systems exceeds the LOC to
just detect the system's endianness and define our own structures for
these network headers.  i'll try to rework this in the next release of

note, however, that you'll probably need a lot more changes to make nmsg
work on OS X; in particular, the module loader assumes a relatively sane
posix/ELF system with dlopen() and DSOs with filenames that end in

also note that i'm not particularly interested in supporting a closed
source operating system like OS X.  at one point i had darwin 8 running
in a qemu virtual machine but it was sloooow and made testing extremely
difficult, and now i can't even find the download link on apple.com for
the installer that i used.  it seems apple is scrubbing almost all
mentions of darwin from their websites, and of course they don't make
installers for newer versions of darwin available now.

> OSX uses a macro for snprintf(). The source file src/argv.c
> LOC_SNPRINTF and SNP_ARGS macros are being evaluated after the
> snprintf() macro resulting in argument errors during compilation.
> I implemented a static wrapper func named loc_snprintf() around
> vsnprintf that the LOC_SNPRINTF() macro is defined to.

the upstream author of the argument parsing code in nmsgtool is gray


could you please submit the patch to him and ask that it be applied
upstream?  he was very responsive when i reported a memory corruption
bug earlier this year.

Robert Edmonds
edmonds at isc.org

More information about the nmsg-dev mailing list