Preliminary main mbed library for nexpaq development

Committer:
nexpaq
Date:
Fri Nov 04 20:54:50 2016 +0000
Revision:
1:d96dbedaebdb
Parent:
0:6c56fb4bc5f0
Removed extra directories for other platforms

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nexpaq 0:6c56fb4bc5f0 1 /* NetworkStack
nexpaq 0:6c56fb4bc5f0 2 * Copyright (c) 2015 ARM Limited
nexpaq 0:6c56fb4bc5f0 3 *
nexpaq 0:6c56fb4bc5f0 4 * Licensed under the Apache License, Version 2.0 (the "License");
nexpaq 0:6c56fb4bc5f0 5 * you may not use this file except in compliance with the License.
nexpaq 0:6c56fb4bc5f0 6 * You may obtain a copy of the License at
nexpaq 0:6c56fb4bc5f0 7 *
nexpaq 0:6c56fb4bc5f0 8 * http://www.apache.org/licenses/LICENSE-2.0
nexpaq 0:6c56fb4bc5f0 9 *
nexpaq 0:6c56fb4bc5f0 10 * Unless required by applicable law or agreed to in writing, software
nexpaq 0:6c56fb4bc5f0 11 * distributed under the License is distributed on an "AS IS" BASIS,
nexpaq 0:6c56fb4bc5f0 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
nexpaq 0:6c56fb4bc5f0 13 * See the License for the specific language governing permissions and
nexpaq 0:6c56fb4bc5f0 14 * limitations under the License.
nexpaq 0:6c56fb4bc5f0 15 */
nexpaq 0:6c56fb4bc5f0 16
nexpaq 0:6c56fb4bc5f0 17 #ifndef NETWORK_STACK_H
nexpaq 0:6c56fb4bc5f0 18 #define NETWORK_STACK_H
nexpaq 0:6c56fb4bc5f0 19
nexpaq 0:6c56fb4bc5f0 20 #include "nsapi_types.h"
nexpaq 0:6c56fb4bc5f0 21 #include "network-socket/SocketAddress.h"
nexpaq 0:6c56fb4bc5f0 22 #include "network-socket/NetworkInterface.h"
nexpaq 0:6c56fb4bc5f0 23
nexpaq 0:6c56fb4bc5f0 24
nexpaq 0:6c56fb4bc5f0 25 /** NetworkStack class
nexpaq 0:6c56fb4bc5f0 26 *
nexpaq 0:6c56fb4bc5f0 27 * Common interface that is shared between hardware that
nexpaq 0:6c56fb4bc5f0 28 * can connect to a network over IP. By implementing the
nexpaq 0:6c56fb4bc5f0 29 * NetworkStack, a network stack can be used as a target
nexpaq 0:6c56fb4bc5f0 30 * for instantiating network sockets.
nexpaq 0:6c56fb4bc5f0 31 */
nexpaq 0:6c56fb4bc5f0 32 class NetworkStack
nexpaq 0:6c56fb4bc5f0 33 {
nexpaq 0:6c56fb4bc5f0 34 public:
nexpaq 0:6c56fb4bc5f0 35 virtual ~NetworkStack() {};
nexpaq 0:6c56fb4bc5f0 36
nexpaq 0:6c56fb4bc5f0 37 /** Get the local IP address
nexpaq 0:6c56fb4bc5f0 38 *
nexpaq 0:6c56fb4bc5f0 39 * @return Null-terminated representation of the local IP address
nexpaq 0:6c56fb4bc5f0 40 * or null if not yet connected
nexpaq 0:6c56fb4bc5f0 41 */
nexpaq 0:6c56fb4bc5f0 42 virtual const char *get_ip_address() = 0;
nexpaq 0:6c56fb4bc5f0 43
nexpaq 0:6c56fb4bc5f0 44 /** Translates a hostname to an IP address
nexpaq 0:6c56fb4bc5f0 45 *
nexpaq 0:6c56fb4bc5f0 46 * The hostname may be either a domain name or an IP address. If the
nexpaq 0:6c56fb4bc5f0 47 * hostname is an IP address, no network transactions will be performed.
nexpaq 0:6c56fb4bc5f0 48 *
nexpaq 0:6c56fb4bc5f0 49 * If no stack-specific DNS resolution is provided, the hostname
nexpaq 0:6c56fb4bc5f0 50 * will be resolve using a UDP socket on the stack.
nexpaq 0:6c56fb4bc5f0 51 *
nexpaq 0:6c56fb4bc5f0 52 * @param address Destination for the host SocketAddress
nexpaq 0:6c56fb4bc5f0 53 * @param host Hostname to resolve
nexpaq 0:6c56fb4bc5f0 54 * @return 0 on success, negative error code on failure
nexpaq 0:6c56fb4bc5f0 55 */
nexpaq 0:6c56fb4bc5f0 56 virtual int gethostbyname(SocketAddress *address, const char *host);
nexpaq 0:6c56fb4bc5f0 57
nexpaq 0:6c56fb4bc5f0 58 /* Set stack-specific stack options
nexpaq 0:6c56fb4bc5f0 59 *
nexpaq 0:6c56fb4bc5f0 60 * The setstackopt allow an application to pass stack-specific hints
nexpaq 0:6c56fb4bc5f0 61 * to the underlying stack. For unsupported options,
nexpaq 0:6c56fb4bc5f0 62 * NSAPI_ERROR_UNSUPPORTED is returned and the stack is unmodified.
nexpaq 0:6c56fb4bc5f0 63 *
nexpaq 0:6c56fb4bc5f0 64 * @param level Stack-specific protocol level
nexpaq 0:6c56fb4bc5f0 65 * @param optname Stack-specific option identifier
nexpaq 0:6c56fb4bc5f0 66 * @param optval Option value
nexpaq 0:6c56fb4bc5f0 67 * @param optlen Length of the option value
nexpaq 0:6c56fb4bc5f0 68 * @return 0 on success, negative error code on failure
nexpaq 0:6c56fb4bc5f0 69 */
nexpaq 0:6c56fb4bc5f0 70 virtual int setstackopt(int level, int optname, const void *optval, unsigned optlen);
nexpaq 0:6c56fb4bc5f0 71
nexpaq 0:6c56fb4bc5f0 72 /* Get stack-specific stack options
nexpaq 0:6c56fb4bc5f0 73 *
nexpaq 0:6c56fb4bc5f0 74 * The getstackopt allow an application to retrieve stack-specific hints
nexpaq 0:6c56fb4bc5f0 75 * from the underlying stack. For unsupported options,
nexpaq 0:6c56fb4bc5f0 76 * NSAPI_ERROR_UNSUPPORTED is returned and optval is unmodified.
nexpaq 0:6c56fb4bc5f0 77 *
nexpaq 0:6c56fb4bc5f0 78 * @param level Stack-specific protocol level
nexpaq 0:6c56fb4bc5f0 79 * @param optname Stack-specific option identifier
nexpaq 0:6c56fb4bc5f0 80 * @param optval Destination for option value
nexpaq 0:6c56fb4bc5f0 81 * @param optlen Length of the option value
nexpaq 0:6c56fb4bc5f0 82 * @return 0 on success, negative error code on failure
nexpaq 0:6c56fb4bc5f0 83 */
nexpaq 0:6c56fb4bc5f0 84 virtual int getstackopt(int level, int optname, void *optval, unsigned *optlen);
nexpaq 0:6c56fb4bc5f0 85
nexpaq 0:6c56fb4bc5f0 86 protected:
nexpaq 0:6c56fb4bc5f0 87 friend class Socket;
nexpaq 0:6c56fb4bc5f0 88 friend class UDPSocket;
nexpaq 0:6c56fb4bc5f0 89 friend class TCPSocket;
nexpaq 0:6c56fb4bc5f0 90 friend class TCPServer;
nexpaq 0:6c56fb4bc5f0 91
nexpaq 0:6c56fb4bc5f0 92 /** Opens a socket
nexpaq 0:6c56fb4bc5f0 93 *
nexpaq 0:6c56fb4bc5f0 94 * Creates a network socket and stores it in the specified handle.
nexpaq 0:6c56fb4bc5f0 95 * The handle must be passed to following calls on the socket.
nexpaq 0:6c56fb4bc5f0 96 *
nexpaq 0:6c56fb4bc5f0 97 * A stack may have a finite number of sockets, in this case
nexpaq 0:6c56fb4bc5f0 98 * NSAPI_ERROR_NO_SOCKET is returned if no socket is available.
nexpaq 0:6c56fb4bc5f0 99 *
nexpaq 0:6c56fb4bc5f0 100 * @param handle Destination for the handle to a newly created socket
nexpaq 0:6c56fb4bc5f0 101 * @param proto Protocol of socket to open, NSAPI_TCP or NSAPI_UDP
nexpaq 0:6c56fb4bc5f0 102 * @return 0 on success, negative error code on failure
nexpaq 0:6c56fb4bc5f0 103 */
nexpaq 0:6c56fb4bc5f0 104 virtual int socket_open(nsapi_socket_t *handle, nsapi_protocol_t proto) = 0;
nexpaq 0:6c56fb4bc5f0 105
nexpaq 0:6c56fb4bc5f0 106 /** Close the socket
nexpaq 0:6c56fb4bc5f0 107 *
nexpaq 0:6c56fb4bc5f0 108 * Closes any open connection and deallocates any memory associated
nexpaq 0:6c56fb4bc5f0 109 * with the socket.
nexpaq 0:6c56fb4bc5f0 110 *
nexpaq 0:6c56fb4bc5f0 111 * @param handle Socket handle
nexpaq 0:6c56fb4bc5f0 112 * @return 0 on success, negative error code on failure
nexpaq 0:6c56fb4bc5f0 113 */
nexpaq 0:6c56fb4bc5f0 114 virtual int socket_close(nsapi_socket_t handle) = 0;
nexpaq 0:6c56fb4bc5f0 115
nexpaq 0:6c56fb4bc5f0 116 /** Bind a specific address to a socket
nexpaq 0:6c56fb4bc5f0 117 *
nexpaq 0:6c56fb4bc5f0 118 * Binding a socket specifies the address and port on which to recieve
nexpaq 0:6c56fb4bc5f0 119 * data. If the IP address is zeroed, only the port is bound.
nexpaq 0:6c56fb4bc5f0 120 *
nexpaq 0:6c56fb4bc5f0 121 * @param handle Socket handle
nexpaq 0:6c56fb4bc5f0 122 * @param address Local address to bind
nexpaq 0:6c56fb4bc5f0 123 * @return 0 on success, negative error code on failure.
nexpaq 0:6c56fb4bc5f0 124 */
nexpaq 0:6c56fb4bc5f0 125 virtual int socket_bind(nsapi_socket_t handle, const SocketAddress &address) = 0;
nexpaq 0:6c56fb4bc5f0 126
nexpaq 0:6c56fb4bc5f0 127 /** Listen for connections on a TCP socket
nexpaq 0:6c56fb4bc5f0 128 *
nexpaq 0:6c56fb4bc5f0 129 * Marks the socket as a passive socket that can be used to accept
nexpaq 0:6c56fb4bc5f0 130 * incoming connections.
nexpaq 0:6c56fb4bc5f0 131 *
nexpaq 0:6c56fb4bc5f0 132 * @param handle Socket handle
nexpaq 0:6c56fb4bc5f0 133 * @param backlog Number of pending connections that can be queued
nexpaq 0:6c56fb4bc5f0 134 * simultaneously
nexpaq 0:6c56fb4bc5f0 135 * @return 0 on success, negative error code on failure
nexpaq 0:6c56fb4bc5f0 136 */
nexpaq 0:6c56fb4bc5f0 137 virtual int socket_listen(nsapi_socket_t handle, int backlog) = 0;
nexpaq 0:6c56fb4bc5f0 138
nexpaq 0:6c56fb4bc5f0 139 /** Connects TCP socket to a remote host
nexpaq 0:6c56fb4bc5f0 140 *
nexpaq 0:6c56fb4bc5f0 141 * Initiates a connection to a remote server specified by the
nexpaq 0:6c56fb4bc5f0 142 * indicated address.
nexpaq 0:6c56fb4bc5f0 143 *
nexpaq 0:6c56fb4bc5f0 144 * @param handle Socket handle
nexpaq 0:6c56fb4bc5f0 145 * @param address The SocketAddress of the remote host
nexpaq 0:6c56fb4bc5f0 146 * @return 0 on success, negative error code on failure
nexpaq 0:6c56fb4bc5f0 147 */
nexpaq 0:6c56fb4bc5f0 148 virtual int socket_connect(nsapi_socket_t handle, const SocketAddress &address) = 0;
nexpaq 0:6c56fb4bc5f0 149
nexpaq 0:6c56fb4bc5f0 150 /** Accepts a connection on a TCP socket
nexpaq 0:6c56fb4bc5f0 151 *
nexpaq 0:6c56fb4bc5f0 152 * The server socket must be bound and set to listen for connections.
nexpaq 0:6c56fb4bc5f0 153 * On a new connection, creates a network socket and stores it in the
nexpaq 0:6c56fb4bc5f0 154 * specified handle. The handle must be passed to following calls on
nexpaq 0:6c56fb4bc5f0 155 * the socket.
nexpaq 0:6c56fb4bc5f0 156 *
nexpaq 0:6c56fb4bc5f0 157 * A stack may have a finite number of sockets, in this case
nexpaq 0:6c56fb4bc5f0 158 * NSAPI_ERROR_NO_SOCKET is returned if no socket is available.
nexpaq 0:6c56fb4bc5f0 159 *
nexpaq 0:6c56fb4bc5f0 160 * This call is non-blocking. If accept would block,
nexpaq 0:6c56fb4bc5f0 161 * NSAPI_ERROR_WOULD_BLOCK is returned immediately.
nexpaq 0:6c56fb4bc5f0 162 *
nexpaq 0:6c56fb4bc5f0 163 * @param server Socket handle to server to accept from
nexpaq 0:6c56fb4bc5f0 164 * @param handle Destination for a handle to the newly created socket
nexpaq 0:6c56fb4bc5f0 165 * @param address Destination for the remote address or NULL
nexpaq 0:6c56fb4bc5f0 166 * @return 0 on success, negative error code on failure
nexpaq 0:6c56fb4bc5f0 167 */
nexpaq 0:6c56fb4bc5f0 168 virtual int socket_accept(nsapi_socket_t server, nsapi_socket_t *handle, SocketAddress *address=0) = 0;
nexpaq 0:6c56fb4bc5f0 169
nexpaq 0:6c56fb4bc5f0 170 /** Send data over a TCP socket
nexpaq 0:6c56fb4bc5f0 171 *
nexpaq 0:6c56fb4bc5f0 172 * The socket must be connected to a remote host. Returns the number of
nexpaq 0:6c56fb4bc5f0 173 * bytes sent from the buffer.
nexpaq 0:6c56fb4bc5f0 174 *
nexpaq 0:6c56fb4bc5f0 175 * This call is non-blocking. If send would block,
nexpaq 0:6c56fb4bc5f0 176 * NSAPI_ERROR_WOULD_BLOCK is returned immediately.
nexpaq 0:6c56fb4bc5f0 177 *
nexpaq 0:6c56fb4bc5f0 178 * @param handle Socket handle
nexpaq 0:6c56fb4bc5f0 179 * @param data Buffer of data to send to the host
nexpaq 0:6c56fb4bc5f0 180 * @param size Size of the buffer in bytes
nexpaq 0:6c56fb4bc5f0 181 * @return Number of sent bytes on success, negative error
nexpaq 0:6c56fb4bc5f0 182 * code on failure
nexpaq 0:6c56fb4bc5f0 183 */
nexpaq 0:6c56fb4bc5f0 184 virtual int socket_send(nsapi_socket_t handle, const void *data, unsigned size) = 0;
nexpaq 0:6c56fb4bc5f0 185
nexpaq 0:6c56fb4bc5f0 186 /** Receive data over a TCP socket
nexpaq 0:6c56fb4bc5f0 187 *
nexpaq 0:6c56fb4bc5f0 188 * The socket must be connected to a remote host. Returns the number of
nexpaq 0:6c56fb4bc5f0 189 * bytes received into the buffer.
nexpaq 0:6c56fb4bc5f0 190 *
nexpaq 0:6c56fb4bc5f0 191 * This call is non-blocking. If recv would block,
nexpaq 0:6c56fb4bc5f0 192 * NSAPI_ERROR_WOULD_BLOCK is returned immediately.
nexpaq 0:6c56fb4bc5f0 193 *
nexpaq 0:6c56fb4bc5f0 194 * @param handle Socket handle
nexpaq 0:6c56fb4bc5f0 195 * @param data Destination buffer for data received from the host
nexpaq 0:6c56fb4bc5f0 196 * @param size Size of the buffer in bytes
nexpaq 0:6c56fb4bc5f0 197 * @return Number of received bytes on success, negative error
nexpaq 0:6c56fb4bc5f0 198 * code on failure
nexpaq 0:6c56fb4bc5f0 199 */
nexpaq 0:6c56fb4bc5f0 200 virtual int socket_recv(nsapi_socket_t handle, void *data, unsigned size) = 0;
nexpaq 0:6c56fb4bc5f0 201
nexpaq 0:6c56fb4bc5f0 202 /** Send a packet over a UDP socket
nexpaq 0:6c56fb4bc5f0 203 *
nexpaq 0:6c56fb4bc5f0 204 * Sends data to the specified address. Returns the number of bytes
nexpaq 0:6c56fb4bc5f0 205 * sent from the buffer.
nexpaq 0:6c56fb4bc5f0 206 *
nexpaq 0:6c56fb4bc5f0 207 * This call is non-blocking. If sendto would block,
nexpaq 0:6c56fb4bc5f0 208 * NSAPI_ERROR_WOULD_BLOCK is returned immediately.
nexpaq 0:6c56fb4bc5f0 209 *
nexpaq 0:6c56fb4bc5f0 210 * @param handle Socket handle
nexpaq 0:6c56fb4bc5f0 211 * @param address The SocketAddress of the remote host
nexpaq 0:6c56fb4bc5f0 212 * @param data Buffer of data to send to the host
nexpaq 0:6c56fb4bc5f0 213 * @param size Size of the buffer in bytes
nexpaq 0:6c56fb4bc5f0 214 * @return Number of sent bytes on success, negative error
nexpaq 0:6c56fb4bc5f0 215 * code on failure
nexpaq 0:6c56fb4bc5f0 216 */
nexpaq 0:6c56fb4bc5f0 217 virtual int socket_sendto(nsapi_socket_t handle, const SocketAddress &address, const void *data, unsigned size) = 0;
nexpaq 0:6c56fb4bc5f0 218
nexpaq 0:6c56fb4bc5f0 219 /** Receive a packet over a UDP socket
nexpaq 0:6c56fb4bc5f0 220 *
nexpaq 0:6c56fb4bc5f0 221 * Receives data and stores the source address in address if address
nexpaq 0:6c56fb4bc5f0 222 * is not NULL. Returns the number of bytes received into the buffer.
nexpaq 0:6c56fb4bc5f0 223 *
nexpaq 0:6c56fb4bc5f0 224 * This call is non-blocking. If recvfrom would block,
nexpaq 0:6c56fb4bc5f0 225 * NSAPI_ERROR_WOULD_BLOCK is returned immediately.
nexpaq 0:6c56fb4bc5f0 226 *
nexpaq 0:6c56fb4bc5f0 227 * @param handle Socket handle
nexpaq 0:6c56fb4bc5f0 228 * @param address Destination for the source address or NULL
nexpaq 0:6c56fb4bc5f0 229 * @param data Destination buffer for data received from the host
nexpaq 0:6c56fb4bc5f0 230 * @param size Size of the buffer in bytes
nexpaq 0:6c56fb4bc5f0 231 * @return Number of received bytes on success, negative error
nexpaq 0:6c56fb4bc5f0 232 * code on failure
nexpaq 0:6c56fb4bc5f0 233 */
nexpaq 0:6c56fb4bc5f0 234 virtual int socket_recvfrom(nsapi_socket_t handle, SocketAddress *address, void *buffer, unsigned size) = 0;
nexpaq 0:6c56fb4bc5f0 235
nexpaq 0:6c56fb4bc5f0 236 /** Register a callback on state change of the socket
nexpaq 0:6c56fb4bc5f0 237 *
nexpaq 0:6c56fb4bc5f0 238 * The specified callback will be called on state changes such as when
nexpaq 0:6c56fb4bc5f0 239 * the socket can recv/send/accept successfully and on when an error
nexpaq 0:6c56fb4bc5f0 240 * occurs. The callback may also be called spuriously without reason.
nexpaq 0:6c56fb4bc5f0 241 *
nexpaq 0:6c56fb4bc5f0 242 * The callback may be called in an interrupt context and should not
nexpaq 0:6c56fb4bc5f0 243 * perform expensive operations such as recv/send calls.
nexpaq 0:6c56fb4bc5f0 244 *
nexpaq 0:6c56fb4bc5f0 245 * @param handle Socket handle
nexpaq 0:6c56fb4bc5f0 246 * @param callback Function to call on state change
nexpaq 0:6c56fb4bc5f0 247 * @param data Argument to pass to callback
nexpaq 0:6c56fb4bc5f0 248 */
nexpaq 0:6c56fb4bc5f0 249 virtual void socket_attach(nsapi_socket_t handle, void (*callback)(void *), void *data) = 0;
nexpaq 0:6c56fb4bc5f0 250
nexpaq 0:6c56fb4bc5f0 251 /* Set stack-specific socket options
nexpaq 0:6c56fb4bc5f0 252 *
nexpaq 0:6c56fb4bc5f0 253 * The setsockopt allow an application to pass stack-specific hints
nexpaq 0:6c56fb4bc5f0 254 * to the underlying stack. For unsupported options,
nexpaq 0:6c56fb4bc5f0 255 * NSAPI_ERROR_UNSUPPORTED is returned and the socket is unmodified.
nexpaq 0:6c56fb4bc5f0 256 *
nexpaq 0:6c56fb4bc5f0 257 * @param handle Socket handle
nexpaq 0:6c56fb4bc5f0 258 * @param level Stack-specific protocol level
nexpaq 0:6c56fb4bc5f0 259 * @param optname Stack-specific option identifier
nexpaq 0:6c56fb4bc5f0 260 * @param optval Option value
nexpaq 0:6c56fb4bc5f0 261 * @param optlen Length of the option value
nexpaq 0:6c56fb4bc5f0 262 * @return 0 on success, negative error code on failure
nexpaq 0:6c56fb4bc5f0 263 */
nexpaq 0:6c56fb4bc5f0 264 virtual int setsockopt(nsapi_socket_t handle, int level, int optname, const void *optval, unsigned optlen);
nexpaq 0:6c56fb4bc5f0 265
nexpaq 0:6c56fb4bc5f0 266 /* Get stack-specific socket options
nexpaq 0:6c56fb4bc5f0 267 *
nexpaq 0:6c56fb4bc5f0 268 * The getstackopt allow an application to retrieve stack-specific hints
nexpaq 0:6c56fb4bc5f0 269 * from the underlying stack. For unsupported options,
nexpaq 0:6c56fb4bc5f0 270 * NSAPI_ERROR_UNSUPPORTED is returned and optval is unmodified.
nexpaq 0:6c56fb4bc5f0 271 *
nexpaq 0:6c56fb4bc5f0 272 * @param handle Socket handle
nexpaq 0:6c56fb4bc5f0 273 * @param level Stack-specific protocol level
nexpaq 0:6c56fb4bc5f0 274 * @param optname Stack-specific option identifier
nexpaq 0:6c56fb4bc5f0 275 * @param optval Destination for option value
nexpaq 0:6c56fb4bc5f0 276 * @param optlen Length of the option value
nexpaq 0:6c56fb4bc5f0 277 * @return 0 on success, negative error code on failure
nexpaq 0:6c56fb4bc5f0 278 */
nexpaq 0:6c56fb4bc5f0 279 virtual int getsockopt(nsapi_socket_t handle, int level, int optname, void *optval, unsigned *optlen);
nexpaq 0:6c56fb4bc5f0 280 };
nexpaq 0:6c56fb4bc5f0 281
nexpaq 0:6c56fb4bc5f0 282
nexpaq 0:6c56fb4bc5f0 283 /** Convert a raw nsapi_stack_t object into a C++ NetworkStack object
nexpaq 0:6c56fb4bc5f0 284 *
nexpaq 0:6c56fb4bc5f0 285 * @param stack Reference to an object that can be converted to a stack
nexpaq 0:6c56fb4bc5f0 286 * - A raw nsapi_stack_t object
nexpaq 0:6c56fb4bc5f0 287 * - A reference to a network stack
nexpaq 0:6c56fb4bc5f0 288 * - A reference to a network interface
nexpaq 0:6c56fb4bc5f0 289 * @return Reference to the underlying network stack
nexpaq 0:6c56fb4bc5f0 290 */
nexpaq 0:6c56fb4bc5f0 291 NetworkStack *nsapi_create_stack(nsapi_stack_t *stack);
nexpaq 0:6c56fb4bc5f0 292 NetworkStack *nsapi_create_stack(NetworkStack *stack);
nexpaq 0:6c56fb4bc5f0 293
nexpaq 0:6c56fb4bc5f0 294 template <typename IF>
nexpaq 0:6c56fb4bc5f0 295 NetworkStack *nsapi_create_stack(IF *iface)
nexpaq 0:6c56fb4bc5f0 296 {
nexpaq 0:6c56fb4bc5f0 297 return nsapi_create_stack(static_cast<NetworkInterface *>(iface)->get_stack());
nexpaq 0:6c56fb4bc5f0 298 }
nexpaq 0:6c56fb4bc5f0 299
nexpaq 0:6c56fb4bc5f0 300
nexpaq 0:6c56fb4bc5f0 301 #endif