Back to index

glibc  2.9
cmsg_nxthdr.c File Reference
#include <stddef.h>
#include <sys/socket.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


struct cmsghdr__cmsg_nxthdr (struct msghdr *mhdr, struct cmsghdr *cmsg)

Function Documentation

struct cmsghdr* __cmsg_nxthdr ( struct msghdr mhdr,
struct cmsghdr cmsg 
) [read]

Definition at line 25 of file cmsg_nxthdr.c.

  if ((size_t) cmsg->cmsg_len < sizeof (struct cmsghdr))
    /* The kernel header does this so there may be a reason.  */
    return NULL;

  cmsg = (struct cmsghdr *) ((unsigned char *) cmsg
                          + CMSG_ALIGN (cmsg->cmsg_len));
  if ((unsigned char *) (cmsg + 1) > ((unsigned char *) mhdr->msg_control
                                  + mhdr->msg_controllen)
      || ((unsigned char *) cmsg + CMSG_ALIGN (cmsg->cmsg_len)
         > ((unsigned char *) mhdr->msg_control + mhdr->msg_controllen)))
    /* No more entries.  */
    return NULL;
  return cmsg;