--- Begin Message ---
On 17/09/2020 22:05, Francois-Xavier Le Bail via tcpdump-workers wrote:
> On 17/09/2020 16:15, Denis Ovsienko via tcpdump-workers wrote:
>> On Sat, 5 Sep 2020 18:20:42 +0200
>> Francois-Xavier Le Bail via tcpdump-workers
>> <tcpdump-workers@lists.tcpdump.org> wrote:
>>
>>> 2) Process all the truncated cases with:
>>> ndo->ndo_ll_hdr_len = 0;
>>> longjmp(ndo->ndo_truncated, 1);
>>> (With a new macro, like 'ND_TRUNCATED' or 'ND_IS_TRUNCATED')
>> The master branch now has a change along these lines. Whilst preparing
>> changes to a couple decoders based on that (still work in progress), I
>> managed to make some observations, will post as soon as it all looks
>> good and makes sense.
> Should we have something like:
> 
>         if (setjmp(ndo->early_end) == 0) {
>                 /* Print the packet. */
>                 (ndo->ndo_if_printer)(ndo, h, sp);
>         } else {
>                 switch (ndo->early_end_reason) {
>               case TRUNCATED:
>                       /* A printer quit because the packet was truncated; 
> report it */
>                       nd_print_trunc(ndo);
>                       break;
>                 case INVALID:
>                       ...
>               }
>         }
> 
> (ndo->ndo_truncated -> ndo->early_end and ndo->early_end_reason = 
> TRUNCATED/INVALID/other?

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.) 
*/

-- 
Francois-Xavier

--- End Message ---
_______________________________________________
tcpdump-workers mailing list
tcpdump-workers@lists.tcpdump.org
https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers

Reply via email to