Add utility routines which vxWorks provides but RTEMS does not.

This commit is contained in:
W. Eric Norum
2000-09-13 16:21:32 +00:00
parent 1536bd52f6
commit bbf577ba54
3 changed files with 78 additions and 1 deletions

View File

@@ -164,6 +164,7 @@ SRCS_WIN32 += dllmain.cpp
# For RTEMS startup
SRCS_RTEMS += rtems_init.c
SRCS_RTEMS += rtems_util.c
# For vxWorks a clock
INC_vxWorks += iocClock.h

View File

@@ -0,0 +1,76 @@
/*
* RTEMS utilitiy routines for EPICS
* $Id$
* Author: W. Eric Norum
* eric@cls.usask.ca
* (306) 966-6055
*
* Supplies routines that are present in vxWorks but missing in RTEMS.
*/
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
/*
* Like connect(), but with an explicit timeout
*/
int connectWithTimeout (int sfd,
struct sockaddr *addr,
int addrlen,
struct timeval *timeout)
{
struct timeval sv;
int svlen = sizeof sv;
int ret;
if (!timeout)
return connect (sfd, addr, addrlen);
if (getsockopt (sfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&sv, &svlen) < 0)
return -1;
if (setsockopt (sfd, SOL_SOCKET, SO_RCVTIMEO, (char *)timeout, sizeof *timeout) < 0)
return -1;
ret = connect (sfd, addr, addrlen);
setsockopt (sfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&sv, sizeof sv);
return ret;
}
/*
* RTEMS does not have the getprotobyXXX routines.
* Provide these simple-minded versions.
*/
static char *ip_alias[] = { "IP", NULL };
static char *icmp_alias[] = { "ICMP", NULL };
static char *tcp_alias[] = { "TCP", NULL };
static char *udp_alias[] = { "UDP", NULL };
static const struct protoent prototab[] = {
{ "IP", ip_alias, IPPROTO_IP },
{ "ICMP", icmp_alias, IPPROTO_ICMP },
{ "TCP", tcp_alias, IPPROTO_TCP },
{ "UDP", udp_alias, IPPROTO_UDP },
};
struct protoent *
getprotobyname (const char *name)
{
int i;
for (i = 0 ; i < (sizeof prototab / sizeof prototab[0]) ; i++) {
if (strcasecmp (name, prototab[i].p_name) == 0)
return (struct protoent *) &prototab[i];
}
return NULL;
}
struct protoent *
getprotobynumber (int proto)
{
int i;
for (i = 0 ; i < (sizeof prototab / sizeof prototab[0]) ; i++) {
if (proto == prototab[i].p_proto)
return (struct protoent *) &prototab[i];
}
return NULL;
}

View File

@@ -1,4 +1,4 @@
#RELEASE Location of external products
EPICS_BASE=_EPICS_BASE_
TEMPLATE_TOP=_TEMPLATE_TOP_
MSI=/usr/local/epics/extensions/bin/$(EPICS_HOST_ARCH)/msi
MSI=/home/epics/CLS/epics/extensions/bin/$(EPICS_HOST_ARCH)/msi