Mistake on this page?
Report an issue in GitHub or email us
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
34 class NetworkStack;
35 class EthInterface;
36 class WiFiInterface;
37 class MeshInterface;
38 class CellularInterface;
39 class EMACInterface;
40 class PPPInterface;
41 
42 /** Common interface that is shared between network devices.
43  *
44  */
45 class NetworkInterface: public DNS {
46 public:
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 the local MAC address.
94  *
95  * Provided MAC address is intended for info or debug purposes and
96  * may be not provided if the underlying network interface does not
97  * provide a MAC address.
98  *
99  * @return Null-terminated representation of the local MAC address
100  * or null if no MAC address is available.
101  */
102  virtual const char *get_mac_address();
103 
104  /** Set the MAC address to the interface.
105  *
106  * Set the provided MAC address on the network interface. The address must
107  * be unique globally. The address must be set before calling the interface
108  * connect() method.
109  *
110  * Not all interfaces are supporting MAC address set and an error is not returned
111  * for this method call. Verify the changed MAC address by checking packet
112  * captures from the used network interface.
113  *
114  * 6-byte EUI-48 MAC addresses are used for Ethernet while Mesh interface is
115  * using 8-byte EUI-64 address.
116  *
117  * More information about obtaining MAC address can be found from:
118  * https://standards.ieee.org/products-services/regauth/index.html
119  *
120  * @param mac_addr Buffer containing the MAC address in hexadecimal format.
121  * @param addr_len Length of provided buffer in bytes (6 or 8)
122  * @retval NSAPI_ERROR_OK on success
123  * @retval NSAPI_ERROR_UNSUPPORTED if this feature is not supported
124  * @retval NSAPI_ERROR_PARAMETER if address is not valid
125  * @retval NSAPI_ERROR_BUSY if address can't be set.
126  */
127  virtual nsapi_error_t set_mac_address(uint8_t *mac_addr, nsapi_size_t addr_len);
128 
129  /** Get the local IP address
130  *
131  * @param address SocketAddress representation of the local IP address
132  * @retval NSAPI_ERROR_OK on success
133  * @retval NSAPI_ERROR_UNSUPPORTED if this feature is not supported
134  * @retval NSAPI_ERROR_PARAMETER if the provided pointer is invalid
135  * @retval NSAPI_ERROR_NO_ADDRESS if the address cannot be obtained from stack
136  */
137  virtual nsapi_error_t get_ip_address(SocketAddress *address);
138 
139  /** Get the IPv6 link local address
140  *
141  * @param address SocketAddress representation of the link local IPv6 address
142  * @retval NSAPI_ERROR_OK on success
143  * @retval NSAPI_ERROR_UNSUPPORTED if this feature is not supported
144  * @retval NSAPI_ERROR_PARAMETER if the provided pointer is invalid
145  */
147 
148  /** Get the local network mask.
149  *
150  * @param address SocketAddress representation of netmask
151  * @retval NSAPI_ERROR_OK on success
152  * @retval NSAPI_ERROR_UNSUPPORTED if this feature is not supported
153  * @retval NSAPI_ERROR_PARAMETER if the provided pointer is invalid
154  * @retval NSAPI_ERROR_NO_ADDRESS if the address cannot be obtained from stack
155  */
156  virtual nsapi_error_t get_netmask(SocketAddress *address);
157 
158  /** Get the local gateway.
159  *
160  * @param address SocketAddress representation of gateway address
161  * @retval NSAPI_ERROR_OK on success
162  * @retval NSAPI_ERROR_UNSUPPORTED if this feature is not supported
163  * @retval NSAPI_ERROR_PARAMETER if the provided pointer is invalid
164  * @retval NSAPI_ERROR_NO_ADDRESS if the address cannot be obtained from stack
165  */
166  virtual nsapi_error_t get_gateway(SocketAddress *address);
167 
168  /** Get the network interface name
169  *
170  * @return Null-terminated representation of the network interface name
171  * or null if interface not exists
172  */
173  virtual char *get_interface_name(char *interface_name);
174 
175  /** Configure this network interface to use a static IP address.
176  * Implicitly disables DHCP, which can be enabled in set_dhcp.
177  * Requires that the network is disconnected.
178  *
179  * @param ip_address SocketAddress object containing the local IP address
180  * @param netmask SocketAddress object containing the local network mask
181  * @param gateway SocketAddress object containing the local gateway
182  * @retval NSAPI_ERROR_OK on success
183  * @retval NSAPI_ERROR_UNSUPPORTED if this function is unsupported
184  */
185  virtual nsapi_error_t set_network(const SocketAddress &ip_address, const SocketAddress &netmask, const SocketAddress &gateway);
186 
187  /** Enable or disable DHCP on connecting the network.
188  *
189  * Enabled by default unless a static IP address has been assigned. Requires
190  * that the network is disconnected.
191  *
192  * @param dhcp True to enable DHCP.
193  * @retval NSAPI_ERROR_OK on success.
194  * @retval NSAPI_ERROR_UNSUPPORTED if operation is not supported.
195  */
196  virtual nsapi_error_t set_dhcp(bool dhcp);
197 
198  /** Connect to a network.
199  *
200  * This blocks until connection is established, but asynchronous operation can be enabled
201  * by calling NetworkInterface::set_blocking(false).
202  *
203  * In asynchronous mode this starts the connection sequence and returns immediately.
204  * Status of the connection can then checked from NetworkInterface::get_connection_status()
205  * or from status callbacks.
206  *
207  * NetworkInterface internally handles reconnections until disconnect() is called.
208  *
209  * @return NSAPI_ERROR_OK if connection established in blocking mode.
210  * @return NSAPI_ERROR_OK if asynchronous operation started.
211  * @return NSAPI_ERROR_BUSY if asynchronous operation cannot be started.
212  Implementation guarantees event generation, which can be used as an
213  trigger to reissue the rejected request.
214  * @return NSAPI_ERROR_IS_CONNECTED if already connected.
215  * @return negative error code on failure.
216  */
217  virtual nsapi_error_t connect() = 0;
218 
219  /** Disconnect from the network
220  *
221  * This blocks until interface is disconnected, unless interface is set to
222  * asynchronous (non-blocking) mode by calling NetworkInterface::set_blocking(false).
223  *
224  * @return NSAPI_ERROR_OK on successfully disconnected in blocking mode.
225  * @return NSAPI_ERROR_OK if asynchronous operation started.
226  * @return NSAPI_ERROR_BUSY if asynchronous operation cannot be started.
227  Implementation guarantees event generation, which can be used as an
228  trigger to reissue the rejected request.
229  * @return NSAPI_ERROR_NO_CONNECTION if already disconnected.
230  * @return negative error code on failure.
231  */
232  virtual nsapi_error_t disconnect() = 0;
233 
234  /** Translate a hostname to an IP address with specific version using network interface name.
235  *
236  * The hostname may be either a domain name or an IP address. If the
237  * hostname is an IP address, no network transactions will be performed.
238  *
239  * If no stack-specific DNS resolution is provided, the hostname
240  * will be resolve using a UDP socket on the stack.
241  *
242  * @param host Hostname to resolve.
243  * @param address Pointer to a SocketAddress to store the result.
244  * @param version IP version of address to resolve, NSAPI_UNSPEC indicates
245  * version is chosen by the stack (defaults to NSAPI_UNSPEC).
246  * @param interface_name Network interface name
247  * @retval NSAPI_ERROR_OK on success
248  * @retval int Negative error code on failure.
249  * See @ref NetworkStack::gethostbyname
250  */
251  virtual nsapi_error_t gethostbyname(const char *host,
252  SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC, const char *interface_name = NULL);
253 
254  /** Translate a hostname to the multiple IP addresses with specific version using network interface name.
255  *
256  * The hostname may be either a domain name or an IP address. If the
257  * hostname is an IP address, no network transactions will be performed.
258  *
259  * If no stack-specific DNS resolution is provided, the hostname
260  * will be resolve using a UDP socket on the stack.
261  *
262  * @param hostname Hostname to resolve.
263  * @param hints Pointer to a SocketAddress with query parameters.
264  * @param res Pointer to a SocketAddress array to store the result..
265  * @param interface_name Network interface name
266  * @return number of results on success, negative error code on failure.
267  */
268  virtual nsapi_value_or_error_t getaddrinfo(const char *hostname, SocketAddress *hints, SocketAddress **res, const char *interface_name = NULL);
269 
270  /** Hostname translation callback (for use with gethostbyname_async()).
271  *
272  * Callback will be called after DNS resolution completes or a failure occurs.
273  *
274  * @note Callback should not take more than 10ms to execute, otherwise it might
275  * prevent underlying thread processing. A portable user of the callback
276  * should not make calls to network operations due to stack size limitations.
277  * The callback should not perform expensive operations such as socket recv/send
278  * calls or blocking operations.
279  *
280  * @param result Negative error code on failure or
281  * value that represents the number of DNS records
282  * @param address On success, destination for the host SocketAddress.
283  */
285 
286  /** Translate a hostname to an IP address (asynchronous) using network interface name.
287  *
288  * The hostname may be either a domain name or a dotted IP address. If the
289  * hostname is an IP address, no network transactions will be performed.
290  *
291  * If no stack-specific DNS resolution is provided, the hostname
292  * will be resolve using a UDP socket on the stack.
293  *
294  * Call is non-blocking. Result of the DNS operation is returned by the callback.
295  * If this function returns failure, callback will not be called. In case result
296  * is success (IP address was found from DNS cache), callback will be called
297  * before function returns.
298  *
299  * @param host Hostname to resolve.
300  * @param callback Callback that is called for result.
301  * @param version IP version of address to resolve, NSAPI_UNSPEC indicates
302  * version is chosen by the stack (defaults to NSAPI_UNSPEC).
303  * @param interface_name Network interface name
304  * @return 0 on immediate success,
305  * negative error code on immediate failure or
306  * a positive unique id that represents the hostname translation operation
307  * and can be passed to cancel.
308  */
309  virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback, nsapi_version_t version = NSAPI_UNSPEC,
310  const char *interface_name = NULL);
311 
312  /** Translate a hostname to the multiple IP addresses (asynchronous) using network interface name.
313  *
314  * The hostname may be either a domain name or a dotted IP address. If the
315  * hostname is an IP address, no network transactions will be performed.
316  *
317  * If no stack-specific DNS resolution is provided, the hostname
318  * will be resolve using a UDP socket on the stack.
319  *
320  * Call is non-blocking. Result of the DNS operation is returned by the callback.
321  * If this function returns failure, callback will not be called. In case result
322  * is success (IP address was found from DNS cache), callback will be called
323  * before function returns.
324  *
325  * @param hostname Hostname to resolve.
326  * @param hints Pointer to a SocketAddress with query parameters.
327  * @param callback Callback that is called for result.
328  * @param interface_name Network interface name
329  * @return 0 on immediate success,
330  * negative error code on immediate failure or
331  * a positive unique id that represents the hostname translation operation
332  * and can be passed to cancel.
333  */
334  virtual nsapi_value_or_error_t getaddrinfo_async(const char *hostname, SocketAddress *hints, hostbyname_cb_t callback, const char *interface_name = NULL);
335 
336  /** Cancel asynchronous hostname translation.
337  *
338  * When translation is cancelled, callback will not be called.
339  *
340  * @param id Unique id of the hostname translation operation (returned
341  * by gethostbyname_async)
342  * @return NSAPI_ERROR_OK on success, negative error code on failure.
343  */
345 
346  /** Add a domain name server to list of servers to query
347  *
348  * @param address Address for the dns host.
349  * @return NSAPI_ERROR_OK on success, negative error code on failure.
350  */
351  virtual nsapi_error_t add_dns_server(const SocketAddress &address, const char *interface_name);
352 
353  /** Get a domain name server from a list of servers to query
354  *
355  * Returns a DNS server address for a index. If returns error no more
356  * DNS servers to read.
357  *
358  * @param index Index of the DNS server, starts from zero
359  * @param address Destination for the host address
360  * @param interface_name Network interface name
361  * @return NSAPI_ERROR_OK on success, negative error code on failure
362  */
363  virtual nsapi_error_t get_dns_server(int index, SocketAddress *address, const char *interface_name = NULL);
364 
365  /** Register callback for status reporting.
366  *
367  * The specified status callback function will be called on status changes
368  * on the network. The parameters on the callback are the event type and
369  * event-type dependent reason parameter. Only one callback can be registered at a time.
370  *
371  * To unregister a callback call with status_cb parameter as a zero.
372  *
373  * *NOTE:* Any callbacks registered with this function will be overwritten if
374  * add_event_listener() API is used.
375  *
376  * @param status_cb The callback for status changes.
377  */
378  virtual void attach(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
379 
380 #if MBED_CONF_NSAPI_ADD_EVENT_LISTENER_RETURN_CHANGE
381  /** Add event listener for interface.
382  *
383  * This API allows multiple callback to be registered for a single interface.
384  * of both leads to undefined behavior.
385  *
386  * @param status_cb The callback for status changes.
387  * @return NSAPI_ERROR_OK on success
388  * @return NSAPI_ERROR_NO_MEMORY if the function fails to create a new entry.
389  */
390  nsapi_error_t add_event_listener(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
391 #else
392  /** Add event listener for interface.
393  *
394  * This API allows multiple callback to be registered for a single interface.
395  * When first called, internal list of event handlers are created and registered to
396  * interface through attach() API.
397  *
398  * Application may only use attach() or add_event_listener() interface. Mixing usage
399  * of both leads to undefined behavior.
400  *
401  * @warning This version of the function does not use the `std::nothrow` feature. Subsequently,
402  * the function may fail to allocate memory and cause a system error. To use the new
403  * version with the changes, set "nsapi.add-event-listener-return-change": 1 in the
404  * target overrides section in your mbed_app.json file.
405  *
406  * @param status_cb The callback for status changes.
407  */
408  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.")
409  void add_event_listener(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
410 #endif
411 
412 #if MBED_CONF_PLATFORM_CALLBACK_COMPARABLE
413  /** Remove event listener from interface.
414  *
415  * Remove previously added callback from the handler list.
416  *
417  * @param status_cb The callback to unregister.
418  */
419  void remove_event_listener(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
420 #endif
421 
422  /** Get the connection status.
423  *
424  * @return The connection status (@see nsapi_types.h).
425  */
426  virtual nsapi_connection_status_t get_connection_status() const;
427 
428  /** Set asynchronous operation of connect() and disconnect() calls.
429  *
430  * By default, interfaces are in synchronous mode which means that
431  * connect() or disconnect() blocks until it reach the target state or requested operation fails.
432  *
433  * @param blocking Use false to set NetworkInterface in asynchronous mode.
434  * @return NSAPI_ERROR_OK on success
435  * @return NSAPI_ERROR_UNSUPPORTED if driver does not support asynchronous mode.
436  * @return negative error code on failure.
437  */
438  virtual nsapi_error_t set_blocking(bool blocking);
439 
440  /** Return pointer to an EthInterface.
441  * @return Pointer to requested interface type or NULL if this class doesn't implement the interface.
442  */
444  {
445  return nullptr;
446  }
447 
448  /** Return pointer to a WiFiInterface.
449  * @return Pointer to requested interface type or NULL if this class doesn't implement the interface.
450  */
452  {
453  return nullptr;
454  }
455 
456  /** Return pointer to a MeshInterface.
457  * @return Pointer to requested interface type or NULL if this class doesn't implement the interface.
458  */
460  {
461  return nullptr;
462  }
463 
464  /** Return pointer to an EMACInterface.
465  * @return Pointer to requested interface type or NULL if this class doesn't implement the interface.
466  */
468  {
469  return nullptr;
470  }
471 
472  /** Return pointer to a CellularInterface.
473  * @return Pointer to requested interface type or NULL if this class doesn't implement the interface.
474  */
476  {
477  return nullptr;
478  }
479 
480 #if !defined(DOXYGEN_ONLY)
481 
482 protected:
483  friend NetworkStack *_nsapi_create_stack(NetworkInterface *iface, std::false_type);
484 
485  /** Provide access to the NetworkStack object
486  *
487  * @return The underlying NetworkStack object
488  */
489  virtual NetworkStack *get_stack() = 0;
490 
491  /** Get the target's default network instance.
492  *
493  * This method can be overridden by the target. Default implementations
494  * are provided weakly by various subsystems as described in
495  * NetworkInterface::get_default_instance(), so targets should not
496  * need to override in simple cases.
497  *
498  * If a target has more elaborate interface selection, it can completely
499  * override this behavior by implementing
500  * NetworkInterface::get_target_default_instance() themselves, either
501  * unconditionally, or for a specific network-default-interface-type setting
502  *
503  * For example, a device with both Ethernet and Wi-fi could be set up its
504  * target so that:
505  * * DEVICE_EMAC is set, and it provides EMAC::get_default_instance(),
506  * which means EthernetInterface provides EthInterface::get_target_instance()
507  * based on that EMAC.
508  * * It provides WifiInterface::get_target_default_instance().
509  * * The core will route NetworkInterface::get_default_instance() to
510  * either of those if network-default-interface-type is set to
511  * ETHERNET or WIFI.
512  * * The board overrides NetworkInterface::get_target_default_instance()
513  * if network-default-interface-type is set to AUTO. This returns
514  * either EthInterface::get_default_instance() or WiFIInterface::get_default_instance()
515  * depending on a cable detection.
516  *
517  *
518  * performs the search described by get_default_instance.
519  */
520  static NetworkInterface *get_target_default_instance();
521 #endif //!defined(DOXYGEN_ONLY)
522 
523 public:
524  /** Set default parameters on an interface.
525  *
526  * A network interface instantiated directly or using calls such as
527  * WiFiInterface::get_default_instance() is initially unconfigured.
528  * This call can be used to set the default parameters that would
529  * have been set if the interface had been requested using
530  * NetworkInterface::get_default_instance() (see nsapi JSON
531  * configuration).
532  */
533  virtual void set_default_parameters();
534 
535 private:
536  // Unified implementation for different versions of add_event_listener.
537  nsapi_error_t internal_add_event_listener(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
538 };
539 
540 #endif
541 
542 /** @}*/
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...
Common interface between Wi-Fi devices.
Definition: WiFiInterface.h:32
virtual void attach(mbed::Callback< void(nsapi_event_t, intptr_t)> status_cb)
Register callback for status reporting.
virtual MeshInterface * meshInterface()
Return pointer to a MeshInterface.
Base class for DNS provider.
Definition: DNS.h:26
SocketAddress class.
virtual EMACInterface * emacInterface()
Return pointer to an EMACInterface.
PPPInterface class Implementation of the NetworkInterface for an PPP-service.
Definition: PPPInterface.h:34
virtual char * get_interface_name(char *interface_name)
Get the network interface name.
NetworkStack class.
Definition: NetworkStack.h:42
virtual nsapi_error_t disconnect()=0
Disconnect from the network.
virtual nsapi_error_t gethostbyname_async_cancel(int id)
Cancel asynchronous hostname translation.
EMACInterface class Implementation of the NetworkInterface for an EMAC-based driver.
Definition: EMACInterface.h:39
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 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 void set_as_default()
Set network interface as default one.
signed int nsapi_error_t
Type used to represent error codes.
Definition: nsapi_types.h:140
virtual void set_default_parameters()
defined(DOXYGEN_ONLY)
Common interface that is shared between mesh hardware.
Definition: MeshInterface.h:30
virtual const char * get_mac_address()
Get the local MAC address.
Callback< R(ArgTs...)> callback(R(*func)(ArgTs...)=nullptr) noexcept
Create a callback class with type inferred from the arguments.
Definition: Callback.h:678
virtual nsapi_error_t set_mac_address(uint8_t *mac_addr, nsapi_size_t addr_len)
Set the MAC address to the interface.
mbed::Callback< void(nsapi_value_or_error_t result, SocketAddress *address)> hostbyname_cb_t
Hostname translation callback (for use with gethostbyname_async()).
signed int nsapi_value_or_error_t
Type used to represent either a value or error.
Definition: nsapi_types.h:158
virtual nsapi_connection_status_t get_connection_status() const
Get the connection status.
virtual WiFiInterface * wifiInterface()
Return pointer to a WiFiInterface.
SocketAddress class.
Definition: SocketAddress.h:37
Common interface that is shared between network devices.
virtual nsapi_error_t set_dhcp(bool dhcp)
Enable or disable DHCP on connecting the network.
void add_event_listener(mbed::Callback< void(nsapi_event_t, intptr_t)> status_cb)
Add event listener for interface.
virtual nsapi_error_t get_gateway(SocketAddress *address)
Get the local gateway.
virtual nsapi_error_t connect()=0
Connect to a network.
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 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...
unsigned int nsapi_size_t
Type used to represent the size of data passed through sockets.
Definition: nsapi_types.h:144
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.
Common interface that is shared between cellular interfaces.
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 set_blocking(bool blocking)
Set asynchronous operation of connect() and disconnect() calls.
virtual nsapi_error_t get_netmask(SocketAddress *address)
Get the local network mask.
virtual CellularInterface * cellularInterface()
Return pointer to a CellularInterface.
Callback class based on template specialization.
Definition: Callback.h:53
Definition: ATHandler.h:46
Common interface between Ethernet hardware.
Definition: EthInterface.h:30
virtual nsapi_error_t get_ipv6_link_local_address(SocketAddress *address)
Get the IPv6 link local address.
static NetworkInterface * get_default_instance()
Return the default network interface.
#define MBED_DEPRECATED_SINCE(D, M)
MBED_DEPRECATED("message string") Mark a function declaration as deprecated, if it used then a warnin...
virtual EthInterface * ethInterface()
Return pointer to an EthInterface.
virtual nsapi_error_t get_ip_address(SocketAddress *address)
Get the local IP address.
Domain Name Service.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.