Skip to content

Including <sys/socket.h> before <net/if.h> shouldn't be needed #67

@anglov

Description

@anglov

While including <net/if.h> in my project I got following issues:

/project/path/_build/armv7m4-stm32l4x6-ismart2/include/net/if.h:63:19: error: field 'ifru_addr' has incomplete type
   63 |   struct sockaddr ifru_addr;
      |                   ^~~~~~~~~
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/net/if.h:64:19: error: field 'ifru_dstaddr' has incomplete type
   64 |   struct sockaddr ifru_dstaddr;
      |                   ^~~~~~~~~~~~
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/net/if.h:65:19: error: field 'ifru_broadaddr' has incomplete type
   65 |   struct sockaddr ifru_broadaddr;
      |                   ^~~~~~~~~~~~~~
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/net/if.h:66:19: error: field 'ifru_netmask' has incomplete type
   66 |   struct sockaddr ifru_netmask;
      |                   ^~~~~~~~~~~~
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/net/if.h:67:19: error: field 'ifru_hwaddr' has incomplete type
   67 |   struct sockaddr ifru_hwaddr;

Including <sys/socket.h> before <net/if.h> in application fix the problem, but it shouldn't be needed

Problem cannot be fixed by including <sys/socket.h> in <net/if.h> (as in Linux) because there are problem with building LWIP then.

In file included from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/socket.h:22,
                 from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/net/if.h:19,
                 from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/sockios.h:20,
                 from port/sockets.c:29:
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/uio.h:25:8: error: redefinition of 'struct iovec'
   25 | struct iovec {
      |        ^~~~~
In file included from port/sockets.c:14:
lib-lwip/src/include/lwip/sockets.h:121:8: note: originally defined here
  121 | struct iovec {
      |        ^~~~~
In file included from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/net/if.h:19,
                 from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/sockios.h:20,
                 from port/sockets.c:29:
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/socket.h:27: warning: "AF_INET6" redefined
   27 | #define AF_INET6 10
      | 
In file included from port/sockets.c:14:
lib-lwip/src/include/lwip/sockets.h:242: note: this is the location of the previous definition
  242 | #define AF_INET6        AF_UNSPEC
      | 
In file included from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/net/if.h:19,
                 from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/sockios.h:20,
                 from port/sockets.c:29:
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/socket.h:40: warning: "SOL_SOCKET" redefined
   40 | #define SOL_SOCKET 0xFFF
      | 
In file included from port/sockets.c:14:
lib-lwip/src/include/lwip/sockets.h:234: note: this is the location of the previous definition
  234 | #define  SOL_SOCKET  0xfff    /* options for socket level */
      | 
In file included from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/net/if.h:19,
                 from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/sockios.h:20,
                 from port/sockets.c:29:
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/socket.h:59: warning: "MSG_OOB" redefined
   59 | #define MSG_OOB  0x01
      | 
In file included from port/sockets.c:14:
lib-lwip/src/include/lwip/sockets.h:262: note: this is the location of the previous definition
  262 | #define MSG_OOB        0x04    /* Unimplemented: Requests out-of-band data. The significance and semantics of out-of-band data are protocol-specific */
      | 
In file included from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/net/if.h:19,
                 from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/sockios.h:20,
                 from port/sockets.c:29:
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/socket.h:60: warning: "MSG_PEEK" redefined
   60 | #define MSG_PEEK 0x02
      | 
In file included from port/sockets.c:14:
lib-lwip/src/include/lwip/sockets.h:260: note: this is the location of the previous definition
  260 | #define MSG_PEEK       0x01    /* Peeks at an incoming message */
      | 
In file included from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/net/if.h:19,
                 from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/sockios.h:20,
                 from port/sockets.c:29:
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/socket.h:70:18: error: conflicting types for 'sa_family_t'
   70 | typedef uint16_t sa_family_t; // match lwIP size: u8 len + u8 family
      |                  ^~~~~~~~~~~
In file included from port/sockets.c:14:
lib-lwip/src/include/lwip/sockets.h:61:14: note: previous declaration of 'sa_family_t' was here
   61 | typedef u8_t sa_family_t;
      |              ^~~~~~~~~~~
In file included from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/net/if.h:19,
                 from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/sockios.h:20,
                 from port/sockets.c:29:
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/socket.h:73:8: error: redefinition of 'struct sockaddr'
   73 | struct sockaddr {
      |        ^~~~~~~~
In file included from port/sockets.c:14:
lib-lwip/src/include/lwip/sockets.h:92:8: note: originally defined here
   92 | struct sockaddr {
      |        ^~~~~~~~
In file included from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/net/if.h:19,
                 from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/sockios.h:20,
                 from port/sockets.c:29:
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/socket.h:80:8: error: redefinition of 'struct sockaddr_storage'
   80 | struct sockaddr_storage {
      |        ^~~~~~~~~~~~~~~~
In file included from port/sockets.c:14:
lib-lwip/src/include/lwip/sockets.h:98:8: note: originally defined here
   98 | struct sockaddr_storage {
      |        ^~~~~~~~~~~~~~~~
In file included from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/net/if.h:19,
                 from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/sockios.h:20,
                 from port/sockets.c:29:
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/socket.h:86:8: error: redefinition of 'struct linger'
   86 | struct linger {
      |        ^~~~~~
In file included from port/sockets.c:14:
lib-lwip/src/include/lwip/sockets.h:226:8: note: originally defined here
  226 | struct linger {
      |        ^~~~~~
In file included from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/net/if.h:19,
                 from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/sockios.h:20,
                 from port/sockets.c:29:
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/socket.h:95:8: error: redefinition of 'struct msghdr'
   95 | struct msghdr {
      |        ^~~~~~
In file included from port/sockets.c:14:
lib-lwip/src/include/lwip/sockets.h:127:8: note: originally defined here
  127 | struct msghdr {
      |        ^~~~~~
In file included from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/net/if.h:19,
                 from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/sockios.h:20,
                 from port/sockets.c:29:
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/socket.h:106:8: error: redefinition of 'struct cmsghdr'
  106 | struct cmsghdr {
      |        ^~~~~~~
In file included from port/sockets.c:14:
lib-lwip/src/include/lwip/sockets.h:142:8: note: originally defined here
  142 | struct cmsghdr {
      |        ^~~~~~~
In file included from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/net/if.h:19,
                 from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/sockios.h:20,
                 from port/sockets.c:29:
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/socket.h:114: warning: "CMSG_SPACE" redefined
  114 | #define CMSG_SPACE(x) (CMSG_ALIGN(x) + sizeof(struct cmsghdr))
      | 
In file included from port/sockets.c:14:
lib-lwip/src/include/lwip/sockets.h:175: note: this is the location of the previous definition
  175 | #define CMSG_SPACE(length) (ALIGN_D(sizeof(struct cmsghdr)) + \
      | 
In file included from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/net/if.h:19,
                 from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/sockios.h:20,
                 from port/sockets.c:29:
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/socket.h:115: warning: "CMSG_LEN" redefined
  115 | #define CMSG_LEN(x) (x)
      | 
In file included from port/sockets.c:14:
lib-lwip/src/include/lwip/sockets.h:178: note: this is the location of the previous definition
  178 | #define CMSG_LEN(length) (ALIGN_D(sizeof(struct cmsghdr)) + \
      | 
In file included from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/net/if.h:19,
                 from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/sockios.h:20,
                 from port/sockets.c:29:
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/socket.h:116: warning: "CMSG_DATA" redefined
  116 | #define CMSG_DATA(x) ((unsigned char *)((x) + 1))
      | 
In file included from port/sockets.c:14:
lib-lwip/src/include/lwip/sockets.h:172: note: this is the location of the previous definition
  172 | #define CMSG_DATA(cmsg) ((void*)((u8_t *)(cmsg) + \
      | 
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/socket.h:118:45: error: expected identifier or '(' before 'struct'
  118 | static inline struct cmsghdr *CMSG_FIRSTHDR(struct msghdr *m)
      |                                             ^~~~~~
lib-lwip/src/include/lwip/sockets.h:159:13: note: in definition of macro 'CMSG_FIRSTHDR'
  159 |           ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
      |             ^~~~
lib-lwip/src/include/lwip/sockets.h:159:18: error: expected ')' before '->' token
  159 |           ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
      |                  ^~
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/socket.h:118:31: note: in expansion of macro 'CMSG_FIRSTHDR'
  118 | static inline struct cmsghdr *CMSG_FIRSTHDR(struct msghdr *m)
      |                               ^~~~~~~~~~~~~
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/socket.h:123:61: error: expected identifier or '(' before 'struct'
  123 | static inline struct cmsghdr *CMSG_NXTHDR(struct msghdr *m, struct cmsghdr *c)
      |                                                             ^~~~~~
lib-lwip/src/include/lwip/sockets.h:164:12: note: in definition of macro 'CMSG_NXTHDR'
  164 |         (((cmsg) == NULL) ? CMSG_FIRSTHDR(mhdr) : \
      |            ^~~~
lib-lwip/src/include/lwip/sockets.h:164:18: error: expected ')' before '==' token
  164 |         (((cmsg) == NULL) ? CMSG_FIRSTHDR(mhdr) : \
      |                  ^~
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/socket.h:123:31: note: in expansion of macro 'CMSG_NXTHDR'
  123 | static inline struct cmsghdr *CMSG_NXTHDR(struct msghdr *m, struct cmsghdr *c)
      |                               ^~~~~~~~~~~
lib-lwip/src/include/lwip/sockets.h:164:27: error: expected ')' before '?' token
  164 |         (((cmsg) == NULL) ? CMSG_FIRSTHDR(mhdr) : \
      |                           ^
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/socket.h:123:31: note: in expansion of macro 'CMSG_NXTHDR'
  123 | static inline struct cmsghdr *CMSG_NXTHDR(struct msghdr *m, struct cmsghdr *c)
      |                               ^~~~~~~~~~~
In file included from /project/path/_build/armv7m4-stm32l4x6-ismart2/include/sys/sockios.h:20,
                 from port/sockets.c:29:
/project/path/_build/armv7m4-stm32l4x6-ismart2/include/net/if.h:41: warning: "IFNAMSIZ" redefined
   41 | #define IFNAMSIZ            16
      | 
In file included from port/sockets.c:14:
lib-lwip/src/include/lwip/sockets.h:182: note: this is the location of the previous definition
  182 | #define IFNAMSIZ NETIF_NAMESIZE
      | 
port/sockets.c: In function 'sa_convert_sys_to_lwip':
port/sockets.c:114:5: error: 'struct sockaddr' has no member named 'sa_len'
  114 |  lsa->sa_len = (uint8_t)salen;
      |     ^~
port/sockets.c: In function 'socket_ioctl':
port/sockets.c:333:21: error: 'struct sockaddr' has no member named 'sa_len'
  333 |    ifreq->ifr_hwaddr.sa_len = interface->hwaddr_len;
      |                     ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions