1999-09-14 09:32:05 -04:00
|
|
|
/*
|
|
|
|
* Scheme48/scsh network interface.
|
|
|
|
* Routines that require custom C support.
|
|
|
|
* Copyright (c) 1994 by Brian D. Carlstrom
|
|
|
|
* Copyright (c) 1994 by Olin Shivers
|
|
|
|
*/
|
2000-12-20 03:31:06 -05:00
|
|
|
#include "sysdep.h"
|
1999-09-14 09:32:05 -04:00
|
|
|
#include "cstuff.h"
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/un.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <netdb.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
2000-07-10 14:01:53 -04:00
|
|
|
#include <fcntl.h>
|
1999-09-14 09:32:05 -04:00
|
|
|
/* Make sure our exports match up w/the implementation: */
|
|
|
|
#include "network1.h"
|
2000-07-10 14:01:53 -04:00
|
|
|
#include "scheme48.h"
|
1999-09-14 09:32:05 -04:00
|
|
|
|
|
|
|
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
2000-07-12 13:28:56 -04:00
|
|
|
s48_value scheme_bind(s48_value sock, s48_value family, s48_value scheme_name)
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
2000-07-12 13:28:56 -04:00
|
|
|
int sockfd = s48_extract_fixnum (sock);
|
|
|
|
switch(s48_extract_fixnum (family))
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
|
|
|
case AF_UNIX:
|
|
|
|
{
|
|
|
|
struct sockaddr_un name;
|
1999-09-15 20:20:37 -04:00
|
|
|
int scheme_length=S48_STRING_LENGTH(scheme_name);
|
2001-06-20 12:01:20 -04:00
|
|
|
memset(&name, 0, sizeof(name));
|
|
|
|
|
1999-09-14 09:32:05 -04:00
|
|
|
name.sun_family=AF_UNIX;
|
|
|
|
if (scheme_length>=(108-1)) /* save space for \0 */
|
2000-07-12 13:28:56 -04:00
|
|
|
return(-1); // TODO: check this in scheme !
|
1999-09-14 09:32:05 -04:00
|
|
|
strncpy(name.sun_path,
|
1999-10-08 14:19:37 -04:00
|
|
|
s48_extract_string(scheme_name),
|
1999-09-14 09:32:05 -04:00
|
|
|
scheme_length); /* copy to c string */
|
|
|
|
name.sun_path[scheme_length]='\0'; /* add null */
|
2000-07-12 13:28:56 -04:00
|
|
|
if ( bind(sockfd,(struct sockaddr *)&name,sizeof(name)) < 0)
|
|
|
|
s48_raise_os_error (errno);
|
|
|
|
return S48_UNSPECIFIC;
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
case AF_INET:
|
|
|
|
{
|
|
|
|
struct sockaddr_in name;
|
2001-06-20 12:01:20 -04:00
|
|
|
unsigned long addr = htonl(s48_extract_unsigned_integer (S48_CAR (scheme_name)));
|
|
|
|
unsigned short port = htons(s48_extract_fixnum (S48_CDR (scheme_name)));
|
|
|
|
memset(&name, 0, sizeof(name));
|
2000-07-13 09:45:00 -04:00
|
|
|
|
1999-09-14 09:32:05 -04:00
|
|
|
name.sin_family=AF_INET;
|
|
|
|
name.sin_addr.s_addr=addr;
|
|
|
|
name.sin_port=port;
|
2000-07-12 13:28:56 -04:00
|
|
|
if (bind(sockfd,(struct sockaddr *)&name,sizeof(name)) < 0)
|
|
|
|
s48_raise_os_error (errno);
|
2000-07-13 09:45:00 -04:00
|
|
|
|
2000-07-12 13:28:56 -04:00
|
|
|
return S48_UNSPECIFIC;
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
default:
|
2000-07-13 09:45:00 -04:00
|
|
|
s48_raise_argtype_error (family);
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
2000-07-10 14:32:45 -04:00
|
|
|
s48_value scheme_connect(s48_value sock, s48_value family, s48_value scheme_name)
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
2000-07-10 14:32:45 -04:00
|
|
|
int sockfd = s48_extract_fixnum (sock);
|
|
|
|
switch(s48_extract_fixnum (family))
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
|
|
|
case AF_UNIX:
|
|
|
|
{
|
|
|
|
struct sockaddr_un name;
|
2000-07-10 14:32:45 -04:00
|
|
|
int ret;
|
1999-09-15 20:20:37 -04:00
|
|
|
int scheme_length=S48_STRING_LENGTH(scheme_name);
|
1999-09-14 09:32:05 -04:00
|
|
|
|
2001-06-21 04:22:18 -04:00
|
|
|
memset(&name, 0, sizeof(name));
|
|
|
|
|
1999-09-14 09:32:05 -04:00
|
|
|
name.sun_family=AF_UNIX;
|
|
|
|
if (scheme_length>=(108-1)) /* save space for \0 */
|
|
|
|
return(-1);
|
|
|
|
strncpy(name.sun_path,
|
2000-07-12 13:28:56 -04:00
|
|
|
s48_extract_string (scheme_name),
|
1999-09-14 09:32:05 -04:00
|
|
|
scheme_length); /* copy to c string */
|
|
|
|
name.sun_path[scheme_length]='\0'; /* add null */
|
2000-07-10 14:32:45 -04:00
|
|
|
|
|
|
|
if (connect(sockfd,(struct sockaddr *)&name,sizeof(name)) == 0)
|
|
|
|
return S48_TRUE;
|
|
|
|
|
|
|
|
if (errno != EWOULDBLOCK && errno != EINTR && errno != EALREADY
|
|
|
|
&& errno != EINPROGRESS && errno != EAGAIN)
|
|
|
|
s48_raise_os_error(errno);
|
|
|
|
|
|
|
|
if (! (s48_add_pending_fd(sockfd, 0)))
|
|
|
|
s48_raise_out_of_memory_error();
|
|
|
|
|
2000-07-12 13:28:56 -04:00
|
|
|
if (errno == EINPROGRESS)
|
|
|
|
return s48_enter_fixnum (0);
|
|
|
|
else return S48_FALSE;
|
2000-07-10 14:32:45 -04:00
|
|
|
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
case AF_INET:
|
|
|
|
{
|
|
|
|
struct sockaddr_in name;
|
|
|
|
|
2001-04-02 10:57:25 -04:00
|
|
|
u_long addr= htonl(s48_extract_unsigned_integer (S48_CAR (scheme_name)));
|
2000-07-12 13:28:56 -04:00
|
|
|
u_short port= htons(s48_extract_fixnum (S48_CDR (scheme_name)));
|
1999-09-14 09:32:05 -04:00
|
|
|
|
2001-06-21 04:22:18 -04:00
|
|
|
memset(&name, 0, sizeof(name));
|
|
|
|
|
1999-09-14 09:32:05 -04:00
|
|
|
name.sin_family=AF_INET;
|
|
|
|
name.sin_addr.s_addr=addr;
|
|
|
|
name.sin_port=port;
|
2000-07-10 14:32:45 -04:00
|
|
|
|
|
|
|
if (connect(sockfd,(struct sockaddr *)&name,sizeof(name)) == 0)
|
|
|
|
return S48_TRUE;
|
|
|
|
|
|
|
|
if (errno != EWOULDBLOCK && errno != EINTR && errno != EALREADY
|
|
|
|
&& errno != EINPROGRESS && errno != EAGAIN)
|
|
|
|
s48_raise_os_error(errno);
|
2000-07-11 06:30:23 -04:00
|
|
|
|
2000-07-10 14:32:45 -04:00
|
|
|
if (! (s48_add_pending_fd(sockfd, 0)))
|
|
|
|
s48_raise_out_of_memory_error();
|
|
|
|
|
2000-07-11 06:30:23 -04:00
|
|
|
if (errno == EINPROGRESS)
|
|
|
|
return s48_enter_fixnum (0);
|
|
|
|
else return S48_FALSE;
|
2000-07-10 14:32:45 -04:00
|
|
|
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
default:
|
2000-07-13 09:45:00 -04:00
|
|
|
s48_raise_argtype_error (family); /* error unknown address family */
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
2000-07-12 13:28:56 -04:00
|
|
|
s48_value scheme_accept(s48_value sockfd_tagged, s48_value family)
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
2000-07-10 14:01:53 -04:00
|
|
|
int sockfd = s48_extract_fixnum (sockfd_tagged);
|
|
|
|
switch(s48_extract_fixnum (family))
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
|
|
|
case AF_UNIX:
|
|
|
|
{
|
|
|
|
struct sockaddr_un name;
|
2000-07-27 09:38:35 -04:00
|
|
|
socklen_t namelen=sizeof(name);
|
1999-09-14 09:32:05 -04:00
|
|
|
int newsockfd=accept(sockfd,(struct sockaddr *)&name,&namelen);
|
|
|
|
|
|
|
|
if (newsockfd < 0)
|
2000-07-10 14:32:45 -04:00
|
|
|
{
|
|
|
|
if ((errno != EWOULDBLOCK) && (errno != EINTR) && (errno != EAGAIN))
|
|
|
|
s48_raise_os_error(errno);
|
|
|
|
if (! s48_add_pending_fd(sockfd, 1))// 1 for is_input
|
|
|
|
s48_raise_out_of_memory_error();
|
|
|
|
return S48_FALSE;
|
|
|
|
}
|
2001-01-01 12:34:08 -05:00
|
|
|
|
2000-07-10 14:01:53 -04:00
|
|
|
return(s48_enter_fixnum (newsockfd));
|
1999-09-14 09:32:05 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AF_INET:
|
|
|
|
{
|
|
|
|
struct sockaddr_in name;
|
2000-07-27 09:38:35 -04:00
|
|
|
socklen_t namelen=sizeof(name);
|
2000-07-10 14:01:53 -04:00
|
|
|
int newsockfd;
|
2000-07-12 13:28:56 -04:00
|
|
|
s48_value result, sock_addr;
|
|
|
|
S48_DECLARE_GC_PROTECT(2);
|
|
|
|
newsockfd = accept (sockfd,
|
|
|
|
(struct sockaddr *)&name,&namelen);
|
1999-09-14 09:32:05 -04:00
|
|
|
|
|
|
|
if (newsockfd < 0)
|
2000-07-10 14:01:53 -04:00
|
|
|
{
|
|
|
|
if ((errno != EWOULDBLOCK) && (errno != EINTR) && (errno != EAGAIN))
|
|
|
|
s48_raise_os_error(errno);
|
|
|
|
if (! s48_add_pending_fd(sockfd, 1))// 1 for is_input
|
|
|
|
s48_raise_out_of_memory_error();
|
|
|
|
return S48_FALSE;
|
|
|
|
}
|
|
|
|
fcntl(newsockfd, F_SETFL, O_NONBLOCK);
|
2000-07-12 13:28:56 -04:00
|
|
|
S48_GC_PROTECT_2 (result, sock_addr);
|
2001-04-02 10:57:25 -04:00
|
|
|
sock_addr = s48_enter_unsigned_integer (ntohl(name.sin_addr.s_addr));
|
2000-07-12 13:28:56 -04:00
|
|
|
|
|
|
|
result = s48_cons (sock_addr, s48_enter_fixnum (ntohs(name.sin_port)));
|
|
|
|
|
|
|
|
result = s48_cons (s48_enter_fixnum (newsockfd),
|
|
|
|
result);
|
|
|
|
S48_GC_UNPROTECT();
|
|
|
|
return result;
|
1999-09-14 09:32:05 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2000-07-10 14:01:53 -04:00
|
|
|
s48_raise_argtype_error (family); /* error unknown address family */
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-21 12:01:05 -05:00
|
|
|
s48_value make_addr (long net_s_addr, int net_s_port)
|
2000-07-12 13:28:56 -04:00
|
|
|
{
|
|
|
|
s48_value result, sock_addr;
|
|
|
|
S48_DECLARE_GC_PROTECT(2);
|
|
|
|
S48_GC_PROTECT_2 (result, sock_addr);
|
2001-04-02 10:57:25 -04:00
|
|
|
sock_addr = s48_enter_unsigned_integer (ntohl (net_s_addr));
|
2000-07-12 13:28:56 -04:00
|
|
|
|
2000-12-21 12:01:05 -05:00
|
|
|
result = s48_cons (sock_addr, s48_enter_fixnum (ntohs (net_s_port)));
|
2000-07-12 13:28:56 -04:00
|
|
|
S48_GC_UNPROTECT();
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1999-09-14 09:32:05 -04:00
|
|
|
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
2000-07-12 13:28:56 -04:00
|
|
|
s48_value scheme_peer_name(s48_value sock, s48_value family)
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
2000-07-12 13:28:56 -04:00
|
|
|
int sockfd = s48_extract_fixnum (sock);
|
|
|
|
switch(s48_extract_fixnum (family))
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
|
|
|
case AF_INET:
|
|
|
|
{
|
|
|
|
struct sockaddr_in name;
|
2000-07-27 09:38:35 -04:00
|
|
|
socklen_t namelen=sizeof(name);
|
1999-09-14 09:32:05 -04:00
|
|
|
int value=getpeername(sockfd,(struct sockaddr *)&name,&namelen);
|
|
|
|
|
2000-07-12 13:28:56 -04:00
|
|
|
if (value < 0) s48_raise_os_error (errno);
|
|
|
|
|
|
|
|
return (make_addr (name.sin_addr.s_addr, name.sin_port));
|
1999-09-14 09:32:05 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2000-07-12 13:28:56 -04:00
|
|
|
s48_raise_argtype_error (family); /* error unknown address family */
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
2000-07-12 13:28:56 -04:00
|
|
|
s48_value scheme_socket_name(s48_value sock, s48_value family)
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
2000-07-12 13:28:56 -04:00
|
|
|
int sockfd = s48_extract_fixnum (sock);
|
|
|
|
switch(s48_extract_fixnum (family))
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
|
|
|
case AF_INET:
|
|
|
|
{
|
|
|
|
struct sockaddr_in name;
|
2000-07-27 09:38:35 -04:00
|
|
|
socklen_t namelen=sizeof(name);
|
1999-09-14 09:32:05 -04:00
|
|
|
int value=getsockname(sockfd,(struct sockaddr *)&name,&namelen);
|
|
|
|
|
2000-07-12 13:28:56 -04:00
|
|
|
if (value < 0) s48_raise_os_error (errno);
|
|
|
|
|
|
|
|
return(make_addr (name.sin_addr.s_addr,
|
|
|
|
name.sin_port));
|
1999-09-14 09:32:05 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2000-07-12 13:28:56 -04:00
|
|
|
s48_raise_argtype_error (family); /* error unknown address family */
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
2001-01-01 12:34:08 -05:00
|
|
|
s48_value scheme_socket_pair(s48_value type)
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
|
|
|
int sv[2];
|
2001-01-01 12:34:08 -05:00
|
|
|
if( socketpair(PF_UNIX,s48_extract_integer (type),0,sv) )
|
|
|
|
s48_raise_os_error_1(errno, type);
|
|
|
|
|
|
|
|
return s48_cons (s48_enter_fixnum (sv[0]),
|
|
|
|
s48_cons (s48_enter_fixnum (sv[1]), S48_NULL));
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
2000-07-14 12:30:02 -04:00
|
|
|
s48_value
|
|
|
|
recv_substring(s48_value scm_sockfd, s48_value flags, s48_value buf,
|
|
|
|
s48_value scm_start, s48_value scm_end)
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
2000-07-14 12:30:02 -04:00
|
|
|
struct sockaddr_in name;
|
2000-07-27 09:38:35 -04:00
|
|
|
socklen_t namelen=sizeof(name);
|
2000-07-14 12:30:02 -04:00
|
|
|
int sockfd = s48_extract_fixnum (scm_sockfd);
|
|
|
|
int start = s48_extract_fixnum (scm_start);
|
|
|
|
int end = s48_extract_fixnum (scm_end);
|
|
|
|
char* buf_part = s48_extract_string (buf) + start;
|
|
|
|
|
|
|
|
int cc=recvfrom(sockfd,
|
|
|
|
buf_part, end-start,
|
|
|
|
s48_extract_fixnum (flags),
|
|
|
|
(struct sockaddr *)&name, &namelen);
|
|
|
|
s48_value result;
|
|
|
|
|
|
|
|
if (cc >= 0)
|
|
|
|
return (s48_cons (s48_enter_fixnum (cc),
|
|
|
|
s48_cons (make_addr (name.sin_addr.s_addr,
|
|
|
|
htonl((u_long)ntohs(name.sin_port))),
|
|
|
|
S48_NULL)));
|
|
|
|
|
|
|
|
|
|
|
|
if ((errno != EWOULDBLOCK) && (errno != EINTR) && (errno != EAGAIN))
|
|
|
|
s48_raise_os_error(errno);
|
|
|
|
if (! s48_add_pending_fd(sockfd, 1))// 1 for is_input
|
|
|
|
s48_raise_out_of_memory_error();
|
|
|
|
return S48_FALSE;
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
2000-07-14 12:30:02 -04:00
|
|
|
s48_value send_substring(s48_value scm_sockfd,
|
|
|
|
s48_value scm_flags,
|
|
|
|
s48_value buf,
|
|
|
|
s48_value scm_start,
|
|
|
|
s48_value scm_end,
|
|
|
|
s48_value scm_family,
|
|
|
|
s48_value scheme_name)
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
2000-07-14 12:30:02 -04:00
|
|
|
int n;
|
|
|
|
int s = s48_extract_fixnum (scm_sockfd);
|
|
|
|
int flags = s48_extract_fixnum (scm_flags);
|
|
|
|
int start = s48_extract_fixnum (scm_start);
|
|
|
|
int end = s48_extract_fixnum (scm_end);
|
|
|
|
char* buf_part = s48_extract_string (buf) + start;
|
|
|
|
|
|
|
|
switch(s48_extract_fixnum (scm_family))
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
|
|
|
case 0: /* only with connected sockets */
|
|
|
|
{
|
2000-07-14 12:30:02 -04:00
|
|
|
n = send(s, buf_part, end-start, flags);
|
|
|
|
break;
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
case AF_UNIX:
|
|
|
|
{
|
|
|
|
struct sockaddr_un name;
|
1999-09-15 20:20:37 -04:00
|
|
|
int scheme_length=S48_STRING_LENGTH(scheme_name);
|
2001-06-21 04:22:18 -04:00
|
|
|
|
|
|
|
memset(&name, 0, sizeof(name));
|
|
|
|
|
1999-09-14 09:32:05 -04:00
|
|
|
name.sun_family=AF_UNIX;
|
|
|
|
if (scheme_length>=(108-1)) /* save space for \0 */
|
|
|
|
return(-1);
|
|
|
|
strncpy(name.sun_path,
|
2000-07-12 13:28:56 -04:00
|
|
|
s48_extract_string(scheme_name),
|
1999-09-14 09:32:05 -04:00
|
|
|
scheme_length); /* copy to c string */
|
|
|
|
name.sun_path[scheme_length]='\0'; /* add null */
|
2000-07-14 12:30:02 -04:00
|
|
|
n = sendto(s,
|
|
|
|
buf_part, end-start,
|
|
|
|
flags,
|
|
|
|
(struct sockaddr *)&name, sizeof(name));
|
1999-09-14 09:32:05 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AF_INET:
|
|
|
|
{
|
|
|
|
struct sockaddr_in name;
|
2001-04-02 10:57:25 -04:00
|
|
|
u_long addr = htonl (s48_extract_unsigned_integer (S48_CAR (scheme_name)));
|
2000-07-14 12:30:02 -04:00
|
|
|
u_short port = htons(s48_extract_fixnum (S48_CDR (scheme_name)));
|
2001-06-21 04:22:18 -04:00
|
|
|
|
|
|
|
memset(&name, 0, sizeof(name));
|
|
|
|
|
1999-09-14 09:32:05 -04:00
|
|
|
name.sin_family=AF_INET;
|
|
|
|
name.sin_addr.s_addr=addr;
|
|
|
|
name.sin_port=port;
|
|
|
|
|
2000-07-14 12:30:02 -04:00
|
|
|
n = sendto(s,
|
|
|
|
buf_part, end-start,
|
|
|
|
flags,
|
|
|
|
(struct sockaddr *)&name, sizeof(name));
|
|
|
|
break;
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
default:
|
2000-07-14 12:30:02 -04:00
|
|
|
s48_raise_argtype_error (s48_extract_fixnum (scm_family));
|
|
|
|
/* error unknown address family */
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
2000-07-14 12:30:02 -04:00
|
|
|
|
|
|
|
if (n >= 0)
|
|
|
|
return s48_enter_fixnum (n);
|
|
|
|
|
|
|
|
if ((errno != EWOULDBLOCK) && (errno != EINTR) && (errno != EAGAIN))
|
|
|
|
s48_raise_os_error(errno);
|
|
|
|
|
|
|
|
if (! s48_add_pending_fd(s, 0))// 0 for is_input
|
|
|
|
s48_raise_out_of_memory_error();
|
|
|
|
|
|
|
|
return S48_FALSE;
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
2000-07-14 12:30:02 -04:00
|
|
|
|
|
|
|
|
1999-09-14 09:32:05 -04:00
|
|
|
|
|
|
|
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
2001-01-01 12:34:08 -05:00
|
|
|
s48_value scheme_getsockopt (s48_value s,
|
|
|
|
s48_value level,
|
|
|
|
s48_value optname)
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
|
|
|
int optval;
|
|
|
|
int optlen=sizeof(optval);
|
|
|
|
|
2001-01-01 12:34:08 -05:00
|
|
|
if (getsockopt(s48_extract_fixnum (s),
|
|
|
|
s48_extract_fixnum (level),
|
|
|
|
s48_extract_fixnum (optname)
|
|
|
|
,(char *)&optval,
|
|
|
|
&optlen) == -1)
|
|
|
|
s48_raise_os_error_3 (errno, s, level, optname);
|
|
|
|
return(s48_enter_fixnum (optval));
|
1999-09-14 09:32:05 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2001-01-01 12:34:08 -05:00
|
|
|
s48_value scheme_getsockopt_linger (s48_value s,
|
|
|
|
s48_value level,
|
|
|
|
s48_value optname)
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
|
|
|
struct linger optval;
|
|
|
|
int optlen=sizeof(optval);
|
|
|
|
|
2001-01-01 12:34:08 -05:00
|
|
|
if (getsockopt(s48_extract_fixnum (s),
|
|
|
|
s48_extract_fixnum (level),
|
|
|
|
s48_extract_fixnum (optname),
|
|
|
|
(char *)&optval,
|
|
|
|
&optlen) == -1) {
|
|
|
|
s48_raise_os_error_3 (errno, s, level, optname);
|
|
|
|
}
|
|
|
|
return s48_cons (s48_enter_fixnum (optval.l_onoff),
|
|
|
|
s48_cons (s48_enter_fixnum (optval.l_linger), S48_NULL));
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
|
2001-01-01 12:34:08 -05:00
|
|
|
s48_value scheme_getsockopt_timeout (s48_value s,
|
|
|
|
s48_value level,
|
|
|
|
s48_value optname)
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
|
|
|
struct timeval optval;
|
2000-05-16 05:24:54 -04:00
|
|
|
size_t optlen=sizeof(optval);
|
1999-09-14 09:32:05 -04:00
|
|
|
|
2001-01-01 12:34:08 -05:00
|
|
|
if (getsockopt(s48_extract_fixnum (s),
|
|
|
|
s48_extract_fixnum (level),
|
|
|
|
s48_extract_fixnum (optname),
|
|
|
|
(char *)&optval,
|
|
|
|
&optlen) == -1) {
|
|
|
|
s48_raise_os_error_3 (errno, s, level, optname);
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
2001-01-01 12:34:08 -05:00
|
|
|
return(s48_cons (s48_enter_fixnum (optval.tv_sec),
|
|
|
|
s48_cons (s48_enter_fixnum (optval.tv_usec), S48_NULL)));
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
2001-01-01 12:34:08 -05:00
|
|
|
s48_value scheme_setsockopt (s48_value s,
|
|
|
|
s48_value level,
|
|
|
|
s48_value optname,
|
|
|
|
s48_value _optval)
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
2001-01-01 12:34:08 -05:00
|
|
|
int optval = s48_extract_fixnum (_optval);
|
|
|
|
if ((setsockopt(s48_extract_fixnum (s),
|
|
|
|
s48_extract_fixnum (level),
|
|
|
|
s48_extract_fixnum (optname),
|
|
|
|
(char *)&optval,sizeof(optval))) == -1)
|
|
|
|
s48_raise_os_error_4 (errno, s, level, optname, _optval);
|
|
|
|
return S48_UNSPECIFIC;
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
|
2001-01-01 12:34:08 -05:00
|
|
|
s48_value scheme_setsockopt_linger (s48_value s,
|
|
|
|
s48_value level,
|
|
|
|
s48_value optname,
|
|
|
|
s48_value onoff,
|
|
|
|
s48_value linger)
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
|
|
|
struct linger optval;
|
|
|
|
|
2001-01-01 12:34:08 -05:00
|
|
|
optval.l_onoff = s48_extract_fixnum (onoff);
|
|
|
|
optval.l_linger = s48_extract_fixnum (linger);
|
1999-09-14 09:32:05 -04:00
|
|
|
|
2001-01-01 12:34:08 -05:00
|
|
|
if ((setsockopt(s48_extract_fixnum (s),
|
|
|
|
s48_extract_fixnum (level),
|
|
|
|
s48_extract_fixnum (optname),
|
|
|
|
(char *)&optval,sizeof(optval))) == -1)
|
|
|
|
s48_raise_os_error_5 (errno, s, level, optname, onoff, linger);
|
|
|
|
return S48_UNSPECIFIC;
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
|
2001-01-01 12:34:08 -05:00
|
|
|
s48_value scheme_setsockopt_timeout (s48_value s,
|
|
|
|
s48_value level,
|
|
|
|
s48_value optname,
|
|
|
|
s48_value sec,
|
|
|
|
s48_value usec)
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
|
|
|
struct timeval optval;
|
2001-01-01 12:34:08 -05:00
|
|
|
optval.tv_sec = s48_extract_fixnum (sec);
|
|
|
|
optval.tv_usec = s48_extract_fixnum (usec);
|
1999-09-14 09:32:05 -04:00
|
|
|
|
2001-01-01 12:34:08 -05:00
|
|
|
if ((setsockopt(s48_extract_fixnum (s),
|
|
|
|
s48_extract_fixnum (level),
|
|
|
|
s48_extract_fixnum (optname),
|
|
|
|
(char *)&optval,sizeof(optval))) == -1)
|
|
|
|
s48_raise_os_error_5 (errno, s, level, optname, sec, usec);
|
|
|
|
return S48_UNSPECIFIC;
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
|
|
|
/* Routines for looking up hosts */
|
|
|
|
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
|
|
|
|
2000-07-12 13:28:56 -04:00
|
|
|
static s48_value host_info_type_binding = S48_FALSE;
|
1999-09-14 09:32:05 -04:00
|
|
|
|
2000-07-12 13:28:56 -04:00
|
|
|
s48_value host_ent2host_info (struct hostent * host)
|
|
|
|
{
|
|
|
|
s48_value host_info = S48_FALSE;
|
2000-07-13 09:45:00 -04:00
|
|
|
s48_value list = S48_FALSE;
|
2000-07-12 13:28:56 -04:00
|
|
|
long * ptr;
|
|
|
|
int i;
|
|
|
|
S48_DECLARE_GC_PROTECT (2);
|
1999-09-14 09:32:05 -04:00
|
|
|
|
|
|
|
if(host==NULL)
|
2000-07-12 13:28:56 -04:00
|
|
|
{
|
|
|
|
return(s48_enter_fixnum (h_errno));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (host_info_type_binding == S48_FALSE)
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
2000-07-12 13:28:56 -04:00
|
|
|
S48_GC_PROTECT_GLOBAL(host_info_type_binding);
|
|
|
|
host_info_type_binding = s48_get_imported_binding ("host-info-type");
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
2000-07-12 13:28:56 -04:00
|
|
|
|
2000-07-13 09:45:00 -04:00
|
|
|
S48_GC_PROTECT_2 (host_info, list);
|
2000-07-12 13:28:56 -04:00
|
|
|
|
|
|
|
host_info = s48_make_record (host_info_type_binding);
|
|
|
|
S48_RECORD_SET (host_info, 0, s48_enter_string (host->h_name));
|
1999-09-14 09:32:05 -04:00
|
|
|
|
2000-07-12 13:28:56 -04:00
|
|
|
ptr = (long *)host->h_aliases;
|
2000-07-13 09:45:00 -04:00
|
|
|
list = S48_NULL;
|
2000-07-12 13:28:56 -04:00
|
|
|
i = 0;
|
|
|
|
while (*ptr)
|
|
|
|
{
|
2000-07-13 09:45:00 -04:00
|
|
|
list = s48_cons (s48_enter_string (host->h_aliases[i]), list);
|
2000-07-12 13:28:56 -04:00
|
|
|
ptr++;
|
|
|
|
i ++;
|
|
|
|
}
|
|
|
|
|
2000-07-13 09:45:00 -04:00
|
|
|
S48_RECORD_SET (host_info, 1, list);
|
2000-07-12 13:28:56 -04:00
|
|
|
|
|
|
|
ptr = (long *)host->h_addr_list;
|
2000-07-13 09:45:00 -04:00
|
|
|
list = S48_NULL;
|
2000-07-12 13:28:56 -04:00
|
|
|
i = 0;
|
|
|
|
while (*ptr)
|
|
|
|
{
|
2000-07-13 09:45:00 -04:00
|
|
|
list =
|
2001-06-20 12:01:20 -04:00
|
|
|
s48_cons (s48_enter_unsigned_integer (ntohl ((unsigned long) *(long *)(host->h_addr_list[i]))),
|
2000-07-13 09:45:00 -04:00
|
|
|
list);
|
2000-07-12 13:28:56 -04:00
|
|
|
ptr++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2000-07-13 09:45:00 -04:00
|
|
|
S48_RECORD_SET (host_info, 2, list);
|
2000-07-12 13:28:56 -04:00
|
|
|
|
|
|
|
S48_GC_UNPROTECT ();
|
|
|
|
return host_info;
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
|
2000-07-12 13:28:56 -04:00
|
|
|
s48_value scheme_host_address2host_info(s48_value addr_port)
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
|
|
|
struct in_addr name;
|
|
|
|
struct hostent *host;
|
|
|
|
|
2001-04-02 10:57:25 -04:00
|
|
|
u_long addr = htonl(s48_extract_unsigned_integer (S48_CAR (addr_port)));
|
2000-07-12 13:28:56 -04:00
|
|
|
name.s_addr = addr;
|
|
|
|
|
|
|
|
host=gethostbyaddr((char *)&name,sizeof(name),AF_INET);
|
|
|
|
return (host_ent2host_info (host));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
s48_value scheme_host_name2host_info(s48_value s_name)
|
|
|
|
{
|
|
|
|
struct in_addr name;
|
|
|
|
struct hostent *host;
|
|
|
|
char * scheme_name = s48_extract_string (s_name);
|
|
|
|
|
1999-09-14 09:32:05 -04:00
|
|
|
if ((name.s_addr=inet_addr(scheme_name)) != -1)
|
|
|
|
host=gethostbyaddr((char *)&name,sizeof(name),AF_INET);
|
|
|
|
else
|
|
|
|
host=gethostbyname(scheme_name);
|
|
|
|
|
2000-07-12 13:28:56 -04:00
|
|
|
return (host_ent2host_info (host));
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
|
|
|
/* Routines for looking up networks */
|
|
|
|
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
2000-07-13 09:45:00 -04:00
|
|
|
static s48_value network_info_type_binding = S48_FALSE;
|
|
|
|
|
|
|
|
s48_value netent2net_info(struct netent *net)
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
2000-07-13 09:45:00 -04:00
|
|
|
s48_value network_info = S48_FALSE;
|
|
|
|
s48_value list = S48_FALSE;
|
|
|
|
long * ptr;
|
|
|
|
int i;
|
|
|
|
S48_DECLARE_GC_PROTECT (2);
|
|
|
|
|
|
|
|
if (net==NULL) return S48_FALSE;
|
|
|
|
|
|
|
|
if (network_info_type_binding == S48_FALSE)
|
|
|
|
{
|
|
|
|
S48_GC_PROTECT_GLOBAL(network_info_type_binding);
|
|
|
|
network_info_type_binding =
|
|
|
|
s48_get_imported_binding ("network-info-type");
|
|
|
|
}
|
|
|
|
S48_GC_PROTECT_2 (network_info, list);
|
|
|
|
|
|
|
|
network_info = s48_make_record (network_info_type_binding);
|
|
|
|
S48_RECORD_SET (network_info, 0, s48_enter_string (net->n_name));
|
|
|
|
|
|
|
|
ptr = (long *)net->n_aliases;
|
|
|
|
list = S48_NULL;
|
|
|
|
i = 0;
|
|
|
|
while (*ptr)
|
|
|
|
{
|
|
|
|
list = s48_cons (s48_enter_string (net->n_aliases[i]), list);
|
|
|
|
ptr++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
S48_RECORD_SET (network_info, 1, list);
|
2001-04-02 10:57:25 -04:00
|
|
|
S48_RECORD_SET (network_info, 2, s48_enter_unsigned_integer (net->n_net));
|
1999-09-14 09:32:05 -04:00
|
|
|
|
2000-07-13 09:45:00 -04:00
|
|
|
S48_GC_UNPROTECT ();
|
|
|
|
|
|
|
|
return network_info;
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
|
2000-07-13 09:45:00 -04:00
|
|
|
s48_value scheme_net_address2net_info(s48_value net_addr)
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
2000-07-13 09:45:00 -04:00
|
|
|
struct netent *net;
|
|
|
|
// expects host byte order :
|
2001-04-02 10:57:25 -04:00
|
|
|
net=getnetbyaddr(s48_extract_unsigned_integer (net_addr),AF_INET);
|
1999-09-14 09:32:05 -04:00
|
|
|
|
2000-07-13 09:45:00 -04:00
|
|
|
return netent2net_info (net);
|
|
|
|
}
|
|
|
|
|
|
|
|
s48_value scheme_net_name2net_info(s48_value scheme_name)
|
|
|
|
{
|
|
|
|
struct netent *net = getnetbyname(s48_extract_string (scheme_name));
|
|
|
|
return netent2net_info (net);
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
|
|
|
/* Routines for looking up services */
|
|
|
|
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
|
|
|
|
2000-07-13 09:45:00 -04:00
|
|
|
|
|
|
|
static s48_value service_info_type_binding = S48_FALSE;
|
|
|
|
|
|
|
|
s48_value servent2service_info(struct servent *serv)
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
2000-07-13 09:45:00 -04:00
|
|
|
s48_value service_info = S48_FALSE;
|
|
|
|
s48_value list = S48_FALSE;
|
|
|
|
long * ptr;
|
|
|
|
int i;
|
|
|
|
S48_DECLARE_GC_PROTECT (2);
|
|
|
|
|
|
|
|
if (serv==NULL) return S48_FALSE;
|
|
|
|
|
|
|
|
if (service_info_type_binding == S48_FALSE)
|
|
|
|
{
|
|
|
|
S48_GC_PROTECT_GLOBAL(service_info_type_binding);
|
|
|
|
service_info_type_binding =
|
|
|
|
s48_get_imported_binding ("service-info-type");
|
|
|
|
}
|
|
|
|
S48_GC_PROTECT_2 (service_info, list);
|
|
|
|
|
|
|
|
service_info = s48_make_record (service_info_type_binding);
|
|
|
|
|
|
|
|
S48_RECORD_SET (service_info, 0, s48_enter_string (serv->s_name));
|
|
|
|
|
|
|
|
ptr = (long *)serv->s_aliases;
|
|
|
|
list = S48_NULL;
|
|
|
|
i = 0;
|
|
|
|
while (*ptr)
|
|
|
|
{
|
|
|
|
list = s48_cons (s48_enter_string (serv->s_aliases[i]), list);
|
|
|
|
ptr++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
S48_RECORD_SET (service_info, 1, list);
|
|
|
|
S48_RECORD_SET (service_info, 2, s48_enter_fixnum (ntohs (serv->s_port)));
|
|
|
|
S48_RECORD_SET (service_info, 3, s48_enter_string (serv->s_proto));
|
|
|
|
|
|
|
|
S48_GC_UNPROTECT ();
|
|
|
|
|
|
|
|
return service_info;
|
|
|
|
}
|
1999-09-14 09:32:05 -04:00
|
|
|
|
2000-07-13 09:45:00 -04:00
|
|
|
s48_value scheme_serv_port2serv_info(s48_value in_port,
|
|
|
|
s48_value in_proto)
|
|
|
|
{
|
|
|
|
struct servent *serv;
|
|
|
|
char * proto;
|
|
|
|
if (in_proto == S48_FALSE) proto = NULL;
|
|
|
|
else proto = s48_extract_string (in_proto);
|
1999-09-14 09:32:05 -04:00
|
|
|
|
2000-07-13 09:45:00 -04:00
|
|
|
serv = getservbyport(ntohs(s48_extract_fixnum (in_port)),
|
|
|
|
proto);
|
1999-09-14 09:32:05 -04:00
|
|
|
|
2000-07-13 09:45:00 -04:00
|
|
|
return servent2service_info (serv);
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
|
2000-07-13 09:45:00 -04:00
|
|
|
s48_value scheme_serv_name2serv_info(s48_value in_name,
|
|
|
|
s48_value in_proto)
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
2000-07-13 09:45:00 -04:00
|
|
|
struct servent *serv;
|
|
|
|
char * proto;
|
1999-09-14 09:32:05 -04:00
|
|
|
|
2000-07-13 09:45:00 -04:00
|
|
|
if (in_proto == S48_FALSE) proto = NULL;
|
|
|
|
else proto = s48_extract_string (in_proto);
|
|
|
|
|
|
|
|
serv = getservbyname(s48_extract_string (in_name),
|
|
|
|
proto);
|
1999-09-14 09:32:05 -04:00
|
|
|
|
2000-07-13 09:45:00 -04:00
|
|
|
return servent2service_info (serv);
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
|
|
|
/* Routines for looking up protocols */
|
|
|
|
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
2000-07-13 09:45:00 -04:00
|
|
|
|
|
|
|
static s48_value protocol_info_type_binding = S48_FALSE;
|
|
|
|
|
|
|
|
s48_value protoent2protocol_info(struct protoent *proto)
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
2000-07-13 09:45:00 -04:00
|
|
|
s48_value protocol_info = S48_FALSE;
|
|
|
|
s48_value list = S48_FALSE;
|
|
|
|
long * ptr;
|
|
|
|
int i;
|
|
|
|
S48_DECLARE_GC_PROTECT (2);
|
|
|
|
|
|
|
|
if (proto==NULL) return S48_FALSE;
|
|
|
|
|
|
|
|
if (protocol_info_type_binding == S48_FALSE)
|
|
|
|
{
|
|
|
|
S48_GC_PROTECT_GLOBAL(protocol_info_type_binding);
|
|
|
|
protocol_info_type_binding =
|
|
|
|
s48_get_imported_binding ("protocol-info-type");
|
|
|
|
}
|
|
|
|
S48_GC_PROTECT_2 (protocol_info, list);
|
|
|
|
|
|
|
|
protocol_info = s48_make_record (protocol_info_type_binding);
|
1999-09-14 09:32:05 -04:00
|
|
|
|
2000-07-13 09:45:00 -04:00
|
|
|
S48_RECORD_SET (protocol_info, 0, s48_enter_string (proto->p_name));
|
|
|
|
|
|
|
|
ptr = (long *)proto->p_aliases;
|
|
|
|
list = S48_NULL;
|
|
|
|
i = 0;
|
|
|
|
while (*ptr)
|
|
|
|
{
|
|
|
|
list = s48_cons (s48_enter_string (proto->p_aliases[i]), list);
|
|
|
|
ptr++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
S48_RECORD_SET (protocol_info, 1, list);
|
|
|
|
S48_RECORD_SET (protocol_info, 2, s48_enter_fixnum (proto->p_proto));
|
|
|
|
|
|
|
|
S48_GC_UNPROTECT ();
|
|
|
|
|
|
|
|
return protocol_info;
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
|
2000-07-13 09:45:00 -04:00
|
|
|
s48_value scheme_proto_num2proto_info(s48_value in_proto)
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
2000-07-13 09:45:00 -04:00
|
|
|
struct protoent *proto;
|
|
|
|
|
|
|
|
proto=getprotobynumber(s48_extract_fixnum (in_proto));
|
1999-09-14 09:32:05 -04:00
|
|
|
|
2000-07-13 09:45:00 -04:00
|
|
|
return protoent2protocol_info (proto);
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
|
2000-07-13 09:45:00 -04:00
|
|
|
s48_value scheme_proto_name2proto_info(s48_value in_name)
|
1999-09-14 09:32:05 -04:00
|
|
|
{
|
2000-07-13 09:45:00 -04:00
|
|
|
struct protoent *proto=getprotobyname(s48_extract_string (in_name));
|
|
|
|
|
|
|
|
return protoent2protocol_info (proto);
|
1999-09-14 09:32:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-13 09:45:00 -04:00
|
|
|
|