libUPnP
1.6.17
|
00001 #ifndef GENLIB_NET_SOCK_H 00002 #define GENLIB_NET_SOCK_H 00003 00004 /************************************************************************** 00005 * 00006 * Copyright (c) 2000-2003 Intel Corporation 00007 * All rights reserved. 00008 * Copyright (c) 2012 France Telecom All rights reserved. 00009 * 00010 * Redistribution and use in source and binary forms, with or without 00011 * modification, are permitted provided that the following conditions are met: 00012 * 00013 * - Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * - Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * - Neither name of Intel Corporation nor the names of its contributors 00019 * may be used to endorse or promote products derived from this software 00020 * without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00025 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR 00026 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00027 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00028 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00029 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00030 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00031 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00032 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 * 00034 **************************************************************************/ 00035 00044 #include "UpnpInet.h" /* for SOCKET, netinet/in */ 00045 #include "UpnpGlobal.h" /* for UPNP_INLINE */ 00046 00047 /* The following are not defined under winsock.h */ 00048 #ifndef SD_RECEIVE 00049 #define SD_RECEIVE 0x00 00050 #define SD_SEND 0x01 00051 #define SD_BOTH 0x02 00052 #endif 00053 00055 typedef struct 00056 { 00058 SOCKET socket; 00060 struct sockaddr_storage foreign_sockaddr; 00061 } SOCKINFO; 00062 00063 #ifdef __cplusplus 00064 extern "C" { 00065 #endif 00066 00072 static UPNP_INLINE int sock_close( 00074 SOCKET sock) 00075 { 00076 int ret = -1; 00077 00078 if (sock != INVALID_SOCKET) 00079 ret = UpnpCloseSocket(sock); 00080 00081 return ret; 00082 } 00083 00093 int sock_init( 00095 SOCKINFO *info, 00097 SOCKET sockfd); 00098 00108 int sock_init_with_ip( 00110 SOCKINFO* info, 00112 SOCKET sockfd, 00114 struct sockaddr *foreign_sockaddr); 00115 00127 int sock_destroy( 00129 SOCKINFO* info, 00131 int ShutdownMethod); 00132 00141 int sock_read( 00143 SOCKINFO *info, 00145 char* buffer, 00147 size_t bufsize, 00149 int *timeoutSecs); 00150 00159 int sock_write( 00161 SOCKINFO *info, 00163 const char *buffer, 00165 size_t bufsize, 00167 int *timeoutSecs); 00168 00174 int sock_make_blocking( 00175 /* [in] socket. */ 00176 SOCKET sock); 00177 00183 int sock_make_no_blocking( 00184 /* [in] socket. */ 00185 SOCKET sock); 00186 00187 #ifdef __cplusplus 00188 } /* #extern "C" */ 00189 #endif 00190 00191 /* @} Sock Network Socket Library */ 00192 00193 #endif /* GENLIB_NET_SOCK_H */