Back to index

glibc  2.9
Functions | Variables
inet6_option.c File Reference
#include <assert.h>
#include <string.h>
#include <netinet/in.h>
#include <netinet/ip6.h>
#include <sys/param.h>

Go to the source code of this file.

Functions

static void internal_function add_pad (struct cmsghdr *cmsg, int len)
static int get_opt_end (const uint8_t **result, const uint8_t *startp, const uint8_t *endp)
static uint8_toption_alloc (struct cmsghdr *cmsg, int datalen, int multx, int plusy)
int inet6_option_space (int nbytes)
 link_warning (inet6_option_space,"inet6_option_space is obsolete, use the RFC 3542 interfaces") int inet6_option_init(bp

Variables

 cmsgp
type void * bp
int type
const uint8_ttypep
int multx
int plusy
int datalen
uint8_t ** tptrp

Function Documentation

static void internal_function add_pad ( struct cmsghdr cmsg,
int  len 
) [static]

Definition at line 29 of file inet6_option.c.

{
  unsigned char *p = CMSG_DATA (cmsg) + cmsg->cmsg_len - CMSG_LEN (0);

  if (len == 1)
    /* Special handling for 1, a one-byte solution.  */
    *p++ = IP6OPT_PAD1;
  else if (len != 0)
    {
      /* Multibyte padding.  */
      *p++ = IP6OPT_PADN;
      *p++ = len - 2;       /* Discount the two header bytes.  */
      /* The rest is filled with zero.  */
      memset (p, '\0', len - 2);
      p += len - 2;
    }

  /* Account for the bytes.  */
  cmsg->cmsg_len += len;
}
static int get_opt_end ( const uint8_t **  result,
const uint8_t startp,
const uint8_t endp 
) [static]

Definition at line 52 of file inet6_option.c.

{
  if (startp >= endp)
    /* Out of bounds.  */
    return -1;

  if (*startp == IP6OPT_PAD1)
    {
      /* Just this one byte.  */
      *result = startp + 1;
      return 0;
    }

  /* Now we know there must be at least two bytes.  */
  if (startp + 2 > endp
      /* Now we can get the length byte.  */
      || startp + startp[1] + 2 > endp)
    return -1;

  *result = startp + startp[1] + 2;

  return 0;
}
int inet6_option_space ( int  nbytes)

Definition at line 92 of file inet6_option.c.

{
  /* Add room for the extension header.  */
  nbytes += sizeof (struct ip6_ext);

  return CMSG_SPACE (roundup (nbytes, 8));
}
link_warning ( inet6_option_space  ,
"inet6_option_space is  obsolete,
use the RFC 3542 interfaces"   
)
static uint8_t* option_alloc ( struct cmsghdr cmsg,
int  datalen,
int  multx,
int  plusy 
) [static]

Variable Documentation

type void* bp

Definition at line 110 of file inet6_option.c.

struct cmsghdr ** cmsgp

Definition at line 110 of file inet6_option.c.

Definition at line 227 of file inet6_option.c.

Definition at line 150 of file inet6_option.c.

Definition at line 151 of file inet6_option.c.

Definition at line 249 of file inet6_option.c.

Definition at line 113 of file inet6_option.c.

Definition at line 148 of file inet6_option.c.