X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=include%2Fsparse%2Fsys%2Fsocket.h;h=13f61e5082ccc9dff45254e6d61652d76982c27b;hb=6ec5f0c5f0e0b8e5827364a3f1b8b46da8b650ad;hp=89e3c2dc2822220fc062af0892e37c0a5cec8802;hpb=b2fda3effc787f265b5ad5dfa967ac00627bd075;p=openvswitch diff --git a/include/sparse/sys/socket.h b/include/sparse/sys/socket.h index 89e3c2dc..13f61e50 100644 --- a/include/sparse/sys/socket.h +++ b/include/sparse/sys/socket.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Nicira Networks. + * Copyright (c) 2011, 2012 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,6 +47,37 @@ struct msghdr { int msg_flags; }; +struct cmsghdr { + size_t cmsg_len; + int cmsg_level; + int cmsg_type; + unsigned char cmsg_data[]; +}; + +#define __CMSG_ALIGNTO sizeof(size_t) +#define CMSG_ALIGN(LEN) \ + (((LEN) + __CMSG_ALIGNTO - 1) / __CMSG_ALIGNTO * __CMSG_ALIGNTO) +#define CMSG_DATA(CMSG) ((CMSG)->cmsg_data) +#define CMSG_LEN(LEN) (sizeof(struct cmsghdr) + (LEN)) +#define CMSG_SPACE(LEN) CMSG_ALIGN(CMSG_LEN(LEN)) +#define CMSG_FIRSTHDR(MSG) \ + ((MSG)->msg_controllen ? (struct cmsghdr *) (MSG)->msg_control : NULL) +#define CMSG_NXTHDR(MSG, CMSG) __cmsg_nxthdr(MSG, CMSG) + +static inline struct cmsghdr * +__cmsg_nxthdr(struct msghdr *msg, struct cmsghdr *cmsg) +{ + size_t ofs = (char *) cmsg - (char *) msg->msg_control; + size_t next_ofs = ofs + CMSG_ALIGN(cmsg->cmsg_len); + return (next_ofs < msg->msg_controllen + ? (void *) ((char *) msg->msg_control + next_ofs) + : NULL); +} + +enum { + SCM_RIGHTS = 1 +}; + enum { SOCK_DGRAM, SOCK_RAW, @@ -74,7 +105,8 @@ enum { SO_SNDBUF, SO_SNDLOWAT, SO_SNDTIMEO, - SO_TYPE + SO_TYPE, + SO_RCVBUFFORCE }; enum {