[PATCH] add traceroute6 applet
Denys Vlasenko
vda.linux at googlemail.com
Sun Nov 22 21:31:13 UTC 2009
On Sunday 22 November 2009 13:03, Leonid Lisovskiy wrote:
> On Sat, Nov 21, 2009 at 6:28 PM, Denys Vlasenko
> <vda.linux at googlemail.com> wrote:
>
> > Reviewed.
>
> Patch reworked, one comment below:
>
> > + printf("\n%d bytes from %s to "
> > + "%s: icmp type %d (%s) code %d\n",
> > + cc,
> > + inet_ntop(AF_INET6, &from_lsa->u.sin6.sin6_addr, pa1, sizeof(pa1)),
> > + inet_ntop(AF_INET6, to, pa2, sizeof(pa2)),
> > + type, pr_type(type, AF_INET6), icp->icmp6_code);
> > +
> > + cc -= sizeof(struct icmp6_hdr);
> > + for (i = 0; i < cc ; i++) {
> > + if (i % 16 == 0)
> > + printf("%04x:", i);
> > + if (i % 4 == 0)
> > + printf(" ");
> > + printf("%02x", 0xff & (unsigned)p[i]);
> > + if (i % 16 == 15 && i + 1 < cc)
> > + printf("\n");
> > + }
>
> > Maybe bin2hex() can be used here?
>
> Original author wants output formatted as:
> 0000: 00010203 04050607 08090a0b 0c0d0e0f
>
> bin2hex() saves code only in case of no spaces between every four bytes.
You can achieve it this way (mkswap.c uses it):
printf("%.8s %.8s %.8s %.8s", bin2hex_result);
Of course, it makes sense if it is really smaller.
--
vda
More information about the busybox
mailing list