tcpdump mailing list archives
Re: Using libnetdissect in other code, outside tcpdump source tree
From: Bill Fenner via tcpdump-workers <tcpdump-workers () lists tcpdump org>
Date: Fri, 14 Aug 2020 11:54:07 -0400
--- Begin Message --- From: Bill Fenner <fenner () gmail com>
Date: Fri, 14 Aug 2020 11:54:07 -0400
On Wed, Aug 12, 2020 at 6:22 PM Guy Harris <gharris () sonic net> wrote:On Aug 12, 2020, at 1:31 PM, Guy Harris via tcpdump-workers < tcpdump-workers () lists tcpdump org> wrote:We should probably have an include/libnetdissect directory in which weinstall netdissect.h and the headers it requires. Or include/netdissect.However, API-declaring headers should *NEVER* require config.h (therewas a particularly horrible case with OpenBSD's version of libz, forcing a painful workaround in Wireshark: ...so if anything in netdissect.h depends on config.h definitions, weshould try to fix that. It looks like it's just declaring replacements for strlcat(), strlcpy(), strdup(), and strsep() if the platform doesn't provide them. That should be done in a non-public header.The specific reason for needing config.h was #ifndef HAVE___ATTRIBUTE__ #define __attribute__(x) #endif because there's other code that doesn't work right without defining the right attributes. Scrolling through netdissect.h, it relies on things like __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS to be able to fully prototype the elements in netdissect_options. (There's probably an argument that netdissect_options should be opaque, with the right accessors and mutators for an API consumer. On the other hand, any API user probably wants to provide ndo_printf, ndo_error, ndo_warning, which themselves have the ndo as the first argument, hm.)That leaves ip.h and ip6.h; I'd have to check to see whether they should be considered part of the API or not. The comments are: #include "ip.h" /* struct ip for nextproto4_cksum() */ #include "ip6.h" /* struct ip6 for nextproto6_cksum() */ so what should probably be done is have a header for *users* of libnetdissect and a separate header for *components* of libnetdissect; the latter can define more things. (The latter would be a non-public header, unless we decide to support third-party dissector plugins; that would also mean we'd probably want to have something like Wireshark's dissector tables to which those plugins would add themselves.)For my use case, "pretty_print_packet()" (and ndo_set_function_pointers() ) is the only public interface I need. I wonder if starting over with a clean header file for API users would be a better start. (Is sunrpcrequest_print() really part of the public api?) Bill
--- End Message ---
_______________________________________________ tcpdump-workers mailing list tcpdump-workers () lists tcpdump org https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers
Current thread:
- Using libnetdissect in other code, outside tcpdump source tree Bill Fenner via tcpdump-workers (Aug 12)
- Re: Using libnetdissect in other code, outside tcpdump source tree Guy Harris via tcpdump-workers (Aug 12)
- Re: Using libnetdissect in other code, outside tcpdump source tree Guy Harris via tcpdump-workers (Aug 12)
- Message not available
- Re: Using libnetdissect in other code, outside tcpdump source tree Bill Fenner via tcpdump-workers (Aug 14)
- Re: Using libnetdissect in other code, outside tcpdump source tree Denis Ovsienko via tcpdump-workers (Aug 24)
- Re: Using libnetdissect in other code, outside tcpdump source tree Guy Harris via tcpdump-workers (Aug 12)