Mbed OS Reference
Loading...
Searching...
No Matches
NetworkInterface.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 ARM Limited
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/** @file NetworkInterface.h Network Interface base class */
19/** @addtogroup netinterface
20 * Network Interface classes
21 * @{ */
22
23
24#ifndef NETWORK_INTERFACE_H
25#define NETWORK_INTERFACE_H
26
27#include "netsocket/nsapi_types.h"
29#include "Callback.h"
30#include "DNS.h"
31
32
33// Predeclared classes
34class NetworkStack;
35class EthInterface;
36class WiFiInterface;
37class MeshInterface;
39class EMACInterface;
40class PPPInterface;
41
42/** Common interface that is shared between network devices.
43 *
44 */
45class NetworkInterface: public DNS {
46public:
47
48 virtual ~NetworkInterface();
49
50 /** Return the default network interface.
51 *
52 * Returns the default network interface, as determined by JSON option
53 * target.network-default-interface-type or other overrides.
54 *
55 * The type of the interface returned can be tested by calling ethInterface(),
56 * wifiInterface(), meshInterface(), cellularInterface(), emacInterface() and checking
57 * for NULL pointers.
58 *
59 * The default behavior is to return the default interface for the
60 * interface type specified by target.network-default-interface-type. Targets
61 * should set this in their targets.json to guide default selection,
62 * and applications may override.
63 *
64 * The interface returned should be already configured for use such that its
65 * connect() method works with no parameters. For connection types needing
66 * configuration, settings should normally be obtained from JSON - the
67 * settings for the core types are under the "nsapi" JSON config tree.
68 *
69 * The list of possible settings for default interface type is open-ended,
70 * as is the number of possible providers. Core providers are:
71 *
72 * * ETHERNET: EthernetInterface, using default EMAC and OnboardNetworkStack
73 * * MESH: ThreadInterface or LoWPANNDInterface, using default NanostackRfPhy
74 * * CELLULAR: OnboardModemInterface
75 * * WIFI: None - always provided by a specific class
76 *
77 * Specific drivers may be activated by other settings of the
78 * default-network-interface-type configuration. This will depend on the
79 * target and the driver. For example a board may have its default setting
80 * as "AUTO" which causes it to autodetect an Ethernet cable. This should
81 * be described in the target's documentation.
82 *
83 * An application can override all target settings by implementing
84 * NetworkInterface::get_default_instance() themselves - the default
85 * definition is weak, and calls get_target_default_instance().
86 */
88
89 /** Set network interface as default one.
90 */
91 virtual void set_as_default();
92
93 /** Get hostname.
94 *
95 * @return Hostname if configured, null otherwise
96 */
97 virtual const char *get_hostname();
98
99 /** Set hostname.
100 *
101 * @param hostname Hostname string
102 * @retval NSAPI_ERROR_OK on success
103 * @retval NSAPI_ERROR_UNSUPPORTED if this feature is not supported
104 * @retval NSAPI_ERROR_PARAMETER if hostname is not valid
105 * @retval NSAPI_ERROR_BUSY if hostname couldn't be set (e.g. for
106 * LwIP stack, hostname can only be set before calling
107 * \c EthernetInterface::connect method)
108 */
109 virtual nsapi_error_t set_hostname(const char *hostname);
110
111 /** Get the local MAC address.
112 *
113 * Provided MAC address is intended for info or debug purposes and
114 * may be not provided if the underlying network interface does not
115 * provide a MAC address.
116 *
117 * @return Null-terminated representation of the local MAC address
118 * or null if no MAC address is available.
119 */
120 virtual const char *get_mac_address();
121
122 /** Set the MAC address to the interface.
123 *
124 * Set the provided MAC address on the network interface. The address must
125 * be unique globally. The address must be set before calling the interface
126 * connect() method.
127 *
128 * Not all interfaces are supporting MAC address set and an error is not returned
129 * for this method call. Verify the changed MAC address by checking packet
130 * captures from the used network interface.
131 *
132 * 6-byte EUI-48 MAC addresses are used for Ethernet while Mesh interface is
133 * using 8-byte EUI-64 address.
134 *
135 * More information about obtaining MAC address can be found from:
136 * https://standards.ieee.org/products-services/regauth/index.html
137 *
138 * @param mac_addr Buffer containing the MAC address in hexadecimal format.
139 * @param addr_len Length of provided buffer in bytes (6 or 8)
140 * @retval NSAPI_ERROR_OK on success
141 * @retval NSAPI_ERROR_UNSUPPORTED if this feature is not supported
142 * @retval NSAPI_ERROR_PARAMETER if address is not valid
143 * @retval NSAPI_ERROR_BUSY if address can't be set.
144 */
145 virtual nsapi_error_t set_mac_address(uint8_t *mac_addr, nsapi_size_t addr_len);
146
147 /** Get the local IP address
148 *
149 * @param address SocketAddress representation of the local IP address
150 * @retval NSAPI_ERROR_OK on success
151 * @retval NSAPI_ERROR_UNSUPPORTED if this feature is not supported
152 * @retval NSAPI_ERROR_PARAMETER if the provided pointer is invalid
153 * @retval NSAPI_ERROR_NO_ADDRESS if the address cannot be obtained from stack
154 */
156
157 /** Get the IPv6 link local address
158 *
159 * @param address SocketAddress representation of the link local IPv6 address
160 * @retval NSAPI_ERROR_OK on success
161 * @retval NSAPI_ERROR_UNSUPPORTED if this feature is not supported
162 * @retval NSAPI_ERROR_PARAMETER if the provided pointer is invalid
163 */
165
166 /** Get the local network mask.
167 *
168 * @param address SocketAddress representation of netmask
169 * @retval NSAPI_ERROR_OK on success
170 * @retval NSAPI_ERROR_UNSUPPORTED if this feature is not supported
171 * @retval NSAPI_ERROR_PARAMETER if the provided pointer is invalid
172 * @retval NSAPI_ERROR_NO_ADDRESS if the address cannot be obtained from stack
173 */
175
176 /** Get the local gateway.
177 *
178 * @param address SocketAddress representation of gateway address
179 * @retval NSAPI_ERROR_OK on success
180 * @retval NSAPI_ERROR_UNSUPPORTED if this feature is not supported
181 * @retval NSAPI_ERROR_PARAMETER if the provided pointer is invalid
182 * @retval NSAPI_ERROR_NO_ADDRESS if the address cannot be obtained from stack
183 */
185
186 /** Get the network interface name
187 *
188 * @return Null-terminated representation of the network interface name
189 * or null if interface not exists
190 */
191 virtual char *get_interface_name(char *interface_name);
192
193 /** Configure this network interface to use a static IP address.
194 * Implicitly disables DHCP, which can be enabled in set_dhcp.
195 * Requires that the network is disconnected.
196 *
197 * @param ip_address SocketAddress object containing the local IP address
198 * @param netmask SocketAddress object containing the local network mask
199 * @param gateway SocketAddress object containing the local gateway
200 * @retval NSAPI_ERROR_OK on success
201 * @retval NSAPI_ERROR_UNSUPPORTED if this function is unsupported
202 */
203 virtual nsapi_error_t set_network(const SocketAddress &ip_address, const SocketAddress &netmask, const SocketAddress &gateway);
204
205 /** Enable or disable DHCP on connecting the network.
206 *
207 * Enabled by default unless a static IP address has been assigned. Requires
208 * that the network is disconnected.
209 *
210 * @param dhcp True to enable DHCP.
211 * @retval NSAPI_ERROR_OK on success.
212 * @retval NSAPI_ERROR_UNSUPPORTED if operation is not supported.
213 */
214 virtual nsapi_error_t set_dhcp(bool dhcp);
215
216 /** Connect to a network.
217 *
218 * This blocks until connection is established, but asynchronous operation can be enabled
219 * by calling NetworkInterface::set_blocking(false).
220 *
221 * In asynchronous mode this starts the connection sequence and returns immediately.
222 * Status of the connection can then checked from NetworkInterface::get_connection_status()
223 * or from status callbacks.
224 *
225 * NetworkInterface internally handles reconnections until disconnect() is called.
226 *
227 * @return NSAPI_ERROR_OK if connection established in blocking mode.
228 * @return NSAPI_ERROR_OK if asynchronous operation started.
229 * @return NSAPI_ERROR_BUSY if asynchronous operation cannot be started.
230 Implementation guarantees event generation, which can be used as an
231 trigger to reissue the rejected request.
232 * @return NSAPI_ERROR_IS_CONNECTED if already connected.
233 * @return negative error code on failure.
234 */
235 virtual nsapi_error_t connect() = 0;
236
237 /** Disconnect from the network
238 *
239 * This blocks until interface is disconnected, unless interface is set to
240 * asynchronous (non-blocking) mode by calling NetworkInterface::set_blocking(false).
241 *
242 * @return NSAPI_ERROR_OK on successfully disconnected in blocking mode.
243 * @return NSAPI_ERROR_OK if asynchronous operation started.
244 * @return NSAPI_ERROR_BUSY if asynchronous operation cannot be started.
245 Implementation guarantees event generation, which can be used as an
246 trigger to reissue the rejected request.
247 * @return NSAPI_ERROR_NO_CONNECTION if already disconnected.
248 * @return negative error code on failure.
249 */
251
252 /** Translate a hostname to an IP address with specific version using network interface name.
253 *
254 * The hostname may be either a domain name or an IP address. If the
255 * hostname is an IP address, no network transactions will be performed.
256 *
257 * If no stack-specific DNS resolution is provided, the hostname
258 * will be resolve using a UDP socket on the stack.
259 *
260 * @param host Hostname to resolve.
261 * @param address Pointer to a SocketAddress to store the result.
262 * @param version IP version of address to resolve, NSAPI_UNSPEC indicates
263 * version is chosen by the stack (defaults to NSAPI_UNSPEC).
264 * @param interface_name Network interface name
265 * @retval NSAPI_ERROR_OK on success
266 * @retval int Negative error code on failure.
267 * See @ref NetworkStack::gethostbyname
268 */
269 virtual nsapi_error_t gethostbyname(const char *host,
270 SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC, const char *interface_name = NULL);
271
272 /** Translate a hostname to the multiple IP addresses with specific version using network interface name.
273 *
274 * The hostname may be either a domain name or an IP address. If the
275 * hostname is an IP address, no network transactions will be performed.
276 *
277 * If no stack-specific DNS resolution is provided, the hostname
278 * will be resolve using a UDP socket on the stack.
279 *
280 * @param hostname Hostname to resolve.
281 * @param hints Pointer to a SocketAddress with query parameters.
282 * @param res Pointer to a SocketAddress array to store the result..
283 * @param interface_name Network interface name
284 * @return number of results on success, negative error code on failure.
285 */
286 virtual nsapi_value_or_error_t getaddrinfo(const char *hostname, SocketAddress *hints, SocketAddress **res, const char *interface_name = NULL);
287
288 /** Hostname translation callback (for use with gethostbyname_async()).
289 *
290 * Callback will be called after DNS resolution completes or a failure occurs.
291 *
292 * @note Callback should not take more than 10ms to execute, otherwise it might
293 * prevent underlying thread processing. A portable user of the callback
294 * should not make calls to network operations due to stack size limitations.
295 * The callback should not perform expensive operations such as socket recv/send
296 * calls or blocking operations.
297 *
298 * <br>
299 * \c result : Negative error code on failure, or value that represents the number of DNS records
300 * <br>
301 * \c address : On success, destination for the host SocketAddress.
302 */
304
305 /** Translate a hostname to an IP address (asynchronous) using network interface name.
306 *
307 * The hostname may be either a domain name or a dotted IP address. If the
308 * hostname is an IP address, no network transactions will be performed.
309 *
310 * If no stack-specific DNS resolution is provided, the hostname
311 * will be resolve using a UDP socket on the stack.
312 *
313 * Call is non-blocking. Result of the DNS operation is returned by the callback.
314 * If this function returns failure, callback will not be called. In case result
315 * is success (IP address was found from DNS cache), callback will be called
316 * before function returns.
317 *
318 * @param host Hostname to resolve.
319 * @param callback Callback that is called for result.
320 * @param version IP version of address to resolve, NSAPI_UNSPEC indicates
321 * version is chosen by the stack (defaults to NSAPI_UNSPEC).
322 * @param interface_name Network interface name
323 * @return 0 on immediate success,
324 * negative error code on immediate failure or
325 * a positive unique id that represents the hostname translation operation
326 * and can be passed to cancel.
327 */
328 virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback, nsapi_version_t version = NSAPI_UNSPEC,
329 const char *interface_name = NULL);
330
331 /** Translate a hostname to the multiple IP addresses (asynchronous) using network interface name.
332 *
333 * The hostname may be either a domain name or a dotted IP address. If the
334 * hostname is an IP address, no network transactions will be performed.
335 *
336 * If no stack-specific DNS resolution is provided, the hostname
337 * will be resolve using a UDP socket on the stack.
338 *
339 * Call is non-blocking. Result of the DNS operation is returned by the callback.
340 * If this function returns failure, callback will not be called. In case result
341 * is success (IP address was found from DNS cache), callback will be called
342 * before function returns.
343 *
344 * @param hostname Hostname to resolve.
345 * @param hints Pointer to a SocketAddress with query parameters.
346 * @param callback Callback that is called for result.
347 * @param interface_name Network interface name
348 * @return 0 on immediate success,
349 * negative error code on immediate failure or
350 * a positive unique id that represents the hostname translation operation
351 * and can be passed to cancel.
352 */
353 virtual nsapi_value_or_error_t getaddrinfo_async(const char *hostname, SocketAddress *hints, hostbyname_cb_t callback, const char *interface_name = NULL);
354
355 /** Cancel asynchronous hostname translation.
356 *
357 * When translation is cancelled, callback will not be called.
358 *
359 * @param id Unique id of the hostname translation operation (returned
360 * by gethostbyname_async)
361 * @return NSAPI_ERROR_OK on success, negative error code on failure.
362 */
364
365 /** Add a domain name server to list of servers to query
366 *
367 * @param address Address for the dns host.
368 * @param interface_name Network interface name. Currently unused, the server is added for all interfaces.
369 * @return NSAPI_ERROR_OK on success, negative error code on failure.
370 */
371 virtual nsapi_error_t add_dns_server(const SocketAddress &address, const char *interface_name);
372
373 /** Get a domain name server from a list of servers to query
374 *
375 * Returns a DNS server address for a index. If returns error no more
376 * DNS servers to read.
377 *
378 * @param index Index of the DNS server, starts from zero
379 * @param address Destination for the host address
380 * @param interface_name Network interface name
381 * @return NSAPI_ERROR_OK on success, negative error code on failure
382 */
383 virtual nsapi_error_t get_dns_server(int index, SocketAddress *address, const char *interface_name = NULL);
384
385 /** Register callback for status reporting.
386 *
387 * The specified status callback function will be called on status changes
388 * on the network. The parameters on the callback are the event type and
389 * event-type dependent reason parameter. Only one callback can be registered at a time.
390 *
391 * To unregister a callback call with status_cb parameter as a zero.
392 *
393 * *NOTE:* Any callbacks registered with this function will be overwritten if
394 * add_event_listener() API is used.
395 *
396 * @param status_cb The callback for status changes.
397 */
398 virtual void attach(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
399
400#if MBED_CONF_NSAPI_ADD_EVENT_LISTENER_RETURN_CHANGE
401 /** Add event listener for interface.
402 *
403 * This API allows multiple callback to be registered for a single interface.
404 * of both leads to undefined behavior.
405 *
406 * @param status_cb The callback for status changes.
407 * @return NSAPI_ERROR_OK on success
408 * @return NSAPI_ERROR_NO_MEMORY if the function fails to create a new entry.
409 */
410 nsapi_error_t add_event_listener(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
411#else
412 /** Add event listener for interface.
413 *
414 * This API allows multiple callback to be registered for a single interface.
415 * When first called, internal list of event handlers are created and registered to
416 * interface through attach() API.
417 *
418 * Application may only use attach() or add_event_listener() interface. Mixing usage
419 * of both leads to undefined behavior.
420 *
421 * @warning This version of the function does not use the `std::nothrow` feature. Subsequently,
422 * the function may fail to allocate memory and cause a system error. To use the new
423 * version with the changes, set "nsapi.add-event-listener-return-change": 1 in the
424 * target overrides section in your mbed_app.json file.
425 *
426 * @param status_cb The callback for status changes.
427 */
428 MBED_DEPRECATED_SINCE("mbed-os-6.12", "This function return value will change to nsapi_error_t in the next major release. See documentation for details.")
429 void add_event_listener(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
430#endif
431
432#if MBED_CONF_PLATFORM_CALLBACK_COMPARABLE
433 /** Remove event listener from interface.
434 *
435 * Remove previously added callback from the handler list.
436 *
437 * @param status_cb The callback to unregister.
438 */
439 void remove_event_listener(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
440#endif
441
442 /** Get the connection status.
443 *
444 * @return The connection status (@see nsapi_types.h).
445 */
446 virtual nsapi_connection_status_t get_connection_status() const;
447
448 /** Set asynchronous operation of connect() and disconnect() calls.
449 *
450 * By default, interfaces are in synchronous mode which means that
451 * connect() or disconnect() blocks until it reach the target state or requested operation fails.
452 *
453 * @param blocking Use false to set NetworkInterface in asynchronous mode.
454 * @return NSAPI_ERROR_OK on success
455 * @return NSAPI_ERROR_UNSUPPORTED if driver does not support asynchronous mode.
456 * @return negative error code on failure.
457 */
458 virtual nsapi_error_t set_blocking(bool blocking);
459
460 /** Return pointer to an EthInterface.
461 * @return Pointer to requested interface type or NULL if this class doesn't implement the interface.
462 */
464 {
465 return nullptr;
466 }
467
468 /** Return pointer to a WiFiInterface.
469 * @return Pointer to requested interface type or NULL if this class doesn't implement the interface.
470 */
472 {
473 return nullptr;
474 }
475
476 /** Return pointer to a MeshInterface.
477 * @return Pointer to requested interface type or NULL if this class doesn't implement the interface.
478 */
480 {
481 return nullptr;
482 }
483
484 /** Return pointer to an EMACInterface.
485 * @return Pointer to requested interface type or NULL if this class doesn't implement the interface.
486 */
488 {
489 return nullptr;
490 }
491
492 /** Return pointer to a CellularInterface.
493 * @return Pointer to requested interface type or NULL if this class doesn't implement the interface.
494 */
496 {
497 return nullptr;
498 }
499
500#if !defined(DOXYGEN_ONLY)
501
502protected:
503 friend NetworkStack *_nsapi_create_stack(NetworkInterface *iface, std::false_type);
504
505 /** Provide access to the NetworkStack object
506 *
507 * @return The underlying NetworkStack object
508 */
509 virtual NetworkStack *get_stack() = 0;
510
511 /** Get the target's default network instance.
512 *
513 * This method can be overridden by the target. Default implementations
514 * are provided weakly by various subsystems as described in
515 * NetworkInterface::get_default_instance(), so targets should not
516 * need to override in simple cases.
517 *
518 * If a target has more elaborate interface selection, it can completely
519 * override this behavior by implementing
520 * NetworkInterface::get_target_default_instance() themselves, either
521 * unconditionally, or for a specific network-default-interface-type setting
522 *
523 * For example, a device with both Ethernet and Wi-fi could be set up its
524 * target so that:
525 * * DEVICE_EMAC is set, and it provides EMAC::get_default_instance(),
526 * which means EthernetInterface provides EthInterface::get_target_instance()
527 * based on that EMAC.
528 * * It provides WifiInterface::get_target_default_instance().
529 * * The core will route NetworkInterface::get_default_instance() to
530 * either of those if network-default-interface-type is set to
531 * ETHERNET or WIFI.
532 * * The board overrides NetworkInterface::get_target_default_instance()
533 * if network-default-interface-type is set to AUTO. This returns
534 * either EthInterface::get_default_instance() or WiFIInterface::get_default_instance()
535 * depending on a cable detection.
536 *
537 *
538 * performs the search described by get_default_instance.
539 */
540 static NetworkInterface *get_target_default_instance();
541#endif //!defined(DOXYGEN_ONLY)
542
543public:
544 /** Set default parameters on an interface.
545 *
546 * A network interface instantiated directly or using calls such as
547 * WiFiInterface::get_default_instance() is initially unconfigured.
548 * This call can be used to set the default parameters that would
549 * have been set if the interface had been requested using
550 * NetworkInterface::get_default_instance() (see nsapi JSON
551 * configuration).
552 */
554
555private:
556 // Unified implementation for different versions of add_event_listener.
557 nsapi_error_t internal_add_event_listener(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
558};
559
560#endif
561
562/** @}*/
Domain Name Service.
SocketAddress class.
Common interface that is shared between cellular interfaces.
Base class for DNS provider.
Definition: DNS.h:28
EMACInterface class Implementation of the NetworkInterface for an EMAC-based driver.
Definition: EMACInterface.h:42
Common interface between Ethernet hardware.
Definition: EthInterface.h:30
Common interface that is shared between mesh hardware.
Definition: MeshInterface.h:30
Common interface that is shared between network devices.
static NetworkInterface * get_default_instance()
Return the default network interface.
virtual WiFiInterface * wifiInterface()
Return pointer to a WiFiInterface.
virtual nsapi_error_t get_dns_server(int index, SocketAddress *address, const char *interface_name=NULL)
Get a domain name server from a list of servers to query.
virtual void set_default_parameters()
defined(DOXYGEN_ONLY)
virtual char * get_interface_name(char *interface_name)
Get the network interface name.
virtual nsapi_error_t gethostbyname_async_cancel(int id)
Cancel asynchronous hostname translation.
virtual nsapi_error_t add_dns_server(const SocketAddress &address, const char *interface_name)
Add a domain name server to list of servers to query.
virtual nsapi_error_t set_hostname(const char *hostname)
Set hostname.
virtual void attach(mbed::Callback< void(nsapi_event_t, intptr_t)> status_cb)
Register callback for status reporting.
virtual nsapi_error_t set_dhcp(bool dhcp)
Enable or disable DHCP on connecting the network.
virtual nsapi_error_t get_ip_address(SocketAddress *address)
Get the local IP address.
virtual nsapi_error_t get_netmask(SocketAddress *address)
Get the local network mask.
virtual const char * get_hostname()
Get hostname.
virtual void set_as_default()
Set network interface as default one.
virtual nsapi_error_t set_mac_address(uint8_t *mac_addr, nsapi_size_t addr_len)
Set the MAC address to the interface.
virtual nsapi_error_t gethostbyname(const char *host, SocketAddress *address, nsapi_version_t version=NSAPI_UNSPEC, const char *interface_name=NULL)
Translate a hostname to an IP address with specific version using network interface name.
virtual MeshInterface * meshInterface()
Return pointer to a MeshInterface.
virtual nsapi_error_t get_ipv6_link_local_address(SocketAddress *address)
Get the IPv6 link local address.
virtual nsapi_connection_status_t get_connection_status() const
Get the connection status.
virtual nsapi_value_or_error_t getaddrinfo(const char *hostname, SocketAddress *hints, SocketAddress **res, const char *interface_name=NULL)
Translate a hostname to the multiple IP addresses with specific version using network interface name.
virtual nsapi_error_t set_blocking(bool blocking)
Set asynchronous operation of connect() and disconnect() calls.
virtual nsapi_value_or_error_t getaddrinfo_async(const char *hostname, SocketAddress *hints, hostbyname_cb_t callback, const char *interface_name=NULL)
Translate a hostname to the multiple IP addresses (asynchronous) using network interface name.
virtual const char * get_mac_address()
Get the local MAC address.
virtual nsapi_error_t connect()=0
Connect to a network.
virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback, nsapi_version_t version=NSAPI_UNSPEC, const char *interface_name=NULL)
Translate a hostname to an IP address (asynchronous) using network interface name.
void add_event_listener(mbed::Callback< void(nsapi_event_t, intptr_t)> status_cb)
Add event listener for interface.
mbed::Callback< void(nsapi_value_or_error_t result, SocketAddress *address)> hostbyname_cb_t
Hostname translation callback (for use with gethostbyname_async()).
virtual EthInterface * ethInterface()
Return pointer to an EthInterface.
virtual EMACInterface * emacInterface()
Return pointer to an EMACInterface.
virtual nsapi_error_t get_gateway(SocketAddress *address)
Get the local gateway.
virtual CellularInterface * cellularInterface()
Return pointer to a CellularInterface.
virtual nsapi_error_t set_network(const SocketAddress &ip_address, const SocketAddress &netmask, const SocketAddress &gateway)
Configure this network interface to use a static IP address.
virtual nsapi_error_t disconnect()=0
Disconnect from the network.
NetworkStack class.
Definition: NetworkStack.h:42
PPPInterface class Implementation of the NetworkInterface for an PPP-service.
Definition: PPPInterface.h:34
SocketAddress class.
Definition: SocketAddress.h:37
Common interface between Wi-Fi devices.
Definition: WiFiInterface.h:32
Callback class based on template specialization.
Definition: Callback.h:53
signed int nsapi_value_or_error_t
Type used to represent either a value or error.
Definition: nsapi_types.h:160
signed int nsapi_error_t
Type used to represent error codes.
Definition: nsapi_types.h:142
unsigned int nsapi_size_t
Type used to represent the size of data passed through sockets.
Definition: nsapi_types.h:146
@ NSAPI_UNSPEC
Definition: nsapi_types.h:240
#define MBED_DEPRECATED_SINCE(D, M)
MBED_DEPRECATED("message string") Mark a function declaration as deprecated, if it used then a warnin...