Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: NNN50_CE_Test_UDP NNN50_linux_firmware NNN50_SoftAP_HelloWorld NNN50_BLEWIFISensor ... more
m2m_socket_host_if.h
00001 /** 00002 * 00003 * \file 00004 * 00005 * \brief BSD compatible socket interface internal types. 00006 * 00007 * Copyright (c) 2016-2017 Atmel Corporation. All rights reserved. 00008 * 00009 * \asf_license_start 00010 * 00011 * \page License 00012 * 00013 * Redistribution and use in source and binary forms, with or without 00014 * modification, are permitted provided that the following conditions are met: 00015 * 00016 * 1. Redistributions of source code must retain the above copyright notice, 00017 * this list of conditions and the following disclaimer. 00018 * 00019 * 2. Redistributions in binary form must reproduce the above copyright notice, 00020 * this list of conditions and the following disclaimer in the documentation 00021 * and/or other materials provided with the distribution. 00022 * 00023 * 3. The name of Atmel may not be used to endorse or promote products derived 00024 * from this software without specific prior written permission. 00025 * 00026 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 00027 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00028 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 00029 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 00030 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00031 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00032 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00033 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 00034 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00035 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00036 * POSSIBILITY OF SUCH DAMAGE. 00037 * 00038 * \asf_license_stop 00039 * 00040 */ 00041 #ifndef __M2M_SOCKET_HOST_IF_H__ 00042 #define __M2M_SOCKET_HOST_IF_H__ 00043 00044 00045 #ifdef __cplusplus 00046 extern "C" { 00047 #endif 00048 00049 /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* 00050 INCLUDES 00051 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/ 00052 00053 #ifndef _BOOT_ 00054 #ifndef _FIRMWARE_ 00055 #include "socket/include/socket.h" 00056 #else 00057 #include "m2m_types.h" 00058 #endif 00059 #endif 00060 00061 /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* 00062 MACROS 00063 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/ 00064 00065 /* 00066 * HOSTNAME_MAX_SIZE is defined here and also in host_drv/socket/include/socket.h 00067 * The two definitions must match. 00068 */ 00069 #ifdef _FIRMWARE_ 00070 #define HOSTNAME_MAX_SIZE (64) 00071 #endif 00072 00073 #define SSL_MAX_OPT_LEN HOSTNAME_MAX_SIZE 00074 00075 00076 00077 #define SOCKET_CMD_INVALID 0x00 00078 /*!< 00079 Invlaid Socket command value. 00080 */ 00081 00082 00083 #define SOCKET_CMD_BIND 0x41 00084 /*!< 00085 Socket Binding command value. 00086 */ 00087 00088 00089 #define SOCKET_CMD_LISTEN 0x42 00090 /*!< 00091 Socket Listening command value. 00092 */ 00093 00094 00095 #define SOCKET_CMD_ACCEPT 0x43 00096 /*!< 00097 Socket Accepting command value. 00098 */ 00099 00100 00101 #define SOCKET_CMD_CONNECT 0x44 00102 /*!< 00103 Socket Connecting command value. 00104 */ 00105 00106 00107 #define SOCKET_CMD_SEND 0x45 00108 /*!< 00109 Socket send command value. 00110 */ 00111 00112 00113 #define SOCKET_CMD_RECV 0x46 00114 /*!< 00115 Socket Recieve command value. 00116 */ 00117 00118 00119 #define SOCKET_CMD_SENDTO 0x47 00120 /*!< 00121 Socket sendTo command value. 00122 */ 00123 00124 00125 #define SOCKET_CMD_RECVFROM 0x48 00126 /*!< 00127 Socket RecieveFrom command value. 00128 */ 00129 00130 00131 #define SOCKET_CMD_CLOSE 0x49 00132 /*!< 00133 Socket Close command value. 00134 */ 00135 00136 00137 #define SOCKET_CMD_DNS_RESOLVE 0x4A 00138 /*!< 00139 Socket DNS Resolve command value. 00140 */ 00141 00142 00143 #define SOCKET_CMD_SSL_CONNECT 0x4B 00144 /*!< 00145 SSL-Socket Connect command value. 00146 */ 00147 00148 00149 #define SOCKET_CMD_SSL_SEND 0x4C 00150 /*!< 00151 SSL-Socket Send command value. 00152 */ 00153 00154 00155 #define SOCKET_CMD_SSL_RECV 0x4D 00156 /*!< 00157 SSL-Socket Recieve command value. 00158 */ 00159 00160 00161 #define SOCKET_CMD_SSL_CLOSE 0x4E 00162 /*!< 00163 SSL-Socket Close command value. 00164 */ 00165 00166 00167 #define SOCKET_CMD_SET_SOCKET_OPTION 0x4F 00168 /*!< 00169 Set Socket Option command value. 00170 */ 00171 00172 00173 #define SOCKET_CMD_SSL_CREATE 0x50 00174 /*!< 00175 */ 00176 00177 00178 #define SOCKET_CMD_SSL_SET_SOCK_OPT 0x51 00179 /*!< 00180 */ 00181 00182 00183 #define SOCKET_CMD_PING 0x52 00184 /*!< 00185 */ 00186 00187 00188 #define SOCKET_CMD_SSL_SET_CS_LIST 0x53 00189 /*!< 00190 Recommend instead using @ref M2M_SSL_REQ_SET_CS_LIST and 00191 associated response @ref M2M_SSL_RESP_SET_CS_LIST 00192 */ 00193 00194 00195 #define SOCKET_CMD_SSL_BIND 0x54 00196 /*!< 00197 */ 00198 00199 00200 #define SOCKET_CMD_SSL_EXP_CHECK 0x55 00201 /*!< 00202 */ 00203 00204 00205 00206 #define PING_ERR_SUCCESS 0 00207 #define PING_ERR_DEST_UNREACH 1 00208 #define PING_ERR_TIMEOUT 2 00209 00210 /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* 00211 DATA TYPES 00212 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/ 00213 00214 00215 /*! 00216 * @brief 00217 */ 00218 typedef struct{ 00219 uint16 u16Family; 00220 uint16 u16Port; 00221 uint32 u32IPAddr; 00222 }tstrSockAddr; 00223 00224 00225 typedef sint8 SOCKET; 00226 typedef tstrSockAddr tstrUIPSockAddr; 00227 00228 00229 00230 /*! 00231 @struct \ 00232 tstrDnsReply 00233 00234 @brief 00235 DNS Reply, contains hostName and HostIP. 00236 */ 00237 typedef struct{ 00238 char acHostName[HOSTNAME_MAX_SIZE]; 00239 uint32 u32HostIP; 00240 }tstrDnsReply; 00241 00242 00243 /*! 00244 @brief 00245 */ 00246 typedef struct{ 00247 tstrSockAddr strAddr; 00248 SOCKET sock; 00249 uint8 u8Void; 00250 uint16 u16SessionID; 00251 }tstrBindCmd; 00252 00253 00254 /*! 00255 @brief 00256 */ 00257 typedef struct{ 00258 SOCKET sock; 00259 sint8 s8Status; 00260 uint16 u16SessionID; 00261 }tstrBindReply; 00262 00263 00264 /*! 00265 * @brief 00266 */ 00267 typedef struct{ 00268 SOCKET sock; 00269 uint8 u8BackLog; 00270 uint16 u16SessionID; 00271 }tstrListenCmd; 00272 00273 00274 /*! 00275 @struct \ 00276 tstrSocketRecvMsg 00277 00278 @brief Socket recv status. 00279 00280 It is passed to the APPSocketEventHandler with SOCKET_MSG_RECV or SOCKET_MSG_RECVFROM message type 00281 in a response to a user call to the recv or recvfrom. 00282 If the received data from the remote peer is larger than the USER Buffer size (given at recv call), the data is 00283 delivered to the user in a number of consecutive chunks according to the USER Buffer size. 00284 */ 00285 typedef struct{ 00286 SOCKET sock; 00287 sint8 s8Status; 00288 uint16 u16SessionID; 00289 }tstrListenReply; 00290 00291 00292 /*! 00293 * @brief 00294 */ 00295 typedef struct{ 00296 tstrSockAddr strAddr; 00297 SOCKET sListenSock; 00298 SOCKET sConnectedSock; 00299 uint16 u16AppDataOffset; 00300 /*!< 00301 In further packet send requests the host interface should put the user application 00302 data at this offset in the allocated shared data packet. 00303 */ 00304 }tstrAcceptReply; 00305 00306 00307 /*! 00308 * @brief 00309 */ 00310 typedef struct{ 00311 tstrSockAddr strAddr; 00312 SOCKET sock; 00313 uint8 u8SslFlags; 00314 uint16 u16SessionID; 00315 }tstrConnectCmd; 00316 00317 00318 /*! 00319 @struct \ 00320 tstrConnectReply 00321 00322 @brief 00323 Connect Reply, contains sock number and error value 00324 */ 00325 typedef struct{ 00326 SOCKET sock; 00327 sint8 s8Error; 00328 uint16 u16AppDataOffset; 00329 /*!< 00330 In further packet send requests the host interface should put the user application 00331 data at this offset in the allocated shared data packet. 00332 */ 00333 }tstrConnectReply; 00334 00335 00336 /*! 00337 @brief 00338 */ 00339 typedef struct{ 00340 SOCKET sock; 00341 uint8 u8Void; 00342 uint16 u16DataSize; 00343 tstrSockAddr strAddr; 00344 uint16 u16SessionID; 00345 uint16 u16Void; 00346 }tstrSendCmd; 00347 00348 00349 /*! 00350 @struct \ 00351 tstrSendReply 00352 00353 @brief 00354 Send Reply, contains socket number and number of sent bytes. 00355 */ 00356 typedef struct{ 00357 SOCKET sock; 00358 uint8 u8Void; 00359 sint16 s16SentBytes; 00360 uint16 u16SessionID; 00361 uint16 u16Void; 00362 }tstrSendReply; 00363 00364 00365 /*! 00366 * @brief 00367 */ 00368 typedef struct{ 00369 uint32 u32Timeoutmsec; 00370 SOCKET sock; 00371 uint8 u8Void; 00372 uint16 u16SessionID; 00373 }tstrRecvCmd; 00374 00375 00376 /*! 00377 @struct 00378 @brief 00379 */ 00380 typedef struct{ 00381 tstrSockAddr strRemoteAddr; 00382 sint16 s16RecvStatus; 00383 uint16 u16DataOffset; 00384 SOCKET sock; 00385 uint8 u8Void; 00386 uint16 u16SessionID; 00387 }tstrRecvReply; 00388 00389 00390 /*! 00391 * @brief 00392 */ 00393 typedef struct{ 00394 uint32 u32OptionValue; 00395 SOCKET sock; 00396 uint8 u8Option; 00397 uint16 u16SessionID; 00398 }tstrSetSocketOptCmd; 00399 00400 00401 typedef struct{ 00402 SOCKET sslSock; 00403 uint8 __PAD24__[3]; 00404 }tstrSSLSocketCreateCmd; 00405 00406 00407 /*! 00408 * @brief 00409 */ 00410 typedef struct{ 00411 SOCKET sock; 00412 uint8 u8Option; 00413 uint16 u16SessionID; 00414 uint32 u32OptLen; 00415 uint8 au8OptVal[SSL_MAX_OPT_LEN]; 00416 }tstrSSLSetSockOptCmd; 00417 00418 00419 /*! 00420 */ 00421 typedef struct{ 00422 uint32 u32DestIPAddr; 00423 uint32 u32CmdPrivate; 00424 uint16 u16PingCount; 00425 uint8 u8TTL; 00426 uint8 __PAD8__; 00427 }tstrPingCmd; 00428 00429 00430 typedef struct{ 00431 uint32 u32IPAddr; 00432 uint32 u32CmdPrivate; 00433 uint32 u32RTT; 00434 uint16 u16Success; 00435 uint16 u16Fail; 00436 uint8 u8ErrorCode; 00437 uint8 __PAD24__[3]; 00438 }tstrPingReply; 00439 00440 00441 /*! 00442 @struct\ 00443 tstrSslCertExpSettings 00444 00445 @brief SSL Certificate Expiry Validation Settings 00446 00447 @sa tenuSslCertExpSettings 00448 */ 00449 typedef struct{ 00450 uint32 u32CertExpValidationOpt; 00451 /*!< 00452 See @tenuSslCertExpSettings for possible values. 00453 */ 00454 }tstrSslCertExpSettings; 00455 00456 00457 #ifdef __cplusplus 00458 } 00459 #endif /* __cplusplus */ 00460 00461 #endif /* __M2M_SOCKET_HOST_IF_H__ */ 00462
Generated on Wed Jul 13 2022 16:32:37 by
1.7.2