Convert string IP address to integer

Deouss
Posts: 425
Joined: Tue Mar 20, 2018 11:36 am

Convert string IP address to integer

Postby Deouss » Mon Dec 31, 2018 12:00 pm

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

fivdiAtESP32
Posts: 47
Joined: Thu Dec 20, 2018 9:47 am

Re: Convert string IP address to integer

Postby fivdiAtESP32 » Mon Dec 31, 2018 12:25 pm

for inet_addr add:

Code: Select all

#include "lwip/inet.h"

Deouss
Posts: 425
Joined: Tue Mar 20, 2018 11:36 am

Re: Convert string IP address to integer

Postby Deouss » Mon Dec 31, 2018 1:52 pm

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.

fivdiAtESP32
Posts: 47
Joined: Thu Dec 20, 2018 9:47 am

Re: Convert string IP address to integer

Postby fivdiAtESP32 » Mon Dec 31, 2018 3:56 pm

The capital "I" at the start of the message indicates that it's an information message rather than a warning,

Who is online

Users browsing this forum: No registered users and 86 guests