From bbf577ba54ebdb9a57be50bf95c089038c056796 Mon Sep 17 00:00:00 2001 From: "W. Eric Norum" Date: Wed, 13 Sep 2000 16:21:32 +0000 Subject: [PATCH] Add utility routines which vxWorks provides but RTEMS does not. --- src/libCom/Makefile | 1 + src/libCom/osi/os/RTEMS/rtems_util.c | 76 +++++++++++++++++++++++++++ src/makeBaseApp/top/configure/RELEASE | 2 +- 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 src/libCom/osi/os/RTEMS/rtems_util.c diff --git a/src/libCom/Makefile b/src/libCom/Makefile index 73493b290..cd598eda9 100644 --- a/src/libCom/Makefile +++ b/src/libCom/Makefile @@ -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 diff --git a/src/libCom/osi/os/RTEMS/rtems_util.c b/src/libCom/osi/os/RTEMS/rtems_util.c new file mode 100644 index 000000000..42e7697ba --- /dev/null +++ b/src/libCom/osi/os/RTEMS/rtems_util.c @@ -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 +#include +#include +#include +#include +#include + +/* + * 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; +} diff --git a/src/makeBaseApp/top/configure/RELEASE b/src/makeBaseApp/top/configure/RELEASE index 708c430bd..e7e09a189 100644 --- a/src/makeBaseApp/top/configure/RELEASE +++ b/src/makeBaseApp/top/configure/RELEASE @@ -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