This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
lib/io_udp.t fails on VMS
authorJonathan Hudson <Jonathan.Hudson@jrhudson.demon.co.uk>
Thu, 22 May 1997 05:56:26 +0000 (17:56 +1200)
committerTim Bunce <Tim.Bunce@ig.co.uk>
Wed, 11 Jun 1997 00:00:00 +0000 (12:00 +1200)
perl 5.004 built without error or warning on VMS AXP/DECC with DECCRTL
(UCX) sockets (no sockshr library). However it fails the
lib/io_udp.t test for the following reasons:

1. The 'fromlen' parameter in pp_sysread *must* be sizeof(struct
   sockaddr) or the DECCRTL fails with an invalid buffer size error.

2. The DECCRTL/UCX getpeerhost() function returns defined and a blank
   'sockaddr' for udp hosts. A similar fix to that in vms/sockadapt.h
   (for sockshr) is required for DECCRTL in pp_sys.c

The following diff (unix, sorry VMS folks) patches pp_sys.c so that
the udp test is successful using UCX.

p5p-msgid: XFMail.970522181042.Jonathan.Hudson@jrhudson.demon.co.uk

pp_sys.c

index 03a10fe..5e1f427 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1243,7 +1243,11 @@ PP(pp_sysread)
 #ifdef HAS_SOCKET
     if (op->op_type == OP_RECV) {
        char namebuf[MAXPATHLEN];
 #ifdef HAS_SOCKET
     if (op->op_type == OP_RECV) {
        char namebuf[MAXPATHLEN];
+#if defined(VMS_DO_SOCKETS) && defined(DECCRTL_SOCKETS)
+       bufsize = sizeof (struct sockaddr_in);
+#else
        bufsize = sizeof namebuf;
        bufsize = sizeof namebuf;
+#endif
        buffer = SvGROW(bufsv, length+1);
        /* 'offset' means 'flags' here */
        length = recvfrom(PerlIO_fileno(IoIFP(io)), buffer, length, offset,
        buffer = SvGROW(bufsv, length+1);
        /* 'offset' means 'flags' here */
        length = recvfrom(PerlIO_fileno(IoIFP(io)), buffer, length, offset,
@@ -1283,7 +1287,11 @@ PP(pp_sysread)
 #ifdef HAS_SOCKET__bad_code_maybe
     if (IoTYPE(io) == 's') {
        char namebuf[MAXPATHLEN];
 #ifdef HAS_SOCKET__bad_code_maybe
     if (IoTYPE(io) == 's') {
        char namebuf[MAXPATHLEN];
+#if defined(VMS_DO_SOCKETS) && defined(DECCRTL_SOCKETS)
+       bufsize = sizeof (struct sockaddr_in);
+#else
        bufsize = sizeof namebuf;
        bufsize = sizeof namebuf;
+#endif
        length = recvfrom(PerlIO_fileno(IoIFP(io)), buffer+offset, length, 0,
                          (struct sockaddr *)namebuf, &bufsize);
     }
        length = recvfrom(PerlIO_fileno(IoIFP(io)), buffer+offset, length, 0,
                          (struct sockaddr *)namebuf, &bufsize);
     }
@@ -1368,6 +1376,7 @@ PP(pp_send)
     }
     else
        length = send(PerlIO_fileno(IoIFP(io)), buffer, blen, length);
     }
     else
        length = send(PerlIO_fileno(IoIFP(io)), buffer, blen, length);
+
 #else
     else
        DIE(no_sock_func, "send");
 #else
     else
        DIE(no_sock_func, "send");
@@ -1986,6 +1995,17 @@ PP(pp_getpeername)
     case OP_GETPEERNAME:
        if (getpeername(fd, (struct sockaddr *)SvPVX(sv), &len) < 0)
            goto nuts2;
     case OP_GETPEERNAME:
        if (getpeername(fd, (struct sockaddr *)SvPVX(sv), &len) < 0)
            goto nuts2;
+#if defined(VMS_DO_SOCKETS) && defined (DECCRTL_SOCKETS)
+       {
+           static const char nowhere[] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
+           /* If the call succeeded, make sure we don't have a zeroed port/addr */
+           if (((struct sockaddr *)SvPVX(sv))->sa_family == AF_INET &&
+               !memcmp((char *)SvPVX(sv) + sizeof(u_short), nowhere,
+                       sizeof(u_short) + sizeof(struct in_addr))) {
+               goto nuts2;         
+           }
+       }
+#endif
        break;
     }
 #ifdef BOGUS_GETNAME_RETURN
        break;
     }
 #ifdef BOGUS_GETNAME_RETURN