diff -uNr ncftp-3.1.6.orig/README.llc ncftp-3.1.6.llc/README.llc --- ncftp-3.1.6.orig/README.llc 1969-12-31 21:00:00.000000000 -0300 +++ ncftp-3.1.6.llc/README.llc 2003-11-30 20:24:33.000000000 -0200 @@ -0,0 +1,2 @@ +If you have problem/trouble/suggestion for LLC related code, +Please contact to acme@conectiva.com.br. diff -uNr ncftp-3.1.6.orig/autoconf/acconfig.h ncftp-3.1.6.llc/autoconf/acconfig.h --- ncftp-3.1.6.orig/autoconf/acconfig.h 2003-12-01 01:09:08.000000000 -0200 +++ ncftp-3.1.6.llc/autoconf/acconfig.h 2003-11-30 20:27:55.000000000 -0200 @@ -242,6 +242,9 @@ /* Define if you want IPv6 support. */ #undef ENABLE_IPV6 +/* Define if you want LLC support. */ +#undef ENABLE_LLC + /* Define as __inline if that's what the C compiler calls it. */ #undef inline diff -uNr ncftp-3.1.6.orig/config.h.in ncftp-3.1.6.llc/config.h.in --- ncftp-3.1.6.orig/config.h.in 2003-12-01 01:09:08.000000000 -0200 +++ ncftp-3.1.6.llc/config.h.in 2003-11-30 20:26:52.000000000 -0200 @@ -513,3 +513,5 @@ /* Define if sockaddr_storage has __ss_family member */ #undef HAVE_SOCKADDR_STORAGE___SS_FAMILY +/* Define if you want LLC support. */ +#undef ENABLE_LLC diff -uNr ncftp-3.1.6.orig/configure.in ncftp-3.1.6.llc/configure.in --- ncftp-3.1.6.orig/configure.in 2003-12-01 01:09:08.000000000 -0200 +++ ncftp-3.1.6.llc/configure.in 2003-12-01 02:53:27.000000000 -0200 @@ -137,6 +137,45 @@ ipv6=no )) +dnl --------------------------------------------------------------------------- +dnl Checks for LLC. +dnl --------------------------------------------------------------------------- +dnl +AC_MSG_CHECKING([whether to enable llc]) +AC_ARG_ENABLE(llc, +[ --enable-llc Enable llc support + --disable-llc Disable llc support], +[ case "$enableval" in + no) + AC_MSG_RESULT(no) + llc=no + ;; + *) AC_MSG_RESULT(yes) + AC_DEFINE(ENABLE_LLC) + llc=yes + ;; + esac ], + + AC_TRY_RUN([ /* AF_LLC available check */ +#include +#include +main() +{ + if (socket(AF_LLC, SOCK_STREAM, 0) < 0) + exit(1); + else + exit(0); +} +], + AC_MSG_RESULT(yes) + AC_DEFINE(ENABLE_LLC) + llc=yes, + AC_MSG_RESULT(no) + llc=no, + AC_MSG_RESULT(no) + llc=no +)) + AC_CHECK_FUNC(getnameinfo, [ AC_DEFINE(HAVE_GETNAMEINFO)], [ AC_LIBOBJ([getnameinfo]) diff -uNr ncftp-3.1.6.orig/libncftp/ftp.c ncftp-3.1.6.llc/libncftp/ftp.c --- ncftp-3.1.6.orig/libncftp/ftp.c 2003-12-01 01:09:08.000000000 -0200 +++ ncftp-3.1.6.llc/libncftp/ftp.c 2003-12-02 00:54:43.000000000 -0200 @@ -51,11 +51,24 @@ #ifndef HAVE_SOCKADDR_SA_LEN #ifndef SA_LEN #ifdef ENABLE_IPV6 +#ifdef ENABLE_LLC #define SA_LEN(x) (((x)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \ : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ + : (((x)->sa_family == AF_LLC) ? sizeof(struct sockaddr_llc) \ + : -1))) +#else /* ENABLE_LLC */ +#define SA_LEN(x) (((x)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \ + : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ + : -1)) +#endif /* ENABLE_LLC */ +#else +#ifdef ENABLE_LLC +#define SA_LEN(x) (((x)->sa_family == AF_LLC) ? sizeof(struct sockaddr_llc) \ + : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ : -1)) #else /* ENABLE_IPV6 */ #define SA_LEN(x) (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) : -1) +#endif /* ENABLE_LLC */ #endif /* ENABLE_IPV6 */ #endif /* SA_LEN */ #endif /* HAVE_SOCKADDR_SA_LEN */ @@ -171,7 +184,7 @@ hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; sprintf(buf, "%d\0", fport); - error = getaddrinfo(fhost, buf, &hints, &res0); + error = mygetaddrinfo(fhost, buf, &hints, &res0); if (error) { FTPLogError(cip, kDontPerror, "%s: %s.\n", fhost, gai_strerror(error)); cip->errNo = kErrHostUnknown; @@ -402,7 +415,7 @@ #endif #endif /* NO_SIGNALS */ - getnameinfo((struct sockaddr*)&cip->servCtlAddr, + mygetnameinfo((struct sockaddr*)&cip->servCtlAddr, #ifdef HAVE_SOCKADDR_SA_LEN cip->servCtlAddr.ss_len, #else @@ -614,6 +627,9 @@ #ifdef ENABLE_IPV6 struct sockaddr_in6 *saddr6; #endif +#ifdef ENABLE_LLC + struct sockaddr_llc *saddrllc; +#endif rp = InitResponse(); if (rp == NULL) { @@ -628,7 +644,7 @@ char host[NI_MAXHOST]; char port[NI_MAXSERV]; - getnameinfo(saddr, sizeof(struct sockaddr_in6), host, sizeof(host), + mygetnameinfo(saddr, sizeof(struct sockaddr_in6), host, sizeof(host), port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV); saddr6 = (struct sockaddr_in6 *)saddr; @@ -649,6 +665,29 @@ } } else { #endif +#ifdef ENABLE_LLC + if (saddr->sa_family == AF_LLC) { + unsigned char host[18]; + unsigned char port[4]; + + mygetnameinfo(saddr, sizeof(struct sockaddr_llc), host, + sizeof(host), port, sizeof(port), + NI_NUMERICHOST | NI_NUMERICSERV); + + saddrllc = (struct sockaddr_llc *)saddr; + a = (char *)&saddrllc->sllc_mac; + /* Need to tell the other side which host (the address) and + * which process (port) on that host to send data to. + */ + result = RCmd(cip, rp, "EPRT |9|%s|%s|", host, port); + if (result != 2) { + result = RCmd(cip, rp, "LPRT 6,8,%d,%d,%d,%d,%d,%d,%d,%d,1,%d", + UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]), + UC(a[4]), UC(a[5]), UC(a[6]), UC(a[7]), + saddrllc->sllc_sap); + } + } else { +#endif saddr4 = (struct sockaddr_in *)saddr; /* These will point to data in network byte order. */ a = (char *) &saddr4->sin_addr; @@ -659,6 +698,9 @@ */ result = RCmd(cip, rp, "PORT %d,%d,%d,%d,%d,%d", UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]), UC(p[0]), UC(p[1])); +#ifdef ENABLE_LLC + } +#endif #ifdef ENABLE_IPV6 } #endif @@ -690,6 +732,9 @@ #ifdef ENABLE_IPV6 struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *)saddr; #endif +#ifdef ENABLE_LLC + struct sockaddr_llc *saddrllc = (struct sockaddr_llc *)saddr; +#endif unsigned short port; rp = InitResponse(); @@ -727,9 +772,20 @@ saddr6->sin6_port = htons(port); } else { #endif +#ifdef ENABLE_LLC + if (saddr->sa_family == AF_LLC) { + memcpy(saddrllc->sllc_mac, + ((struct sockaddr_llc *)&cip->servCtlAddr)->sllc_mac, + sizeof(saddrllc->sllc_mac)); + saddrllc->sllc_sap = port; + } else { +#endif saddr4->sin_addr = ((struct sockaddr_in *)&cip->servCtlAddr)->sin_addr; saddr4->sin_port = htons(port); +#ifdef ENABLE_LLC + } +#endif #ifdef ENABLE_IPV6 } #endif @@ -804,6 +860,66 @@ (void) memcpy(&saddr6->sin6_port, &n[16], (size_t) 2); } else { #endif +#ifdef ENABLE_LLC + if (saddr->sa_family == AF_LLC) { + int af, hal, pal; + + result = RCmd(cip, rp, "LPSV"); + if (result < 0) + goto done; + + if (rp->codeType != 2) { + /* Didn't understand or didn't want passive port selection. */ + cip->errNo = result = kErrPASVFailed; + goto done; + } + + /* The other side returns a specification in the form of + * an mac address as the first four integers (each + * integer stands for 8-bits of the real 48-bit address), + * and one more integer for the port (8-bit port). + * + * It should give us something like: + * "Entering Passive Mode (129,93,33,1,10,187)", so look for + * digits with sscanf() starting 24 characters down the string. + */ + for (cp = rp->msg.first->line; ; cp++) { + if (*cp == '\0') { + FTPLogError(cip, kDontPerror, "Cannot parse LPSV response: %s\n", rp->msg.first->line); + goto done; + } + if (isdigit((int) *cp)) + break; + } + + if (sscanf(cp, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", + &af, &hal, + &i[ 0], &i[ 1], &i[ 2], &i[ 3], + &i[ 4], &i[ 5], &i[ 6], &i[ 7], + &pal, + &i[8]) != 12) { + FTPLogError(cip, kDontPerror, "Cannot parse LPSV response: %s\n", rp->msg.first->line); + goto done; + } + if (af != 9 || hal != 8 || pal != 1) { + FTPLogError(cip, kDontPerror, "Cannot parse LPSV response: %s\n", rp->msg.first->line); + goto done; + } + + for (j=0, *weird = 0; j < 9; j++) { + /* Some ftp servers return bogus port octets. + * Let the caller know if we got a + * weird looking octet. + */ + if ((i[j] < 0) || (i[j] > 255)) + *weird = *weird + 1; + n[j] = (unsigned char) (i[j] & 0xff); + } + (void) memcpy(&saddrllc->sllc_mac, &n[0], (size_t)8); + saddrllc->sllc_sap = n[8]; + + } else { +#endif result = RCmd(cip, rp, "PASV"); if (result < 0) goto done; @@ -849,6 +965,9 @@ } (void) memcpy(&saddr4->sin_addr, &n[0], (size_t) 4); (void) memcpy(&saddr4->sin_port, &n[4], (size_t) 2); +#ifdef ENABLE_LLC + } +#endif #ifdef ENABLE_IPV6 } #endif @@ -879,6 +998,11 @@ ((struct sockaddr_in6 *)addrp)->sin6_port = 0; /* Let system pick one. */ else #endif +#ifdef ENABLE_LLC + if (addrp->sa_family == AF_LLC) + ((struct sockaddr_llc *)addrp)->sllc_sap = 0; /* Let system pick one. */ + else +#endif ((struct sockaddr_in *)addrp)->sin_port = 0; /* Let system pick one. */ #ifdef HAVE_SOCKADDR_SA_LEN result = bind(sockfd, addrp, addrp->sa_len); @@ -895,6 +1019,14 @@ ((struct sockaddr_in6 *)addrp)->sin6_port = htons(port); else #endif +#ifdef ENABLE_LLC + if (addrp->sa_family == AF_LLC) { + port &= 0xFF; + if (port == 0xFF) + --port; + ((struct sockaddr_llc *)addrp)->sllc_sap = port; + } else +#endif ((struct sockaddr_in *)addrp)->sin_port = htons(port); #ifdef HAVE_SOCKADDR_SA_LEN result = bind(sockfd, addrp, addrp->sa_len); @@ -937,7 +1069,7 @@ result = 0; CloseDataConnection(cip); /* In case we didn't before... */ -#ifdef ENABLE_IPV6 +#if defined(ENABLE_IPV6) || defined(ENABLE_LLC) dataSocket = socket(cip->ourCtlAddr.ss_family, SOCK_STREAM, 0); #else dataSocket = socket(AF_INET, SOCK_STREAM, 0); @@ -1218,6 +1350,30 @@ } } else { #endif +#ifdef ENABLE_LLC + if (cip->servDataAddr.ss_family == AF_LLC) { + struct sockaddr_llc *servDataAddr = + (struct sockaddr_llc *) &cip->servDataAddr; + struct sockaddr_llc *servCtlAddr = + (struct sockaddr_llc *) &cip->servCtlAddr; + + remoteDataPort = servDataAddr->sllc_sap; + remoteCtrlPort = servCtlAddr->sllc_sap; + if ((int) remoteDataPort != ((int) remoteCtrlPort - 1)) { + FTPLogError(cip, kDontPerror, "Data connection did not originate on correct port!\n"); + (void) DisposeSocket(newSocket); + cip->dataSocket = kClosedFileDescriptor; + cip->errNo = kErrAcceptDataSocket; + return (kErrAcceptDataSocket); + } else if (memcmp(&servDataAddr->sllc_mac, &servCtlAddr->sllc_mac, sizeof(servDataAddr->sllc_mac)) != 0) { + FTPLogError(cip, kDontPerror, "Data connection did not originate from remote server!\n"); + (void) DisposeSocket(newSocket); + cip->dataSocket = kClosedFileDescriptor; + cip->errNo = kErrAcceptDataSocket; + return (kErrAcceptDataSocket); + } + } else { +#endif struct sockaddr_in *servDataAddr = (struct sockaddr_in *) &cip->servDataAddr; struct sockaddr_in *servCtlAddr = @@ -1238,6 +1394,9 @@ cip->errNo = kErrAcceptDataSocket; return (kErrAcceptDataSocket); } +#ifdef ENABLE_LLC + } +#endif #ifdef ENABLE_IPV6 } #endif diff -uNr ncftp-3.1.6.orig/libncftp/syshdrs.h ncftp-3.1.6.llc/libncftp/syshdrs.h --- ncftp-3.1.6.orig/libncftp/syshdrs.h 2003-12-01 01:09:08.000000000 -0200 +++ ncftp-3.1.6.llc/libncftp/syshdrs.h 2003-12-01 02:45:49.000000000 -0200 @@ -129,6 +129,9 @@ # include # include # include +# ifdef ENABLE_LLC +# include +# endif # include # include # include diff -uNr ncftp-3.1.6.orig/libncftp/u_misc.c ncftp-3.1.6.llc/libncftp/u_misc.c --- ncftp-3.1.6.orig/libncftp/u_misc.c 2002-03-27 07:13:41.000000000 -0300 +++ ncftp-3.1.6.llc/libncftp/u_misc.c 2003-12-01 03:31:52.000000000 -0200 @@ -6,6 +6,7 @@ */ #include "syshdrs.h" +#include #ifdef PRAGMA_HDRSTOP # pragma hdrstop #endif @@ -333,3 +334,125 @@ } /* WinStat64 */ #endif + +int +llcgetaddrinfo(const char *node, const char *service, + const struct addrinfo *hints, + struct addrinfo **res) +{ + char *x; + unsigned char port; + struct ether_addr e; + struct addrinfo *ai; + struct sockaddr_llc *sllc; + int rc = EAI_NONAME; + + if (node && !ether_aton_r(node, &e) && ether_hostton(node, &e)) + goto out; + rc = EAI_MEMORY; + ai = malloc(sizeof(*ai)); + if (!ai) + goto out_mem_ai; + sllc = malloc(sizeof(*sllc)); + if (!sllc) + goto out_mem_sllc; + memset(ai, 0, sizeof(*ai)); + memset(sllc, 0, sizeof(*sllc)); + ai->ai_next = 0; + ai->ai_family = AF_LLC; + ai->ai_socktype = SOCK_STREAM; + ai->ai_addrlen = sizeof(*sllc); + ai->ai_addr = (struct sockaddr *)sllc; + sllc->sllc_family = AF_LLC; + sllc->sllc_arphrd = 1; + port = strtol(service ? service : "0", &x, 0); + if (*x) { /* service is not numeric */ + struct servent* se = getservbyname(service, "llc"); + + rc = EAI_SERVICE; + if (!se) + goto out_service; + port = se->s_port; + } + if (node) + memcpy(sllc->sllc_mac, e.ether_addr_octet, IFHWADDRLEN); + sllc->sllc_sap = port; + rc = 0; + *res = ai; +out: + return rc; +out_service: + free(sllc); +out_mem_sllc: + free(ai); +out_mem_ai: + rc = EAI_MEMORY; + goto out; +} + +int +mygetaddrinfo(const char *node, const char *service, + const struct addrinfo *hints, + struct addrinfo **res) +{ + int rc; + + if (hints->ai_family == AF_UNSPEC || + hints->ai_family == AF_LLC) { + rc = llcgetaddrinfo(node, service, hints, res); + if (!rc || hints->ai_family == AF_LLC) + goto out; + } + rc = getaddrinfo(node, service, hints, res); +out: + return rc; +} + +int llcgetnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, + size_t hostlen, char *serv, size_t servlen, int flags) +{ + struct sockaddr_llc *sllc = (struct sockaddr_llc *)sa; + + if (host && hostlen > 0) { /* resolve host */ + char name[64]; + struct ether_addr *eth = (struct ether_addr *)sllc->sllc_mac; + if ((flags & NI_NUMERICHOST) || + ether_ntohost(name, eth)) + if (!ether_ntoa_r(eth, name)) + return EAI_NONAME; + strncpy(host, name, hostlen - 1); + host[hostlen - 1] = '\0'; + } + if (serv && servlen > 0) { /* resolve service */ + struct servent *s; + + snprintf(serv, servlen - 1, "%d", sllc->sllc_sap); + + if (!(flags & NI_NUMERICHOST)) { + s = getservbyport(sllc->sllc_sap, "llc"); + + if (!s) + return EAI_NONAME; + strncpy(serv, s->s_name, servlen - 1); + } + serv[servlen - 1] = '\0'; + } + return 0; +} + +int mygetnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, + size_t hostlen, char *serv, size_t servlen, int flags) +{ + int rc; + sa_family_t f = ((struct sockaddr_storage *)sa)->ss_family; + + if (f == AF_LLC || f == AF_UNSPEC) { + rc = llcgetnameinfo(sa, salen, host, hostlen, + serv, servlen, flags); + if (!rc || f == AF_LLC) + goto out; + } + rc = getnameinfo(sa, salen, host, hostlen, serv, servlen, flags); +out: + return rc; +} diff -uNr ncftp-3.1.6.orig/libncftp/util.h ncftp-3.1.6.llc/libncftp/util.h --- ncftp-3.1.6.orig/libncftp/util.h 2002-10-13 19:25:07.000000000 -0200 +++ ncftp-3.1.6.llc/libncftp/util.h 2003-12-01 02:52:38.000000000 -0200 @@ -152,4 +152,10 @@ void RemoteGlobCollapse(const FTPCIPtr, const char *pattern, FTPLineListPtr fileList); int PathContainsIntermediateDotDotSubDir(const char *s); +int mygetaddrinfo(const char *node, const char *service, + const struct addrinfo *hints, struct addrinfo **res); +int mygetnameinfo(const struct sockaddr *sa, socklen_t salen, + char *host, size_t hostlen, char *serv, + size_t servlen, int flags); + #endif /* _util_h_ */ diff -uNr ncftp-3.1.6.orig/ncftp/util.c ncftp-3.1.6.llc/ncftp/util.c --- ncftp-3.1.6.orig/ncftp/util.c 2003-12-01 01:09:08.000000000 -0200 +++ ncftp-3.1.6.llc/ncftp/util.c 2003-12-01 02:47:42.000000000 -0200 @@ -672,12 +672,12 @@ memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; - error = getaddrinfo(hn, NULL, &hints, &res); + error = mygetaddrinfo(hn, NULL, &hints, &res); if (error == 0) { char buf[NI_MAXHOST]; - getnameinfo(res->ai_addr, res->ai_addrlen, + mygetnameinfo(res->ai_addr, res->ai_addrlen, buf, sizeof(buf), NULL, 0, NI_NUMERICHOST); (void) Strncpy(dst, buf, dsize); @@ -717,7 +717,7 @@ hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = 0; - error = getaddrinfo(hn, NULL, &hints, &res); + error = mygetaddrinfo(hn, NULL, &hints, &res); if (t > 0) (void) alarm(0); (void) NcSignal(SIGPIPE, osigpipe); @@ -726,7 +726,7 @@ if (error == 0) { char buf[NI_MAXHOST]; - getnameinfo(res->ai_addr, res->ai_addrlen, + mygetnameinfo(res->ai_addr, res->ai_addrlen, buf, sizeof(buf), NULL, 0, NI_NUMERICHOST); (void) Strncpy(dst, buf, dsize); diff -uNr ncftp-3.1.6.orig/sio/SAcceptA.c ncftp-3.1.6.llc/sio/SAcceptA.c --- ncftp-3.1.6.orig/sio/SAcceptA.c 2003-12-01 01:09:08.000000000 -0200 +++ ncftp-3.1.6.llc/sio/SAcceptA.c 2003-12-01 01:23:43.000000000 -0200 @@ -11,11 +11,24 @@ #ifndef HAVE_SOCKADDR_SA_LEN #ifndef SA_LEN #ifdef ENABLE_IPV6 +#ifdef ENABLE_LLC #define SA_LEN(x) (((x)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \ : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ + : (((x)->sa_family == AF_LLC) ? sizeof(struct sockaddr_llc) \ + : -1))) +#else +#define SA_LEN(x) (((x)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \ + : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ + : -1)) +#endif +#else +#ifdef ENABLE_LLC +#define SA_LEN(x) (((x)->sa_family == AF_LLC) ? sizeof(struct sockaddr_llc) \ + : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ : -1)) -#else /* ENABLE_IPV6 */ +#else /* ENABLE_IPV6/ENABLE_LLC */ #define SA_LEN(x) (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) : -1) +#endif /* ENABLE_LLC */ #endif /* ENABLE_IPV6 */ #endif /* SA_LEN */ #endif /* HAVE_SOCKADDR_SA_LEN */ diff -uNr ncftp-3.1.6.orig/sio/SAcceptS.c ncftp-3.1.6.llc/sio/SAcceptS.c --- ncftp-3.1.6.orig/sio/SAcceptS.c 2003-12-01 01:09:08.000000000 -0200 +++ ncftp-3.1.6.llc/sio/SAcceptS.c 2003-12-01 01:23:48.000000000 -0200 @@ -6,11 +6,24 @@ #ifndef HAVE_SOCKADDR_SA_LEN #ifndef SA_LEN #ifdef ENABLE_IPV6 +#ifdef ENABLE_LLC #define SA_LEN(x) (((x)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \ : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ + : (((x)->sa_family == AF_LLC) ? sizeof(struct sockaddr_llc) \ + : -1))) +#else +#define SA_LEN(x) (((x)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \ + : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ + : -1)) +#endif +#else +#ifdef ENABLE_LLC +#define SA_LEN(x) (((x)->sa_family == AF_LLC) ? sizeof(struct sockaddr_llc) \ + : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ : -1)) -#else /* ENABLE_IPV6 */ +#else /* ENABLE_IPV6/ENABLE_LLC */ #define SA_LEN(x) (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) : -1) +#endif /* ENABLE_LLC */ #endif /* ENABLE_IPV6 */ #endif /* SA_LEN */ #endif /* HAVE_SOCKADDR_SA_LEN */ diff -uNr ncftp-3.1.6.orig/sio/SConnect.c ncftp-3.1.6.llc/sio/SConnect.c --- ncftp-3.1.6.orig/sio/SConnect.c 2003-12-01 01:09:08.000000000 -0200 +++ ncftp-3.1.6.llc/sio/SConnect.c 2003-12-01 01:23:54.000000000 -0200 @@ -13,11 +13,24 @@ #ifndef HAVE_SOCKADDR_SA_LEN #ifndef SA_LEN #ifdef ENABLE_IPV6 +#ifdef ENABLE_LLC #define SA_LEN(x) (((x)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \ : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ + : (((x)->sa_family == AF_LLC) ? sizeof(struct sockaddr_llc) \ + : -1))) +#else +#define SA_LEN(x) (((x)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \ + : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ + : -1)) +#endif +#else +#ifdef ENABLE_LLC +#define SA_LEN(x) (((x)->sa_family == AF_LLC) ? sizeof(struct sockaddr_llc) \ + : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ : -1)) -#else /* ENABLE_IPV6 */ +#else /* ENABLE_IPV6/ENABLE_LLC */ #define SA_LEN(x) (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) : -1) +#endif /* ENABLE_LLC */ #endif /* ENABLE_IPV6 */ #endif /* SA_LEN */ #endif /* HAVE_SOCKADDR_SA_LEN */ diff -uNr ncftp-3.1.6.orig/sio/SSendto.c ncftp-3.1.6.llc/sio/SSendto.c --- ncftp-3.1.6.orig/sio/SSendto.c 2003-12-01 01:09:08.000000000 -0200 +++ ncftp-3.1.6.llc/sio/SSendto.c 2003-12-01 01:23:57.000000000 -0200 @@ -6,16 +6,28 @@ #ifndef HAVE_SOCKADDR_SA_LEN #ifndef SA_LEN #ifdef ENABLE_IPV6 +#ifdef ENABLE_LLC #define SA_LEN(x) (((x)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \ - : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ - : -1)) -#else /* ENABLE_IPV6 */ + : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ + : (((x)->sa_family == AF_LLC) ? sizeof(struct sockaddr_llc) \ + : -1))) +#else +#define SA_LEN(x) (((x)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \ + : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ + : -1)) +#endif +#else +#ifdef ENABLE_LLC +#define SA_LEN(x) (((x)->sa_family == AF_LLC) ? sizeof(struct sockaddr_llc) \ + : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ + : -1)) +#else /* ENABLE_IPV6/ENABLE_LLC */ #define SA_LEN(x) (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) : -1) +#endif /* ENABLE_LLC */ #endif /* ENABLE_IPV6 */ #endif /* SA_LEN */ #endif /* HAVE_SOCKADDR_SA_LEN */ - #ifndef NO_SIGNALS extern Sjmp_buf gNetTimeoutJmp; extern Sjmp_buf gPipeJmp; diff -uNr ncftp-3.1.6.orig/sio/StrAddr.c ncftp-3.1.6.llc/sio/StrAddr.c --- ncftp-3.1.6.orig/sio/StrAddr.c 2003-12-01 01:09:08.000000000 -0200 +++ ncftp-3.1.6.llc/sio/StrAddr.c 2003-12-01 02:47:50.000000000 -0200 @@ -6,11 +6,24 @@ #ifndef HAVE_SOCKADDR_SA_LEN #ifndef SA_LEN #ifdef ENABLE_IPV6 +#ifdef ENABLE_LLC #define SA_LEN(x) (((x)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \ - : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ - : -1)) -#else /* ENABLE_IPV6 */ + : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ + : (((x)->sa_family == AF_LLC) ? sizeof(struct sockaddr_llc) \ + : -1))) +#else +#define SA_LEN(x) (((x)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \ + : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ + : -1)) +#endif +#else +#ifdef ENABLE_LLC +#define SA_LEN(x) (((x)->sa_family == AF_LLC) ? sizeof(struct sockaddr_llc) \ + : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ + : -1)) +#else /* ENABLE_IPV6/ENABLE_LLC */ #define SA_LEN(x) (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) : -1) +#endif /* ENABLE_LLC */ #endif /* ENABLE_IPV6 */ #endif /* SA_LEN */ #endif /* HAVE_SOCKADDR_SA_LEN */ @@ -269,7 +282,7 @@ memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; - error = getaddrinfo(hostcp, portp, &hints, &res); + error = mygetaddrinfo(hostcp, portp, &hints, &res); if (error != 0) return (kAddrStrToAddrBadHost); memcpy(sa, res->ai_addr, res->ai_addrlen); @@ -299,14 +312,14 @@ dns = NI_NUMERICHOST; else dns = 0; - getnameinfo(saddrp, + mygetnameinfo(saddrp, #ifdef HAVE_SOCKADDR_SA_LEN saddrp->sa_len, #else SA_LEN(saddrp), #endif addrName, sizeof(addrName), portName, sizeof(portName), dns); - getnameinfo(saddrp, + mygetnameinfo(saddrp, #ifdef HAVE_SOCKADDR_SA_LEN saddrp->sa_len, #else diff -uNr ncftp-3.1.6.orig/sio/syshdrs.h ncftp-3.1.6.llc/sio/syshdrs.h --- ncftp-3.1.6.orig/sio/syshdrs.h 2003-12-01 01:09:08.000000000 -0200 +++ ncftp-3.1.6.llc/sio/syshdrs.h 2003-12-01 02:14:56.000000000 -0200 @@ -82,6 +82,9 @@ # include # include # include +# ifdef ENABLE_LLC +# include +# endif # include # include # include