-
Notifications
You must be signed in to change notification settings - Fork 268
Updated with Set Host Name fuctionality -Tested with Arduino 1.6.13 #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Updated to add Set Host Name fuctionality . Added Example Sketch for set Host Name.
Formating of output message in Sketch, Added linefeed
DhcpHostName.inoPlease use the Arduino IDE to do a Tools > Auto Format, which will fix some trailing whitespace and indentation issues. Dhcp.cpp, Ethernet.cppPlease conform to the formatting standard established throughout the rest of this file and library by using spaces instead of tabs. |
Hey guys, just wanna know whats the update on this and whether this can be expected to be merged. |
Similar to arduino/Arduino#5701 |
Have to ask too: is this extremely useful feature coming soon? |
@per1234 can this be merged? |
@Misiu, since @technofreakz never made the changes I requested 2.5 years ago, I would say no. However, I'm not the one who can decide whether or not this will be merged. |
Hello All, Thank you all for feedback's. Good Day. |
@technofreakz I've checked your changes yesterday and a simple sketch worked perfectly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick look on the pr but the code has some more flaws in my opinion.
else | ||
{ | ||
buffer[16] = hostName; | ||
buffer[17] = strlen(HOST_NAME); // length of hostname + last 3 bytes of mac address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong comment.
{ | ||
buffer[16] = hostName; | ||
buffer[17] = strlen(HOST_NAME); // length of hostname + last 3 bytes of mac address | ||
strcpy((char*)&(buffer[18]), HOST_NAME); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible buffer overflow.
@@ -9,6 +9,12 @@ | |||
#include "Arduino.h" | |||
#include "utility/util.h" | |||
|
|||
char HOST_NAME[12] = "WIZNet"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UPPERCASE is for constants.
char HOST_NAME[12] = "WIZNet"; | ||
|
||
void DhcpClass::setHostName(char *dhcpHost) { | ||
strcpy(HOST_NAME, dhcpHost); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing sanity check.
@@ -172,6 +172,9 @@ class DhcpClass { | |||
|
|||
int beginWithDHCP(uint8_t *, unsigned long timeout = 60000, unsigned long responseTimeout = 4000); | |||
int checkLease(); | |||
// | |||
void setHostName(char *); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing documentation: min max value; type of input: char array vs string.
@@ -27,6 +27,9 @@ class EthernetClass { | |||
void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet); | |||
int maintain(); | |||
|
|||
void hostName(char *dhcp_HostName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misleading naming. Should begin with set
.
char *EthernetClass::getHostName() | ||
{ | ||
char *_getDhcpHostName = _dhcp ->getHostName(); | ||
return _getDhcpHostName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be simplified with previous line.
Please use File > Preferences to set Warnings to All. setHostName() should take a const char * as its input? Without const, passing a string literal will generate compiler warnings. The use of strcpy() also appears to be unsafe. It should check the string length and avoid overwriting beyond the end of the buffer. |
@technofreakz any updates on this? |
technofreakz seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Working well
Updated to add Set Host Name functionality .
Added Example Sketch for set Host Name.
For Arduino 1.6.13