source: npl/system/netkit-ftp/patches/14-netkit-ftp-0.17-multiipv6.patch @ 76ea60c

Last change on this file since 76ea60c was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 1.9 KB
  • netkit-ftp-0.17/ftp/ftp.c

    old new  
    7878#include <netinet/in.h>
    7979#include <netinet/ip.h>
    8080#include <arpa/ftp.h>
    81 #include <arpa/inet.h>
    8281#include <arpa/telnet.h>
    83 
    8482#include <stdio.h>
    8583#include <signal.h>
    8684#include <string.h>
     
    132130static sigjmp_buf ptabort;
    133131static int ptabflg = 0;
    134132static int abrtflag = 0;
    135 struct sockaddr_in source;
     133struct sockaddr_storage source;
    136134
    137135void lostpeer(int);
    138136extern int connected;
     
    154152char *
    155153hookup(const char *host, const char *port)
    156154{
    157         int s, tos, error, alen;
    158         socklen_t len;
     155        int s, tos, error;
     156        socklen_t len, alen;
    159157        static char hostnamebuf[256];
    160158        struct addrinfo hints, *res, *res0;
    161159        char hbuf[MAXHOSTNAMELEN], pbuf[NI_MAXSERV];
     
    281279                printf("Connected to %s (%s).\n", hostname, hbuf);
    282280        alen = sizeof(source);
    283281        getsockname(s,(struct sockaddr*)&source, &alen);
    284         source.sin_port = 0;    /* We just want the addr, not the port */
     282        switch (source.ss_family) {
     283            /* We just want the addr, not the port */
     284            case AF_INET:
     285                ((struct sockaddr_in *) &source)->sin_port = 0;
     286                break;
     287            case AF_INET6:
     288                ((struct sockaddr_in6 *) &source)->sin6_port = 0;
     289                break;
     290        }
    285291
    286292        if (getreply(0) > 2) {  /* read startup message from server    */
    287293                if (cin)
     
    12601266                        return(1);
    12611267                }
    12621268                if((multihome) &&
    1263                         bind(data, (struct sockaddr*)&source, sizeof(source)) == -1) {
    1264                         close(data);
    1265                         data = -1;
    1266                         perror("ftp multihome bind");
    1267                         return(1);
     1269                       bind(data, (struct sockaddr *)&source, sizeof(source)) == -1) {
     1270                       close(data);
     1271                       data = -1;
     1272                       perror("ftp multihome bind");
     1273                       return(1);
    12681274                }
    12691275                if (options & SO_DEBUG &&
    12701276                    setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on,
Note: See TracBrowser for help on using the repository browser.