Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: BLE_file_test BLE_Blink ExternalEncoder
EthernetInterface.h
00001 /* LWIP implementation of NetworkInterfaceAPI 00002 * Copyright (c) 2015 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef ETHERNET_INTERFACE_H 00018 #define ETHERNET_INTERFACE_H 00019 00020 #include "nsapi.h" 00021 #include "rtos.h" 00022 #include "lwip/netif.h" 00023 00024 // Forward declaration 00025 class NetworkStack; 00026 00027 00028 /** EthernetInterface class 00029 * Implementation of the NetworkStack for LWIP 00030 */ 00031 class EthernetInterface : public EthInterface 00032 { 00033 public: 00034 /** EthernetInterface lifetime 00035 */ 00036 EthernetInterface(); 00037 00038 /** Set a static IP address 00039 * 00040 * Configures this network interface to use a static IP address. 00041 * Implicitly disables DHCP, which can be enabled in set_dhcp. 00042 * Requires that the network is disconnected. 00043 * 00044 * @param address Null-terminated representation of the local IP address 00045 * @param netmask Null-terminated representation of the local network mask 00046 * @param gateway Null-terminated representation of the local gateway 00047 * @return 0 on success, negative error code on failure 00048 */ 00049 virtual int set_network(const char *ip_address, const char *netmask, const char *gateway); 00050 00051 /** Enable or disable DHCP on the network 00052 * 00053 * Requires that the network is disconnected 00054 * 00055 * @param dhcp False to disable dhcp (defaults to enabled) 00056 * @return 0 on success, negative error code on failure 00057 */ 00058 virtual int set_dhcp(bool dhcp); 00059 00060 /** Start the interface 00061 * @return 0 on success, negative on failure 00062 */ 00063 virtual int connect(); 00064 00065 /** Stop the interface 00066 * @return 0 on success, negative on failure 00067 */ 00068 virtual int disconnect(); 00069 00070 /** Get the local MAC address 00071 * 00072 * Provided MAC address is intended for info or debug purposes and 00073 * may not be provided if the underlying network interface does not 00074 * provide a MAC address 00075 * 00076 * @return Null-terminated representation of the local MAC address 00077 * or null if no MAC address is available 00078 */ 00079 virtual const char *get_mac_address(); 00080 00081 /** Get the local IP address 00082 * 00083 * @return Null-terminated representation of the local IP address 00084 * or null if no IP address has been recieved 00085 */ 00086 virtual const char *get_ip_address(); 00087 00088 /** Get the local network mask 00089 * 00090 * @return Null-terminated representation of the local network mask 00091 * or null if no network mask has been recieved 00092 */ 00093 virtual const char *get_netmask(); 00094 00095 /** Get the local gateways 00096 * 00097 * @return Null-terminated representation of the local gateway 00098 * or null if no network mask has been recieved 00099 */ 00100 virtual const char *get_gateway(); 00101 00102 protected: 00103 /** Provide access to the underlying stack 00104 * 00105 * @return The underlying network stack 00106 */ 00107 virtual NetworkStack *get_stack(); 00108 00109 bool _dhcp; 00110 char _ip_address[IPADDR_STRLEN_MAX]; 00111 char _netmask[NSAPI_IPv4_SIZE]; 00112 char _gateway[NSAPI_IPv4_SIZE]; 00113 }; 00114 00115 00116 #endif
Generated on Tue Jul 12 2022 15:19:28 by
1.7.2