fixed parsing of address to handle [<addr>]
This commit is contained in:
parent
fe2c972ef3
commit
90ae09c7e5
2 changed files with 6 additions and 4 deletions
|
@ -53,15 +53,17 @@ uiplib_ipaddrconv(const char *addrstr, uip_ipaddr_t *ipaddr)
|
||||||
|
|
||||||
value = 0;
|
value = 0;
|
||||||
zero = -1;
|
zero = -1;
|
||||||
|
if(*addrstr == '[') addrstr++;
|
||||||
|
|
||||||
for(len = 0; len < sizeof(uip_ipaddr_t) - 1; addrstr++) {
|
for(len = 0; len < sizeof(uip_ipaddr_t) - 1; addrstr++) {
|
||||||
c = *addrstr;
|
c = *addrstr;
|
||||||
if(c == ':' || c == '\0') {
|
if(c == ':' || c == '\0' || c == ']') {
|
||||||
ipaddr->u8[len] = (value >> 8) & 0xff;
|
ipaddr->u8[len] = (value >> 8) & 0xff;
|
||||||
ipaddr->u8[len + 1] = value & 0xff;
|
ipaddr->u8[len + 1] = value & 0xff;
|
||||||
len += 2;
|
len += 2;
|
||||||
value = 0;
|
value = 0;
|
||||||
|
|
||||||
if(c == '\0') {
|
if(c == '\0' || c == ']') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,13 +46,13 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
/* The address of the server to register the services for this node */
|
/* The address of the server to register the services for this node */
|
||||||
#define SERVER "aaaa::1"
|
#define SERVER "[aaaa::1]"
|
||||||
|
|
||||||
/* This command registers two services (/0 and /1) to turn the leds on or off */
|
/* This command registers two services (/0 and /1) to turn the leds on or off */
|
||||||
#define REGISTER_COMMAND "/r?p=0&d=Turn%20off%20leds&p=1&d=Turn%20on%20leds"
|
#define REGISTER_COMMAND "/r?p=0&d=Turn%20off%20leds&p=1&d=Turn%20on%20leds"
|
||||||
|
|
||||||
/* The address of the other node to control */
|
/* The address of the other node to control */
|
||||||
#define OTHER_NODE "aaaa::212:7403:3:303"
|
#define OTHER_NODE "[aaaa::1]"
|
||||||
|
|
||||||
/* The commands to send to the other node */
|
/* The commands to send to the other node */
|
||||||
#define SET_LEDS_ON "/1"
|
#define SET_LEDS_ON "/1"
|
||||||
|
|
Loading…
Reference in a new issue