Perhaps I have missed a function that may already exist, if not I guess this
would be a request for a new feature/function.
When displaying an IP address as a string this kind of call is often made:
printf("Starting lwIP, StaticIP %s\n", inet_ntoa(*(struct
in_addr*)&netadr.ip));
The function inet_ntoa() takes a "struct in_addr" parameter.
However the "netadr.ip" value here contains a "struct ip_addr". Since they
are not the same, all the above type casting is done to force it to work.
This causes a warning everywhere from GCC about alignment etc.
A better way to do this is to create a new function such as:
// display ip_addr value as string
char *ip_ntoa(struct ip_addr adr) {
struct in_addr ip;
ip.s_addr = adr.addr;
return(inet_ntoa(ip));
} // ip_ntoa
So the above call with the new function is then:
printf("Starting lwIP, StaticIP %s\n", ip_ntoa(netadr.ip));
This eliminates all the type casting and warnings. Since lwIP has both
"struct in_addr" and "struct ip_addr" used throughout, it seems like having
a str conversion routine for each type would make sense.
I added ip_ntoa() to the ip_addr.c and ip_addr.h files which makes it easy
to use anywhere.
Chris.
_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users