curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: curl 7.66.0 to 7.76.0 yield make error: `sa_family_t' undeclared

From: Kevin R. Bulgrien via curl-library <curl-library_at_cool.haxx.se>
Date: Mon, 19 Apr 2021 12:02:48 -0500 (CDT)

> Every build for releases after 7.65.3 fail with a message similar to:
>
> $ make
> Making all in lib
> make[1]: Entering directory '/csdi/src/sco507/curl/curl-7.66.0/lib'
> make all-am
> make[2]: Entering directory '/csdi/src/sco507/curl/curl-7.66.0/lib'
> CC libcurl_la-connect.lo
> connect.c: In function `Curl_addr2string':
> connect.c:668: error: `sa_family_t' undeclared (first use in this
> function)
> connect.c:668: error: (Each undeclared identifier is reported only
> once
> connect.c:668: error: for each function it appears in.)
> make[2]: *** [Makefile:1852: libcurl_la-connect.lo] Error 1
> make[2]: Leaving directory '/csdi/src/sco507/curl/curl-7.66.0/lib'
> make[1]: *** [Makefile:1046: all] Error 2
> make[1]: Leaving directory '/csdi/src/sco507/curl/curl-7.66.0/lib'
> make: *** [Makefile:946: all-recursive] Error 1

...

> This is where the problem occurs:
>
> #if defined(HAVE_SYS_UN_H) && defined(AF_UNIX)
> case AF_UNIX:
> if(salen > sizeof(sa_family_t)) {
> su = (struct sockaddr_un*)sa;
> msnprintf(addr, MAX_IPADR_LEN, "%s", su->sun_path);
> }
> else
> addr[0] = 0; /* socket with no name */
> *port = 0;
> return TRUE;
> #endif
>
> In 2018, a patch for include/curl/system.h allowed building recent
> releases on SCO OpenServer 5.0.7:
>
> -#elif defined(__GNUC__)
> +#elif defined(__GNUC__) && !defined(_SCO_DS)
> ...
> #else
> /* generic "safe guess" on old 32 bit style */
> # define CURL_TYPEOF_CURL_OFF_T long
> # define CURL_FORMAT_CURL_OFF_T "ld"
> # define CURL_FORMAT_CURL_OFF_TU "lu"
> # define CURL_SUFFIX_CURL_OFF_T L
> # define CURL_SUFFIX_CURL_OFF_TU UL
> # define CURL_TYPEOF_CURL_SOCKLEN_T int
> #endif
>
> Is there perhaps a generic, "safe guess" for this...

After some digging, it seems /usr/include/sys/socket.h is relevant:

/*
 * Address families.
 */
#define AF_UNSPEC 0 /* unspecified */
#define AF_UNIX 1 /* local to host (pipes, portals) */
#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
#define AF_IMPLINK 3 /* arpanet imp addresses */
#define AF_PUP 4 /* pup protocols: e.g. BSP */
#define AF_CHAOS 5 /* mit CHAOS protocols */
#define AF_NS 6 /* XEROX NS protocols */
#define AF_ISO 7 /* ISO protocols */
#define AF_OSI AF_ISO
#define AF_ECMA 8 /* european computer manufacturers */
#define AF_DATAKIT 9 /* datakit protocols */
#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
#define AF_SNA 11 /* IBM SNA */
#define AF_DECnet 12 /* DECnet */
#define AF_DLI 13 /* Direct data link interface */
#define AF_LAT 14 /* LAT */
#define AF_HYLINK 15 /* NSC Hyperchannel */
#define AF_APPLETALK 16 /* Apple Talk */
#define AF_ROUTE 17 /* Internal Routing Protocol */
#define AF_LINK 18 /* Link layer interface */
#define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */

#define AF_MAX 20

/*
 * Structure used by kernel to store most addresses.
 */
struct sockaddr {
        u_short sa_family; /* address family */
        char sa_data[14]; /* up to 14 bytes of direct address */
};

Any suggestions on a curl convention to follow with respect to
handling this variance to what other systems define?

Kevin R. Bulgrien
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.se/mail/etiquette.html
Received on 2021-04-19