--- Begin Message ---
On Fri, 18 Sep 2020 10:25:13 +0200
Francois-Xavier Le Bail <devel.fx.leb...@orange.fr> wrote:
[...]
> Or perhaps better (no need for a 'early_end_reason' field):
> switch (setjmp(ndo->early_end)) {
> case 0:
> /* Print the packet. */
> (ndo->ndo_if_printer)(ndo, h, sp);
> break;
> case ND_TRUNCATED:
> /* A printer quit because the packet was truncated;
> report it */ nd_print_trunc(ndo);
> break;
> case ND_INVALID:
> ND_PRINT(" (invalid)"); /* or calling a function that
> do the print */ }
>
> With:
> #define ND_TRUNCATED 1
> #define ND_INVALID 2
> and use
> longjmp(ndo->early_end, ND_TRUNCATED); /* for packet truncated cases
> */ longjmp(ndo->early_end, ND_INVALID); /* for invalid cases (bad
> length, etc.) */
That could be another way of doing the same thing. In some programs that
could be the best or the only way to tell the reason for returning in a
thread-safe manner, but in this case struct netdissect_options makes it
really easy.
--
Denis Ovsienko
--- End Message ---
_______________________________________________
tcpdump-workers mailing list
tcpdump-workers@lists.tcpdump.org
https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers