• Support
  • adding an include file for " inet_addr()" call

This line does not compile:
addr_struct->sin_addr.s_addr = inet_addr(addr_str);

Including inet.h does not help because of an “extern” (or “look somewhere else”)
extern in_addr_t inet_addr (const char *__cp) __THROW;

The inet_addr() call is a generic POSIX call , and I have a POSIX enabled in prj.conf:
CONFIG_NET_SOCKETS_POSIX_NAMES=y.

However, the compiler says that it can not still find the inet_addr(). Any ideas are appreciated,

    warning: implicit declaration of function ‘inet_addr’ [-Wimplicit-function-declaration]
    Includes that I have (which are over-kill, I am sure):
    #include <zephyr/posix/netinet/in.h>
    #include <zephyr/net/net_pkt.h>
    #include <zephyr/net/buf.h>
    #include <zephyr/net/net_ip.h>
    #include <zephyr/net/net_if.h>
    #include <zephyr/net/loopback.h> . I am also using IPv4 (no IPv6 yet), so my prj.conf settings are:
    CONFIG_NET_IPV6=n
    CONFIG_NET_IPV4=y
    CONFIG_NET_MGMT=n
    CONFIG_NET_TCP=y
    CONFIG_NET_UDP=y
    CONFIG_NET_LOOPBACK=y
    The setting CONFIG_NET_SOCKETS_POSIX_NAMES=y does not enable all of the POSIX operations (in my experience).
    Thank you !

      I don’t think that’s a valid API call in Zephyr. You may want to check out the settings here: zephyr/subsys/net/ip/Kconfig.ipv4

      This sample seems to set the IP manually: zephyr/samples/net/virtual/src/main.c using net_addr_pton

      Hope that helps!

        Terms and Conditions | Privacy Policy