Re: Maybe need to enrich `-T' option in netcat manual

2018-09-21 Thread Jason McIntyre
On Fri, Sep 21, 2018 at 10:07:54PM +0800, Nan Xiao wrote:
> Hi Jason,
> 
> Thanks very much for your response!
> 
> I check the ping & traceroute code, For ping:
> 
> if (options & F_TTL) {
> if (IN_MULTICAST(ntohl(dst4.sin_addr.s_addr)))
> moptions |= MULTICAST_TTL;
> else
> options |= F_HDRINCL;
> }
> 
> For traceroute:
> void
> check_tos(struct ip *ip, int *last_tos)
> {
> struct icmp *icp;
> struct ip *inner_ip;
> 
> icp = (struct icmp *) (((u_char *)ip)+(ip->ip_hl<<2));
> inner_ip = (struct ip *) (((u_char *)icp)+8);
> 
> if (inner_ip->ip_tos != *last_tos)
> printf (" (TOS=%d!)", inner_ip->ip_tos);
> 
> *last_tos = inner_ip->ip_tos;
> }
> 
> They indeed don't handle IPv6. But for netcat, it actually hangle IPv6
> case at leaet from code in preceding mail. If netcat doesn't want to
> handle IPv6 intentionally, I think the IPv6 code should be removed,
> thanks!
> 

if you submit a diff for whatever improvement you hope for, there is a
chance i can find people to review it and possibly commit it.

judging by the lack of responses from everyone else about your mail, i'd
say nothing will happen without such a diff.

jmc



Re: Maybe need to enrich `-T' option in netcat manual

2018-09-21 Thread Nan Xiao
Hi Jason,

Thanks very much for your response!

I check the ping & traceroute code, For ping:

if (options & F_TTL) {
if (IN_MULTICAST(ntohl(dst4.sin_addr.s_addr)))
moptions |= MULTICAST_TTL;
else
options |= F_HDRINCL;
}

For traceroute:
void
check_tos(struct ip *ip, int *last_tos)
{
struct icmp *icp;
struct ip *inner_ip;

icp = (struct icmp *) (((u_char *)ip)+(ip->ip_hl<<2));
inner_ip = (struct ip *) (((u_char *)icp)+8);

if (inner_ip->ip_tos != *last_tos)
printf (" (TOS=%d!)", inner_ip->ip_tos);

*last_tos = inner_ip->ip_tos;
}

They indeed don't handle IPv6. But for netcat, it actually hangle IPv6
case at leaet from code in preceding mail. If netcat doesn't want to
handle IPv6 intentionally, I think the IPv6 code should be removed,
thanks!

Best Regards
Nan Xiao
On Thu, Sep 20, 2018 at 7:45 PM Jason McIntyre  wrote:
>
> On Wed, Sep 19, 2018 at 06:35:13PM +0800, Nan Xiao wrote:
> > Hi tech@,
> >
> > For `-T' option explanation in netcat manual:
> >
> > -T keyword
> > Change the IPv4 TOS value or the TLS options.
> >
> > But in fact, the netcat code not only processes IPv4 but also IPv6:
> >
> >   if (Tflag != -1) {
> >   if (af == AF_INET && setsockopt(s, IPPROTO_IP,
> >   IP_TOS, , sizeof(Tflag)) == -1)
> >   err(1, "set IP ToS");
> >
> >   else if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6,
> >   IPV6_TCLASS, , sizeof(Tflag)) == -1)
> >   err(1, "set IPv6 traffic class");
> >   }
> >
> > So I think maybe the netcat manual should be enriched at least for `-T'
> > option, thanks!
> >
>
> hi.
>
> i think if you submit a diff, there will be a better chance of getting
> an ok (or otherwise).
>
> i'm unsure about -T myself. i know that we synced the -T options for
> ping/nc/traceroute to keep them in sync with pf, but none of those other
> docs claim support for ip6 classes - actually quite the opposite.
> so i'm unsure if they work (have you tested?) or whether we want to
> document them.
>
> jmc
>



Re: Maybe need to enrich `-T' option in netcat manual

2018-09-20 Thread Jason McIntyre
On Wed, Sep 19, 2018 at 06:35:13PM +0800, Nan Xiao wrote:
> Hi tech@,
> 
> For `-T' option explanation in netcat manual:
> 
> -T keyword
> Change the IPv4 TOS value or the TLS options.
> 
> But in fact, the netcat code not only processes IPv4 but also IPv6:
> 
>   if (Tflag != -1) {
>   if (af == AF_INET && setsockopt(s, IPPROTO_IP,
>   IP_TOS, , sizeof(Tflag)) == -1)
>   err(1, "set IP ToS");
> 
>   else if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6,
>   IPV6_TCLASS, , sizeof(Tflag)) == -1)
>   err(1, "set IPv6 traffic class");
>   }
> 
> So I think maybe the netcat manual should be enriched at least for `-T'
> option, thanks!
> 

hi.

i think if you submit a diff, there will be a better chance of getting
an ok (or otherwise).

i'm unsure about -T myself. i know that we synced the -T options for
ping/nc/traceroute to keep them in sync with pf, but none of those other
docs claim support for ip6 classes - actually quite the opposite.
so i'm unsure if they work (have you tested?) or whether we want to
document them.

jmc



Maybe need to enrich `-T' option in netcat manual

2018-09-19 Thread Nan Xiao
Hi tech@,

For `-T' option explanation in netcat manual:

-T keyword
Change the IPv4 TOS value or the TLS options.

But in fact, the netcat code not only processes IPv4 but also IPv6:

if (Tflag != -1) {
if (af == AF_INET && setsockopt(s, IPPROTO_IP,
IP_TOS, , sizeof(Tflag)) == -1)
err(1, "set IP ToS");

else if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6,
IPV6_TCLASS, , sizeof(Tflag)) == -1)
err(1, "set IPv6 traffic class");
}

So I think maybe the netcat manual should be enriched at least for `-T'
option, thanks!

-- 
Best Regards
Nan Xiao