Page 1 of 1

Convert string IP address to integer

Posted: Mon Dec 31, 2018 12:00 pm
by Deouss
How to properly translate IP in form of string like "192.168.1.0" to 32bit integer ?
What is the best function - it will be used for socket IPv4 address.
I found some info on inet_addr() and inet_pton() but when I tried to use them they show error:
error: implicit declaration of function 'inet_addr' [-Werror=implicit-function-declaration]
I could just shift bytes myself but not sure what is the layouts of bits for socket address word.
Thanks for help

Re: Convert string IP address to integer

Posted: Mon Dec 31, 2018 12:25 pm
by fivdiAtESP32
for inet_addr add:

Code: Select all

#include "lwip/inet.h"

Re: Convert string IP address to integer

Posted: Mon Dec 31, 2018 1:52 pm
by Deouss
Works good. Thanks

Now I get some strange warnings
I (6165) wpa: PTK has been installed, it may be an attack, ignor it.
I (6165) wpa: GTK has been installed, it may be an attack, ignor it.

Re: Convert string IP address to integer

Posted: Mon Dec 31, 2018 3:56 pm
by fivdiAtESP32
The capital "I" at the start of the message indicates that it's an information message rather than a warning,