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: HelloWizFi250Interface
Fork of NetworkSocketAPI by
Revision 52:52a6c4ea7128, committed 2016-02-25
- Comitter:
- Christopher Haster
- Date:
- Thu Feb 25 06:42:40 2016 -0600
- Parent:
- 51:f2a088d58051
- Child:
- 53:26b5f1c69822
- Commit message:
- Changed handling of DHCP to allow buffer reuse in implementations
Changed in this revision
| NetworkInterface.cpp | Show annotated file Show diff for this revision Revisions of this file |
| NetworkInterface.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/NetworkInterface.cpp Thu Feb 25 04:11:11 2016 -0600
+++ b/NetworkInterface.cpp Thu Feb 25 06:42:40 2016 -0600
@@ -20,17 +20,16 @@
#include <string.h>
NetworkInterface::NetworkInterface()
+ : _dhcp_enabled(true)
{
memset(_ip_address, 0, NS_IP_SIZE);
memset(_network_mask, 0, NS_IP_SIZE);
memset(_gateway, 0, NS_IP_SIZE);
}
-void NetworkInterface::useDHCP()
+void NetworkInterface::setDHCP(bool enabled)
{
- memset(_ip_address, 0, NS_IP_SIZE);
- memset(_network_mask, 0, NS_IP_SIZE);
- memset(_gateway, 0, NS_IP_SIZE);
+ _dhcp_enabled = enabled;
}
void NetworkInterface::setIPAddress(const char *ip)
@@ -48,6 +47,11 @@
strcpy(_gateway, gateway);
}
+bool NetworkInterface::getDHCP()
+{
+ return _dhcp_enabled;
+}
+
const char *NetworkInterface::getIPAddress()
{
if (_ip_address[0]) {
--- a/NetworkInterface.h Thu Feb 25 04:11:11 2016 -0600
+++ b/NetworkInterface.h Thu Feb 25 06:42:40 2016 -0600
@@ -48,11 +48,12 @@
class NetworkInterface
{
public:
- /** Enables DHCP and clears any static address
- * DHCP resolution does not occur until connect call
- * DHCP is enabled by default
+ /** Enables or disables DHCP
+ * @note DHCP resolution does not occur until connect
+ * @note DHCP is enabled by default
+ * @param enable Enables DHCP if true
*/
- virtual void useDHCP();
+ virtual void setDHCP(bool enable);
/** Set the static IP address of the network interface
* @param ip Static IP address, copied internally
@@ -69,6 +70,11 @@
*/
virtual void setGateway(const char *gateway);
+ /** Checks if DHCP is enabled
+ * @return True if DHCP is enabled
+ */
+ virtual bool getDHCP();
+
/** Get the IP address
* @return IP address of the interface
*/
@@ -119,6 +125,7 @@
virtual void destroySocket(SocketInterface *socket) = 0;
private:
+ bool _dhcp_enabled;
char _ip_address[NS_IP_SIZE];
char _network_mask[NS_IP_SIZE];
char _gateway[NS_IP_SIZE];
