diff -ruN pvm3.old/console/cmds.c pvm3/console/cmds.c --- pvm3.old/console/cmds.c 2001-09-27 01:37:22.000000000 +0200 +++ pvm3/console/cmds.c 2005-04-19 19:09:26.000000000 +0200 @@ -433,7 +433,7 @@ int hd_dsig; /* data signature */ int hd_err; /* error code */ int hd_mtu; /* max snd/rcv length */ - /* struct sockaddr_in hd_sad; /^ UDP address/port */ + /* struct SOCKADDR_IN hd_sad; /^ UDP address/port */ int hd_rxseq; /* expected next seq num from host */ int hd_txseq; /* next tx seq num to host */ /* struct pkt *hd_txq; /^ not-yet-sent packet queue to host */ diff -ruN pvm3.old/hoster/pvmwinrexec.c pvm3/hoster/pvmwinrexec.c --- pvm3.old/hoster/pvmwinrexec.c 1998-11-20 20:47:48.000000000 +0100 +++ pvm3/hoster/pvmwinrexec.c 2005-04-19 19:09:26.000000000 +0200 @@ -312,7 +312,7 @@ { WSADATA wsadata; - struct sockaddr_in server_addr, my_err_addr, junk_addr; + struct SOCKADDR_IN server_addr, my_err_addr, junk_addr; struct servent *sv; struct hostent *hent; static char portbuf[30]; @@ -335,7 +335,7 @@ return(0); } - hent = gethostbyname(remote_host); + hent = GETHOSTBYNAME(remote_host); if(!hent) { fprintf(stderr, "Lookup of server hostname failed: error=%d.\n", WSAGetLastError()); @@ -367,7 +367,7 @@ memset(&my_err_addr, '\0', sizeof my_err_addr); my_err_addr.sin_addr.s_addr = htonl(INADDR_ANY); - my_err_addr.sin_family = AF_INET; + my_err_addr.sin_family = AF_FAMILY; my_err_addr.sin_port = 0; if ((sTmp=socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) { diff -ruN pvm3.old/hoster/pvmwinrsh.c pvm3/hoster/pvmwinrsh.c --- pvm3.old/hoster/pvmwinrsh.c 1999-03-15 22:52:03.000000000 +0100 +++ pvm3/hoster/pvmwinrsh.c 2005-04-19 19:09:26.000000000 +0200 @@ -33,8 +33,8 @@ #include #include -struct sockaddr_in anaddr; // local socket address structure -struct sockaddr_in saddr; // server socket address structure +struct SOCKADDR_IN anaddr; // local socket address structure +struct SOCKADDR_IN saddr; // server socket address structure u_short rshPort; // the local rsh port; determined dynamically u_short rshErrPort; // the local rsh port for client stderr output @@ -61,12 +61,12 @@ int rresvport (u_short *alport, int sProto) { - struct sockaddr_in sin; + struct SOCKADDR_IN sin; int s; - sin.sin_family=AF_INET; + sin.sin_family=AF_FAMILY; sin.sin_addr.s_addr=INADDR_ANY; - s=socket(AF_INET, SOCK_STREAM, sProto); + s=socket(PF_FAMILY, SOCK_STREAM, sProto); if(s<0) return -1; @@ -139,7 +139,7 @@ if(saddr.sin_addr.s_addr==(u_long)INADDR_NONE) { // must have gotten host name instead of IP address; resolve! - struct hostent* hostInfo=gethostbyname(hostname); + struct hostent* hostInfo=GETHOSTBYNAME(hostname); if(!hostInfo) { fprintf(stdout,"Invalid hostname!"); return 0; @@ -285,7 +285,7 @@ initSocket(); if(!initErrSocket()) fprintf(stdout,"Cannot create error socket!"); - saddr.sin_family=AF_INET; + saddr.sin_family=AF_FAMILY; saddr.sin_port=rshSPort; if(connect(rshClient, (struct sockaddr FAR*)&saddr, sizeof(saddr))) fprintf(stdout,"Cannot connect to RSH port!\n"); diff -ruN pvm3.old/src/AIX4SP2/pvmdmimd.c pvm3/src/AIX4SP2/pvmdmimd.c --- pvm3.old/src/AIX4SP2/pvmdmimd.c 2001-09-25 23:19:00.000000000 +0200 +++ pvm3/src/AIX4SP2/pvmdmimd.c 2005-04-19 19:09:26.000000000 +0200 @@ -838,13 +838,13 @@ mksock() { struct hostd *hp = hosts->ht_hosts[hosts->ht_local]; - struct sockaddr_in sin; + struct SOCKADDR_IN sin; char buf[128]; char *p; int cc; int sock; - if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { + if ((sock = socket(PF_FAMILY, SOCK_STREAM, 0)) == -1) { pvmlogperror("mksock() socket"); return -1; } diff -ruN pvm3.old/src/BEOLIN/pvmdmimd.c pvm3/src/BEOLIN/pvmdmimd.c --- pvm3.old/src/BEOLIN/pvmdmimd.c 2000-02-17 22:02:24.000000000 +0100 +++ pvm3/src/BEOLIN/pvmdmimd.c 2005-04-19 19:09:26.000000000 +0200 @@ -160,7 +160,7 @@ struct hostent *hostaddr; int i; int n; - struct in_addr node_sin_addr; + struct IN_ADDR node_sin_addr; char nname[128]; /* node name */ char *p, *q; char *plist; /* processor list */ @@ -195,16 +195,16 @@ n = (q = CINDEX(p, ':')) ? q - p : strlen(p); strncpy(nname, p, n); nname[n] = 0; - if (!(hostaddr = gethostbyname( nname ))) + if (!(hostaddr = GETHOSTBYNAME( nname ))) { - sprintf( pvmtxt, "mpp_init() can't gethostbyname() for %s\n", + sprintf( pvmtxt, "mpp_init() can't GETHOSTBYNAME() for %s\n", nname ); pvmlogerror( pvmtxt ); } else { /* got addr, now save it */ BCOPY( hostaddr->h_addr_list[0], (char*)&node_sin_addr, - sizeof(struct in_addr)); + sizeof(struct IN_ADDR)); } nodeaddr[i] = node_sin_addr.s_addr; nodelist[i++] = STRALLOC(nname); diff -ruN pvm3.old/src/ddpro.c pvm3/src/ddpro.c --- pvm3.old/src/ddpro.c 2001-09-27 01:35:19.000000000 +0200 +++ pvm3/src/ddpro.c 2005-04-22 19:38:20.059222888 +0200 @@ -416,11 +416,13 @@ #include "msgbox.h" #include "global.h" +#include "pvmipv6.h" + void pvmbailout(); char *inadport_hex(); char *getenv(); -void hex_inadport __ProtoGlarp__ (( char *, struct sockaddr_in * )); +void hex_inadport __ProtoGlarp__ (( char *, struct SOCKADDR_IN * )); void mesg_rewind __ProtoGlarp__ (( struct pmsg * )); void tev_send_newtask(); @@ -903,7 +905,7 @@ hp = hosts->ht_hosts[hosts->ht_local]; - if ( hp->hd_sad.sin_addr.s_addr == htonl(0x7f000001) ) { + if ( ADDR_IS_LOOPBACK(ADDR_FROM_SA(hp->hd_sad))) { /* damn, we're hosed. bail on host adds with new */ /* PvmIPLoopback error code... */ @@ -926,14 +928,14 @@ if (hp->hd_err) continue; - if (he = gethostbyname(hp->hd_aname ? hp->hd_aname : hp->hd_name)) { - BCOPY(he->h_addr_list[0], (char*)&hp->hd_sad.sin_addr, - sizeof(struct in_addr)); + if (he = GETHOSTBYNAME(hp->hd_aname ? hp->hd_aname : hp->hd_name)) { + BCOPY(he->h_addr_list[0], (char*)&ADDR_FROM_SA(hp->hd_sad), + sizeof(struct IN_ADDR)); } else { if (pvmdebmask & PDMSTARTUP) { pvmlogprintf( - "start_slaves() can't gethostbyname: %s\n", + "start_slaves() can't GETHOSTBYNAME: %s\n", hp->hd_name); } hp->hd_err = PvmNoHost; @@ -945,7 +947,7 @@ if (!(hp->hd_flag & HF_OVERLOAD)) { for (hh = hosts->ht_last; hh > 0; hh--) if ((hp2 = hosts->ht_hosts[hh]) - && (hp2->hd_sad.sin_addr.s_addr == hp->hd_sad.sin_addr.s_addr)) { + && (ADDR_EQUALS(ADDR_FROM_SA(hp2->hd_sad), ADDR_FROM_SA(hp->hd_sad)))) { hp->hd_err = PvmDupHost; break; } @@ -955,8 +957,7 @@ /* make sure new ones aren't duplicated */ for (j = i; j-- > 0; ) - if (hp->hd_sad.sin_addr.s_addr - == wxp->w_hosts[j]->hd_sad.sin_addr.s_addr) { + if (ADDR_EQUALS(ADDR_FROM_SA(hp->hd_sad),ADDR_FROM_SA(wxp->w_hosts[j]->hd_sad))) { hp->hd_err = PvmDupHost; break; } @@ -1722,7 +1723,11 @@ { int count; /* number of hosts in message */ int hh; +#ifdef INET6 + char buf[INET6_ADDRSTRLEN+2+20]; /* for converting sockaddr */ +#else char buf[16]; /* for converting sockaddr */ +#endif struct pmsg *mp2; /* unpack new host table params */ @@ -2039,7 +2044,11 @@ int count; /* num of new hosts */ int happy; /* num of happy new hosts */ struct waitc_add *wxp; +#ifdef INET6 + char *av[INET6_ADDRSTRLEN+2+20]; /* for reply parsing */ +#else char *av[16]; /* for reply parsing */ +#endif int ac; int ver; int i, j; diff -ruN pvm3.old/src/host.c pvm3/src/host.c --- pvm3.old/src/host.c 2001-09-27 01:35:18.000000000 +0200 +++ pvm3/src/host.c 2005-04-19 19:09:26.000000000 +0200 @@ -266,7 +266,7 @@ BZERO((char*)hp, sizeof(struct hostd)); hp->hd_ref = 1; hp->hd_hostpart = hh << (ffs(tidhmask) - 1); - hp->hd_sad.sin_family = AF_INET; + FAMILY_FROM_SA(hp->hd_sad) = AF_FAMILY; hp->hd_txq = pk_new(0); hp->hd_opq = pk_new(0); hp->hd_rxq = pk_new(0); @@ -814,7 +814,7 @@ int err = 0; /* error count */ struct hostent *he; char *p; - struct in_addr *my_in_addrs; + struct IN_ADDR *my_in_addrs; int num_addrs; int i; int maxhostid = tidhmask >> (ffs(tidhmask) - 1); @@ -885,21 +885,21 @@ /* look up ip addr */ - if (!(he = gethostbyname(hp->hd_aname ? hp->hd_aname : hp->hd_name))) { - pvmlogprintf("readhostfile() %s %d: %s: can't gethostbyname\n", + if (!(he = GETHOSTBYNAME(hp->hd_aname ? hp->hd_aname : hp->hd_name))) { + pvmlogprintf("readhostfile() %s %d: %s: can't GETHOSTBYNAME\n", fn, lnum, hp->hd_name); err++; goto badline; } - BCOPY(he->h_addr_list[0], (char*)&hp->hd_sad.sin_addr, - sizeof(struct in_addr)); + BCOPY(he->h_addr_list[0], (char*)&ADDR_FROM_SA(hp->hd_sad), + sizeof(struct IN_ADDR)); /* mark master host to not start */ if (!(hp->hd_flag & HF_OVERLOAD)) for (i = num_addrs; i-- > 0; ) { - if (BCMP((char*)&my_in_addrs[i], (char*)&hp->hd_sad.sin_addr, - sizeof(struct in_addr)) == 0) { + if (BCMP((char*)&my_in_addrs[i], (char*)&ADDR_FROM_SA(hp->hd_sad), + sizeof(struct IN_ADDR)) == 0) { hp->hd_flag |= HF_NOSTART; break; } @@ -937,16 +937,77 @@ * * Return list of addresses for active network interfaces. */ +#ifdef INET6 +int +iflist(alp, np) + struct IN_ADDR **alp; /* return list of addresses */ + int *np; /* return len of alp */ +{ + static struct IN_ADDR *iplist = 0; /* list of interface addrs found */ + int nip = 0; /* length of iplist */ + char **p; + + FILE *f; + char addr6[40], devname[20]; + struct SOCKADDR_IN sap; + int plen, scope, dad_status, if_idx; + char addr6p[8][5]; + + + if (iplist) + PVM_FREE(iplist); + iplist = TALLOC(10, struct IN_ADDR, "ifl"); + +#ifdef IMA_LINUX +#ifndef _PATH_PROCNET_IFINET6 +#define _PATH_PROCNET_IFINET6 "/proc/net/if_inet6" +#endif /* _PATH_PROCNET_IFNET6 */ +#else +#error "Don't know where to look for IPv6 interfaces" +#endif + + if ((f = fopen(_PATH_PROCNET_IFINET6, "r")) != NULL) { + while (fscanf(f, "%4s%4s%4s%4s%4s%4s%4s%4s %02x %02x %02x %02x %20s\n", + addr6p[0], addr6p[1], addr6p[2], addr6p[3], + addr6p[4], addr6p[5], addr6p[6], addr6p[7], + &if_idx, &plen, &scope, &dad_status, devname) != EOF) { + sprintf(addr6, "%s:%s:%s:%s:%s:%s:%s:%s", + addr6p[0], addr6p[1], addr6p[2], addr6p[3], + addr6p[4], addr6p[5], addr6p[6], addr6p[7]); + pvmlogprintf(" Got interface IPv6 %s\n",addr6); + inet_pton(AF_INET6, addr6, sap.sin6_addr.s6_addr); + if (nip > 0 && !(nip % 10)) + iplist = TREALLOC(iplist, (nip + 10), struct IN_ADDR); + memcpy(&iplist[nip],&sap.sin6_addr,sizeof(struct IN_ADDR)); + nip++; + + } + fclose(f); + } + else + { + fprintf(stderr, "can't open %s\n",_PATH_PROCNET_IFINET6); + goto bail; + } + + *alp = iplist; + *np = nip; + return 0; + +bail: + return -1; +} +#else #ifdef SIOCGIFCONF int iflist(alp, np) - struct in_addr **alp; /* return list of addresses */ + struct IN_ADDR **alp; /* return list of addresses */ int *np; /* return len of alp */ { int soc = -1; /* socket */ - static struct in_addr *iplist = 0; /* list of interface addrs found */ + static struct IN_ADDR *iplist = 0; /* list of interface addrs found */ int nip = 0; /* length of iplist */ char buf[4096]; /* return space for SIOCGIOCONF */ struct ifconf sif; @@ -956,9 +1017,9 @@ if (iplist) PVM_FREE(iplist); - iplist = TALLOC(10, struct in_addr, "ifl"); + iplist = TALLOC(10, struct IN_ADDR, "ifl"); - if ((soc = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { + if ((soc = socket(PF_FAMILY, SOCK_DGRAM, 0)) == -1) { perror("socket"); goto bail; } @@ -985,7 +1046,7 @@ cp += sizeof(*reqp) - sizeof(struct sockaddr) + SIZ(reqp->ifr_addr)) { reqp = (struct ifreq*)cp; - if (reqp->ifr_addr.sa_family != AF_INET) + if (reqp->ifr_addr.sa_family != AF_FAMILY) continue; BCOPY(reqp->ifr_name, req.ifr_name, sizeof(req.ifr_name)); if (ioctl(soc, SIOCGIFFLAGS, &req) == -1) { @@ -996,13 +1057,13 @@ /* if (IFF_UP & req.ifr_flags) { */ if (IFF_UP & req.ifr_ifru.ifru_flags) { if (nip > 0 && !(nip % 10)) - iplist = TREALLOC(iplist, (nip + 10), struct in_addr); + iplist = TREALLOC(iplist, (nip + 10), struct IN_ADDR); iplist[nip++] = - ((struct sockaddr_in*)(&reqp->ifr_ifru.ifru_addr))->sin_addr; + ((struct SOCKADDR_IN*)(&reqp->ifr_ifru.ifru_addr))->sin_addr; if (pvmdebmask & PDMNET) { long a; - a = ((struct sockaddr_in*)(&reqp->ifr_ifru.ifru_addr))->sin_addr.s_addr; + a = ((struct SOCKADDR_IN*)(&reqp->ifr_ifru.ifru_addr))->sin_addr.s_addr; a = ntohl(a); pvmlogprintf("iflist() %s %d.%d.%d.%d\n", reqp->ifr_name, @@ -1027,10 +1088,10 @@ int iflist(alp, np) - struct in_addr **alp; /* return list of addresses */ + struct IN_ADDR **alp; /* return list of addresses */ int *np; /* return len of alp */ { - static struct in_addr *iplist = 0; /* list of interface addrs found */ + static struct IN_ADDR *iplist = 0; /* list of interface addrs found */ int nip = 0; /* length of iplist */ char hn[MAXHOSTNAMELEN]; struct hostent *he; @@ -1038,20 +1099,20 @@ if (iplist) PVM_FREE(iplist); - iplist = TALLOC(10, struct in_addr, "ifl"); + iplist = TALLOC(10, struct IN_ADDR, "ifl"); if (gethostname(hn, sizeof(hn))) { perror("gethostname"); goto bail; } - if (!(he = gethostbyname(hn))) { - fprintf(stderr, "can't gethostbyname\n"); + if (!(he = GETHOSTBYNAME(hn))) { + fprintf(stderr, "can't GETHOSTBYNAME\n"); goto bail; } for (; he->h_addr_list[nip]; nip++) { if (nip > 0 && !(nip % 10)) - iplist = TREALLOC(iplist, (nip + 10), struct in_addr); - iplist[nip].s_addr = ((struct in_addr*)(he->h_addr_list[nip]))->s_addr; + iplist = TREALLOC(iplist, (nip + 10), struct IN_ADDR); + iplist[nip].s_addr = ((struct IN_ADDR*)(he->h_addr_list[nip]))->s_addr; } *alp = iplist; @@ -1064,6 +1125,7 @@ #endif /*SIOCGIFCONF*/ +#endif /* INET6 */ /* acav() * diff -ruN pvm3.old/src/host.h pvm3/src/host.h --- pvm3.old/src/host.h 2001-09-27 01:35:21.000000000 +0200 +++ pvm3/src/host.h 2005-04-19 19:09:26.000000000 +0200 @@ -71,7 +71,7 @@ * */ - +#include "pvmipv6.h" /* Host descriptor */ struct hostd { @@ -89,7 +89,7 @@ int hd_dsig; /* data signature */ int hd_err; /* error code */ int hd_mtu; /* max snd/rcv length */ - struct sockaddr_in hd_sad; /* UDP address/port */ + struct SOCKADDR_IN hd_sad; /* UDP address/port */ int hd_rxseq; /* expected next seq num from host */ int hd_txseq; /* next tx seq num to host */ struct pkt *hd_txq; /* not-yet-sent packet queue to host */ diff -ruN pvm3.old/src/lpvm.c pvm3/src/lpvm.c --- pvm3.old/src/lpvm.c 2001-09-25 23:20:17.000000000 +0200 +++ pvm3/src/lpvm.c 2005-04-22 19:32:28.288700136 +0200 @@ -633,7 +633,7 @@ ***************/ char *getenv(); -void hex_inadport __ProtoGlarp__ (( char *, struct sockaddr_in * )); +void hex_inadport __ProtoGlarp__ (( char *, struct SOCKADDR_IN * )); extern char *inadport_decimal(); extern char *inadport_hex(); @@ -660,7 +660,7 @@ ***************/ static int mxfersingle = 1; /* mxfer returns after single frag */ -static struct sockaddr_in pvmourinet; /* our host ip addr */ +static struct SOCKADDR_IN pvmourinet; /* our host ip addr */ static struct ttpcb *ttlist = 0; /* dll of connected tasks */ static struct ttpcb *topvmd = 0; /* default route (to pvmd) */ static int pvmnfds = 0; /* 1 + highest bit set in fds */ @@ -1229,7 +1229,7 @@ #endif /*NOUNIXDOM*/ } else { - if ((pcbp->tt_fd = socket(AF_INET, SOCK_STREAM, 0)) + if ((pcbp->tt_fd = socket(PF_FAMILY, SOCK_STREAM, 0)) == -1) { pvmlogperror("pvm_tc_conreq() socket"); @@ -1390,7 +1390,7 @@ #endif /*NOUNIXDOM*/ } else { - pcbp->tt_osad.sin_family = AF_INET; + FAMILY_FROM_SA(pcbp->tt_osad) = AF_FAMILY; hex_inadport(buf, &pcbp->tt_osad); while ((i = connect(pcbp->tt_fd, (struct sockaddr*)&pcbp->tt_osad, @@ -1765,7 +1765,7 @@ #endif char *txcp = 0; /* point to remainder of txfp */ int txtogo = 0; /* len of remainder of txfp */ - struct sockaddr_in sad; + struct SOCKADDR_IN sad; int s; struct ttpcb *pcbp; char *inPlaceHeader = (char *) NULL; /* for inplace data */ @@ -2318,7 +2318,7 @@ int s; /* socket */ int sbf; /* temp TC_CONREQ message */ struct pmsg *up, *up2; - struct sockaddr_in sad; + struct SOCKADDR_IN sad; int l; #ifdef SOCKLENISUINT #ifdef IMA_AIX4SP2 @@ -2426,7 +2426,7 @@ #endif /* !NOUNIXDOM */ /* Open a TCP direct Connection here, instead */ - if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1) { + if ((s = socket(PF_FAMILY, SOCK_STREAM, 0)) == -1) { pvmlogperror("mroute() socket"); } else { @@ -2852,7 +2852,7 @@ #endif /*NOUNIXDOM*/ } else { - if ((topvmd->tt_fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { + if ((topvmd->tt_fd = socket(PF_FAMILY, SOCK_STREAM, 0)) == -1) { pvmlogperror("mksocs() socket"); goto bail; } @@ -2860,7 +2860,7 @@ try = 5; while (1) { /* goto is at the root of all good programming style */ hex_inadport(p, &topvmd->tt_osad); - topvmd->tt_osad.sin_family = AF_INET; + FAMILY_FROM_SA(topvmd->tt_osad) = AF_FAMILY; n = sizeof(topvmd->tt_osad); if (connect(topvmd->tt_fd, (struct sockaddr*)&topvmd->tt_osad, n) @@ -2948,7 +2948,11 @@ char authfn[PVMTMPNAMLEN]; /* auth file name */ int authfd = -1; /* auth fd to validate pvmd ident */ int i; +#ifdef INET6 + char buf[INET6_ADDRSTRLEN+2+20]; /* for converting sockaddr */ +#else char buf[16]; /* for converting sockaddr */ +#endif char *p; struct pvmminfo minfo; int outtid, outctx, outtag; @@ -3249,23 +3253,23 @@ hex_inadport(buf, &pvmourinet); } else { /* got name, now get addr */ - if (!(hostaddr = gethostbyname( namebuf ))) { - pvmlogprintf( "pvmbeatask() can't gethostbyname() for %s\n", + if (!(hostaddr = GETHOSTBYNAME( namebuf ))) { + pvmlogprintf( "pvmbeatask() can't GETHOSTBYNAME() for %s\n", namebuf ); hex_inadport(buf, &pvmourinet); } else { /* got addr, now save it */ BCOPY( hostaddr->h_addr_list[0], (char*)&pvmourinet.sin_addr, - sizeof(struct in_addr)); + sizeof(struct IN_ADDR)); } } #else hex_inadport(buf, &pvmourinet); #endif - pvmourinet.sin_family = AF_INET; - pvmourinet.sin_port = 0; + FAMILY_FROM_SA(pvmourinet) = AF_FAMILY; + PORT_FROM_SA(pvmourinet) = 0; pvm_upkint(&pvmschedtid, 1, 1); #endif diff -ruN pvm3.old/src/lpvm.h pvm3/src/lpvm.h --- pvm3.old/src/lpvm.h 2000-02-16 23:00:59.000000000 +0100 +++ pvm3/src/lpvm.h 2005-04-19 19:09:26.000000000 +0200 @@ -107,6 +107,8 @@ #endif extern int pvmautoerr; /* whether to auto print err msgs */ +#include "pvmipv6.h" + extern struct Pvmtracer pvmctrc; /* child tracer info */ extern struct Pvmtracer pvmtrc; /* task tracer info */ @@ -190,8 +192,8 @@ int tt_tid; /* tid of peer or 0 if master of list */ int tt_state; int tt_fd; /* fd of connection or -1 */ - struct sockaddr_in tt_sad; /* address of our socket */ - struct sockaddr_in tt_osad; /* (authd) address of peer socket */ + struct SOCKADDR_IN tt_sad; /* address of our socket */ + struct SOCKADDR_IN tt_osad; /* (authd) address of peer socket */ struct pmsg *tt_rxfrag; /* not-assembled incm msg */ struct frag *tt_rxf; /* partial incm frag */ #ifndef NOUNIXDOM diff -ruN pvm3.old/src/lpvmmimd.c pvm3/src/lpvmmimd.c --- pvm3.old/src/lpvmmimd.c 2001-05-11 19:32:28.000000000 +0200 +++ pvm3/src/lpvmmimd.c 2005-04-19 19:09:26.000000000 +0200 @@ -287,7 +287,7 @@ #endif char *getenv(); -void hex_inadport __ProtoGlarp__ (( char *, struct sockaddr_in * )); +void hex_inadport __ProtoGlarp__ (( char *, struct SOCKADDR_IN * )); extern struct encvec *enctovec(); @@ -1216,7 +1216,7 @@ { char *p; int dsock; /* pvmd socket */ - struct sockaddr_in dsadr; /* address of pvmd socket */ + struct SOCKADDR_IN dsadr; /* address of pvmd socket */ int n; int pvminfo[SIZEHINFO]; /* ntask, hostpart, ptid, MTU, NDF */ char nullmsg[TDFRAGHDR+TTMSGHDR]; @@ -1227,14 +1227,14 @@ exit(2); } mpierrcode = 0; - if ((dsock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { + if ((dsock = socket(PF_FAMILY, SOCK_STREAM, 0)) == -1) { pvmlogperror("pvmhost() socket"); MPI_Finalize(); exit(3); } BZERO((char*)&dsadr, sizeof(dsadr)); hex_inadport(p, &dsadr); - dsadr.sin_family = AF_INET; + dsadr.sin_family = AF_FAMILY; n = sizeof(dsadr); while (connect(dsock, (struct sockaddr*)&dsadr, n) == -1) if (errno != EINTR) { diff -ruN pvm3.old/src/lpvmshmem.c pvm3/src/lpvmshmem.c --- pvm3.old/src/lpvmshmem.c 2001-09-25 23:21:00.000000000 +0200 +++ pvm3/src/lpvmshmem.c 2005-04-19 19:09:26.000000000 +0200 @@ -493,7 +493,7 @@ char *getenv(); -void hex_inadport __ProtoGlarp__ (( char *, struct sockaddr_in * )); +void hex_inadport __ProtoGlarp__ (( char *, struct SOCKADDR_IN * )); /* These prototypes stop compiler casting structs to ints... */ struct pmsg *midtobuf(); /* Oops someone forgot this one KEV/GEF */ @@ -574,7 +574,7 @@ static int pvminboxsz = 0; /* size of incoming message buffer */ static int mypidtid = -1; /* my position in pid-tid table */ static int pvmdpid = 0; /* pvmd's Unix proc ID */ -static struct sockaddr_in pvmdsad; /* address of pvmd socket */ +static struct SOCKADDR_IN pvmdsad; /* address of pvmd socket */ static int pvmdsock = -1; /* pvmd socket descriptor */ static void (*pvmoldtermhdlr)() = 0; @@ -628,7 +628,7 @@ } hex_inadport(p, &pvmdsad); - pvmdsad.sin_family = AF_INET; + pvmdsad.sin_family = AF_FAMILY; } @@ -644,7 +644,7 @@ static char dummy[TDFRAGHDR]; if (pvmdsock == -1) { - if ((pvmdsock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { + if ((pvmdsock = socket(PF_FAMILY, SOCK_STREAM, 0)) == -1) { pvmlogperror("prodpvmd() socket"); return; } @@ -2688,7 +2688,7 @@ char *txcp = 0; /* point to remainder of txfp */ int txtogo = 0; /* len of remainder of txfp */ - struct sockaddr_in sad; + struct SOCKADDR_IN sad; int s; struct msgid *sendmsg = (struct msgid *) NULL; char errtxt[64]; diff -ruN pvm3.old/src/mppmsg.c pvm3/src/mppmsg.c --- pvm3.old/src/mppmsg.c 2000-02-17 00:30:02.000000000 +0100 +++ pvm3/src/mppmsg.c 2005-04-19 19:09:26.000000000 +0200 @@ -63,7 +63,7 @@ /* --- external declarations */ -void hex_inadport __ProtoGlarp__ (( char *, struct sockaddr_in * )); +void hex_inadport __ProtoGlarp__ (( char *, struct SOCKADDR_IN * )); extern int errno; extern int pvmdebmask; /* from pvmd.c */ @@ -829,7 +829,7 @@ { char *p; int dsock; /* pvmd socket */ - struct sockaddr_in dsadr; /* address of pvmd socket */ + struct SOCKADDR_IN dsadr; /* address of pvmd socket */ int n; int i; int cc; @@ -850,14 +850,14 @@ pvm_mpp_message_stop(); exit(2); } - if ((dsock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { + if ((dsock = socket(PF_FAMILY, SOCK_STREAM, 0)) == -1) { pvmlogperror("pvmhost() socket"); pvm_mpp_message_stop(); exit(3); } BZERO((char*)&dsadr, sizeof(dsadr)); hex_inadport(p, &dsadr); - dsadr.sin_family = AF_INET; + dsadr.sin_family = AF_FAMILY; n = sizeof(dsadr); while (connect(dsock, (struct sockaddr*)&dsadr, n) == -1) if (errno != EINTR) { diff -ruN pvm3.old/src/OS2/src/rexec.c pvm3/src/OS2/src/rexec.c --- pvm3.old/src/OS2/src/rexec.c 1997-08-28 23:30:49.000000000 +0200 +++ pvm3/src/OS2/src/rexec.c 2005-04-19 19:09:26.000000000 +0200 @@ -55,12 +55,12 @@ int *fd2p; { int s, timo = 1, s3; - struct sockaddr_in sin, sin2, from; + struct SOCKADDR_IN sin, sin2, from; char c; u_short port; struct hostent *hp; static char savename[256]; - hp = gethostbyname(*ahost); + hp = GETHOSTBYNAME(*ahost); if (hp == 0) { fprintf(stderr, "%s: unknown host\n", *ahost); return (-1); @@ -72,7 +72,7 @@ ruserpass(*ahost, &name, &pass); /* stdlog("rexec: %s %s %s %s\n",*ahost,name,pass,cmd); */ retry: - s = socket(AF_INET, SOCK_STREAM, 0); + s = socket(PF_FAMILY, SOCK_STREAM, 0); if (s < 0) { perror("rexec: socket"); return (-1); @@ -94,7 +94,7 @@ char num[8]; int s2, sin2len; - s2 = socket(AF_INET, SOCK_STREAM, 0); + s2 = socket(PF_FAMILY, SOCK_STREAM, 0); if (s2 < 0) { (void) close(s); return (-1); diff -ruN pvm3.old/src/OS2/src/ruserpas.c pvm3/src/OS2/src/ruserpas.c --- pvm3.old/src/OS2/src/ruserpas.c 1997-08-28 23:30:50.000000000 +0200 +++ pvm3/src/OS2/src/ruserpas.c 2005-04-19 19:09:26.000000000 +0200 @@ -48,11 +48,11 @@ strncpy(name, host, sizeof(name) - 1); - if (hp = gethostbyname (name)) + if (hp = GETHOSTBYNAME (name)) strncpy(name,hp->h_name, sizeof(name) - 1); renv(name, aname, apass); if (*aname == 0 || *apass == 0) - rnetrc(name,aname,apass); /*rnetrc would call gethostbyname */ + rnetrc(name,aname,apass); /*rnetrc would call GETHOSTBYNAME */ if (*aname == 0) { *aname = getlogin(); if (*aname == NULL) { @@ -191,7 +191,7 @@ case MACHINE: if (token() != ID) continue; - if(hp = gethostbyname (tokval)) + if(hp = GETHOSTBYNAME (tokval)) { if (strcmp(host, hp->h_name)) continue; diff -ruN pvm3.old/src/pvmcruft.c pvm3/src/pvmcruft.c --- pvm3.old/src/pvmcruft.c 2001-09-27 23:25:10.000000000 +0200 +++ pvm3/src/pvmcruft.c 2005-04-22 18:52:59.847757888 +0200 @@ -661,17 +661,40 @@ /* hex_inadport() * * Takes a string of format 00000000:0000 and returns a sockaddr_in. +* Alternatively, takes a string of format [2a03:800:40ec::10]:8a43 and returns a SOCKADDR_IN */ void hex_inadport(s, sad) char *s; - struct sockaddr_in *sad; + struct SOCKADDR_IN *sad; { +#ifdef INET6 + char hostname[INET6_ADDRSTRLEN]; + char *aux; + strncpy(hostname,s+1,INET6_ADDRSTRLEN); // Shift the initial '[' + aux = strchr(hostname,']'); + *aux = '\0'; // Drop the final ']' + s = (s = CINDEX(s, ']')) ? s + 2 : ""; // Get the port beyond ']:' + FAMILY_FROM_SA(*sad)=AF_FAMILY; + inet_pton(AF_FAMILY,hostname,&ADDR_FROM_SA(*sad)); + PORT_FROM_SA(*sad) = htons((unsigned short)pvmxtoi(s)); +#else sad->sin_addr.s_addr = htonl((unsigned)pvmxtoi(s)); s = (s = CINDEX(s, ':')) ? s + 1 : ""; sad->sin_port = htons((unsigned short)pvmxtoi(s)); +#endif +} + + +#ifdef INET6 +const char * inet6_ntoa(const struct in6_addr in) +{ + static char buff[INET6_ADDRSTRLEN]; + + return (const char *)inet_ntop(AF_INET6, &in, buff, INET6_ADDRSTRLEN); } +#endif /* inadport_decimal() @@ -681,11 +704,14 @@ char * inadport_decimal(sad) - struct sockaddr_in *sad; + struct SOCKADDR_IN *sad; { +#ifdef INET6 + static char buf[INET6_ADDRSTRLEN+2+20]; + sprintf(buf, "[%s]:%d",SA_NTOA(*sad),(int)ntohs(PORT_FROM_SA(*sad))); +#else static char buf[32]; int a; - a = ntohl(0xffffffff & sad->sin_addr.s_addr); sprintf(buf, "%d.%d.%d.%d:%d", 0xff & (a >> 24), @@ -693,6 +719,7 @@ 0xff & (a >> 8), 0xff & a, 0xffff & (int)ntohs(sad->sin_port)); +#endif return buf; } @@ -702,15 +729,21 @@ * Returns printable string corr. to sockaddr_in with addr in hex. */ + char * inadport_hex(sad) - struct sockaddr_in *sad; + struct SOCKADDR_IN *sad; { +#ifdef INET6 + static char buf[INET6_ADDRSTRLEN+2+20]; + sprintf(buf, "[%s]:%04x", SA_NTOA(*sad), 0xffff & ntohs(PORT_FROM_SA(*sad))); +#else static char buf[16]; int a; a = ntohl(0xffffffff & sad->sin_addr.s_addr); sprintf(buf, "%08x:%04x", a, 0xffff & (int)ntohs(sad->sin_port)); +#endif return buf; } diff -ruN pvm3.old/src/pvmd.c pvm3/src/pvmd.c --- pvm3.old/src/pvmd.c 2001-09-28 14:43:18.000000000 +0200 +++ pvm3/src/pvmd.c 2005-04-19 19:09:26.000000000 +0200 @@ -675,6 +675,8 @@ #include #include "global.h" +#include "pvmipv6.h" + #ifdef IMA_CRAY #define MAXPATHLEN PATH_MAX+1 #endif @@ -730,7 +732,7 @@ char *pvmgetroot(); void reap(); void i_dump(); -void hex_inadport __ProtoGlarp__ (( char *, struct sockaddr_in * )); +void hex_inadport __ProtoGlarp__ (( char *, struct SOCKADDR_IN * )); void mesg_rewind __ProtoGlarp__ (( struct pmsg * )); void locl_spawn(); /* void make_valid(char *n); sls */ @@ -1706,7 +1708,7 @@ #else int oslen; #endif - struct sockaddr_in osad; + struct SOCKADDR_IN osad; struct timeval t; char buf[DDFRAGHDR]; @@ -2292,7 +2294,7 @@ int netinput() { - struct sockaddr_in osad; /* sender's ip addr */ + struct SOCKADDR_IN osad; /* sender's ip addr */ #ifdef SOCKLENISUINT #ifdef IMA_AIX4SP2 unsigned int oslen; @@ -2381,8 +2383,8 @@ * XXX removing these lines is a hack and reduces security between * XXX pvmds somewhat, but it's the easiest fix for Linux right now. */ - || (osad.sin_addr.s_addr != hp->hd_sad.sin_addr.s_addr) - || (osad.sin_port != hp->hd_sad.sin_port) + || (!ADDR_EQUALS(ADDR_FROM_SA(osad),ADDR_FROM_SA(hp->hd_sad))) + || (PORT_FROM_SA(osad) != PORT_FROM_SA(hp->hd_sad)) /* #endif */ ) { pvmlogprintf("netinput() bogus pkt from %s\n", @@ -4702,7 +4704,7 @@ { struct hostd *hp = hosts->ht_hosts[hosts->ht_local]; struct hostd *hp0 = hosts->ht_hosts[0]; - struct sockaddr_in sin; + struct SOCKADDR_IN sin; char buf[128]; char *sfn; #ifndef WIN32 @@ -4737,12 +4739,12 @@ * make pvmd-pvmd socket */ - if ((netsock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { + if ((netsock = socket(PF_FAMILY, SOCK_DGRAM, 0)) == -1) { pvmlogperror("mksocs() socket netsock"); return 1; } - hp->hd_sad.sin_port = 0; + PORT_FROM_SA(hp->hd_sad) = 0; oslen = sizeof(hp->hd_sad); if (bind(netsock, (struct sockaddr*)&hp->hd_sad, oslen) == -1) { @@ -4759,12 +4761,12 @@ * make pvmd-pvmd' socket */ - if ((ppnetsock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { + if ((ppnetsock = socket(PF_FAMILY, SOCK_DGRAM, 0)) == -1) { pvmlogperror("mksocs() socket ppnetsock"); return 1; } - hp0->hd_sad.sin_port = 0; + PORT_FROM_SA(hp0->hd_sad) = 0; oslen = sizeof(hp0->hd_sad); if (bind(ppnetsock, (struct sockaddr*)&hp0->hd_sad, oslen) == -1) { pvmlogperror("mksocs() bind ppnetsock"); @@ -4781,7 +4783,7 @@ */ #ifdef NOUNIXDOM - if ((loclsock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { + if ((loclsock = socket(PF_FAMILY, SOCK_STREAM, 0)) == -1) { pvmlogperror("mksocs() socket loclsock"); return 1; } @@ -4798,24 +4800,24 @@ #ifdef IMA_BEOLIN /* allow connection from another node */ - sin.sin_family = AF_INET; + sin.sin_family = AF_FAMILY; if (gethostname(buf, sizeof(buf)-1) == -1) { pvmlogerror("mksocs() can't gethostname()\n"); return 1; } else { /* got name, now get addr */ - if (!(hostaddr = gethostbyname( buf ))) { - pvmlogprintf( "mksocs() can't gethostbyname() for %s\n", buf ); + if (!(hostaddr = GETHOSTBYNAME( buf ))) { + pvmlogprintf( "mksocs() can't GETHOSTBYNAME() for %s\n", buf ); return 1; } else { /* got addr, now save it */ BCOPY( hostaddr->h_addr_list[0], (char*)&sin.sin_addr, - sizeof(struct in_addr)); + sizeof(struct IN_ADDR)); } } sin.sin_port = 0; #else - sin.sin_family = AF_INET; + sin.sin_family = AF_FAMILY; sin.sin_addr.s_addr = htonl(0x7f000001); sin.sin_port = 0; #endif @@ -5229,17 +5231,17 @@ pvmlogperror(s); PVM_FREE(s); - if (!(he = gethostbyname(hp->hd_aname ? hp->hd_aname : hp->hd_name))) { - pvmlogprintf("master_config() %s: can't gethostbyname\n", hn); + if (!(he = GETHOSTBYNAME(hp->hd_aname ? hp->hd_aname : hp->hd_name))) { + pvmlogprintf("master_config() %s: can't GETHOSTBYNAME\n", hn); pvmbailout(0); } - BCOPY(he->h_addr_list[0], (char*)&hp->hd_sad.sin_addr, - sizeof(struct in_addr)); + BCOPY(he->h_addr_list[0], (char*)&ADDR_FROM_SA(hp->hd_sad), + sizeof(struct IN_ADDR)); hp = hosts->ht_hosts[0]; - BCOPY(he->h_addr_list[0], (char*)&hp->hd_sad.sin_addr, - sizeof(struct in_addr)); + BCOPY(he->h_addr_list[0], (char*)&ADDR_FROM_SA(hp->hd_sad), + sizeof(struct IN_ADDR)); if (pvmdebmask & (PDMHOST|PDMSTARTUP)) { pvmlogerror("master_config() host table:\n"); diff -ruN pvm3.old/src/pvmipv6.h pvm3/src/pvmipv6.h --- pvm3.old/src/pvmipv6.h 1970-01-01 01:00:00.000000000 +0100 +++ pvm3/src/pvmipv6.h 2005-04-19 19:09:26.000000000 +0200 @@ -0,0 +1,48 @@ + +#ifndef __pvmipv6_ +#define __pvmipv6_ + +#ifdef INET6 +#define IN_ADDR in6_addr +#define SOCKADDR_IN sockaddr_in6 +#define MAXIPSTRLEN INET6_ADDRSTRLEN /* 46 */ +#define PF_FAMILY PF_INET6 +#define AF_FAMILY AF_INET6 +#define ADDR_IS_LOOPBACK(s) \ + (memcmp(&(s), &in6addr_loopback, sizeof(&in6addr_loopback)) == 0) +#define SA_NTOA(s) \ + inet6_ntoa((s).sin6_addr) +#define ADDR_FROM_SA(s) \ + ((s).sin6_addr) +#define PORT_FROM_SA(s) \ + ((s).sin6_port) +#define FAMILY_FROM_SA(s) \ + ((s).sin6_family) +#define ADDR_EQUALS(s1,s2) \ + (memcmp(&(s1), &(s2), sizeof(struct IN_ADDR)) == 0) +#define GETHOSTBYNAME(name) \ + gethostbyname2(name, AF_INET6) + + +#else +#define IN_ADDR in_addr +#define SOCKADDR_IN sockaddr_in +#define MAXIPSTRLEN INET_ADDRSTRLEN /* 16 */ +#define PF_FAMILY PF_INET +#define AF_FAMILY AF_INET +#define ADDR_IS_LOOPBACK(s) \ + ((s).s_addr == htonl(0x7f000001)) +#define SA_NTOA(s) \ + inet_ntoa((s).sin_addr) +#define ADDR_FROM_SA(s) \ + ((s).sin_addr) +#define PORT_FROM_SA(s) \ + ((s).sin_port) +#define FAMILY_FROM_SA(s) \ + ((s).sin_family) +#define ADDR_EQUALS(s1,s2) \ + (memcmp(&(s1), &(s2), sizeof(struct IN_ADDR)) == 0) +#define GETHOSTBYNAME(name) \ + gethostbyname(name) +#endif +#endif /* not defined __pvmipv6_ */ diff -ruN pvm3.old/src/SP2MPI/pvmdmimd.c pvm3/src/SP2MPI/pvmdmimd.c --- pvm3.old/src/SP2MPI/pvmdmimd.c 2001-09-25 23:19:28.000000000 +0200 +++ pvm3/src/SP2MPI/pvmdmimd.c 2005-04-19 19:09:26.000000000 +0200 @@ -839,13 +839,13 @@ mksock() { struct hostd *hp = hosts->ht_hosts[hosts->ht_local]; - struct sockaddr_in sin; + struct SOCKADDR_IN sin; char buf[128]; char *p; int cc; int sock; - if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { + if ((sock = socket(PF_FAMILY, SOCK_STREAM, 0)) == -1) { pvmlogperror("mksock() socket"); return -1; } diff -ruN pvm3.old/src/task.h pvm3/src/task.h --- pvm3.old/src/task.h 2000-06-16 18:27:33.000000000 +0200 +++ pvm3/src/task.h 2005-04-19 19:09:26.000000000 +0200 @@ -106,6 +106,7 @@ * */ +#include "pvmipv6.h" /* descriptor for a pvm task */ @@ -122,7 +123,7 @@ int t_flag; /* status */ int t_pid; /* unix pid */ int t_sock; /* t-d tcp socket */ - struct sockaddr_in t_sad; /* addr of sock */ + struct SOCKADDR_IN t_sad; /* addr of sock */ int t_salen; /* addr length */ struct waitc *t_wait; /* wait channel */ struct pkt *t_txq; /* to task */