-/* Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2003-2019 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
#include <assert.h>
#include <string.h>
static void
-internal_function
add_pad (struct cmsghdr *cmsg, int len)
{
unsigned char *p = CMSG_DATA (cmsg) + cmsg->cmsg_len - CMSG_LEN (0);
beginning (the value y in the alignment term "xn + y"), the type
byte, the length byte, and the option data. */
int
-inet6_option_space (nbytes)
- int nbytes;
+inet6_option_space (int nbytes)
{
/* Add room for the extension header. */
nbytes += sizeof (struct ip6_ext);
contain either Hop-by-Hop or Destination options. It returns 0 on
success or -1 on an error. */
int
-inet6_option_init (bp, cmsgp, type)
- void *bp;
- struct cmsghdr **cmsgp;
- int type;
+inet6_option_init (void *bp, struct cmsghdr **cmsgp, int type)
{
/* Only Hop-by-Hop or Destination options allowed. */
if (type != IPV6_HOPOPTS && type != IPV6_DSTOPTS)
inet6_option_init(). This function returns 0 if it succeeds or -1 on
an error. */
int
-inet6_option_append (cmsg, typep, multx, plusy)
- struct cmsghdr *cmsg;
- const uint8_t *typep;
- int multx;
- int plusy;
+inet6_option_append (struct cmsghdr *cmsg, const uint8_t *typep, int multx,
+ int plusy)
{
/* typep is a pointer to the 8-bit option type. It is assumed that this
field is immediately followed by the 8-bit option data length field,
int dsize = cmsg->cmsg_len - CMSG_LEN (0);
/* The first two bytes of the option are for the extended header. */
- if (__builtin_expect (dsize == 0, 0))
+ if (__glibc_unlikely (dsize == 0))
{
cmsg->cmsg_len += sizeof (struct ip6_ext);
dsize = sizeof (struct ip6_ext);
/* Too long. */
return NULL;
- ((struct ip6_ext *) CMSG_DATA (cmsg))->ip6e_len = len8b;
+ struct ip6_ext *ie = (void *) CMSG_DATA (cmsg);
+ ie->ip6e_len = len8b;
return result;
}
uint8_t *
-inet6_option_alloc (cmsg, datalen, multx, plusy)
- struct cmsghdr *cmsg;
- int datalen;
- int multx;
- int plusy;
+inet6_option_alloc (struct cmsghdr *cmsg, int datalen, int multx, int plusy)
{
return option_alloc (cmsg, datalen, multx, plusy);
}
to be processed, the return value is -1 and *tptrp is NULL. If an
error occurs, the return value is -1 and *tptrp is not NULL. */
int
-inet6_option_next (cmsg, tptrp)
- const struct cmsghdr *cmsg;
- uint8_t **tptrp;
+inet6_option_next (const struct cmsghdr *cmsg, uint8_t **tptrp)
{
/* Make sure it is an option of the right type. */
if (cmsg->cmsg_level != IPPROTO_IPV6
pointer to cmsghdr structure of which cmsg_level equals IPPROTO_IPV6
and cmsg_type equals either IPV6_HOPOPTS or IPV6_DSTOPTS. */
int
-inet6_option_find (cmsg, tptrp, type)
- const struct cmsghdr *cmsg;
- uint8_t **tptrp;
- int type;
+inet6_option_find (const struct cmsghdr *cmsg, uint8_t **tptrp, int type)
{
/* Make sure it is an option of the right type. */
if (cmsg->cmsg_level != IPPROTO_IPV6