On 2015-04-25 at 09:07:35 +0200, Vadim Kochan <[email protected]> wrote:
> On Thu, Apr 23, 2015 at 02:24:16PM +0300, Vadim Kochan wrote:
> >  static inline void __show_frame_hdr(uint8_t *packet, size_t len, int 
> > linktype,
> >                                 struct sockaddr_ll *s_ll, void *raw_hdr,
> > -                               int mode, bool v3)
> > +                               int mode, bool v3, unsigned long *count)
> >  {
> >     char tmp[IFNAMSIZ];
> >     union tpacket_uhdr hdr;
> > @@ -73,34 +73,40 @@ static inline void __show_frame_hdr(uint8_t *packet, 
> > size_t len, int linktype,
> >             pkttype = hdr->nlmsg_pid == 0 ? PACKET_KERNEL : PACKET_USER;
> >     }
> >  
> > +   if (count)
> > +           *count += 1;
> > +
> >     hdr.raw = raw_hdr;
> >     switch (mode) {
> >     case PRINT_LESS:
> > -           tprintf("%s %s %u",
> > +           tprintf("%s %s %u (#%lu) ",
> >                     packet_types[pkttype] ? : "?",
> >                     if_indextoname(s_ll->sll_ifindex, tmp) ? : "?",
> > -                   tpacket_uhdr(hdr, tp_len, v3));
> > +                   tpacket_uhdr(hdr, tp_len, v3), *count);
> >             break;
> >     default:
> > -           tprintf("%s %s %u %us.%uns %s\n",
> > +           tprintf("%s %s %u %us.%uns %s (#%lu)\n",
> >                     packet_types[pkttype] ? : "?",
> >                     if_indextoname(s_ll->sll_ifindex, tmp) ? : "?",
> >                     tpacket_uhdr(hdr, tp_len, v3),
> >                     tpacket_uhdr(hdr, tp_sec, v3),
> >                     tpacket_uhdr(hdr, tp_nsec, v3),
> > -                   v3 ? "" : __show_ts_source(hdr.h2->tp_status));
> > +                   v3 ? "" : __show_ts_source(hdr.h2->tp_status), *count);
> >             break;
> >     }
> >  }
> 
> I just realized that count will be dereferenced even if it was passed as
> NULL so if you agree with the feature I can re-send v2 ...

Why pass the count as as pointer in the first place? I'd rather pass it
by value and do the increment at the calling site (even if it means a
bit of code duplication).

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to