| 1 | /* |
| 2 | Copyright (c) 2012, Broadcom Europe Ltd |
| 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 are met: |
| 7 | * Redistributions of source code must retain the above copyright |
| 8 | notice, this list of conditions and the following disclaimer. |
| 9 | * Redistributions in binary form must reproduce the above copyright |
| 10 | notice, this list of conditions and the following disclaimer in the |
| 11 | documentation and/or other materials provided with the distribution. |
| 12 | * Neither the name of the copyright holder nor the |
| 13 | names of its contributors may be used to endorse or promote products |
| 14 | derived from this software without specific prior written permission. |
| 15 | |
| 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
| 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | #ifndef _NET_SOCKETS_PRIV_H_ |
| 29 | #define _NET_SOCKETS_PRIV_H_ |
| 30 | |
| 31 | #include "net_sockets.h" |
| 32 | |
| 33 | #ifdef WIN32 |
| 34 | #include "net_sockets_win32.h" |
| 35 | #else |
| 36 | #include "net_sockets_bsd.h" |
| 37 | #endif |
| 38 | |
| 39 | #ifdef __cplusplus |
| 40 | extern "C" { |
| 41 | #endif |
| 42 | |
| 43 | typedef enum |
| 44 | { |
| 45 | STREAM_CLIENT = 0, /**< TCP client */ |
| 46 | STREAM_SERVER, /**< TCP server */ |
| 47 | DATAGRAM_SENDER, /**< UDP sender */ |
| 48 | DATAGRAM_RECEIVER /**< UDP receiver */ |
| 49 | } vc_container_net_type_t; |
| 50 | |
| 51 | |
| 52 | /** Perform implementation-specific per-socket initialization. |
| 53 | * |
| 54 | * \return VC_CONTAINER_NET_SUCCESS or one of the error codes on failure. */ |
| 55 | vc_container_net_status_t vc_container_net_private_init( void ); |
| 56 | |
| 57 | /** Perform implementation-specific per-socket deinitialization. |
| 58 | * This function is always called once for each successful call to socket_private_init(). */ |
| 59 | void vc_container_net_private_deinit( void ); |
| 60 | |
| 61 | /** Return the last error from the socket implementation. */ |
| 62 | vc_container_net_status_t vc_container_net_private_last_error( void ); |
| 63 | |
| 64 | /** Implementation-specific internal socket close. |
| 65 | * |
| 66 | * \param sock Internal socket to be closed. */ |
| 67 | void vc_container_net_private_close( SOCKET_T sock ); |
| 68 | |
| 69 | /** Enable or disable socket address reusability. |
| 70 | * |
| 71 | * \param sock Internal socket to be closed. |
| 72 | * \param enable True to enable reusability, false to clear it. */ |
| 73 | void vc_container_net_private_set_reusable( SOCKET_T sock, bool enable ); |
| 74 | |
| 75 | /** Query the maximum datagram size for the socket. |
| 76 | * |
| 77 | * \param sock The socket to query. |
| 78 | * \return The maximum supported datagram size on the socket. */ |
| 79 | size_t vc_container_net_private_maximum_datagram_size( SOCKET_T sock ); |
| 80 | |
| 81 | #ifdef __cplusplus |
| 82 | } |
| 83 | #endif |
| 84 | |
| 85 | #endif /* _NET_SOCKETS_PRIV_H_ */ |
| 86 | |