This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[inseparable changes from match from perl-5.003_97h to perl-5.003_97i]
[perl5.git] / vms / sockadapt.c
CommitLineData
a0d0e21e
LW
1/* sockadapt.c
2 *
3 * Author: Charles Bailey bailey@genetics.upenn.edu
9607fc9c 4 * Last Revised: 4-Mar-1997
a0d0e21e
LW
5 *
6 * This file should contain stubs for any of the TCP/IP functions perl5
7 * requires which are not supported by your TCP/IP stack. These stubs
8 * can attempt to emulate the routine in question, or can just return
9 * an error status or cause perl to die.
10 *
9607fc9c 11 * This version is set up for perl5 with UCX (or emulation) via
12 * the DECCRTL or SOCKETSHR 0.9D.
a0d0e21e
LW
13 */
14
4633a7c4
LW
15#include "EXTERN.h"
16#include "perl.h"
9607fc9c 17
c07a80fd 18#if defined(__DECC) && defined(__DECC_VER) && (__DECC_VER >= 50200000)
9607fc9c 19# define __sockadapt_my_hostent_t __struct_hostent_ptr32
c07a80fd 20# define __sockadapt_my_netent_t __struct_netent_ptr32
9607fc9c 21# define __sockadapt_my_servent_t __struct_servent_ptr32
c07a80fd 22# define __sockadapt_my_addr_t __in_addr_t
23# define __sockadapt_my_name_t const char *
24#else
9607fc9c 25# define __sockadapt_my_hostent_t struct hostent *
c07a80fd 26# define __sockadapt_my_netent_t struct netent *
9607fc9c 27# define __sockadapt_my_servent_t struct servent *
c07a80fd 28# define __sockadapt_my_addr_t long
29# define __sockadapt_my_name_t char *
30#endif
a0d0e21e 31
9607fc9c 32void setnetent(int stayopen) {
33 croak("Function \"setnetent\" not implemented in this version of perl");
34}
35void endnetent() {
36 croak("Function \"endnetent\" not implemented in this version of perl");
37}
38
39#if defined(DECCRTL_SOCKETS)
40 /* Use builtin socket interface in DECCRTL and
41 * UCX emulation in whatever TCP/IP stack is present.
42 */
43
44 void sethostent(int stayopen) {
45 croak("Function \"sethostent\" not implemented in this version of perl");
46 }
47 void endhostent() {
48 croak("Function \"endhostent\" not implemented in this version of perl");
49 }
50 void setprotoent(int stayopen) {
51 croak("Function \"setprotoent\" not implemented in this version of perl");
52 }
53 void endprotoent() {
54 croak("Function \"endprotoent\" not implemented in this version of perl");
55 }
56 void setservent(int stayopen) {
57 croak("Function \"setservent\" not implemented in this version of perl");
58 }
59 void endservent() {
60 croak("Function \"endservent\" not implemented in this version of perl");
61 }
62 __sockadapt_my_hostent_t gethostent() {
63 croak("Function \"gethostent\" not implemented in this version of perl");
64 return (__sockadapt_my_hostent_t )NULL; /* Avoid MISSINGRETURN warning, not reached */
65 }
66 __sockadapt_my_servent_t getservent() {
67 croak("Function \"getservent\" not implemented in this version of perl");
68 return (__sockadapt_my_servent_t )NULL; /* Avoid MISSINGRETURN warning, not reached */
69 }
70
71#else
72 /* Work around things missing/broken in SOCKETSHR. */
73
c07a80fd 74__sockadapt_my_netent_t getnetbyaddr( __sockadapt_my_addr_t net, int type) {
4633a7c4
LW
75 croak("Function \"getnetbyaddr\" not implemented in this version of perl");
76 return (struct netent *)NULL; /* Avoid MISSINGRETURN warning, not reached */
77}
c07a80fd 78__sockadapt_my_netent_t getnetbyname( __sockadapt_my_name_t name) {
4633a7c4
LW
79 croak("Function \"getnetbyname\" not implemented in this version of perl");
80 return (struct netent *)NULL; /* Avoid MISSINGRETURN warning, not reached */
81}
c07a80fd 82__sockadapt_my_netent_t getnetent() {
4633a7c4 83 croak("Function \"getnetent\" not implemented in this version of perl");
9607fc9c 84 return (__sockadapt_my_netent_t )NULL; /* Avoid MISSINGRETURN warning, not reached */
c07a80fd 85}
42084d09 86
87/* Some TCP/IP implementations seem to return success, when getpeername()
88 * is called on a UDP socket, but the port and in_addr are all zeroes.
89 */
90
91int my_getpeername(int sock, struct sockaddr *addr, int *addrlen) {
92 static 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";
93 int rslt;
94
95 rslt = si_getpeername(sock, addr, addrlen);
96
97 /* Just pass an error back up the line */
98 if (rslt) return rslt;
99
100 /* If the call succeeded, make sure we don't have a zeroed port/addr */
101 if (addr->sa_family == AF_INET &&
102 !memcmp((char *)addr + sizeof(u_short), nowhere,
103 sizeof(u_short) + sizeof(struct in_addr))) {
104 rslt = -1;
105 SETERRNO(ENOTCONN,SS$_CLEARED);
106 }
107 return rslt;
108}
9607fc9c 109#endif /* SOCKETSHR stuff */