Modified official MBED EthernetInterface The only changes are to allow hostname to be set and got
Dependencies: Socket lwip-eth lwip-sys lwip
Dependents: SpideyWallWeb RdGasUseMonitor
Fork of EthernetInterface by
Diff: EthernetInterface.cpp
- Revision:
- 50:8e692841213c
- Parent:
- 37:926eb6517318
--- a/EthernetInterface.cpp Thu Mar 12 16:58:57 2015 +0000
+++ b/EthernetInterface.cpp Mon Aug 31 08:58:07 2015 +0000
@@ -40,6 +40,8 @@
static Semaphore netif_linked(0);
static Semaphore netif_up(0);
+static char myName[33]; // holds the name, when setName() is called.
+
static void tcpip_init_done(void *arg) {
tcpip_inited.release();
}
@@ -153,4 +155,21 @@
return networkmask;
}
+int EthernetInterface::setName(const char * myname) {
+ strncpy(myName, myname, 32);
+ myName[32] = '\0'; // be sure it is NULL terminated.
+ // make the name 'safe'
+ for (int i=0; i<32 && myName[i]; i++) {
+ if (!(myName[i] >= '0' && myName[i] <= '9')
+ && !(myName[i] >= 'A' && myName[i] <= 'Z')
+ && !(myName[i] >= 'a' && myName[i] <= 'z'))
+ myName[i] = '-';
+ }
+ netif_set_hostname(&netif, myName);
+ return 0;
+}
+char* EthernetInterface::getName() {
+ return netif_get_hostname(&netif);
+
+}
