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 /**
187 * @brief Get the network interface name
188 *
189 * Note that for LwIP, interface names are always 3-4 characters and look like "st0" or "en0".
190 * For Nanostack, interface names are always 4-5 characters and look like "ETH0".
191 *
192 * @param interface_name Pointer to char array where the interface name will be stored.
193 *
194 * @return The passed pointer if successful, or null if not implemented or another error occurs.
195 */
196 virtual char *get_interface_name(char *interface_name);
197
198 /** Configure this network interface to use a static IP address.
199 * Implicitly disables DHCP, which can be enabled in set_dhcp.
200 * Requires that the network is disconnected.
201 *
202 * @param ip_address SocketAddress object containing the local IP address
203 * @param netmask SocketAddress object containing the local network mask
204 * @param gateway SocketAddress object containing the local gateway
205 * @retval NSAPI_ERROR_OK on success
206 * @retval NSAPI_ERROR_UNSUPPORTED if this function is unsupported
207 */
208 virtual nsapi_error_t set_network(const SocketAddress &ip_address, const SocketAddress &netmask, const SocketAddress &gateway);
209
210 /** Enable or disable DHCP on connecting the network.
211 *
212 * Enabled by default unless a static IP address has been assigned. Requires
213 * that the network is disconnected.
214 *
215 * @param dhcp True to enable DHCP.
216 * @retval NSAPI_ERROR_OK on success.
217 * @retval NSAPI_ERROR_UNSUPPORTED if operation is not supported.
218 */
219 virtual nsapi_error_t set_dhcp(bool dhcp);
220
221 /** Connect to a network.
222 *
223 * This blocks until connection is established, but asynchronous operation can be enabled
224 * by calling NetworkInterface::set_blocking(false).
225 *
226 * In asynchronous mode this starts the connection sequence and returns immediately.
227 * Status of the connection can then checked from NetworkInterface::get_connection_status()
228 * or from status callbacks.
229 *
230 * NetworkInterface internally handles reconnections until disconnect() is called.
231 *
232 * @return NSAPI_ERROR_OK if connection established in blocking mode.
233 * @return NSAPI_ERROR_OK if asynchronous operation started.
234 * @return NSAPI_ERROR_BUSY if asynchronous operation cannot be started.
235 Implementation guarantees event generation, which can be used as an
236 trigger to reissue the rejected request.
237 * @return NSAPI_ERROR_IS_CONNECTED if already connected.
238 * @return negative error code on failure.
239 */
240 virtual nsapi_error_t connect() = 0;
241
242 /** Disconnect from the network
243 *
244 * This blocks until interface is disconnected, unless interface is set to
245 * asynchronous (non-blocking) mode by calling NetworkInterface::set_blocking(false).
246 *
247 * @return NSAPI_ERROR_OK on successfully disconnected in blocking mode.
248 * @return NSAPI_ERROR_OK if asynchronous operation started.
249 * @return NSAPI_ERROR_BUSY if asynchronous operation cannot be started.
250 Implementation guarantees event generation, which can be used as an
251 trigger to reissue the rejected request.
252 * @return NSAPI_ERROR_NO_CONNECTION if already disconnected.
253 * @return negative error code on failure.
254 */
256
257 /** Translate a hostname to an IP address with specific version using network interface name.
258 *
259 * The hostname may be either a domain name or an IP address. If the
260 * hostname is an IP address, no network transactions will be performed.
261 *
262 * If no stack-specific DNS resolution is provided, the hostname
263 * will be resolve using a UDP socket on the stack.
264 *
265 * @param host Hostname to resolve.
266 * @param address Pointer to a SocketAddress to store the result.
267 * @param version IP version of address to resolve, NSAPI_UNSPEC indicates
268 * version is chosen by the stack (defaults to NSAPI_UNSPEC).
269 * @param interface_name Network interface name
270 * @retval NSAPI_ERROR_OK on success
271 * @retval int Negative error code on failure.
272 * See @ref NetworkStack::gethostbyname
273 */
274 virtual nsapi_error_t gethostbyname(const char *host,
275 SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC, const char *interface_name = NULL);
276
277 /** Translate a hostname to the multiple IP addresses with specific version using network interface name.
278 *
279 * The hostname may be either a domain name or an IP address. If the
280 * hostname is an IP address, no network transactions will be performed.
281 *
282 * If no stack-specific DNS resolution is provided, the hostname
283 * will be resolve using a UDP socket on the stack.
284 *
285 * @param hostname Hostname to resolve.
286 * @param hints Pointer to a SocketAddress with query parameters.
287 * @param res Pointer to a SocketAddress array to store the result..
288 * @param interface_name Network interface name
289 * @return number of results on success, negative error code on failure.
290 */
291 virtual nsapi_value_or_error_t getaddrinfo(const char *hostname, SocketAddress *hints, SocketAddress **res, const char *interface_name = NULL);
292
293 /** Hostname translation callback (for use with gethostbyname_async()).
294 *
295 * Callback will be called after DNS resolution completes or a failure occurs.
296 *
297 * @note Callback should not take more than 10ms to execute, otherwise it might
298 * prevent underlying thread processing. A portable user of the callback
299 * should not make calls to network operations due to stack size limitations.
300 * The callback should not perform expensive operations such as socket recv/send
301 * calls or blocking operations.
302 *
303 * <br>
304 * \c result : Negative error code on failure, or value that represents the number of DNS records
305 * <br>
306 * \c address : On success, destination for the host SocketAddress.
307 */
309
310 /** Translate a hostname to an IP address (asynchronous) using network interface name.
311 *
312 * The hostname may be either a domain name or a dotted IP address. If the
313 * hostname is an IP address, no network transactions will be performed.
314 *
315 * If no stack-specific DNS resolution is provided, the hostname
316 * will be resolve using a UDP socket on the stack.
317 *
318 * Call is non-blocking. Result of the DNS operation is returned by the callback.
319 * If this function returns failure, callback will not be called. In case result
320 * is success (IP address was found from DNS cache), callback will be called
321 * before function returns.
322 *
323 * @param host Hostname to resolve.
324 * @param callback Callback that is called for result.
325 * @param version IP version of address to resolve, NSAPI_UNSPEC indicates
326 * version is chosen by the stack (defaults to NSAPI_UNSPEC).
327 * @param interface_name Network interface name
328 * @return 0 on immediate success,
329 * negative error code on immediate failure or
330 * a positive unique id that represents the hostname translation operation
331 * and can be passed to cancel.
332 */
333 virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback, nsapi_version_t version = NSAPI_UNSPEC,
334 const char *interface_name = NULL);
335
336 /** Translate a hostname to the multiple IP addresses (asynchronous) using network interface name.
337 *
338 * The hostname may be either a domain name or a dotted IP address. If the
339 * hostname is an IP address, no network transactions will be performed.
340 *
341 * If no stack-specific DNS resolution is provided, the hostname
342 * will be resolve using a UDP socket on the stack.
343 *
344 * Call is non-blocking. Result of the DNS operation is returned by the callback.
345 * If this function returns failure, callback will not be called. In case result
346 * is success (IP address was found from DNS cache), callback will be called
347 * before function returns.
348 *
349 * @param hostname Hostname to resolve.
350 * @param hints Pointer to a SocketAddress with query parameters.
351 * @param callback Callback that is called for result.
352 * @param interface_name Network interface name
353 * @return 0 on immediate success,
354 * negative error code on immediate failure or
355 * a positive unique id that represents the hostname translation operation
356 * and can be passed to cancel.
357 */
358 virtual nsapi_value_or_error_t getaddrinfo_async(const char *hostname, SocketAddress *hints, hostbyname_cb_t callback, const char *interface_name = NULL);
359
360 /** Cancel asynchronous hostname translation.
361 *
362 * When translation is cancelled, callback will not be called.
363 *
364 * @param id Unique id of the hostname translation operation (returned
365 * by gethostbyname_async)
366 * @return NSAPI_ERROR_OK on success, negative error code on failure.
367 */
369
370 /** Add a domain name server to list of servers to query
371 *
372 * @param address Address for the dns host.
373 * @param interface_name Network interface name. Currently unused, the server is added for all interfaces.
374 * @return NSAPI_ERROR_OK on success, negative error code on failure.
375 */
376 virtual nsapi_error_t add_dns_server(const SocketAddress &address, const char *interface_name);
377
378 /** Get a domain name server from a list of servers to query
379 *
380 * Returns a DNS server address for a index. If returns error no more
381 * DNS servers to read.
382 *
383 * @param index Index of the DNS server, starts from zero
384 * @param address Destination for the host address
385 * @param interface_name Network interface name. Note that for some stacks this can be left as nullptr to
386 * display all DNS servers, but for LwIP this needs to be set.
387 * @return NSAPI_ERROR_OK on success, negative error code on failure
388 */
389 virtual nsapi_error_t get_dns_server(int index, SocketAddress *address, const char *interface_name = nullptr);
390
391 /** Register callback for status reporting.
392 *
393 * The specified status callback function will be called on status changes
394 * on the network. The parameters on the callback are the event type and
395 * event-type dependent reason parameter. Only one callback can be registered at a time.
396 *
397 * To unregister a callback call with status_cb parameter as a zero.
398 *
399 * *NOTE:* Any callbacks registered with this function will be overwritten if
400 * add_event_listener() API is used.
401 *
402 * @param status_cb The callback for status changes.
403 */
404 virtual void attach(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
405
406#if MBED_CONF_NSAPI_ADD_EVENT_LISTENER_RETURN_CHANGE
407 /** Add event listener for interface.
408 *
409 * This API allows multiple callback to be registered for a single interface.
410 * of both leads to undefined behavior.
411 *
412 * @param status_cb The callback for status changes.
413 * @return NSAPI_ERROR_OK on success
414 * @return NSAPI_ERROR_NO_MEMORY if the function fails to create a new entry.
415 */
416 nsapi_error_t add_event_listener(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
417#else
418 /** Add event listener for interface.
419 *
420 * This API allows multiple callback to be registered for a single interface.
421 * When first called, internal list of event handlers are created and registered to
422 * interface through attach() API.
423 *
424 * Application may only use attach() or add_event_listener() interface. Mixing usage
425 * of both leads to undefined behavior.
426 *
427 * @warning This version of the function does not use the `std::nothrow` feature. Subsequently,
428 * the function may fail to allocate memory and cause a system error. To use the new
429 * version with the changes, set "nsapi.add-event-listener-return-change": 1 in the
430 * target overrides section in your mbed_app.json file.
431 *
432 * @param status_cb The callback for status changes.
433 */
434 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.")
435 void add_event_listener(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
436#endif
437
438#if MBED_CONF_PLATFORM_CALLBACK_COMPARABLE
439 /** Remove event listener from interface.
440 *
441 * Remove previously added callback from the handler list.
442 *
443 * @param status_cb The callback to unregister.
444 */
445 void remove_event_listener(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
446#endif
447
448 /** Get the connection status.
449 *
450 * @return The connection status (@see nsapi_types.h).
451 */
452 virtual nsapi_connection_status_t get_connection_status() const;
453
454 /** Set asynchronous operation of connect() and disconnect() calls.
455 *
456 * By default, interfaces are in synchronous mode which means that
457 * connect() or disconnect() blocks until it reach the target state or requested operation fails.
458 *
459 * @param blocking Use false to set NetworkInterface in asynchronous mode.
460 * @return NSAPI_ERROR_OK on success
461 * @return NSAPI_ERROR_UNSUPPORTED if driver does not support asynchronous mode.
462 * @return negative error code on failure.
463 */
464 virtual nsapi_error_t set_blocking(bool blocking);
465
466 /** Return pointer to an EthInterface.
467 * @return Pointer to requested interface type or NULL if this class doesn't implement the interface.
468 */
470 {
471 return nullptr;
472 }
473
474 /** Return pointer to a WiFiInterface.
475 * @return Pointer to requested interface type or NULL if this class doesn't implement the interface.
476 */
478 {
479 return nullptr;
480 }
481
482 /** Return pointer to a MeshInterface.
483 * @return Pointer to requested interface type or NULL if this class doesn't implement the interface.
484 */
486 {
487 return nullptr;
488 }
489
490 /** Return pointer to an EMACInterface.
491 * @return Pointer to requested interface type or NULL if this class doesn't implement the interface.
492 */
494 {
495 return nullptr;
496 }
497
498 /** Return pointer to a CellularInterface.
499 * @return Pointer to requested interface type or NULL if this class doesn't implement the interface.
500 */
502 {
503 return nullptr;
504 }
505
506#if !defined(DOXYGEN_ONLY)
507
508protected:
509 friend NetworkStack *_nsapi_create_stack(NetworkInterface *iface, std::false_type);
510
511 /** Provide access to the NetworkStack object
512 *
513 * @return The underlying NetworkStack object
514 */
515 virtual NetworkStack *get_stack() = 0;
516
517 /** Get the target's default network instance.
518 *
519 * This method can be overridden by the target. Default implementations
520 * are provided weakly by various subsystems as described in
521 * NetworkInterface::get_default_instance(), so targets should not
522 * need to override in simple cases.
523 *
524 * If a target has more elaborate interface selection, it can completely
525 * override this behavior by implementing
526 * NetworkInterface::get_target_default_instance() themselves, either
527 * unconditionally, or for a specific network-default-interface-type setting
528 *
529 * For example, a device with both Ethernet and Wi-fi could be set up its
530 * target so that:
531 * * DEVICE_EMAC is set, and it provides EMAC::get_default_instance(),
532 * which means EthernetInterface provides EthInterface::get_target_instance()
533 * based on that EMAC.
534 * * It provides WifiInterface::get_target_default_instance().
535 * * The core will route NetworkInterface::get_default_instance() to
536 * either of those if network-default-interface-type is set to
537 * ETHERNET or WIFI.
538 * * The board overrides NetworkInterface::get_target_default_instance()
539 * if network-default-interface-type is set to AUTO. This returns
540 * either EthInterface::get_default_instance() or WiFIInterface::get_default_instance()
541 * depending on a cable detection.
542 *
543 *
544 * performs the search described by get_default_instance.
545 */
546 static NetworkInterface *get_target_default_instance();
547#endif //!defined(DOXYGEN_ONLY)
548
549public:
550 /** Set default parameters on an interface.
551 *
552 * A network interface instantiated directly or using calls such as
553 * WiFiInterface::get_default_instance() is initially unconfigured.
554 * This call can be used to set the default parameters that would
555 * have been set if the interface had been requested using
556 * NetworkInterface::get_default_instance() (see nsapi JSON
557 * configuration).
558 */
560
561private:
562 // Unified implementation for different versions of add_event_listener.
563 nsapi_error_t internal_add_event_listener(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
564};
565
566#endif
567
568/** @}*/
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.
Common interface between Ethernet hardware.
Common interface that is shared between mesh hardware.
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 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_error_t get_dns_server(int index, SocketAddress *address, const char *interface_name=nullptr)
Get a domain name server from a list of servers to query.
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.
PPPInterface class Implementation of the NetworkInterface for an PPP-service.
SocketAddress class.
Common interface between Wi-Fi devices.
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.
signed int nsapi_error_t
Type used to represent error codes.
unsigned int nsapi_size_t
Type used to represent the size of data passed through sockets.
@ NSAPI_UNSPEC
#define MBED_DEPRECATED_SINCE(D, M)
MBED_DEPRECATED("message string") Mark a function declaration as deprecated, if it used then a warnin...