Commit Graph

17 Commits

Author SHA1 Message Date
Pedro F. Giffuni
422fa64be3 Minor indentation issue. 2016-04-20 16:03:53 +00:00
Pedro F. Giffuni
75a5de5a40 libc: use our roundup2/rounddown2() macros when param.h is available.
rounddown2 tends to produce longer lines than the original code but
still it makes the code more readable.
2016-04-20 01:21:39 +00:00
Andriy Voskoboinyk
2cf5e9365d libc: do not include <sys/types.h> where <sys/param.h> was already included
According to style(9):
> normally, include <sys/types.h> OR <sys/param.h>, but not both.
(<sys/param.h> already includes <sys/types.h> when LOCORE is not defined).
2016-04-18 21:05:15 +00:00
Pedro F. Giffuni
7c498a0950 Hint out check for unsigned negative values.
On FreeBSD socklen_t is unsigned so the check negative len
in inet6_opt_append() is redundant and likely to be optimized
away by the compiler.

On other operating systems this is not necessarily so, and
in the future we may want to sign it so leave the check in
but place it in a secondary position as a subtle indication
that the bogus check is intentional.

Discussed with:	rpaulo

CID:	1017783
2015-02-27 01:59:29 +00:00
Marcel Moolenaar
4ed06f2924 Accept RFC 2292 option values so that RFC 2292 compliant programs that
are unaware of RFC 3542 can construct control messages.

The kernel disallows mixing RFC 2292 behaviour with RFC 3542 behaviour.
Only sockets that have specifically been marked as using the RFC 2292
API can use RFC 2292 specific options. This is all good and well, but
libc itself seems inconsistent with this.

The root cause of this inconsistency seems to relate to the definitions
of IPV6_HOPOPTS and IPV6_DSTOPTS. They are defined in RFC 2292 and re-used
in RFC 3542, yet have distinct values in the kernel. It's for this reason
that the kernel also has definitions for IPV6_2292HOPOPTS and
IPV6_2292DSTOPTS. Not so in libc.

For example: some program calls inet6_option_init() (defined by RFC 2292)
with the RFC 2292 defined IPV6_HOPOPTS and IPV6_DSTOPTS. Before RFC 3542,
this was translated to values of 22 and 23 (resp.) The libc implementation
correctly checks that only options IPV6_HOPOPTS and IPV6_DSTOPTS are given
(as per RFC 2292) but since these defines have taken on the values defined
by RFC 3542 (values 49 and 50 resp,) rejects the correct option values
(22 and 23) passed said program and returns -1.

The precisie fix is to have inet6_option_init() and friends only accept the
RFC 2292 defined IPV6_HOPOPTS & IPV6_DSTOPTS, but that breaks other code
(like mld6query(8)), which seem to not be aware of RFC 3542 and how it
hi-jacked the option names. So the best fix is to accept the options from
both.

Obtained from:	Juniper Networks, Inc.
MFC after:	1 week
2014-04-05 18:32:40 +00:00
Eitan Adler
7059326b09 libc/net: fix a portability issue
* POSIX does not require socklen_t to be  unsigned

Submitted by:	bde
MFC After:	1 week (with r261454)
2014-02-05 02:00:31 +00:00
Eitan Adler
c6c4136a0a libc/net: Fix some issues in inet6_opt_init() (from RFC 3542):
* The RFC says (in section 10.1) that only when extbuf is not NULL,
extlen shall be checked, so don't perform this check when NULL is
passed.

* socklen_t is unsigned, so checking extlen for less than zero is
not needed.

Submitted by:	swildner@dragonflybsd.org
Reviewed by:	Mark Martinec <Mark.Martinec+freebsd@ijs.si>
Reviewed by:	hrs
Obtained by:	DragonFlyBSD
2014-02-04 03:01:33 +00:00
Eitan Adler
db702c59cf remove duplicate semicolons where possible.
Approved by:	cperciva
MFC after:	1 week
2012-10-22 03:00:37 +00:00
Hajimu UMEMOTO
a087c7295d ANSIfy.
MFC after:	1 week
2009-11-11 15:21:06 +00:00
Hajimu UMEMOTO
d84e21303c refer RFC 3542 rather than RFC 2292bis.
Submitted by:	Keiichi SHIMA <keiichi__at__iijlab.net>
Obtained from:	KAME
2005-07-19 18:13:58 +00:00
Hajimu UMEMOTO
2daa2369f0 u_int8_t cannot carry a number greater than 255.
Reported by:	nectar
2003-11-14 18:07:50 +00:00
Hajimu UMEMOTO
8827557e37 according to RFC3542 10.5, the 5th argment of inet6_opt_next()
is not size_t but socklen_t.

Reported by:	tinderbox
2003-10-25 06:51:23 +00:00
Hajimu UMEMOTO
f95d46333d Switch Advanced Sockets API for IPv6 from RFC2292 to RFC3542
(aka RFC2292bis).  Though I believe this commit doesn't break
backward compatibility againt existing binaries, it breaks
backward compatibility of API.
Now, the applications which use Advanced Sockets API such as
telnet, ping6, mld6query and traceroute6 use RFC3542 API.

Obtained from:	KAME
2003-10-24 18:26:30 +00:00
Maxime Henrion
434252892a An u_int8_t can never be bigger than 255, so remove a useless check.
Spotted by:	GCC
2003-07-25 12:23:25 +00:00
David E. O'Brien
333fc21e3c Fix the style of the SCM ID's.
I believe have made all of libc .c's as consistent as possible.
2002-03-22 21:53:29 +00:00
David E. O'Brien
8fb3f3f682 Remove 'register' keyword. 2002-03-21 18:49:23 +00:00
Yoshinobu Inoue
05a244b407 KAME 4th patch
IPv6 specific library functions addition.
(getnameinfo(), getaddrinfo(), and IPv6 transport support is not yet)

Reviewed by: freebsd-arch, cvs-committers
Obtained from: KAME project
1999-12-16 18:32:01 +00:00