1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in 12 * the documentation and/or other materials provided with the 13 * distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29 #include <sys/socket.h> 30 31 #include "header_checks.h" 32 33 static void sys_socket_h() { 34 TYPE(socklen_t); 35 TYPE(sa_family_t); 36 37 TYPE(struct sockaddr); 38 STRUCT_MEMBER(struct sockaddr, sa_family_t, sa_family); 39 STRUCT_MEMBER_ARRAY(struct sockaddr, char/*[]*/, sa_data); 40 41 TYPE(struct sockaddr_storage); 42 STRUCT_MEMBER(struct sockaddr_storage, sa_family_t, ss_family); 43 44 TYPE(struct msghdr); 45 STRUCT_MEMBER(struct msghdr, void*, msg_name); 46 STRUCT_MEMBER(struct msghdr, socklen_t, msg_namelen); 47 STRUCT_MEMBER(struct msghdr, struct iovec*, msg_iov); 48 #if defined(__BIONIC__) || defined(__GLIBC__) 49 STRUCT_MEMBER(struct msghdr, size_t, msg_iovlen); 50 #else 51 STRUCT_MEMBER(struct msghdr, int, msg_iovlen); 52 #endif 53 STRUCT_MEMBER(struct msghdr, void*, msg_control); 54 #if defined(__BIONIC__) || defined(__GLIBC__) 55 STRUCT_MEMBER(struct msghdr, size_t, msg_controllen); 56 #else 57 STRUCT_MEMBER(struct msghdr, socklen_t, msg_controllen); 58 #endif 59 STRUCT_MEMBER(struct msghdr, int, msg_flags); 60 61 TYPE(struct iovec); 62 63 TYPE(struct cmsghdr); 64 #if defined(__BIONIC__) || defined(__GLIBC__) 65 STRUCT_MEMBER(struct cmsghdr, size_t, cmsg_len); 66 #else 67 STRUCT_MEMBER(struct cmsghdr, socklen_t, cmsg_len); 68 #endif 69 STRUCT_MEMBER(struct cmsghdr, int, cmsg_level); 70 STRUCT_MEMBER(struct cmsghdr, int, cmsg_type); 71 72 MACRO(SCM_RIGHTS); 73 74 #if !defined(CMSG_DATA) 75 #error CMSG_DATA 76 #endif 77 #if !defined(CMSG_NXTHDR) 78 #error CMSG_NXTHDR 79 #endif 80 #if !defined(CMSG_FIRSTHDR) 81 #error CMSG_FIRSTHDR 82 #endif 83 84 TYPE(struct linger); 85 STRUCT_MEMBER(struct linger, int, l_onoff); 86 STRUCT_MEMBER(struct linger, int, l_linger); 87 88 MACRO(SOCK_DGRAM); 89 MACRO(SOCK_RAW); 90 MACRO(SOCK_SEQPACKET); 91 MACRO(SOCK_STREAM); 92 93 MACRO(SOL_SOCKET); 94 95 MACRO(SO_ACCEPTCONN); 96 MACRO(SO_BROADCAST); 97 MACRO(SO_DEBUG); 98 MACRO(SO_DONTROUTE); 99 MACRO(SO_ERROR); 100 MACRO(SO_KEEPALIVE); 101 MACRO(SO_LINGER); 102 MACRO(SO_OOBINLINE); 103 MACRO(SO_RCVBUF); 104 MACRO(SO_RCVLOWAT); 105 MACRO(SO_RCVTIMEO); 106 MACRO(SO_REUSEADDR); 107 MACRO(SO_SNDBUF); 108 MACRO(SO_SNDLOWAT); 109 MACRO(SO_SNDTIMEO); 110 MACRO(SO_TYPE); 111 112 MACRO(SOMAXCONN); 113 114 MACRO(MSG_CTRUNC); 115 MACRO(MSG_DONTROUTE); 116 MACRO(MSG_EOR); 117 MACRO(MSG_OOB); 118 MACRO(MSG_NOSIGNAL); 119 MACRO(MSG_PEEK); 120 MACRO(MSG_TRUNC); 121 MACRO(MSG_WAITALL); 122 123 MACRO(AF_INET); 124 MACRO(AF_INET6); 125 MACRO(AF_UNIX); 126 MACRO_VALUE(AF_UNSPEC, 0); 127 128 MACRO(SHUT_RD); 129 MACRO(SHUT_RDWR); 130 MACRO(SHUT_WR); 131 132 TYPE(size_t); 133 TYPE(ssize_t); 134 135 FUNCTION(accept, int (*f)(int, struct sockaddr*, socklen_t*)); 136 FUNCTION(bind, int (*f)(int, const struct sockaddr*, socklen_t)); 137 FUNCTION(connect, int (*f)(int, const struct sockaddr*, socklen_t)); 138 FUNCTION(getpeername, int (*f)(int, struct sockaddr*, socklen_t*)); 139 FUNCTION(getsockname, int (*f)(int, struct sockaddr*, socklen_t*)); 140 FUNCTION(getsockopt, int (*f)(int, int, int, void*, socklen_t*)); 141 FUNCTION(listen, int (*f)(int, int)); 142 FUNCTION(recv, ssize_t (*f)(int, void*, size_t, int)); 143 FUNCTION(recvfrom, ssize_t (*f)(int, void*, size_t, int, struct sockaddr*, socklen_t*)); 144 FUNCTION(send, ssize_t (*f)(int, const void*, size_t, int)); 145 FUNCTION(sendmsg, ssize_t (*f)(int, const struct msghdr*, int)); 146 FUNCTION(sendto, ssize_t (*f)(int, const void*, size_t, int, const struct sockaddr*, socklen_t)); 147 FUNCTION(setsockopt, int (*f)(int, int, int, const void*, socklen_t)); 148 FUNCTION(shutdown, int (*f)(int, int)); 149 #if !defined(__BIONIC__) // Obsolete, plus ioctl disallowed by SELinux. 150 FUNCTION(sockatmark, int (*f)(int)); 151 #endif 152 FUNCTION(socket, int (*f)(int, int, int)); 153 FUNCTION(socketpair, int (*f)(int, int, int, int[2])); 154 } 155