Commit | Line | Data |
a0d0e21e |
1 | /* sockadapt.c |
2 | * |
3 | * Author: Charles Bailey bailey@genetics.upenn.edu |
c07a80fd |
4 | * Last Revised: 29-Jan-1996 |
a0d0e21e |
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 | * |
748a9306 |
11 | * This version is set up for perl5 with socketshr 0.9D TCP/IP support. |
a0d0e21e |
12 | */ |
13 | |
4633a7c4 |
14 | #include "EXTERN.h" |
15 | #include "perl.h" |
c07a80fd |
16 | #if defined(__DECC) && defined(__DECC_VER) && (__DECC_VER >= 50200000) |
17 | # define __sockadapt_my_netent_t __struct_netent_ptr32 |
18 | # define __sockadapt_my_addr_t __in_addr_t |
19 | # define __sockadapt_my_name_t const char * |
20 | #else |
21 | # define __sockadapt_my_netent_t struct netent * |
22 | # define __sockadapt_my_addr_t long |
23 | # define __sockadapt_my_name_t char * |
24 | #endif |
a0d0e21e |
25 | |
c07a80fd |
26 | __sockadapt_my_netent_t getnetbyaddr( __sockadapt_my_addr_t net, int type) { |
4633a7c4 |
27 | croak("Function \"getnetbyaddr\" not implemented in this version of perl"); |
28 | return (struct netent *)NULL; /* Avoid MISSINGRETURN warning, not reached */ |
29 | } |
c07a80fd |
30 | __sockadapt_my_netent_t getnetbyname( __sockadapt_my_name_t name) { |
4633a7c4 |
31 | croak("Function \"getnetbyname\" not implemented in this version of perl"); |
32 | return (struct netent *)NULL; /* Avoid MISSINGRETURN warning, not reached */ |
33 | } |
c07a80fd |
34 | __sockadapt_my_netent_t getnetent() { |
4633a7c4 |
35 | croak("Function \"getnetent\" not implemented in this version of perl"); |
36 | return (struct netent *)NULL; /* Avoid MISSINGRETURN warning, not reached */ |
37 | } |
38 | void setnetent() { |
39 | croak("Function \"setnetent\" not implemented in this version of perl"); |
40 | } |
c07a80fd |
41 | void endnetent() { |
42 | croak("Function \"endnetent\" not implemented in this version of perl"); |
43 | } |
42084d09 |
44 | |
45 | /* Some TCP/IP implementations seem to return success, when getpeername() |
46 | * is called on a UDP socket, but the port and in_addr are all zeroes. |
47 | */ |
48 | |
49 | int my_getpeername(int sock, struct sockaddr *addr, int *addrlen) { |
50 | 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"; |
51 | int rslt; |
52 | |
53 | rslt = si_getpeername(sock, addr, addrlen); |
54 | |
55 | /* Just pass an error back up the line */ |
56 | if (rslt) return rslt; |
57 | |
58 | /* If the call succeeded, make sure we don't have a zeroed port/addr */ |
59 | if (addr->sa_family == AF_INET && |
60 | !memcmp((char *)addr + sizeof(u_short), nowhere, |
61 | sizeof(u_short) + sizeof(struct in_addr))) { |
62 | rslt = -1; |
63 | SETERRNO(ENOTCONN,SS$_CLEARED); |
64 | } |
65 | return rslt; |
66 | } |