Re: [TOMOYO #5 11/18] Network access control functions.

YOSHIFUJI Hideaki / 吉藤英明
2007-11-16T17:57:28Z

Hello.

In article <20071116173527.282964575@I-love.SAKURA.ne.jp> (at Sat, 17 Nov 2007 02:34:50 +0900), penguin-kernel@I-love.SAKURA.ne.jp says:

> + *cp++ = '\0';
> + count = sscanf(cp,
> + NIP6_FMT "-" NIP6_FMT,
> + &min[0], &min[1], &min[2], &min[3],
> + &min[4], &min[5], &min[6], &min[7],
> + &max[0], &max[1], &max[2], &max[3],
> + &max[4], &max[5], &max[6], &max[7]);
> +

I think you can use in6_pton() here.

> + count = sscanf(cp,
> + NIPQUAD_FMT "-" NIPQUAD_FMT,
> + &min[0], &min[1],
> + &min[2], &min[3],
> + &max[0], &max[1],
> + &max[2], &max[3]);
> +

in4_pton().

> +
> +/**
> + * tmy_print_ipv6 - print ipv6 address
> + * @buffer: pointer to buffer to save the result.
> + * @buffer_len: sizeof @buffer .
> + * @ip: pointer to an IPv6 address in network byte order.
> + *
> + * Returns @buffer .
> + */
> +char *tmy_print_ipv6(char *buffer, const int buffer_len, const u16 *ip)
> +{
> + memset(buffer, 0, buffer_len);
> + snprintf(buffer, buffer_len - 1, NIP6_FMT,
> + ntohs(ip[0]), ntohs(ip[1]), ntohs(ip[2]), ntohs(ip[3]),
> + ntohs(ip[4]), ntohs(ip[5]), ntohs(ip[6]), ntohs(ip[7]));
> + return buffer;
> +}
> +

snprintf(buffer, buffer_len - 1, NIP6_FMT, NIP6(*(struct in6_addr *)ip));

> + count = sscanf(cp2,
> + NIP6_FMT "-" NIP6_FMT,
> + &min[0], &min[1], &min[2], &min[3],
> + &min[4], &min[5], &min[6], &min[7],
> + &max[0], &max[1], &max[2], &max[3],
> + &max[4], &max[5], &max[6], &max[7]);
> +

again, in6_pton().

> + count = sscanf(cp2,
> + NIPQUAD_FMT "-" NIPQUAD_FMT,
> + &min[0], &min[1], &min[2], &min[3],
> + &max[0], &max[1], &max[2], &max[3]);
> +

in4_pton().

--yoshfuji