Jinbuhm Kim
/
W5500_Driver
Wiznet W5500 driver and TCP/UDP loopback
Embed:
(wiki syntax)
Show/hide line numbers
socket.h
00001 /* Wiznet W5500 Library 00002 * Copyright (c) 2013, WIZnet Co., LTD. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 /** 00018 * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs 00019 * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. 00020 * But there is a little bit of difference. 00021 * @details 00022 * <b> Comparison between WIZnet and Berkeley SOCKET APIs </b> 00023 * <table> 00024 * <tr> <td><b>API</b></td> <td><b>WIZnet</b></td> <td><b>Berkeley</b></td> </tr> 00025 * <tr> <td>socket()</td> <td>O</td> <td>O</td> </tr> 00026 * <tr> <td><b>bind()</b></td> <td>X</td> <td>O</td> </tr> 00027 * <tr> <td><b>listen()</b></td> <td>O</td> <td>O</td> </tr> 00028 * <tr> <td><b>connect()</b></td> <td>O</td> <td>O</td> </tr> 00029 * <tr> <td><b>accept()</b></td> <td>X</td> <td>O</td> </tr> 00030 * <tr> <td><b>recv()</b></td> <td>O</td> <td>O</td> </tr> 00031 * <tr> <td><b>send()</b></td> <td>O</td> <td>O</td> </tr> 00032 * <tr> <td><b>recvfrom()</b></td> <td>O</td> <td>O</td> </tr> 00033 * <tr> <td><b>sendto()</b></td> <td>O</td> <td>O</td> </tr> 00034 * <tr> <td><b>closesocket()</b></td> <td>O<br>close() & disconnect()</td> <td>O</td> </tr> 00035 * </table> 00036 * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, 00037 * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, 00038 * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n 00039 * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. 00040 * When the listen SOCKET accepts a connection request from a client, it keeps listening. 00041 * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n 00042 * Following figure shows network flow diagram by Berkeley SOCKET API. 00043 * @image html Berkeley_SOCKET.jpg "<Berkeley SOCKET API>" 00044 * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n 00045 * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, 00046 * it is changed in order to communicate with the client. 00047 * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n 00048 * If there're many listen SOCKET with same listen port number and a client requests a connection, 00049 * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n 00050 * Following figure shows network flow diagram by WIZnet SOCKET API. 00051 * @image html WIZnet_SOCKET.jpg "<WIZnet SOCKET API>" 00052 */ 00053 #ifdef __cplusplus 00054 extern "C" { 00055 #endif 00056 00057 #ifndef _SOCKET_H_ 00058 #define _SOCKET_H_ 00059 00060 #include "Ethernet/wizchip_conf.h" 00061 00062 #define SOCK_OK 1 ///< Result is OK about socket process. 00063 #define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. 00064 #define SOCK_FATAL -1000 ///< Result is fatal error about socket process. 00065 00066 #define SOCK_ERROR 0 00067 #define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number 00068 #define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option 00069 #define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized 00070 #define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. 00071 #define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. 00072 #define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag 00073 #define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. 00074 #define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argrument. 00075 #define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero 00076 #define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address 00077 #define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred 00078 #define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. 00079 #define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. 00080 00081 #define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. 00082 00083 /* 00084 * SOCKET FLAG 00085 */ 00086 #define SF_ETHER_OWN (Sn_MR_MFEN) ///< In \ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet 00087 #define SF_IGMP_VER2 (Sn_MR_MC) ///< In \ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. 00088 #define SF_TCP_NODELAY (Sn_MR_ND) ///< In \ref Sn_MR_TCP, Use to nodelayed ack. 00089 #define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In \ref Sn_MR_UDP, Enable multicast mode. 00090 00091 #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In \ref Sn_MR_UDP or \ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 00092 #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In \ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 00093 #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In \ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 00094 #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In \ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 00095 00096 #define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). 00097 00098 /* 00099 * UDP & MACRAW Packet Infomation 00100 */ 00101 #define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. 00102 #define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remaine a packet to be received. 00103 #define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. 00104 00105 /** 00106 * @ingroup WIZnet_socket_APIs 00107 * @brief Open a socket. 00108 * @details Initializes the socket with 'sn' passed as parameter and open. 00109 * 00110 * @param sn Socket number. It should be <b>0 ~ @ref \_WIZCHIP_SOCK_NUM_</b>. 00111 * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. 00112 * @param port Port number to be bined. 00113 * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n 00114 * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. 00115 * @sa Sn_MR 00116 * 00117 * @return @b Success : The socket number @b 'sn' passed as parameter\n 00118 * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n 00119 * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n 00120 * @ref SOCKERR_SOCKFLAG - Invaild socket flag. 00121 */ 00122 int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); 00123 00124 /** 00125 * @ingroup WIZnet_socket_APIs 00126 * @brief Close a socket. 00127 * @details It closes the socket with @b'sn' passed as parameter. 00128 * 00129 * @param sn Socket number. It should be <b>0 ~ @ref \_WIZCHIP_SOCK_NUM_</b>. 00130 * 00131 * @return @b Success : @ref SOCK_OK \n 00132 * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number 00133 */ 00134 int8_t close(uint8_t sn); 00135 00136 /** 00137 * @ingroup WIZnet_socket_APIs 00138 * @brief Listen to a connection request from a client. 00139 * @details It is listening to a connection request from a client. 00140 * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. 00141 * 00142 * @param sn Socket number. It should be <b>0 ~ @ref \_WIZCHIP_SOCK_NUM_</b>. 00143 * @return @b Success : @ref SOCK_OK \n 00144 * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n 00145 * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. 00146 */ 00147 int8_t listen(uint8_t sn); 00148 00149 /** 00150 * @ingroup WIZnet_socket_APIs 00151 * @brief Try to connect a server. 00152 * @details It requests connection to the server with destination IP address and port number passed as parameter.\n 00153 * @note It is valid only in TCP client mode. 00154 * In block io mode, it does not return until connection is completed. 00155 * In Non-block io mode, it return @ref SOCK_BUSY immediatly. 00156 * 00157 * @param sn Socket number. It should be <b>0 ~ @ref \_WIZCHIP_SOCK_NUM_</b>. 00158 * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. 00159 * @param port Destination port number. 00160 * 00161 * @return @b Success : @ref SOCK_OK \n 00162 * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n 00163 * @ref SOCKERR_SOCKMODE - Invalid socket mode\n 00164 * @ref SOCKERR_SOCKINIT - Socket is not initialized\n 00165 * @ref SOCKERR_IPINVALID - Wrong server IP address\n 00166 * @ref SOCKERR_PORTZERO - Server port zero\n 00167 * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n 00168 * @ref SOCK_BUSY - In non-block io mode, it returned immediatly\n 00169 */ 00170 int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port); 00171 00172 /** 00173 * @ingroup WIZnet_socket_APIs 00174 * @brief Try to disconnect a connection socket. 00175 * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. 00176 * @note It is valid only in TCP server or client mode. \n 00177 * In block io mode, it does not return until disconnection is completed. \n 00178 * In Non-block io mode, it return @ref SOCK_BUSY immediatly. \n 00179 00180 * @param sn Socket number. It should be <b>0 ~ @ref \_WIZCHIP_SOCK_NUM_</b>. 00181 * @return @b Success : @ref SOCK_OK \n 00182 * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n 00183 * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n 00184 * @ref SOCKERR_TIMEOUT - Timeout occurred \n 00185 * @ref SOCK_BUSY - Socket is busy. 00186 */ 00187 int8_t disconnect(uint8_t sn); 00188 00189 /** 00190 * @ingroup WIZnet_socket_APIs 00191 * @brief Send data to the connected peer in TCP socket. 00192 * @details It is used to send outgoing data to the connected socket. 00193 * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n 00194 * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n 00195 * In non-block io mode, It return @ref SOCK_BUSY immediatly when socket buffer is not enough. \n 00196 * @param sn Socket number. It should be <b>0 ~ @ref \_WIZCHIP_SOCK_NUM_</b>. 00197 * @param buf Pointer buffer containing data to be sent. 00198 * @param len The byte length of data in buf. 00199 * @return @b Success : The sent data size \n 00200 * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n 00201 * @ref SOCKERR_TIMEOUT - Timeout occurred \n 00202 * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n 00203 * @ref SOCKERR_SOCKNUM - Invalid socket number \n 00204 * @ref SOCKERR_DATALEN - zero data length \n 00205 * @ref SOCK_BUSY - Socket is busy. 00206 */ 00207 int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); 00208 00209 /** 00210 * @ingroup WIZnet_socket_APIs 00211 * @brief Receive data from the connected peer. 00212 * @details It is used to read incoming data from the connected socket.\n 00213 * It waits for data as much as the application wants to receive. 00214 * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n 00215 * In block io mode, it doesn't return until data reception is completed - data is filled as <I>len</I> in socket buffer. \n 00216 * In non-block io mode, it return @ref SOCK_BUSY immediatly when <I>len</I> is greater than data size in socket buffer. \n 00217 * 00218 * @param sn Socket number. It should be <b>0 ~ @ref \_WIZCHIP_SOCK_NUM_</b>. 00219 * @param buf Pointer buffer to read incoming data. 00220 * @param len The max data length of data in buf. 00221 * @return @b Success : The real received data size \n 00222 * @b Fail :\n 00223 * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n 00224 * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n 00225 * @ref SOCKERR_SOCKNUM - Invalid socket number \n 00226 * @ref SOCKERR_DATALEN - zero data length \n 00227 * @ref SOCK_BUSY - Socket is busy. 00228 */ 00229 int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); 00230 00231 /** 00232 * @ingroup WIZnet_socket_APIs 00233 * @brief Sends datagram to the peer with destination IP address and port number passed as parameter. 00234 * @details It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.\n 00235 * Even if the connectionless socket has been previously connected to a specific address, 00236 * the address and port number parameters override the destination address for that particular datagram only. 00237 * @note In block io mode, It doesn't return until data send is completed - socket buffer size is greater than <I>len</I>. 00238 * In non-block io mode, It return @ref SOCK_BUSY immediatly when socket buffer is not enough. 00239 * 00240 * @param sn Socket number. It should be <b>0 ~ @ref \_WIZCHIP_SOCK_NUM_</b>. 00241 * @param buf Pointer buffer to send outgoing data. 00242 * @param len The byte length of data in buf. 00243 * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. 00244 * @param port Destination port number. 00245 * 00246 * @return @b Success : The sent data size \n 00247 * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n 00248 * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n 00249 * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n 00250 * @ref SOCKERR_DATALEN - zero data length \n 00251 * @ref SOCKERR_IPINVALID - Wrong server IP address\n 00252 * @ref SOCKERR_PORTZERO - Server port zero\n 00253 * @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n 00254 * @ref SOCKERR_TIMEOUT - Timeout occurred \n 00255 * @ref SOCK_BUSY - Socket is busy. 00256 */ 00257 int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); 00258 00259 /** 00260 * @ingroup WIZnet_socket_APIs 00261 * @brief Receive datagram of UDP or MACRAW 00262 * @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n 00263 * This function is used to receive UDP and MAC_RAW mode, and handle the header as well. 00264 * This function can divide to recevie the packet data. 00265 * On the MACRAW SOCKET, the addr and port parameters are ignored. 00266 * @note In block io mode, it doesn't return until data reception is completed - data is filled as <I>len</I> in socket buffer 00267 * In non-block io mode, it return @ref SOCK_BUSY immediatly when <I>len</I> is greater than data size in socket buffer. 00268 * 00269 * @param sn Socket number. It should be <b>0 ~ @ref \_WIZCHIP_SOCK_NUM_</b>. 00270 * @param buf Pointer buffer to read incoming data. 00271 * @param len The max data length of data in buf. 00272 * When the received packet size <= len, receives data as packet sized. 00273 * When others, receives data as len. 00274 * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. 00275 * It is valid only when the first call recvform for receiving the packet. 00276 * When it is valid, packinfo[7] should be set as '1'. 00277 * @param port Pointer variable of destination port number. 00278 * It is valid only when the first call recvform for receiving the packet. 00279 * When it is valid, packinfo[7] should be set as '1'. 00280 * @param packinfo Notify whether the packet is received completely or not. 00281 * When it completed to receive the packet data in socket buffer, packinfo[0] set as '0'. @ref PACK_FIRST 00282 * When it Remained packet data that receives not yet but remained in socket buffer, packinfo[1] set as '1'. @ref PACK_COMPLETED 00283 * 00284 * @return @b Success : This function return real received data size for success.\n 00285 * @b Fail : @ref SOCKERR_DATALEN - zero data length \n 00286 * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n 00287 * @ref SOCKERR_SOCKNUM - Invalid socket number \n 00288 * @ref SOCKBUSY - Socket is busy. 00289 */ 00290 int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port, uint8_t* packinfo); 00291 00292 00293 ///////////////////////////// 00294 // SOCKET CONTROL & OPTION // 00295 ///////////////////////////// 00296 #define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). 00297 #define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). 00298 00299 /** 00300 * @defgroup DATA_TYPE DATA TYPE 00301 */ 00302 00303 /** 00304 * @ingroup DATA_TYPE 00305 * @brief The kind of Socket Interrupt. 00306 * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() 00307 */ 00308 typedef enum 00309 { 00310 SIK_CONNECTED = (1 << 0), ///< conntected 00311 SIK_DISCONNECTED = (1 << 1), ///< disconnected 00312 SIK_RECEIVED = (1 << 2), ///< data received 00313 SIK_TIMEOUT = (1 << 3), ///< timeout occured 00314 SIK_SENT = (1 << 4), ///< send ok 00315 SIK_ALL = 0x1F, ///< all interrupt 00316 }sockint_kind; 00317 00318 /** 00319 * @ingroup DATA_TYPE 00320 * @brief The type of @ref ctlsocket(). 00321 */ 00322 typedef enum 00323 { 00324 CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK 00325 CS_GET_IOMODE, ///< get socket IO mode 00326 CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory 00327 CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory 00328 CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind 00329 CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind 00330 CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind 00331 CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind 00332 }ctlsock_type; 00333 00334 00335 /** 00336 * @ingroup DATA_TYPE 00337 * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() 00338 */ 00339 typedef enum 00340 { 00341 SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to <I>flag</I> in @ref socket(). 00342 SO_TTL, ///< Set/Get TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) 00343 SO_TOS, ///< Set/Get TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) 00344 SO_MSS, ///< Set/Get MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) 00345 SO_DESTIP, ///< Set/Get the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) 00346 SO_DESTPORT, ///< Set/Get the destionation Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) 00347 SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode 00348 SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transimittion timer in TCP mode 00349 SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() 00350 SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() 00351 SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() 00352 SO_REMAINSIZE ///< Valid only in getsockopt. Get the remaind packet size in other then TCP mode. 00353 }sockopt_type; 00354 00355 /** 00356 * @ingroup WIZnet_socket_APIs 00357 * @brief Control socket. 00358 * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. 00359 * Refer to @ref ctlsock_type. 00360 * @param sn socket number 00361 * @param cstype type of control socket. refer to @ref ctlsock_type. 00362 * @param arg Data type and value is determined according to @ref ctlsock_type. \n 00363 * <table> 00364 * <tr> <td> @b cstype </td> <td> @b data type</td><td>@b value</td></tr> 00365 * <tr> <td> @ref CS_SET_IOMODE \n @ref CS_GET_IOMODE </td> <td> uint8_t </td><td>@ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK</td></tr> 00366 * <tr> <td> @ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF </td> <td> uint16_t </td><td> 0 ~ 16K </td></tr> 00367 * <tr> <td> @ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT </td> <td> @ref sockint_kind </td><td> @ref SIK_CONNECTED, etc. </td></tr> 00368 * <tr> <td> @ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK </td> <td> @ref sockint_kind </td><td> @ref SIK_CONNECTED, etc. </td></tr> 00369 * </table> 00370 * @return @b Success @ref SOCK_OK \n 00371 * @b fail @ref SOCKERR_ARG - Invalid argument\n 00372 */ 00373 int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); 00374 00375 /** 00376 * @ingroup WIZnet_socket_APIs 00377 * @brief set socket options 00378 * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. 00379 * 00380 * @param sn socket number 00381 * @param sotype socket option type. refer to @ref sockopt_type 00382 * @param arg Data type and value is determined according to <I>sotype</I>. \n 00383 * <table> 00384 * <tr> <td> @b sotype </td> <td> @b data type</td><td>@b value</td></tr> 00385 * <tr> <td> @ref SO_TTL </td> <td> uint8_t </td><td> 0 ~ 255 </td> </tr> 00386 * <tr> <td> @ref SO_TOS </td> <td> uint8_t </td><td> 0 ~ 255 </td> </tr> 00387 * <tr> <td> @ref SO_MSS </td> <td> uint16_t </td><td> 0 ~ 65535 </td> </tr> 00388 * <tr> <td> @ref SO_DESTIP </td> <td> uint8_t[4] </td><td> </td></tr> 00389 * <tr> <td> @ref SO_DESTPORT </td> <td> uint16_t </td><td> 0 ~ 65535 </td></tr> 00390 * <tr> <td> @ref SO_KEEPALIVESEND </td> <td> null </td><td> null </td></tr> 00391 * <tr> <td> @ref SO_KEEPALIVEAUTO </td> <td> uint8_t </td><td> 0 ~ 255 </td></tr> 00392 * </table> 00393 * @return 00394 * - @b Success : @ref SOCK_OK \n 00395 * - @b Fail 00396 * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n 00397 * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n 00398 * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n 00399 * - @ref SOCKERR_TIMEOUT - Timeout occured when sending keep-alive packet \n 00400 */ 00401 int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); 00402 00403 /** 00404 * @ingroup WIZnet_socket_APIs 00405 * @brief get socket options 00406 * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type 00407 * @param sn socket number 00408 * @param sotype socket option type. refer to @ref sockopt_type 00409 * @param arg Data type and value is determined according to <I>sotype</I>. \n 00410 * <table> 00411 * <tr> <td> @b sotype </td> <td>@b data type</td><td>@b value</td></tr> 00412 * <tr> <td> @ref SO_FLAG </td> <td> uint8_t </td><td> @ref SF_ETHER_OWN, etc... </td> </tr> 00413 * <tr> <td> @ref SO_TOS </td> <td> uint8_t </td><td> 0 ~ 255 </td> </tr> 00414 * <tr> <td> @ref SO_MSS </td> <td> uint16_t </td><td> 0 ~ 65535 </td> </tr> 00415 * <tr> <td> @ref SO_DESTIP </td> <td> uint8_t[4] </td><td> </td></tr> 00416 * <tr> <td> @ref SO_DESTPORT </td> <td> uint16_t </td><td> </td></tr> 00417 * <tr> <td> @ref SO_KEEPALIVEAUTO </td> <td> uint8_t </td><td> 0 ~ 255 </td></tr> 00418 * <tr> <td> @ref SO_SENDBUF </td> <td> uint16_t </td><td> 0 ~ 65535 </td></tr> 00419 * <tr> <td> @ref SO_RECVBUF </td> <td> uint16_t </td><td> 0 ~ 65535 </td></tr> 00420 * <tr> <td> @ref SO_STATUS </td> <td> uint8_t </td><td> @ref SOCK_ESTABLISHED, etc.. </td></tr> 00421 * <tr> <td> @ref SO_REMAINSIZE </td> <td> uint16_t </td><td> 0~ 65535 </td></tr> 00422 * </table> 00423 * @return 00424 * - @b Success : @ref SOCK_OK \n 00425 * - @b Fail 00426 * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n 00427 * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n 00428 * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n 00429 */ 00430 int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); 00431 00432 #endif // _SOCKET_H_ 00433 00434 #ifdef __cplusplus 00435 } 00436 #endif
Generated on Tue Jul 12 2022 18:48:21 by 1.7.2