diff --git a/.ci-local/defaults.set b/.ci-local/defaults.set deleted file mode 100644 index 1e35c182..00000000 --- a/.ci-local/defaults.set +++ /dev/null @@ -1,6 +0,0 @@ -# EPICS Base -BASE_DIRNAME=base -BASE_REPONAME=epics-base -BASE_REPOOWNER=epics-base -BASE_VARNAME=EPICS_BASE -BASE_RECURSIVE=no diff --git a/.github/workflows/ci-scripts-build.yml b/.github/workflows/ci-scripts-build.yml deleted file mode 100644 index 85320341..00000000 --- a/.github/workflows/ci-scripts-build.yml +++ /dev/null @@ -1,158 +0,0 @@ -# .github/workflows/ci-scripts-build.yml for use with EPICS Base ci-scripts -# (see: https://github.com/epics-base/ci-scripts) - -# This is YAML - indentation levels are crucial - -# Set the 'name:' properties to values that work for you (pvxs) - -name: recsync - -# Trigger on pushes and PRs to any branch -on: - push: - paths: - - client/** - - .github/workflows/ci-scripts-build.yml - pull_request: - paths: - - client/** - - .github/workflows/ci-scripts-build.yml - -env: - SETUP_PATH: .ci-local:.ci - EPICS_TEST_IMPRECISE_TIMING: YES - -jobs: - - build-linux: - defaults: - run: - working-directory: client - name: ${{ matrix.cmp }} / ${{ matrix.configuration }} / ${{ matrix.os }} - runs-on: ${{ matrix.os }} - env: - CMP: ${{ matrix.cmp }} - BCFG: ${{ matrix.configuration }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-24.04, ubuntu-22.04] - cmp: [gcc, clang] - configuration: [default, static, debug, static-debug] - steps: - - uses: actions/checkout@v6 - with: - submodules: true - - name: Prepare and compile dependencies - run: python .ci/cue.py prepare - - name: Build main module (example app) - run: python .ci/cue.py build - - name: Run main module tests - run: python .ci/cue.py -T 15M test - - name: Collect and show test results - run: python .ci/cue.py test-results - - build-macos: - defaults: - run: - working-directory: client - name: ${{ matrix.cmp }} / ${{ matrix.configuration }} / ${{ matrix.os }} - runs-on: ${{ matrix.os }} - env: - CMP: ${{ matrix.cmp }} - BCFG: ${{ matrix.configuration }} - strategy: - fail-fast: false - matrix: - os: [macos-15, macos-14, macos-13] - cmp: [clang] - configuration: [default, debug] - steps: - - uses: actions/checkout@v6 - with: - submodules: true - - name: Prepare and compile dependencies - run: python .ci/cue.py prepare - - name: Build main module (example app) - run: python .ci/cue.py build - - name: Run main module tests - run: python .ci/cue.py -T 15M test - - name: Collect and show test results - run: python .ci/cue.py test-results - - build-windows: - defaults: - run: - working-directory: client - name: ${{ matrix.cmp }} / ${{ matrix.configuration }} / ${{ matrix.os }} - runs-on: ${{ matrix.os }} - env: - CMP: ${{ matrix.cmp }} - BCFG: ${{ matrix.configuration }} - strategy: - fail-fast: false - matrix: - os: [windows-2022, windows-2025] - cmp: [gcc, vs2022] - configuration: [default, static, debug, static-debug] - # TODO: Remove this exclusion once ci-scripts supports windows-2025-vs2026 with - # CMP=vs2022: https://github.com/epics-base/ci-scripts/issues/112 - exclude: - - os: windows-2025 - cmp: vs2022 - steps: - - uses: actions/checkout@v6 - with: - submodules: true - - name: Prepare and compile dependencies - run: python .ci/cue.py prepare - - name: Build main module (example app) - run: python .ci/cue.py build - - name: Run main module tests - run: python .ci/cue.py -T 15M test - - name: Collect and show test results - run: python .ci/cue.py test-results - - build-cross: - defaults: - run: - working-directory: client - name: cross ${{ matrix.cross }} / ${{ matrix.cmp }} / ${{ matrix.configuration }} - runs-on: ubuntu-latest - env: - CMP: gcc - BCFG: default - CI_CROSS_TARGETS: ${{ matrix.cross }} - TEST: ${{ matrix.test }} - APT: re2c - strategy: - fail-fast: false - matrix: - # configuration: [default, static, debug, static-debug] - configuration: [default] - cross: - - linux-aarch64 - - linux-arm@arm-linux-gnueabi - - linux-arm@arm-linux-gnueabihf - - linux-ppc - - linux-ppc64 - - win32-x86-mingw - - windows-x64-mingw - - RTEMS-pc386-qemu@4.9 - - RTEMS-pc386-qemu@4.10 - - RTEMS-pc686-qemu@5 - include: - - cross: RTEMS-pc386-qemu@4.10 - test: NO - steps: - - uses: actions/checkout@v6 - with: - submodules: true - - name: Prepare and compile dependencies - run: python .ci/cue.py prepare - - name: Build main module (example app) - run: python .ci/cue.py build - - name: Run main module tests - run: python .ci/cue.py -T 15M test - - name: Collect and show test results - run: python .ci/cue.py test-results diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 7e141dcc..00000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule ".ci"] - path = client/.ci - url = https://github.com/epics-base/ci-scripts.git diff --git a/README.md b/README.md index 8a7a2066..49ace25f 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ RecSync ======= The record synchronizer project includes two parts. -A client ([RecCaster](./client/README.md)) which runing as part of an EPICS -IOC, and a server ([RecCeiver](./server/README.md)) which is a stand alone -daemon. Together they work to ensure the the server(s) +A client [RecCaster](https://github.com/ChannelFinder/reccaster) which runing +as part of an EPICS IOC, and a server ([RecCeiver](./server/README.md)) +which is a stand alone daemon. Together they work to ensure the the server(s) have a complete list of all records currently provided by the client IOCs. @@ -20,17 +20,6 @@ about its Process Database. * Any info() tags associated with these records * Any additional environment variables specified in addReccasterEnvVars iocsh calls -RecCaster Usage ---------------- - -The RecCaster source in the `client/` sub-directory -is build as an EPICS support module. -It provides `reccaster.dbd` and the `reccaster` library. -The client demo IOC in `client/demoApp/` provides -an example of how to build RecCaster into an IOC. - -RecCaster requires only EPICS Base 3.15 and later 3.14 releases. - RecCeiver Usage --------------- diff --git a/client/.ci b/client/.ci deleted file mode 160000 index fbbfced9..00000000 --- a/client/.ci +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fbbfced900b5e87de9a176a68c40b8cafa3e8e01 diff --git a/client/.dockerignore b/client/.dockerignore deleted file mode 100644 index 44d0fd3a..00000000 --- a/client/.dockerignore +++ /dev/null @@ -1,16 +0,0 @@ -O.* -bin -lib -dbd -envPaths -dropin.cache - -*.pyc -*.pyo -*.log -*.pid -configure/*.local - -*~ -.*.swp -.ci diff --git a/client/.gitignore b/client/.gitignore deleted file mode 100644 index e40a2389..00000000 --- a/client/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -O.*/ -bin/ -lib/ -include/ -envPaths - -configure/*.local - -dbd/ -db/ - - -.iocsh_history diff --git a/client/Dockerfile b/client/Dockerfile deleted file mode 100644 index 5baf8c9e..00000000 --- a/client/Dockerfile +++ /dev/null @@ -1,58 +0,0 @@ -# Download Epics -FROM --platform=$BUILDPLATFORM debian:bookworm-slim AS epics-download-extract -SHELL ["/bin/bash", "-c"] -RUN apt-get update && apt-get install -yq wget git -WORKDIR /var/cache -ARG EPICSVERSION=7.0.9 -RUN wget -q --show-progress https://epics-controls.org/download/base/base-$EPICSVERSION.tar.gz \ -&& mkdir /epics/ \ -&& tar -xf base-$EPICSVERSION.tar.gz -C /epics \ -&& rm base-$EPICSVERSION.tar.gz - -FROM --platform=$BUILDPLATFORM debian:bookworm-slim AS base - -FROM base AS base-amd64 -ENV EPICS_HOST_ARCH=linux-x86_64 - -FROM base AS base-386 -ENV EPICS_HOST_ARCH=linux-x86 - -FROM base AS base-arm64 -ENV EPICS_HOST_ARCH=linux-arm - -FROM base AS base-arm -ENV EPICS_HOST_ARCH=linux-arm - -# Now finally choose the right base image: -FROM base-$TARGETARCH AS build-epics -SHELL ["/bin/bash", "-c"] -ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update \ - && apt-get install --no-install-recommends -yq \ - build-essential \ - ca-certificates \ - curl \ - libreadline-dev \ - telnet \ - && apt-get clean && rm -rf /var/lib/apt/lists/* && rm -rf /var/cache/apt - -WORKDIR /epics -COPY --from=epics-download-extract /epics /epics -ARG EPICSVERSION=7.0.9 -RUN mv base-$EPICSVERSION base -RUN cd base && make -j$(nproc) - -FROM build-epics AS recsync-base - -WORKDIR /recsync -COPY . /recsync/ -RUN mv docker/RELEASE.local configure/RELEASE.local -ENV EPICS_ROOT=/epics -ENV EPICS_BASE=${EPICS_ROOT}/base -RUN make - -FROM recsync-base AS ioc-runner - -WORKDIR /recsync/bin/${EPICS_HOST_ARCH} - -CMD ./demo /recsync/iocBoot/iocdemo/st.cmd diff --git a/client/Makefile b/client/Makefile deleted file mode 100644 index 23379e68..00000000 --- a/client/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -#Makefile at top of application tree -TOP = . -include $(TOP)/configure/CONFIG -DIRS := $(DIRS) configure -DIRS := $(DIRS) castApp -ifneq ($(SKIPDEMO),YES) -DIRS := $(DIRS) demoApp -endif -DIRS := $(DIRS) iocBoot - -define DIR_template - $(1)_DEPEND_DIRS = configure -endef -$(foreach dir, $(filter-out configure,$(DIRS)),$(eval $(call DIR_template,$(dir)))) - -iocBoot_DEPEND_DIRS += $(filter %App,$(DIRS)) -demoApp_DEPEND_DIRS += castApp - -include $(TOP)/configure/RULES_TOP diff --git a/client/README.md b/client/README.md deleted file mode 100644 index 44d8e654..00000000 --- a/client/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# Reccaster - -Reccaster is an EPICS module to facilitate the communication between IOCs and [recceiver](../server). Before `iocInit`, reccaster will publish all records and their metadata to recceiver. - -## IOC Shell Functions and Variables - -See the demo [st.cmd](iocBoot/iocdemo/st.cmd) for examples of configuring each of these optional settings. - -### addReccasterExcludePattern - -addReccasterExcludePattern allows you to exclude PVs from being sent by reccaster via wildcard patterns. It must be called before `iocInit`. - -You can specify multiple exclusion patterns: - -``` -addReccasterExcludePattern("*_") -addReccasterExcludePattern("*:Internal:*") -``` - -Adding this call to your st.cmd would disable all PVs from being sent to recceiver: - -``` -addReccasterExcludePattern("*") -``` - -### addReccasterEnvVars - -addReccasterEnvVars allows you to specify extra environment variables to send along with each PV. It must be called before `iocInit`. - -For example, you might define which building an IOC is in via `epicsEnvSet("BUILDING", "MyBuilding")`. You can then include this in reccaster by adding this in your st.cmd: - -``` -addReccasterEnvVars("BUILDING") -``` - -Note: There is a list of common environment variables that are sent by default. They are defined in [dbcb.c](castApp/src/dbcb.c). - -### reccastTimeout - -The reccastTimeout variable allows you to customize the timeout duration (in seconds) for the TCP socket connection. Once a connection is established and the TCP phase is complete, this timeout is increased by a factor of 4 for the periodic ping messages. - -The default value is 20 seconds and this can be changed in your st.cmd: - -``` -var(reccastTimeout, 5.0) -``` - -### reccastMaxHoldoff - -reccastMaxHoldoff sets the upper limit in seconds on how long to delay between a successful UDP search and starting the TCP phase of the reccaster protocol. There is some randomness added to the holdoff time to prevent all IOC instances from starting the TCP phase at the same time (in the event of restarting recceiver or restarting many IOCs). - -The default value is 10 seconds. - -``` -var(reccastMaxHoldoff, 5.0) -``` diff --git a/client/castApp/Db/Makefile b/client/castApp/Db/Makefile deleted file mode 100644 index 5a4fd677..00000000 --- a/client/castApp/Db/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -TOP=../.. -include $(TOP)/configure/CONFIG -#---------------------------------------- -# ADD MACRO DEFINITIONS AFTER THIS LINE - -DB += reccaster.db - -include $(TOP)/configure/RULES -#---------------------------------------- -# ADD RULES AFTER THIS LINE diff --git a/client/castApp/Db/reccaster.db b/client/castApp/Db/reccaster.db deleted file mode 100644 index 86985a07..00000000 --- a/client/castApp/Db/reccaster.db +++ /dev/null @@ -1,17 +0,0 @@ -record(mbbi, "$(P)State-Sts") { - field(DTYP, "RecCaster") - field(PINI, "RUNNING") - field(SCAN, "I/O Intr") - - field(ZRST, "Init") - field(ONST, "Listening") - field(TWST, "Connecting") - field(THST, "Uploading") - field(FRST, "Done") -} - -record(stringin, "$(P)Msg-I") { - field(DTYP, "RecCaster") - field(PINI, "RUNNING") - field(SCAN, "I/O Intr") -} diff --git a/client/castApp/Makefile b/client/castApp/Makefile deleted file mode 100644 index ab15bfb1..00000000 --- a/client/castApp/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -TOP = .. -include $(TOP)/configure/CONFIG -DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *src*)) -DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *Src*)) -DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *db*)) -DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *Db*)) -include $(TOP)/configure/RULES_DIRS diff --git a/client/castApp/src/Makefile b/client/castApp/src/Makefile deleted file mode 100644 index 5ecc4316..00000000 --- a/client/castApp/src/Makefile +++ /dev/null @@ -1,76 +0,0 @@ -TOP=../.. - -include $(TOP)/configure/CONFIG -#---------------------------------------- -# ADD MACRO DEFINITIONS AFTER THIS LINE -#============================= - -LIBRARY_IOC = reccaster - -# Will increment with ABI changes -SHRLIB_VERSION = 0 - -PROD_SYS_LIBS_WIN32 = iphlpapi netapi32 ws2_32 -LIB_SYS_LIBS_WIN32 = iphlpapi netapi32 ws2_32 - -reccaster_SRCS += sockhelpers.c -reccaster_SRCS += caster.c -reccaster_SRCS += castudp.c -reccaster_SRCS += casttcp.c -reccaster_SRCS += castinit.c -reccaster_SRCS += dbcb.c - -reccaster_SYS_LIBS_WIN32 += ws2_32 -reccaster_LIBS += $(EPICS_BASE_IOC_LIBS) - -DBD += reccaster.dbd - -PROD_LIBS += reccaster -PROD_LIBS += $(EPICS_BASE_IOC_LIBS) - -TESTPROD_HOST += testsock -testsock_SRCS += testsock.c -testsock_SYS_LIBS_WIN32 = ws2_32 -TESTS += testsock - -TESTPROD_HOST += testudp -testudp_SRCS += testudp.c -testudp_SYS_LIBS_WIN32 = ws2_32 -TESTS += testudp - -TESTPROD_HOST += testtcp -testtcp_SRCS += testtcp.c -testtcp_SYS_LIBS_WIN32 = ws2_32 -TESTS += testtcp - -TESTPROD_HOST += testAddEnvVars -testAddEnvVars_SRCS += testAddEnvVars.c -testAddEnvVars_SRCS += dbcb.c -testAddEnvVars_SYS_LIBS_WIN32 = ws2_32 -TESTS += testAddEnvVars - -TESTPROD_HOST += testAddExcludePattern -testAddExcludePattern_SRCS += testAddExcludePattern.c -testAddExcludePattern_SYS_LIBS_WIN32 = ws2_32 -TESTS += testAddExcludePattern - -TESTSCRIPTS_HOST += $(TESTS:%=%.t) -ifneq ($(filter $(T_A),$(CROSS_COMPILER_RUNTEST_ARCHS)),) -TESTPROD = $(TESTPROD_HOST) -TESTSCRIPTS += $(TESTSCRIPTS_HOST) -endif - -#=========================== - -include $(TOP)/configure/RULES -#---------------------------------------- -# ADD RULES AFTER THIS LINE - -ifdef T_A -.PHONY: help -help: - @echo "In $$PWD" - @echo "TESTS: $(TESTS)" - @echo "TESTSCRIPTS_HOST: $(TESTSCRIPTS_HOST)" - @echo "TESTSCRIPTS: $(TESTSCRIPTS)" -endif diff --git a/client/castApp/src/castMain.cpp b/client/castApp/src/castMain.cpp deleted file mode 100644 index 918fa9c1..00000000 --- a/client/castApp/src/castMain.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* castMain.cpp */ -/* Author: Marty Kraimer Date: 17MAR2000 */ - -#include -#include -#include -#include -#include - -#include "epicsExit.h" -#include "epicsThread.h" -#include "iocsh.h" - -int main(int argc,char *argv[]) -{ - if(argc>=2) { - iocsh(argv[1]); - epicsThreadSleep(.2); - } - iocsh(NULL); - epicsExit(0); - return(0); -} diff --git a/client/castApp/src/caster.c b/client/castApp/src/caster.c deleted file mode 100644 index a84395b0..00000000 --- a/client/castApp/src/caster.c +++ /dev/null @@ -1,332 +0,0 @@ - -#include -#include -#include - -#include -#include -#include -#include - -#define epicsExportSharedSymbols - -#include "caster.h" - -#ifdef STATIC_ASSERT -STATIC_ASSERT(sizeof(casterAnnounce)==0x10); -STATIC_ASSERT(sizeof(casterHeader)==8); -#else -# warning Base version does not provide STATIC_ASSERT. Skipping checks. -#endif - -epicsShareDef double reccastTimeout = 20.0; -epicsShareDef double reccastMaxHoldoff = 10.0; - -static void casterThread(void* junk) -{ - caster_t *self=junk; - - casterMsg(self, "Starting"); - - while(1) { - int shutdown; - epicsMutexMustLock(self->lock); - shutdown = self->shutdown; - epicsMutexUnlock(self->lock); - - if(shutdown) - break; - - self->timeout = reccastTimeout; - - if(self->errors>10) - self->errors=10; - if(self->errors) - epicsThreadSleep(self->errors*5.0); - - self->errors++; /* be pessemistic */ - - self->current = casterStateListen; - casterMsg(self, "Searching"); - - - if(doCasterUDPPhase(self)) - continue; - - casterMsg(self, "Found server"); - - /* random holdoff */ - { - int result; - shSocket junk; - double holdoff = reccastMaxHoldoff*rand()/RAND_MAX; - - if(holdoff>2.0) - casterMsg(self, "connect hold-off %f", holdoff); - - shSocketInit(&junk); - shSetTimeout(&junk, holdoff); - junk.wakeup = self->wakeup[1]; - - result = shWaitFor(&junk, 0, 0); - if(result!=-1 && SOCKERRNO!=SOCK_ETIMEDOUT) { - casterMsg(self, "holdoff error"); - continue; - } - } - - self->current = casterStateConnect; - if(self->haveserv) { - char abuf[80]; - sockAddrToA(&self->nameserv.sa, abuf, sizeof(abuf)); - casterMsg(self, "Connecting to: %s", abuf); - } - - if(!doCasterTCPPhase(self)) - self->errors = 0; - - self->current = casterStateListen; - if(self->haveserv) { - char abuf[80]; - sockAddrToA(&self->nameserv.sa, abuf, sizeof(abuf)); - casterMsg(self, "Lost server: %s", abuf); - } - } - - casterMsg(self, "Stopping"); - - epicsEventSignal(self->shutdownEvent); -} - -static -void casterShowMsgDefault(void* arg, struct _caster_t* self) -{ - errlogPrintf("%s\n", self->lastmsg); -} - -void casterInit(caster_t *self) -{ - memset(self, 0, sizeof(*self)); - self->udpport = RECAST_PORT; - self->shutdownEvent = epicsEventMustCreate(epicsEventEmpty); - self->lock = epicsMutexMustCreate(); - self->nextRecID = 1; - self->onmsg = &casterShowMsgDefault; - self->current = casterStateInit; - self->timeout = reccastTimeout; - ellInit(&self->envs); - ellInit(&self->exclude_patterns); - - /* add default_envs to envs list which can be expanded by the user with addReccasterEnvVars iocsh function */ - addToReccasterLinkedList(self, default_envs_count, default_envs, &self->envs, "casterInit", "Default environment variable"); - - if(shSocketPair(self->wakeup)) - errlogPrintf("Error: casterInit failed to create shutdown socket: %d\n", SOCKERRNO); -} - -void casterShutdown(caster_t *self) -{ - epicsUInt32 junk = htonl(0xdeadbeef); - - epicsMutexMustLock(self->lock); - self->shutdown = 1; - epicsMutexUnlock(self->lock); - - if(sizeof(junk)!=send(self->wakeup[0], (char*)&junk, sizeof(junk), 0)) { - errlogPrintf("Warning: casterShutdown notification failed. Skipping."); - return; - } - - epicsEventMustWait(self->shutdownEvent); - - epicsMutexMustLock(self->lock); - ellFree(&self->envs); - ellFree(&self->exclude_patterns); - epicsMutexUnlock(self->lock); - - epicsEventDestroy(self->shutdownEvent); - self->shutdownEvent = NULL; - if (self->wakeup[0] != INVALID_SOCKET) { - epicsSocketDestroy(self->wakeup[0]); - } - if (self->wakeup[1] != INVALID_SOCKET) { - epicsSocketDestroy(self->wakeup[1]); - } - epicsMutexDestroy(self->lock); -} - -int casterStart(caster_t *self) -{ - epicsThreadId id; - if(self->wakeup[0]==INVALID_SOCKET) { - /* casterInit() failed */ - return 2; - } - id = epicsThreadCreate("reccaster", - epicsThreadPriorityMedium, - epicsThreadGetStackSize(epicsThreadStackSmall), - &casterThread, self); - return !id; -} - - -void casterMsg(caster_t *self, const char* msg, ...) -{ - int ret; - va_list args; - - va_start(args, msg); - ret = epicsVsnprintf(self->lastmsg, sizeof(self->lastmsg), msg, args); - va_end(args); - - if(ret<0) { - errlogMessage("casterMsg failed\n"); - return; - } - - self->lastmsg[sizeof(self->lastmsg)-1] = '\0'; - - (*self->onmsg)(self->arg, self); -} - -static -ssize_t casterSendRA(caster_t* self, epicsUInt8 type, size_t rid, const char* rtype, const char* rname) -{ - union casterTCPBody buf; - epicsUInt32 blen = sizeof(buf.c_add); - size_t lt=rtype ? strlen(rtype) : 0, ln=strlen(rname); - - buf.c_add.rid = htonl(rid); - buf.c_add.rtype = type; - buf.c_add.rtlen = lt; - buf.c_add.rnlen = htons(ln); - - blen += lt + ln; - - if(casterSendPHead(self->csock, 0x0003, blen)!=1) - return -1; - - if(shSendAll(self->csock, &buf.bytes, sizeof(buf.c_add), 0)!=1) - return -1; - - if(rtype && shSendAll(self->csock, rtype, lt, 0)!=1) - return -1; - - if(shSendAll(self->csock, rname, ln, 0)!=1) - return -1; - - return 0; -} - -ssize_t casterSendRecord(caster_t* self, const char* rtype, const char* rname) -{ - size_t rid; - - if(self->nextRecID<0) - return -1; - - rid = self->nextRecID++; - - if(casterSendRA(self, 0, rid, rtype, rname)) - return -1; - return rid; -} - -ssize_t casterSendAlias(caster_t* self, size_t rid, const char* rname) -{ - return casterSendRA(self, 1, rid, NULL, rname); -} - -int casterSendInfo(caster_t *self, ssize_t rid, const char* name, const char* val) -{ - union casterTCPBody buf; - epicsUInt32 blen = sizeof(buf.c_info); - size_t ln=strlen(name), lv=strlen(val); - - if(rid<0) - return -1; - - buf.c_info.rid = htonl(rid); - buf.c_info.klen = ln; - buf.c_info.reserved = 0; - buf.c_info.vlen = htons(lv); - - blen += ln + lv; - - if(casterSendPHead(self->csock, 0x0006, blen)!=1) - return -1; - - if(shSendAll(self->csock, &buf.bytes, sizeof(buf.c_info), 0)!=1) - return -1; - - if(shSendAll(self->csock, name, ln, 0)!=1) - return -1; - - if(shSendAll(self->csock, val, lv, 0)!=1) - return -1; - - return 0; -} - -int casterRecvPHead(shSocket *s, epicsUInt16* id, epicsUInt32* len, int flags) -{ - int ret; - union casterTCPHead hbuf; - - ret = shRecvExact(s, &hbuf.m_bytes, sizeof(hbuf.m_bytes), flags); - if(ret!=sizeof(hbuf.m_bytes)) - return ret; - - if(ntohs(hbuf.m_msg.pid) != RECAST_MAGIC) - return -1; - - *id = ntohs(hbuf.m_msg.msgid); - - *len = ntohl(hbuf.m_msg.bodylen); - - return 1; -} - -ssize_t casterRecvPMsg(shSocket* s, epicsUInt16* id, - void *buf, size_t len, int flags) -{ - union casterTCPHead hbuf; - ssize_t ret, blen, rlen; - - ret = shRecvExact(s, &hbuf.m_bytes, sizeof(hbuf.m_bytes), flags); - if(ret!=sizeof(hbuf.m_bytes)) - return ret; - - if(ntohs(hbuf.m_msg.pid) != RECAST_MAGIC) - return -1; - - *id = ntohs(hbuf.m_msg.msgid); - - blen = ntohl(hbuf.m_msg.bodylen); - if(blen<0) - return -1; /* overflow */ - - ret = shRecvExact(s, buf, blen>len ?len :blen, flags); - if(ret<=0) - return -1; - rlen = ret; - - if(blen>len) { - ret = shRecvIgnore(s, blen-len, flags); - if(ret<=0) - return -1; - } - - return rlen; -} - -int casterSendPHead(shSocket* s, epicsUInt16 id, epicsInt32 blen) -{ - union casterTCPHead buf; - - buf.m_msg.pid = htons(RECAST_MAGIC); - buf.m_msg.msgid = htons(id); - buf.m_msg.bodylen = htonl(blen); - - return shSendAll(s, buf.m_bytes, sizeof(buf.m_msg), 0); -} diff --git a/client/castApp/src/caster.h b/client/castApp/src/caster.h deleted file mode 100644 index de5b7514..00000000 --- a/client/castApp/src/caster.h +++ /dev/null @@ -1,243 +0,0 @@ -#ifndef CASTER_H -#define CASTER_H - -#if defined(_MSC_VER) - #include - #include - typedef SSIZE_T ssize_t; -#endif - -#include -#include -#include -#include -#include -#include - -#include "sockhelpers.h" - -#define RECAST_PORT 5049 - -epicsShareExtern double reccastTimeout; -epicsShareExtern double reccastMaxHoldoff; - -extern const char* default_envs[]; -extern const size_t default_envs_count; - -typedef enum { - casterUDPSetup, - casterTCPSetup, -} caster_h; - -typedef enum { - casterStateInit, - casterStateListen, - casterStateConnect, - casterStateUpload, - casterStateDone, -} casterState; - -typedef struct { - ELLNODE node; - char *item_str; -} string_list_t; - -typedef struct _caster_t { - double timeout; - - unsigned short udpport; - - ssize_t nextRecID; - shSocket *csock; - - /* doCaster*Phase() listens on [1] */ - SOCKET wakeup[2]; - - int errors; - epicsEventId shutdownEvent; - - int haveserv; - osiSockAddr nameserv; - epicsUInt32 servkey; - - /* overwritable hook functions */ - void (*testhook)(struct _caster_t*, caster_h); - - void *arg; - int (*getrecords)(void*, struct _caster_t*); - void (*onmsg)(void*, struct _caster_t*); - - casterState current; - - /* lock for message and shutdown flags */ - epicsMutexId lock; - - int shutdown; - char lastmsg[MAX_STRING_SIZE]; - - ELLLIST envs; - ELLLIST exclude_patterns; - -} caster_t; - -epicsShareFunc -void casterMsg(caster_t *self, const char* msg, ...) EPICS_PRINTF_STYLE(2,3); - -#define ERRTO(TAG, CASTER, ...) do{ casterMsg(CASTER, __VA_ARGS__); goto TAG; }while(0) - -#define ERRRET(VAL, CASTER, ...) do{ casterMsg(CASTER, __VA_ARGS__); return (VAL); }while(0) - -epicsShareFunc -void casterInit(caster_t *self); -epicsShareFunc -void casterShutdown(caster_t *self); -epicsShareFunc -int casterStart(caster_t *self); - -epicsShareFunc -ssize_t casterSendRecord(caster_t* c, const char* rtype, const char* rname); -epicsShareFunc -ssize_t casterSendAlias(caster_t* c, size_t rid, const char* rname); -epicsShareFunc -int casterSendInfo(caster_t *c, ssize_t rid, const char* name, const char* val); - -/* push process database information */ -epicsShareFunc -int casterPushPDB(void *junk, caster_t *caster); - -epicsShareFunc -int addToReccasterLinkedList(caster_t* self, size_t itemCount, const char **items, ELLLIST* reccastList, const char* funcName, const char* itemDesc); - -epicsShareFunc -int addReccasterEnvVars(caster_t* self, int argc, char **argv); - -epicsShareFunc -int addReccasterExcludePattern(caster_t* self, int argc, char **argv); - -/* internal */ - -epicsShareFunc -int doCasterUDPPhase(caster_t *self); -epicsShareFunc -int doCasterTCPPhase(caster_t *self); - -/* recv() a TCP protocol message. - * Message id is stored in *id. - * returns the number of body bytes stored in the buffer. - * If a message w/ zero body length is recieved this - * is reported as a disconnect. - * - * Unless MSG_PARTIAL is given, message bodies too long - * to find in the provided buffer will trigger an error. - */ -epicsShareFunc -ssize_t casterRecvPMsg(shSocket* s, epicsUInt16* id, - void *buf, size_t len, int flags); - -/* recv() a TCP protocol header. - * - * returns 1 on success, 0 when connection is lost, and -1 on error - */ -epicsShareFunc -int casterRecvPHead(shSocket *s, epicsUInt16* id, epicsUInt32* len, int flags); - -epicsShareFunc -int casterSendPHead(shSocket* s, epicsUInt16 id, epicsInt32 blen); - -#define RECAST_MAGIC 0x5243 /* 'RC' */ - -/* UDP server advertisement message - * - * | 0 | 1 | 2 | 3 | - * 00 | ID | 0 | X | - * 04 | SERV ADDR | - * 08 | PORT | X | X | - * 0C | SERV KEY | - * 10 | ignore... - */ -typedef struct { - epicsUInt16 pid; /* protocol ID RECAST_MAGIC */ - epicsUInt8 version; /* must be 0 */ - epicsUInt8 reserved0; - epicsUInt32 serverIP; - epicsUInt16 serverPort; - epicsUInt16 reserved1; - epicsUInt32 serverKey; -} casterAnnounce; - -union casterUDP { - casterAnnounce m_msg; - char m_bytes[sizeof(casterAnnounce)]; -}; - -/* TCP message header - * - * | 0 | 1 | 2 | 3 | - * 00 | PID | MSGID | - * 04 | body length | - * 08 | body bytes... - */ -typedef struct { - epicsUInt16 pid; /* protocol ID RECAST_MAGIC */ - epicsUInt16 msgid; - epicsUInt32 bodylen; -} casterHeader; - -union casterTCPHead { - casterHeader m_msg; - char m_bytes[sizeof(casterHeader)]; -}; - -/* server messages */ -typedef struct { - epicsUInt8 version; -} casterServerGreet; /* 0x8001 */ - -typedef struct { - epicsUInt32 nonce; -} casterPing; /* 0x8002 and 0x0002 */ - -/* client messages */ -typedef struct { - epicsUInt8 version; - epicsUInt8 type; /* 0 - static, 1 - dynamic, >127 - Site specific */ - epicsUInt8 reserved[2]; - epicsUInt32 serverKey; -} casterClientGreet; /* 0x0001 */ - -typedef struct { - epicsUInt32 rid; /* record instance id */ - epicsUInt8 rtype; /* 0 - IOC Rec, 1 - IOC Alias */ - epicsUInt8 rtlen; /* # of bytes in record type name (0 for aliases) */ - epicsUInt16 rnlen; /* # of bytes in record instance name */ - /* record type and instance names follow */ -} casterClientAddRec; /* 0x0003 */ - -typedef struct { - epicsUInt32 rid; /* record instance id */ -} casterClientDelRec; /* 0x0004 */ - -/* casterClientDone 0x0005 dummy 4 byte payload */ - -typedef struct { - epicsUInt32 rid; /* record instance id */ - epicsUInt8 klen; /* # of bytes in record type name */ - epicsUInt8 reserved; - epicsUInt16 vlen; /* # of bytes in record instance name */ - /* key and value strings follow */ -} casterClientAddInfo; /* 0x0006 */ - -union casterTCPBody { - casterServerGreet s_greet; - casterPing ping; - - casterClientGreet c_greet; - casterClientAddRec c_add; - casterClientDelRec c_del; - casterClientAddInfo c_info; - - char bytes[sizeof(casterClientAddRec)]; -}; - - -#endif // CASTER_H diff --git a/client/castApp/src/castinit.c b/client/castApp/src/castinit.c deleted file mode 100644 index 9b539730..00000000 --- a/client/castApp/src/castinit.c +++ /dev/null @@ -1,326 +0,0 @@ - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#define epicsExportSharedSymbols - -#include "caster.h" - -#ifndef VERSION_INT -# define VERSION_INT(V,R,M,P) ( ((V)<<24) | ((R)<<16) | ((M)<<8) | (P)) -#endif -#ifndef EPICS_VERSION_INT -# define EPICS_VERSION_INT VERSION_INT(EPICS_VERSION, EPICS_REVISION, EPICS_MODIFICATION, EPICS_PATCH_LEVEL) -#endif -#if EPICS_VERSION_INT < VERSION_INT(7,0,3,1) -static int iocshSetError(int err) { return err; } -#endif - -static caster_t thecaster; - -typedef struct { - epicsMutexId lock; - IOSCANPVT scan; - casterState laststate; - osiSockAddr lastserv; - int intraccept; - char lastmsg[MAX_STRING_SIZE]; -} dpriv; - -static dpriv thepriv; - -static -void dsetshowmsg(void* arg, struct _caster_t* self) -{ - epicsMutexMustLock(thepriv.lock); - thepriv.laststate = self->current; - memcpy(&thepriv.lastserv, &self->nameserv, sizeof(self->nameserv)); - strcpy(thepriv.lastmsg, self->lastmsg); - epicsMutexUnlock(thepriv.lock); - if(thepriv.intraccept) - scanIoRequest(thepriv.scan); -} - -static void castexit(void *raw) -{ - casterShutdown(&thecaster); -} - -static void casthook(initHookState state) -{ - if(state==initHookAfterInterruptAccept) - thepriv.intraccept = 1; - - if(state!=initHookAfterIocRunning) - return; - - - thecaster.getrecords = &casterPushPDB; - thecaster.onmsg = &dsetshowmsg; - - if(casterStart(&thecaster)) { - printf("reccaster failed to start...\n"); - return; - } - - epicsAtExit(&castexit, NULL); -} - -/* Helper function to add items from iocsh calls to internal linked lists - * self is the caster instance - * itemCount is the number of items in the items array - * items is the array of strings to add to the list - * reccastList is the linked list to add the items to - * funcName is the name of the IOC shell function being called (for error messages) - * itemDesc is string to describe what is being added (for error messages) - */ -int addToReccasterLinkedList(caster_t* self, size_t itemCount, const char **items, ELLLIST* reccastList, const char* funcName, const char* itemDesc) -{ - size_t i; - int dup; - ELLNODE *cur; - - epicsMutexMustLock(self->lock); - if(self->shutdown) { - /* shutdown in progress, silent no-op */ - epicsMutexUnlock(self->lock); - return 0; - } - else if(self->current != casterStateInit) { - /* Attempt to add after iocInit(), when we may be connected. - To fully support, would need to force reconnect or resend w/ updated list. */ - errlogSevPrintf(errlogMinor, "%s called after iocInit() when reccaster might already be connected. Not supported\n", funcName); - epicsMutexUnlock(self->lock); - return -1; - } - - /* sanitize input - check for dups and empty args */ - for (i = 0; i < itemCount; i++) { - const size_t arg_len = strlen(items[i]) + 1; - if(items[i][0] == '\0') { - errlogSevPrintf(errlogMinor, "Arg is empty for %s\n", funcName); - continue; - } - dup = 0; - /* check if dup in existing linked list */ - for(cur = ellFirst(reccastList); cur; cur = ellNext(cur)) { - string_list_t *pitem = CONTAINER(cur, string_list_t, node); - if (strcmp(items[i], pitem->item_str) == 0) { - dup = 1; - break; - } - } - if(dup) { - errlogSevPrintf(errlogMinor, "%s %s already in list for %s\n", itemDesc, items[i], funcName); - continue; - } - string_list_t *new_node = mallocMustSucceed(sizeof(string_list_t) + arg_len, funcName); - new_node->item_str = (char *)(new_node + 1); - memcpy(new_node->item_str, items[i], arg_len); - - ellAdd(reccastList, &new_node->node); - } - epicsMutexUnlock(self->lock); - return 0; -} - -/* Example call: addReccasterEnvVars("SECTOR") or addReccasterEnvVars("SECTOR", "BUILDING") - * Appends the given env variables to the envs list to be sent. This includes some hard-coded env vars sent by default - */ -int addReccasterEnvVars(caster_t* self, int argc, char **argv) -{ - argv++; argc--; /* skip function arg */ - if(argc < 1) { - errlogSevPrintf(errlogMinor, "At least one argument expected for addReccasterEnvVars\n"); - return -1; - } - return addToReccasterLinkedList(self, argc, (const char **)argv, &self->envs, "addReccasterEnvVars", "Environment variable"); -} - -/* Example call: addReccasterExcludePattern("TEST:*") or addReccasterExcludePattern("TEST:*", "*_") - * Appends the given patterns to the exclude_patterns list so those PVs and their meta-data are not sent - */ -int addReccasterExcludePattern(caster_t* self, int argc, char **argv) -{ - argv++; argc--; /* skip function arg */ - if(argc < 1) { - errlogSevPrintf(errlogMinor, "At least one argument expected for addReccasterExcludePattern\n"); - return -1; - } - return addToReccasterLinkedList(self, argc, (const char **)argv, &self->exclude_patterns, "addReccasterExcludePattern", "Exclude pattern"); -} - -static const iocshArg addReccasterEnvVarsArg0 = { "environmentVar", iocshArgArgv }; -static const iocshArg * const addReccasterEnvVarsArgs[] = { &addReccasterEnvVarsArg0 }; -static const iocshFuncDef addReccasterEnvVarsFuncDef = { - "addReccasterEnvVars", - 1, - addReccasterEnvVarsArgs, -#ifdef IOCSHFUNCDEF_HAS_USAGE - "Reccaster has a default list of environment variables it sends on IOC startup.\n" - "This function will append extra variables to that default list.\n" - "Must be called before iocInit\n" - "Example: addReccasterEnvVars 'SECTOR' 'BUILDING'\n" -#endif -}; -static void addReccasterEnvVarsCallFunc(const iocshArgBuf *args) -{ - iocshSetError(addReccasterEnvVars(&thecaster, args[0].aval.ac, args[0].aval.av)); -} - -static const iocshArg addReccasterExcludePatternArg0 = { "excludePattern", iocshArgArgv }; -static const iocshArg * const addReccasterExcludePatternArgs[] = { &addReccasterExcludePatternArg0 }; -static const iocshFuncDef addReccasterExcludePatternFuncDef = { - "addReccasterExcludePattern", - 1, - addReccasterExcludePatternArgs, -#ifdef IOCSHFUNCDEF_HAS_USAGE - "By default, reccaster will send all PVs on IOC startup.\n" - "This function allows you to exclude PVs by specifying patterns to exclude.\n" - "Must be called before iocInit\n" - "Example: addReccasterExcludePattern 'TEST:*' '*_'\n" -#endif -}; -static void addReccasterExcludePatternCallFunc(const iocshArgBuf *args) -{ - iocshSetError(addReccasterExcludePattern(&thecaster, args[0].aval.ac, args[0].aval.av)); -} - -static void reccasterRegistrar(void) -{ - osiSockAttach(); - initHookRegister(&casthook); - casterInit(&thecaster); - thepriv.lock = epicsMutexMustCreate(); - scanIoInit(&thepriv.scan); - thepriv.laststate=casterStateInit; - strcpy(thepriv.lastmsg, "Initializing"); - iocshRegister(&addReccasterEnvVarsFuncDef,addReccasterEnvVarsCallFunc); - iocshRegister(&addReccasterExcludePatternFuncDef,addReccasterExcludePatternCallFunc); -} - -static long drv_report(int lvl) -{ - casterState laststate; - const char * lastname = "UNKNOWN"; - char lastmsg[MAX_STRING_SIZE] = ""; - osiSockAddr lastserv; - - epicsMutexMustLock(thepriv.lock); - switch(laststate = thepriv.laststate) { -#define CASE(NAME) case casterState ## NAME : lastname = #NAME ; break - CASE(Init); - CASE(Listen); - CASE(Connect); - CASE(Upload); - CASE(Done); -#undef CASE - } - memcpy(lastmsg, thepriv.lastmsg, sizeof(thepriv.lastmsg)); - lastmsg[sizeof(lastmsg)-1] = '\0'; - memcpy(&lastserv, &thepriv.lastserv, sizeof(thepriv.lastserv)); - epicsMutexUnlock(thepriv.lock); - - printf(" State: %s\n", lastname); - printf(" Msg: %s\n", lastmsg); - - // reuse char buffer - ipAddrToDottedIP(&lastserv.ia, lastmsg, sizeof(lastmsg)); - lastmsg[sizeof(lastmsg)-1] = '\0'; - - switch(laststate) { - case casterStateConnect: - case casterStateUpload: - case casterStateDone: - printf(" Server: %s\n", lastname); - break; - default: - break; - } - - return 0; -} - -static long init_record(void* prec) -{ - return 0; -} - -static long get_ioint_info(int dir, void *prec, IOSCANPVT *scan) -{ - *scan = thepriv.scan; - return 0; -} - -static long read_mbbi(mbbiRecord *prec) -{ - epicsMutexMustLock(thepriv.lock); - prec->val = thepriv.laststate; - prec->udf = 0; - epicsMutexUnlock(thepriv.lock); - return 2; -} - -static long read_stringin(stringinRecord *prec) -{ - epicsMutexMustLock(thepriv.lock); - strncpy(prec->val, thepriv.lastmsg, sizeof(prec->val)); - prec->val[sizeof(prec->val)-1] = '\0'; - epicsMutexUnlock(thepriv.lock); - return 0; -} - -static drvet drvCaster = { - 2, - (DRVSUPFUN)drv_report, - NULL, -}; - -typedef struct { - dset common; - DEVSUPFUN read; -} dset5; - -#define DSETCOMMON {5, NULL, NULL, (DEVSUPFUN)&init_record, (DEVSUPFUN)&get_ioint_info} - -static dset5 devCasterMBBIState = { - DSETCOMMON, - (DEVSUPFUN)&read_mbbi -}; - -static dset5 devCasterSIMsg = { - DSETCOMMON, - (DEVSUPFUN)&read_stringin -}; - -#include - -epicsExportAddress(double,reccastTimeout); -epicsExportAddress(double,reccastMaxHoldoff); - -epicsExportAddress(dset, devCasterMBBIState); -epicsExportAddress(dset, devCasterSIMsg); - -epicsExportAddress(drvet, drvCaster); - -epicsExportRegistrar(reccasterRegistrar); diff --git a/client/castApp/src/casttcp.c b/client/castApp/src/casttcp.c deleted file mode 100644 index 80f48791..00000000 --- a/client/castApp/src/casttcp.c +++ /dev/null @@ -1,107 +0,0 @@ - -#include - -#include - -#define epicsExportSharedSymbols - -#include "caster.h" - -int doCasterTCPPhase(caster_t *self) -{ - int ret = -1; - shSocket sock; - union casterTCPBody buf; - epicsUInt16 msgid; - ssize_t blen; - - memset(&buf, 0, sizeof(buf)); - - shSocketInit(&sock); - sock.wakeup = self->wakeup[1]; - shSetTimeout(&sock, self->timeout); - - if(!self->haveserv) - return -1; - - sock.sd = shCreateSocket(AF_INET, SOCK_STREAM, 0); - if(sock.sd == INVALID_SOCKET) - ERRRET(-1, self, "Failed to create socket"); - - if(shConnect(&sock, &self->nameserv)) - ERRTO(done, self, "Failed to connect (%d)", (int)SOCKERRNO); - - if(self->testhook) - (*self->testhook)(self, casterTCPSetup); - - /* handshake phase. Send greeting and wait for same */ - buf.c_greet.serverKey = htonl(self->servkey); - - if(casterSendPHead(&sock, 0x0001, sizeof(buf.c_greet))!=1) - ERRTO(done, self, "Failed to send greeting header"); - - if(shSendAll(&sock, &buf.bytes, sizeof(buf.c_greet), 0)!=1) - ERRTO(done, self, "Failed to send greeting body"); - - blen = casterRecvPMsg(&sock, &msgid, &buf.bytes, sizeof(buf.bytes), 0); - if(blen<0) - ERRTO(done, self, "Missing greeting header"); - - if(msgid!=0x8001 || blencsock = &sock; /* set callback socket */ - - self->current = casterStateUpload; - casterMsg(self, "Connected"); - - /* record upload phase. */ - if((*self->getrecords)(self->arg, self)) - ERRTO(done, self, "Error during record upload"); - - buf.ping.nonce = 0; - - if(casterSendPHead(&sock, 0x0005, 4)!=1) - ERRTO(done, self, "Failed to send all done"); - - if(shSendAll(&sock, &buf.bytes, sizeof(buf.ping), 0)!=1) - ERRTO(done, self, "Failed to send all done body"); - - self->current = casterStateDone; - casterMsg(self, "Synchronized"); - - /* longer timeout while we wait for periodic pings */ - shSetTimeout(&sock, self->timeout*4.0); - - while(!self->shutdown) { - int err; - blen = casterRecvPMsg(&sock, &msgid, &buf.bytes, sizeof(buf.bytes), 0); - err = SOCKERRNO; - if(blen==0) - break; /* normal end of connection */ - else if(blen<0 && (err==SOCK_ECONNRESET || err==SOCK_ECONNABORTED)) - ERRTO(done, self, "RecCaster connection closed by peer"); - else if(blen<0 && err==SOCK_ETIMEDOUT) - ERRTO(done, self, "RecCaster server timeout"); - else if(blen<0) - ERRTO(done, self, "Missing ping header"); - - if(msgid!=0x8002) - continue; - - if(blencsock = NULL; - epicsSocketDestroy(sock.sd); - return ret; -} diff --git a/client/castApp/src/castudp.c b/client/castApp/src/castudp.c deleted file mode 100644 index 7f43ce71..00000000 --- a/client/castApp/src/castudp.c +++ /dev/null @@ -1,108 +0,0 @@ - -#include - -#define epicsExportSharedSymbols - -#include "caster.h" - -/* Decode server announcement. - * - * | 0 | 1 | 2 | 3 | - * 00 | ID | 0 | X | - * 04 | SERV ADDR | - * 08 | PORT | X | X | - * 0C | SERV KEY | - * 10 | ignore... - */ -static void haveCandidate(caster_t *self, - casterAnnounce *buf, - osiSockAddr* peer) -{ - if(ntohs(buf->pid) != RECAST_MAGIC) - return; /* not a recast announcement */ - - if(ntohs(buf->version)!=0) - return; /* reserved for later expansion */ - - self->nameserv.ia.sin_family = AF_INET; - if(ntohl(buf->serverIP)==0xffffffff) { - /* direct from the source */ - self->nameserv.ia.sin_addr = peer->ia.sin_addr; - } else { - /* proxied */ - self->nameserv.ia.sin_addr.s_addr = buf->serverIP; - } - self->nameserv.ia.sin_port = buf->serverPort; - - /* ignore TOU16(buf,0xA) */ - - self->servkey = ntohl(buf->serverKey); - - self->haveserv = 1; -} - -int doCasterUDPPhase(caster_t *self) -{ - shSocket sock; /* UDP listener */ - osiSockAddr me, peer; - osiSocklen_t peerlen = sizeof(peer); - int ret = -1; - - self->haveserv = 0; - - shSocketInit(&sock); - - sock.sd = epicsSocketCreate(AF_INET, SOCK_DGRAM, 0); - if(sock.sd==INVALID_SOCKET) { - casterMsg(self,"failed to create udp socket."); - return -1; /* try again */ - } - sock.wakeup = self->wakeup[1]; - - epicsSocketEnableAddressUseForDatagramFanout(sock.sd); - - me.ia.sin_family = AF_INET; - me.ia.sin_addr.s_addr = htonl(INADDR_ANY); - me.ia.sin_port = htons(self->udpport); - - if(bind(sock.sd, &me.sa, sizeof(me))) - ERRTO(done, self,"failed to bind udp socket."); - - if(self->udpport==0) { - osiSocklen_t slen = sizeof(me); - if(getsockname(sock.sd, &me.sa, &slen)) - ERRTO(done, self,"reccaster failed to find udp name\n"); - self->udpport = ntohs(me.ia.sin_port); - } - - if(self->testhook) - (*self->testhook)(self, casterUDPSetup); - - while(!self->haveserv && !self->shutdown) { - union casterUDP buf; - ssize_t ret; - - if(shWaitFor(&sock, SH_CANRX, MSG_NOTIMO)) { - if(SOCKERRNO==SOCK_ETIMEDOUT) - continue; - goto done; - } - - ret = recvfrom(sock.sd, buf.m_bytes, sizeof(buf.m_bytes), 0, - &peer.sa, &peerlen); - if(ret<0) { - if(SOCKERRNO==SOCK_EWOULDBLOCK) - continue; - casterMsg(self, "recaster UDP recv error %d\n", (int)SOCKERRNO); - goto done; - } else if(peerlen -#include -#include -#include - -#include -#include - -#define epicsExportSharedSymbols - -#include "caster.h" - -const char* default_envs[] = -{ - /* automatic (if unset) */ - "HOSTNAME", - - /* from envPaths */ - "EPICS_BASE", - "TOP", - "ARCH", - "IOC", - - /* CA related */ - "EPICS_CA_ADDR_LIST", - "EPICS_CA_AUTO_ADDR_LIST", - "EPICS_CA_MAX_ARRAY_BYTES", - "RSRV_SERVER_PORT", - - /* PVA related */ - "PVAS_SERVER_PORT", - - /* Common */ - "PWD", - "EPICS_HOST_ARCH", - "IOCNAME", - - /* iocStats */ - "ENGINEER", - "LOCATION", - - NULL -}; -const size_t default_envs_count = NELEMENTS(default_envs) - 1; /* exclude NULL */ - -static int pushEnv(caster_t *caster) -{ - ELLNODE *cur; - int ret = 0; - - if(!getenv("HOSTNAME")) { - const size_t blen = 256; - char *buf = calloc(1,blen); - if(buf && gethostname(buf, blen)==0) { - buf[blen-1] = '\0'; /* paranoia */ - epicsEnvSet("HOSTNAME", buf); - } - free(buf); - } - - ret = casterSendInfo(caster, 0, "EPICS_VERSION", EPICS_VERSION_STRING); - if(ret) - ERRRET(ret, caster, "Failed to send epics version"); - - epicsMutexMustLock(caster->lock); - for(cur = ellFirst(&caster->envs); !ret && cur; cur = ellNext(cur)) { - const string_list_t *penvvar = CONTAINER(cur, string_list_t, node); - const char *val = getenv(penvvar->item_str); - if (val && val[0] != '\0') - ret = casterSendInfo(caster, 0, penvvar->item_str, val); - if (ret) - casterMsg(caster, "Error sending env %s", penvvar->item_str); - } - epicsMutexUnlock(caster->lock); - - return ret; -} - -static int pushRecord(caster_t *caster, DBENTRY *pent) -{ - dbCommon *prec = pent->precnode->precord; - ssize_t rid; - ELLNODE *cur; - int ret = 0; - long status; - - if(dbIsAlias(pent)) - return 0; - - for(cur = ellFirst(&caster->exclude_patterns); cur; cur = ellNext(cur)) { - const string_list_t *ppattern = CONTAINER(cur, string_list_t, node); - if(epicsStrGlobMatch(prec->name, ppattern->item_str)) - return 0; - } - - rid = casterSendRecord(caster, prec->rdes->name, prec->name); - if(rid<=0) - return rid; - - if(pent->precnode->flags & DBRN_FLAGS_HASALIAS) { - DBENTRY subent; - - dbCopyEntryContents(pent, &subent); - - for(status = dbFirstRecord(&subent); !ret && !status; - status = dbNextRecord(&subent)) - { - if(dbIsAlias(&subent) && - subent.precnode->precord == prec) - { - ret = casterSendAlias(caster, rid, subent.precnode->recordname); - } - } - - dbFinishEntry(&subent); - } - - for(status=dbFirstInfo(pent); !ret && !status; - status=dbNextInfo(pent)) - { - const char *name = dbGetInfoName(pent), - *val = dbGetInfoString(pent); - - if(val && val[0]!='\0') - ret = casterSendInfo(caster, rid, name, val); - } - - /* send desc as INFO tag */ - const char *name = "recordDesc"; - const char *val= prec->desc; - if(val && val[0]!='\0') - ret = casterSendInfo(caster, rid, name, val); - - return ret; -} - -int casterPushPDB(void *junk, caster_t *caster) -{ - DBENTRY ent; - int ret; - long rtstat, rstat; - - ret = pushEnv(caster); - if(ret) - return ret; - - dbInitEntry(pdbbase, &ent); - - for(rtstat=dbFirstRecordType(&ent); !rtstat; - rtstat=dbNextRecordType(&ent)) - { - for(rstat=dbFirstRecord(&ent); !rstat; - rstat=dbNextRecord(&ent)) - { - ret = pushRecord(caster, &ent); - if(ret) - goto done; - } - } - -done: - dbFinishEntry(&ent); - return ret; -} diff --git a/client/castApp/src/reccaster.dbd b/client/castApp/src/reccaster.dbd deleted file mode 100644 index 3b10b84d..00000000 --- a/client/castApp/src/reccaster.dbd +++ /dev/null @@ -1,6 +0,0 @@ -registrar(reccasterRegistrar) -variable(reccastTimeout,double) -variable(reccastMaxHoldoff,double) -device(mbbi, INST_IO, devCasterMBBIState, "RecCaster") -device(stringin, INST_IO, devCasterSIMsg, "RecCaster") -driver(drvCaster) diff --git a/client/castApp/src/sockhelpers.c b/client/castApp/src/sockhelpers.c deleted file mode 100644 index 773fe487..00000000 --- a/client/castApp/src/sockhelpers.c +++ /dev/null @@ -1,423 +0,0 @@ - -#if defined(_WIN32) && !defined(_WIN32_WINNT) -/* Windows API level default to Vista */ -# define _WIN32_WINNT 0x600 -#endif - -#include - -#include -#include - -#include - -#define epicsExportSharedSymbols - -#include "sockhelpers.h" - -#if (defined(_WIN32_WINNT) && _WIN32_WINNT < 0x600) || defined(vxWorks) || (defined(__rtems__) && !defined(RTEMS_HAS_LIBBSD)) -# define USE_SELECT -#else -# ifndef _WIN32 -# include -# else -# define poll WSAPoll -# ifndef POLLIN -# define POLLIN POLLRDNORM -# define POLLOUT POLLWRNORM -# endif -# endif -# define USE_POLL -#endif - -void shSocketInit(shSocket *s) -{ - s->sd = s->wakeup = INVALID_SOCKET; - s->timeout.tv_sec = s->timeout.tv_usec = 0; -} - -void shSetTimeout(shSocket *s, double val) -{ - struct timeval tv = {0,0}; - - if(val<0.0 || val>=0x7fffffff) - return; /* ignore invalid */ - - else if(val>0.0) { - tv.tv_sec = (epicsUInt32)val; - tv.tv_usec = (epicsUInt32)(1e6*(val-(double)tv.tv_sec)); - } - - s->timeout = tv; -} - -SOCKET shCreateSocket(int domain, int type, int protocol) -{ - SOCKET sd = epicsSocketCreate(domain, type, protocol); - int ret; - osiSockIoctl_t flag; - - if(sd==INVALID_SOCKET) - return sd; - - /* set non-blocking IO */ - flag = 1; - ret = socket_ioctl(sd, FIONBIO, &flag); - - if(ret) { - epicsSocketDestroy(sd); - sd = INVALID_SOCKET; - } - - return sd; -} - -int socketpair_compat(int af, int st, int p, SOCKET sd[2]) -{ - SOCKET listener; - int ret = -1; - osiSockAddr ep[2]; - osiSocklen_t slen = sizeof(ep[0]); - - if(st!=SOCK_STREAM) { - SOCKERRNOSET(SOCK_EINVAL); - return -1; - } - - listener = epicsSocketCreate(AF_INET, SOCK_STREAM, 0); - sd[0] = INVALID_SOCKET; - sd[1] = shCreateSocket(AF_INET, SOCK_STREAM, 0); - - if(listener==INVALID_SOCKET || sd[1]==INVALID_SOCKET) { - SOCKERRNOSET(SOCK_EMFILE); - goto fail; - } - - memset(ep, 0, sizeof(ep)); - ep[0].ia.sin_family = AF_INET; - ep[0].ia.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - - if(bind(listener, &ep[0].sa, sizeof(ep[0]))) - goto fail; - - if(getsockname(listener, &ep[0].sa, &slen)) - goto fail; - - if(listen(listener, 2)) - goto fail; - - /* begin async connect(), which can't possibly succeed before accept() */ - if(connect(sd[1], &ep[0].sa, sizeof(ep[0]))==0) { -#ifdef __rtems__ - /* except for RTEMS, which is special... */ - errno = SOCK_EWOULDBLOCK; -#else - ret = -2; - goto fail; -#endif - } - - if(SOCKERRNO!=SOCK_EINPROGRESS && SOCKERRNO!=SOCK_EWOULDBLOCK) { - ret = -3; - goto fail; - } - - while(1) { - int err; - shSocket atemp; - SOCKET temp; - osiSocklen_t olen = sizeof(err); - - slen = sizeof(ep[1]); - do { - temp = epicsSocketAccept(listener, &ep[1].sa, &slen); - } while(temp==INVALID_SOCKET && SOCKERRNO == SOCK_EINTR); - - if(temp==INVALID_SOCKET) { - if(SOCKERRNO == SOCK_EWOULDBLOCK) - continue; - goto fail; - } - - shSocketInit(&atemp); - atemp.sd = sd[1]; - - if(shWaitFor(&atemp, SH_CANTX, 0)) { - /* someone raced us and won... */ - epicsSocketDestroy(temp); - continue; - } - - if(getsockopt(sd[1], SOL_SOCKET, SO_ERROR, (char*)&err, &olen)) { - ret = -4; - goto fail; - } - - if(err) { - SOCKERRNOSET(err); - goto fail; - } - - sd[0] = temp; - break; - } - - { - /* restore blocking IO */ - osiSockIoctl_t flag = 0; - if(socket_ioctl(sd[1], FIONBIO, &flag)) - goto fail; - } - - epicsSocketDestroy(listener); - - return 0; -fail: - if(listener!=INVALID_SOCKET) - epicsSocketDestroy(listener); - if(sd[0]!=INVALID_SOCKET) - epicsSocketDestroy(sd[0]); - if(sd[1]!=INVALID_SOCKET) - epicsSocketDestroy(sd[1]); - return ret; -} - -int shSocketPair(SOCKET sd[2]) -{ - /* Winsock doesn't provide socketpair() at all. - * RTEMS (classic stack) provides a no-op stub - */ -#if defined(_WIN32) || (defined(__rtems__) && !defined(RTEMS_HAS_LIBBSD)) - int ret = socketpair_compat(AF_INET, SOCK_STREAM, 0, sd); -#else - int ret = socketpair(AF_UNIX, SOCK_STREAM, 0, sd); -#endif - if(ret) { - sd[0] = sd[1] = INVALID_SOCKET; - } - return ret; -} - -#ifdef USE_SELECT -int shWaitFor(shSocket *s, int op, int flags) -{ - struct timeval timo = s->timeout, *ptimo=NULL; - int ret, maxid = s->sd+1; - fd_set wset, rset; - - if(!(flags&MSG_NOTIMO) && (timo.tv_sec || timo.tv_usec) ) - ptimo = &timo; - - FD_ZERO(&wset); - FD_ZERO(&rset); - if(s->wakeup!=INVALID_SOCKET) - FD_SET(s->wakeup, &rset); - - if(s->wakeup>s->sd) - maxid = s->wakeup+1; - - switch(op) { - case 0: break; - case SH_CANTX: FD_SET(s->sd, &wset); break; - case SH_CANRX: FD_SET(s->sd, &rset); break; - default: - SOCKERRNOSET(SOCK_EINVAL); - return -1; - } - - do { - ret = select(maxid, &rset, &wset, NULL, ptimo); - } while(ret==-1 && SOCKERRNO == SOCK_EINTR); - - if(ret<0) { - return ret; - } else if(ret==0 || (s->wakeup!=INVALID_SOCKET && FD_ISSET(s->wakeup, &rset))) { - SOCKERRNOSET(SOCK_ETIMEDOUT); - return -1; - } else { /* ret>0 && !FD_ISSET(wakeup, &rset) */ - return 0; /* socket ready */ - } -} -#endif /* USE_SELECT */ - -#ifdef USE_POLL -int shWaitFor(shSocket *s, int op, int flags) -{ - int timeout = -1; - struct pollfd fds[2]; - int ret; - unsigned nfds = 1u; - - if(!(flags&MSG_NOTIMO) && (s->timeout.tv_sec || s->timeout.tv_usec) ) { - timeout = s->timeout.tv_sec * 1000 + s->timeout.tv_usec / 1000; - } - - memset(&fds, 0, sizeof(fds)); - fds[0].fd = s->sd; - switch(op) { - case 0: break; - case SH_CANTX: fds[0].events = POLLOUT; break; - case SH_CANRX: fds[0].events = POLLIN; break; - default: - SOCKERRNOSET(SOCK_EINVAL); - return -1; - } - - if(s->wakeup!=INVALID_SOCKET) { - fds[1].fd = s->wakeup; - fds[1].events = POLLIN; - nfds = 2; - } - - do{ - ret = poll(fds, nfds, timeout); - }while(ret<0 && SOCKERRNO == SOCK_EINTR); - - if(ret<0) { - return -1; - } else if(ret==0 || (fds[1].revents&POLLIN)) { // timeout or interrupt - SOCKERRNOSET(SOCK_ETIMEDOUT); - return -1; - } else { - return 0; - } -} -#endif /* USE_POLL */ - -int shConnect(shSocket *s, const osiSockAddr *peer) -{ - int ret; - - do { - ret = connect(s->sd, &peer->sa, sizeof(peer->sa)); - } while(ret==-1 && SOCKERRNO == SOCK_EINTR); - - if(ret<0 && (SOCKERRNO==SOCK_EINPROGRESS || SOCKERRNO==SOCK_EWOULDBLOCK)) { - - ret = shWaitFor(s, SH_CANTX, 0); - - if(ret == 0) { /* operation complete */ - int err; - osiSocklen_t elen = sizeof(err); - ret = getsockopt(s->sd, SOL_SOCKET, SO_ERROR, (char*)&err, &elen); - if(ret==0 && err) { - SOCKERRNOSET(err); - ret = -1; - } - - } - } - - return ret; -} - -ssize_t shRecvExact(shSocket *s, void *buf, size_t len, int flags) -{ - char *cbuf=buf; - ssize_t ret; - size_t sofar = 0; - - while(sofarsd, cbuf+sofar, len-sofar, 0); - if(ret<0 && (SOCKERRNO == SOCK_EWOULDBLOCK || SOCKERRNO == SOCK_EINTR)) { - if(shWaitFor(s, SH_CANRX, flags)) - return -1; - continue; - } else if(ret<=0) { - if(ret==0) - SOCKERRNOSET(SOCK_ECONNRESET); /* actually normal close */ - return -1; - } - - sofar += ret; - } - return sofar; -} - -ssize_t shRecvIgnore(shSocket *s, size_t len, int flags) -{ - ssize_t ret; - size_t sofar = 0; - char buf[40]; - - while(sofarsd, buf, sizeof(buf), 0); - if(ret<0 && (SOCKERRNO == SOCK_EWOULDBLOCK || SOCKERRNO == SOCK_EINTR)) { - if(shWaitFor(s, SH_CANRX, flags)) - return -1; - continue; - } else if(ret<=0) { - if(ret==0) - SOCKERRNOSET(SOCK_ECONNRESET); - return -1; - } - - sofar += ret; - } - return sofar; -} - -ssize_t shRecvFrom(shSocket* s, void *buf, size_t len, int flags, - osiSockAddr *peer) -{ - ssize_t ret; - osiSocklen_t slen = sizeof(*peer); - - if(shWaitFor(s, SH_CANRX, flags)) - return -1; - - do { - ret = recvfrom(s->sd, buf, len, 0, &peer->sa, &slen); - } while(ret==-1 && (SOCKERRNO == SOCK_EWOULDBLOCK || SOCKERRNO == SOCK_EINTR)); - - if(ret<0) { - if(SOCKERRNO==SOCK_EWOULDBLOCK) { - /* we already waited and were told that some data was available, - * so treat this as a timeout - */ - SOCKERRNOSET(SOCK_ETIMEDOUT); - } - } else if(slenia)) { - SOCKERRNOSET(SOCK_EADDRINUSE); /* something strange happened... */ - ret = -1; - } - return ret; -} - -int shSendTo(shSocket* s, const void *buf, size_t len, int flags, - const osiSockAddr* peer) -{ - ssize_t ret; - - if(shWaitFor(s, SH_CANTX, flags)) - return -1; - - do { - ret = sendto(s->sd, buf, len, 0, &peer->sa, sizeof(*peer)); - } while(ret==-1 && (SOCKERRNO == SOCK_EWOULDBLOCK || SOCKERRNO == SOCK_EINTR)); - - return ret!=len; -} - -int shSendAll(shSocket* s, const void *buf, size_t len, int flags) -{ - ssize_t ret; - const char *cbuf = buf; - size_t sofar = 0; - - while(sofarsd, cbuf+sofar, len-sofar, MSG_NOSIGNAL); - if(ret<=0 && (SOCKERRNO == SOCK_EWOULDBLOCK || SOCKERRNO == SOCK_EINTR)) - continue; - else if(ret<=0) - return ret; - - sofar += ret; - } - - return 1; -} diff --git a/client/castApp/src/sockhelpers.h b/client/castApp/src/sockhelpers.h deleted file mode 100644 index ba2f4526..00000000 --- a/client/castApp/src/sockhelpers.h +++ /dev/null @@ -1,112 +0,0 @@ -#ifndef SOCKHELPERS_H -#define SOCKHELPERS_H -/* blocking socket operations w/ timeouts and interruptions */ -#include -#include - -#if defined(_MSC_VER) - #include - #include - typedef SSIZE_T ssize_t; -#endif - -#ifndef SOCKERRNOSET -# if defined(WIN32) || defined(WIN64) -# define SOCKERRNOSET(E) WSASetLastError(E) -# else -# define SOCKERRNOSET(E) do{ SOCKERRNO = (E); }while(0) -# endif -#endif - -#include - -#ifndef MSG_NOSIGNAL -# define MSG_NOSIGNAL 0 -#endif - -/* Try to distinguish the RTEMS "classic" network stack from the newer libbsd stack - */ -#ifdef __rtems__ -# include -# if defined(RTEMS_NETWORKING) - /* legacy stack circa RTEMS <= 5 */ -# else -# ifdef __has_include -# if __has_include() - /* legacy stack circa RTEMS > 5 */ -# elif __has_include() -# define RTEMS_HAS_LIBBSD -# else -# error Unexpected RTEMS configuration -# endif -# else -# error RTEMS < 5 needs BSP with --enable-network -# endif -# endif -#endif /* __rtems__ */ - -typedef struct { - SOCKET sd; /* data socket */ - SOCKET wakeup; /* force timeout socket */ - struct timeval timeout; /* normal timeout */ -} shSocket; - -epicsShareFunc -void shSocketInit(shSocket *s); - -epicsShareFunc -void shSetTimeout(shSocket* s, double val); - -/* create a new non-blocking socket */ -epicsShareFunc -SOCKET shCreateSocket(int domain, int type, int protocol); - -/* create a pair of connected stream sockets */ -epicsShareFunc -int shSocketPair(SOCKET sd[2]); - -/* Connect w/ timeout */ -epicsShareFunc -int shConnect(shSocket* s, const osiSockAddr *peer); - -#define SH_CANTX 1 -#define SH_CANRX 2 - -/* disable timeout for this call */ -#define MSG_NOTIMO 0x4000 - -/* wait for socket sd event, or data available on - * wakeup socket. - * Wakeup socket ready is treated as a timeout - * on socket sd. - */ -epicsShareFunc -int shWaitFor(shSocket* s, int op, int flags); - -/* recv() exactly the requested number of bytes. - * returns either 'len', 0 for disconnect, or an error -1. - */ -epicsShareFunc -ssize_t shRecvExact(shSocket* s, void *buf, size_t len, int flags); - -/* pull 'len' bytes from the stream and discard them */ -epicsShareFunc -ssize_t shRecvIgnore(shSocket* s, size_t len, int flags); - -epicsShareFunc -ssize_t shRecvFrom(shSocket* s, void *buf, size_t len, int flags, - osiSockAddr *peer); - -/* returns zero if all bytes sent. -1 on error, 1 on incomplete */ -epicsShareFunc -int shSendTo(shSocket* s, const void *buf, size_t len, int flags, - const osiSockAddr* peer); - -/* returns 1 if all bytes sent, 0 when connection lost, and -1 on error */ -epicsShareFunc -int shSendAll(shSocket* s, const void *buf, size_t len, int flags); - -epicsShareFunc -int socketpair_compat(int af, int st, int p, SOCKET sd[2]); - -#endif // SOCKHELPERS_H diff --git a/client/castApp/src/testAddEnvVars.c b/client/castApp/src/testAddEnvVars.c deleted file mode 100644 index 696bc1ec..00000000 --- a/client/castApp/src/testAddEnvVars.c +++ /dev/null @@ -1,207 +0,0 @@ -#include - -#include -#include - -#include "caster.h" - -void* epicsRtemsFSImage; - -static void testLog(void* arg, struct _caster_t* self) -{ - testDiag("ERR %s", self->lastmsg); -} - -static void testAddEnvVarsX(void) -{ - int i = 0; - caster_t caster; - casterInit(&caster); - caster.onmsg = &testLog; - - int argc; - char *argvlist[6]; - argvlist[0] = "addReccasterEnvVars"; - - char *expectedExtraEnvs[] = - { - "SECTOR", - "BUILDING", - "CONTACT", - "DEVICE", - "FAMILY" - }; - int expectedNumExtraEnvs = default_envs_count; - - testDiag("Testing addReccasterEnvVars with one good env"); - argvlist[1] = "SECTOR"; - argc = 2; - i = 0; - testOk1(caster.envs.count==expectedNumExtraEnvs); - addReccasterEnvVars(&caster, argc, argvlist); - expectedNumExtraEnvs++; - testOk1(caster.envs.count==expectedNumExtraEnvs); - ELLNODE *cur; - cur = ellFirst(&caster.envs); - while (cur != NULL) { - string_list_t *temp = (string_list_t *)cur; - if (i < default_envs_count) { - testOk1(strcmp(temp->item_str, default_envs[i]) == 0); - } - else { - testOk1(strcmp(temp->item_str, expectedExtraEnvs[i - default_envs_count]) == 0); - } - i++; - cur = ellNext(cur); - } - - testDiag("Testing addReccasterEnvVars with two more good envs"); - argvlist[1] = "BUILDING"; - argvlist[2] = "CONTACT"; - argc = 3; - i = 0; - testOk1(caster.envs.count==expectedNumExtraEnvs); - addReccasterEnvVars(&caster, argc, argvlist); - expectedNumExtraEnvs += 2; - testOk1(caster.envs.count==expectedNumExtraEnvs); - cur = ellFirst(&caster.envs); - while (cur != NULL) { - string_list_t *temp = (string_list_t *)cur; - if (i < default_envs_count) { - testOk1(strcmp(temp->item_str, default_envs[i]) == 0); - } - else { - testOk1(strcmp(temp->item_str, expectedExtraEnvs[i - default_envs_count]) == 0); - } - i++; - cur = ellNext(cur); - } - - testDiag("Testing addReccasterEnvVars with duplicate env"); - argvlist[1] = "SECTOR"; - argc = 2; - i = 0; - testOk1(caster.envs.count==expectedNumExtraEnvs); - addReccasterEnvVars(&caster, argc, argvlist); - testOk1(caster.envs.count==expectedNumExtraEnvs); - cur = ellFirst(&caster.envs); - while (cur != NULL) { - string_list_t *temp = (string_list_t *)cur; - if (i < default_envs_count) { - testOk1(strcmp(temp->item_str, default_envs[i]) == 0); - } - else { - testOk1(strcmp(temp->item_str, expectedExtraEnvs[i - default_envs_count]) == 0); - } - i++; - cur = ellNext(cur); - } - - testDiag("Testing addReccasterEnvVars with one dup and one good env"); - argvlist[1] = "CONTACT"; - argvlist[2] = "DEVICE"; - argc = 3; - i = 0; - testOk1(caster.envs.count==expectedNumExtraEnvs); - addReccasterEnvVars(&caster, argc, argvlist); - expectedNumExtraEnvs++; - testOk1(caster.envs.count==expectedNumExtraEnvs); - cur = ellFirst(&caster.envs); - while (cur != NULL) { - string_list_t *temp = (string_list_t *)cur; - if (i < default_envs_count) { - testOk1(strcmp(temp->item_str, default_envs[i]) == 0); - } - else { - testOk1(strcmp(temp->item_str, expectedExtraEnvs[i - default_envs_count]) == 0); - } - i++; - cur = ellNext(cur); - } - - testDiag("Testing addReccasterEnvVars with a good env and a dup of that env"); - argvlist[1] = "FAMILY"; - argvlist[2] = "FAMILY"; - argc = 3; - i = 0; - testOk1(caster.envs.count==expectedNumExtraEnvs); - addReccasterEnvVars(&caster, argc, argvlist); - expectedNumExtraEnvs++; - testOk1(caster.envs.count==expectedNumExtraEnvs); - cur = ellFirst(&caster.envs); - while (cur != NULL) { - string_list_t *temp = (string_list_t *)cur; - if (i < default_envs_count) { - testOk1(strcmp(temp->item_str, default_envs[i]) == 0); - } - else { - testOk1(strcmp(temp->item_str, expectedExtraEnvs[i - default_envs_count]) == 0); - } - i++; - cur = ellNext(cur); - } - - testDiag("Testing addReccasterEnvVars with a env vars from default list"); - argvlist[1] = "EPICS_BASE"; - argvlist[2] = "EPICS_CA_MAX_ARRAY_BYTES"; - argvlist[3] = "PVAS_SERVER_PORT"; - argvlist[4] = "RSRV_SERVER_PORT"; - argvlist[5] = "ENGINEER"; - argc = 6; - i = 0; - testOk1(caster.envs.count==expectedNumExtraEnvs); - addReccasterEnvVars(&caster, argc, argvlist); - testOk1(caster.envs.count==expectedNumExtraEnvs); /* these are all defaults so the count should not change */ - cur = ellFirst(&caster.envs); - while (cur != NULL) { - string_list_t *temp = (string_list_t *)cur; - if (i < default_envs_count) { - testOk1(strcmp(temp->item_str, default_envs[i]) == 0); - } - else { - testOk1(strcmp(temp->item_str, expectedExtraEnvs[i - default_envs_count]) == 0); - } - i++; - cur = ellNext(cur); - } - - epicsEventSignal(caster.shutdownEvent); - casterShutdown(&caster); -} - -static void testAddEnvVarsBadInput(void) -{ - caster_t caster; - casterInit(&caster); - caster.onmsg = &testLog; - - int argc; - char *argvlist[3]; - argvlist[0] = "addReccasterEnvVars"; - - testDiag("Testing addReccasterEnvVars with no arguments"); - argc = 1; - testOk1(caster.envs.count==default_envs_count); - addReccasterEnvVars(&caster, argc, argvlist); - testOk1(caster.envs.count==default_envs_count); - - testDiag("Testing addReccasterEnvVars with empty string argument"); - argvlist[1] = ""; - argc = 2; - testOk1(caster.envs.count==default_envs_count); - addReccasterEnvVars(&caster, argc, argvlist); - testOk1(caster.envs.count==default_envs_count); - - epicsEventSignal(caster.shutdownEvent); - casterShutdown(&caster); -} - -MAIN(testAddEnvVars) -{ - testPlan(37 + default_envs_count * 6); - osiSockAttach(); - testAddEnvVarsX(); - testAddEnvVarsBadInput(); - osiSockRelease(); - return testDone(); -} diff --git a/client/castApp/src/testAddExcludePattern.c b/client/castApp/src/testAddExcludePattern.c deleted file mode 100644 index 8f0a9d67..00000000 --- a/client/castApp/src/testAddExcludePattern.c +++ /dev/null @@ -1,173 +0,0 @@ -#include - -#include -#include - -#include "caster.h" - -void* epicsRtemsFSImage; - -static void testLog(void* arg, struct _caster_t* self) -{ - testDiag("ERR %s", self->lastmsg); -} - -static void testAddExcludePatternX(void) -{ - int i = 0; - caster_t caster; - casterInit(&caster); - caster.onmsg = &testLog; - - int argc; - char *argvlist[5]; - argvlist[0] = "addReccasterExcludePattern"; - - char *expectedPatterns[] = - { - "*_", - "*__", - "*:Intrnl:*", - "*_internal", - "*exclude_me" - }; - int expectedNumPatterns = 0; - - testDiag("Testing addReccasterExcludePattern with one good env"); - argvlist[1] = "*_"; - argc = 2; - testOk1(caster.exclude_patterns.count==expectedNumPatterns); - addReccasterExcludePattern(&caster, argc, argvlist); - expectedNumPatterns++; - testOk1(caster.exclude_patterns.count==expectedNumPatterns); - ELLNODE *cur; - cur = ellFirst(&caster.exclude_patterns); - while (cur != NULL) { - string_list_t *temp = (string_list_t *)cur; - testOk1(strcmp(temp->item_str, expectedPatterns[i]) == 0); - i++; - cur = ellNext(cur); - } - - testDiag("Testing addReccasterExcludePattern with two more patterns"); - argvlist[1] = "*__"; - argvlist[2] = "*:Intrnl:*"; - argc = 3; - i = 0; - testOk1(caster.exclude_patterns.count==expectedNumPatterns); - addReccasterExcludePattern(&caster, argc, argvlist); - expectedNumPatterns += 2; - testOk1(caster.exclude_patterns.count==expectedNumPatterns); - cur = ellFirst(&caster.exclude_patterns); - while (cur != NULL) { - string_list_t *temp = (string_list_t *)cur; - testOk1(strcmp(temp->item_str, expectedPatterns[i]) == 0); - i++; - cur = ellNext(cur); - } - - testDiag("Testing addReccasterExcludePattern with a duplicate pattern"); - argvlist[1] = "*_"; - argc = 2; - i = 0; - testOk1(caster.exclude_patterns.count==expectedNumPatterns); - addReccasterExcludePattern(&caster, argc, argvlist); - testOk1(caster.exclude_patterns.count==expectedNumPatterns); - cur = ellFirst(&caster.exclude_patterns); - while (cur != NULL) { - string_list_t *temp = (string_list_t *)cur; - testOk1(strcmp(temp->item_str, expectedPatterns[i]) == 0); - i++; - cur = ellNext(cur); - } - - testDiag("Testing addReccasterExcludePattern with a new and a duplicate"); - argvlist[1] = "*_internal"; - argvlist[2] = "*__"; - argc = 3; - i = 0; - testOk1(caster.exclude_patterns.count==expectedNumPatterns); - addReccasterExcludePattern(&caster, argc, argvlist); - expectedNumPatterns++; - testOk1(caster.exclude_patterns.count==expectedNumPatterns); - cur = ellFirst(&caster.exclude_patterns); - while (cur != NULL) { - string_list_t *temp = (string_list_t *)cur; - testOk1(strcmp(temp->item_str, expectedPatterns[i]) == 0); - i++; - cur = ellNext(cur); - } - - testDiag("Testing addReccasterExcludePattern with two of the same pattern"); - argvlist[1] = "*exclude_me"; - argvlist[2] = "*exclude_me"; - argc = 3; - i = 0; - testOk1(caster.exclude_patterns.count==expectedNumPatterns); - addReccasterExcludePattern(&caster, argc, argvlist); - expectedNumPatterns++; - testOk1(caster.exclude_patterns.count==expectedNumPatterns); - cur = ellFirst(&caster.exclude_patterns); - while (cur != NULL) { - string_list_t *temp = (string_list_t *)cur; - testOk1(strcmp(temp->item_str, expectedPatterns[i]) == 0); - i++; - cur = ellNext(cur); - } - - testDiag("Testing addReccasterExcludePattern with duplicates in argv and exclude pattern list"); - argvlist[1] = "*__"; - argvlist[2] = "*__"; - argc = 3; - i = 0; - testOk1(caster.exclude_patterns.count==expectedNumPatterns); - addReccasterExcludePattern(&caster, argc, argvlist); - testOk1(caster.exclude_patterns.count==expectedNumPatterns); - cur = ellFirst(&caster.exclude_patterns); - while (cur != NULL) { - string_list_t *temp = (string_list_t *)cur; - testOk1(strcmp(temp->item_str, expectedPatterns[i]) == 0); - i++; - cur = ellNext(cur); - } - - epicsEventSignal(caster.shutdownEvent); - casterShutdown(&caster); -} - -static void testAddExcludePatternBadInput() -{ - caster_t caster; - casterInit(&caster); - caster.onmsg = &testLog; - - int argc; - char *argvlist[2]; - argvlist[0] = "addReccasterExcludePattern"; - - testDiag("Testing addReccasterExcludePattern with no arguments"); - argc = 1; - testOk1(caster.exclude_patterns.count==0); - addReccasterExcludePattern(&caster, argc, argvlist); - testOk1(caster.exclude_patterns.count==0); - - testDiag("Testing addReccasterExcludePattern with empty string argument"); - argvlist[1] = ""; - argc = 2; - testOk1(caster.exclude_patterns.count==0); - addReccasterExcludePattern(&caster, argc, argvlist); - testOk1(caster.exclude_patterns.count==0); - - epicsEventSignal(caster.shutdownEvent); - casterShutdown(&caster); -} - -MAIN(testAddExcludePattern) -{ - testPlan(37); - osiSockAttach(); - testAddExcludePatternX(); - testAddExcludePatternBadInput(); - osiSockRelease(); - return testDone(); -} diff --git a/client/castApp/src/testsock.c b/client/castApp/src/testsock.c deleted file mode 100644 index a6886489..00000000 --- a/client/castApp/src/testsock.c +++ /dev/null @@ -1,113 +0,0 @@ - -#include - -#include -#include - -#include "sockhelpers.h" - -void* epicsRtemsFSImage; - -static void testUDP(void) -{ - shSocket sock[2]; - osiSockAddr addr0, addr1; - osiSocklen_t alen; - static const char testmsg[] = "Hello world"; - char buf[20]; - - shSocketInit(&sock[0]); - shSocketInit(&sock[1]); - shSetTimeout(&sock[0], 0.1); - shSetTimeout(&sock[1], 0.1); - - sock[0].sd = shCreateSocket(AF_INET, SOCK_DGRAM, 0); - sock[1].sd = shCreateSocket(AF_INET, SOCK_DGRAM, 0); - - testOk1(sock[0].sd!=INVALID_SOCKET); - testOk1(sock[1].sd!=INVALID_SOCKET); - - memset(&addr0, 0, sizeof(addr0)); - - /* bind to loopback on a random port */ - addr0.ia.sin_family = AF_INET; - addr0.ia.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - - testOk1(0==bind(sock[0].sd, &addr0.sa, sizeof(addr0))); - - alen = sizeof(addr0); - testOk1(0==getsockname(sock[0].sd, &addr0.sa, &alen)); - testOk1(alen>=sizeof(addr0.ia)); - - testDiag("sd[0] bound to %d", ntohs(addr0.ia.sin_port)); - - testDiag("Recv timeout"); - - testOk1(-1==shWaitFor(&sock[0], SH_CANRX, 0)); - testOk1(SOCKERRNO==SOCK_ETIMEDOUT); - SOCKERRNOSET(0); - - testOk1(-1==shRecvIgnore(&sock[0], 4, 0)); - testOk1(SOCKERRNO==SOCK_ETIMEDOUT); - - testDiag("Test send"); - - testOk1(0==shWaitFor(&sock[1], SH_CANTX, 0)); - - testOk1(0==shSendTo(&sock[1], testmsg, sizeof(testmsg), 0, &addr0)); - testDiag("error: %s", strerror(SOCKERRNO)); - - testOk1(0==shWaitFor(&sock[0], SH_CANRX, 0)); - - testOk1(sizeof(testmsg)==shRecvFrom(&sock[0], buf, sizeof(buf), 0, &addr1)); - - testOk1(memcmp(buf, testmsg, sizeof(testmsg))==0); - - epicsSocketDestroy(sock[0].sd); - epicsSocketDestroy(sock[1].sd); -} - -static void testWakeup(void) -{ - shSocket sock; - SOCKET wakeup[2]; - epicsUInt32 junk = 0; - int ret; - - shSocketInit(&sock); - - sock.sd = shCreateSocket(AF_INET, SOCK_DGRAM, 0); - testOk1(sock.sd!=INVALID_SOCKET); - - ret=socketpair_compat(AF_INET, SOCK_STREAM, 0, wakeup); - testOk(ret==0, "socketpair_compat() -> %d == 0 (%d)", ret, SOCKERRNO); - - sock.wakeup = wakeup[1]; - - shSetTimeout(&sock, 100.0); /* something noticable */ - - testOk1(sizeof(junk)==send(wakeup[0], (char*)&junk, sizeof(junk), 0)); - - SOCKERRNOSET(0); - ret = shWaitFor(&sock, SH_CANTX, 0); - testOk(ret==-1 && SOCKERRNO==SOCK_ETIMEDOUT, - "shWaitFor(&sock, SH_CANTX, 0)==%d (%d) ==-1 (SOCK_ETIMEDOUT)", ret, (int)SOCKERRNO); - - epicsSocketDestroy(sock.sd); - epicsSocketDestroy(wakeup[0]); - epicsSocketDestroy(wakeup[1]); -} - -MAIN(testsock) -{ - testPlan(18); - osiSockAttach();; - testUDP(); - #ifdef __APPLE__ - testSkip(4, "testWakeup is flaky on mac os"); - #else - testWakeup(); - #endif - osiSockRelease(); - return testDone(); -} diff --git a/client/castApp/src/testtcp.c b/client/castApp/src/testtcp.c deleted file mode 100644 index c9e2ddb0..00000000 --- a/client/castApp/src/testtcp.c +++ /dev/null @@ -1,280 +0,0 @@ - -#include - -#include -#include - -#include -#include - -#include "caster.h" -#include "sockhelpers.h" -static int result; -static size_t cycles; -static epicsEventId cycled[2]; -static epicsMutexId lock; - -void* epicsRtemsFSImage; - -static void testLog(void* arg, struct _caster_t* self) -{ - testDiag("MSG %s", self->lastmsg); -} - -static void tester(void *raw) -{ - caster_t *self = raw; - epicsEventId sd; - - testDiag("TCP tester starts"); - - epicsMutexMustLock(lock); - - while(1) { - - epicsMutexUnlock(lock); - epicsEventMustWait(cycled[1]); - epicsMutexMustLock(lock); - if(self->shutdown) { - epicsEventSignal(cycled[0]); - break; - } - - result = doCasterTCPPhase(self); - cycles++; - - testDiag("TCP tester cycle ends %d", result); - - epicsEventSignal(cycled[0]); - } - - testDiag("TCP tester stops"); - sd = self->shutdownEvent; - epicsMutexUnlock(lock); - - epicsEventSignal(sd); -} - -static int getrecords(void *arg, caster_t *self) -{ - testOk1(arg==self); - epicsEventSignal(cycled[0]); - return 0; -} - -static void testTCP(void) -{ - caster_t caster; - SOCKET listener; - shSocket sock; - osiSockAddr dest, client; - osiSocklen_t slen; - epicsUInt16 msgid; - union casterTCPBody buf; - ssize_t ret; - - testDiag("Test TCP client"); - - shSocketInit(&sock); - - lock = epicsMutexMustCreate(); - cycled[0] = epicsEventMustCreate(epicsEventEmpty); - cycled[1] = epicsEventMustCreate(epicsEventEmpty); - - listener = epicsSocketCreate(AF_INET, SOCK_STREAM, 0); - if(listener==INVALID_SOCKET) { - testAbort("Failed to create socket"); - return; - } - - casterInit(&caster); - caster.onmsg = &testLog; - - memset(&dest, 0, sizeof(dest)); - dest.ia.sin_family = AF_INET; - dest.ia.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - - if(bind(listener, &dest.sa, sizeof(dest))) { - testAbort("Failed to bind socket"); - return; - } - - slen = sizeof(dest); - if(getsockname(listener, &dest.sa, &slen) || slen - -#include -#include - -#include -#include - -#include "caster.h" -#include "sockhelpers.h" - -static int result; -static size_t cycles; -static epicsEventId cycled[2]; -static epicsMutexId lock; - -void* epicsRtemsFSImage; - -static void testLog(void* arg, struct _caster_t* self) -{ - testDiag("ERR %s", self->lastmsg); -} - -static void testerhook(caster_t *self, caster_h state) -{ - if(state!=casterUDPSetup) - return; - epicsMutexUnlock(lock); - - epicsEventSignal(cycled[0]); - - epicsEventMustWait(cycled[1]); - epicsMutexMustLock(lock); -} - -static void tester(void *raw) -{ - caster_t *self = raw; - epicsEventId sd; - - testDiag("UDP tester starts"); - - epicsMutexMustLock(lock); - - while(!self->shutdown) { - - epicsMutexUnlock(lock); - epicsEventMustWait(cycled[1]); - epicsMutexMustLock(lock); - - result = doCasterUDPPhase(self); - cycles++; - - epicsEventSignal(cycled[0]); - } - - testDiag("UDP tester stops"); - sd = self->shutdownEvent; - epicsMutexUnlock(lock); - - epicsEventSignal(sd); -} - -static void testUDP(void) -{ - caster_t caster; - shSocket sender; - osiSockAddr dest; - union casterUDP buf; - - shSocketInit(&sender); - - sender.sd = shCreateSocket(AF_INET, SOCK_DGRAM, 0); - if(sender.sd==INVALID_SOCKET) { - testAbort("Failed to create socket"); - return; - } - - lock = epicsMutexMustCreate(); - cycled[0] = epicsEventMustCreate(epicsEventEmpty); - cycled[1] = epicsEventMustCreate(epicsEventEmpty); - - casterInit(&caster); - caster.onmsg = &testLog; - - caster.udpport = 0; /* test with random port */ - caster.testhook = &testerhook; - - epicsThreadMustCreate("udptester", - epicsThreadPriorityMedium, - epicsThreadGetStackSize(epicsThreadStackSmall), - &tester, &caster); - - epicsEventSignal(cycled[1]); - - /* wait for tester thread to setup socket */ - epicsEventMustWait(cycled[0]); - - epicsMutexMustLock(lock); - - testOk1(caster.udpport!=0); - - testDiag("UDP test with port %d", caster.udpport); - - memset(&dest, 0, sizeof(dest)); - dest.ia.sin_family = AF_INET; - dest.ia.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - dest.ia.sin_port = htons(caster.udpport); - - epicsMutexUnlock(lock); - - /* allow tester thread to begin recv() */ - epicsEventSignal(cycled[1]); - - testDiag("Test announcement directly from server"); - - memset(&buf, 0, sizeof(buf)); - buf.m_msg.pid = htons(RECAST_MAGIC); - buf.m_msg.serverIP = htonl(0xffffffff); - buf.m_msg.serverPort = htons(0x1020); - buf.m_msg.serverKey = htonl(0x12345678); - - testOk1(0==shSendTo(&sender, &buf.m_bytes, 0x10, 0, &dest)); - - /* wait for tester thread to completer recv() and end cycle */ - epicsEventMustWait(cycled[0]); - - epicsMutexMustLock(lock); - testOk1(cycles==1); - testOk1(result==0); - testOk1(caster.haveserv==1); - testOk1(caster.nameserv.ia.sin_family==AF_INET); - testOk1(caster.nameserv.ia.sin_addr.s_addr==htonl(INADDR_LOOPBACK)); - testOk1(caster.nameserv.ia.sin_port==htons(0x1020)); - testOk1(caster.servkey==0x12345678); - epicsMutexUnlock(lock); - - testDiag("Test proxied announcement"); - - /* start next cycle */ - epicsEventSignal(cycled[1]); - - /* wait for tester thread to setup socket */ - epicsEventMustWait(cycled[0]); - - epicsMutexMustLock(lock); - - dest.ia.sin_port = htons(caster.udpport); - - epicsMutexUnlock(lock); - - buf.m_msg.serverIP = htonl(0x50607080); - - /* allow tester thread to begin recv() */ - epicsEventSignal(cycled[1]); - - testOk1(0==shSendTo(&sender, &buf.m_bytes, 0x10, 0, &dest)); - - /* wait for tester thread to completer recv() and end cycle */ - epicsEventMustWait(cycled[0]); - - epicsMutexMustLock(lock); - testOk1(cycles==2); - testOk1(result==0); - testOk1(caster.haveserv==1); - testOk1(caster.nameserv.ia.sin_family==AF_INET); - testOk1(caster.nameserv.ia.sin_addr.s_addr==htonl(0x50607080)); - testOk1(caster.nameserv.ia.sin_port==htons(0x1020)); - epicsMutexUnlock(lock); - - /* begin shutdown cycle */ - epicsEventSignal(cycled[1]); - epicsEventMustWait(cycled[0]); - epicsEventSignal(cycled[1]); - - - casterShutdown(&caster); - - epicsEventDestroy(cycled[0]); - epicsEventDestroy(cycled[1]); - epicsMutexDestroy(lock); -} - -MAIN(testudp) -{ - testPlan(16); - osiSockAttach();; - testUDP(); - osiSockRelease(); - return testDone(); -} diff --git a/client/configure/CONFIG b/client/configure/CONFIG deleted file mode 100644 index 331fd702..00000000 --- a/client/configure/CONFIG +++ /dev/null @@ -1,28 +0,0 @@ -# CONFIG - Load build configuration data -# -# Do not make changes to this file! - -# Allow user to override where the build rules come from -RULES = $(EPICS_BASE) - -# RELEASE files point to other application tops -include $(TOP)/configure/RELEASE --include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).Common -ifdef T_A --include $(TOP)/configure/RELEASE.Common.$(T_A) --include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).$(T_A) -endif - -CONFIG = $(RULES)/configure -include $(CONFIG)/CONFIG - -# Override the Base definition: -INSTALL_LOCATION = $(TOP) - -# CONFIG_SITE files contain other build configuration settings -include $(TOP)/configure/CONFIG_SITE --include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).Common -ifdef T_A - -include $(TOP)/configure/CONFIG_SITE.Common.$(T_A) - -include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A) -endif diff --git a/client/configure/CONFIG_SITE b/client/configure/CONFIG_SITE deleted file mode 100644 index 85f8b033..00000000 --- a/client/configure/CONFIG_SITE +++ /dev/null @@ -1,45 +0,0 @@ -# CONFIG_SITE - -# Make any application-specific changes to the EPICS build -# configuration variables in this file. -# -# Host/target specific settings can be specified in files named -# CONFIG_SITE.$(EPICS_HOST_ARCH).Common -# CONFIG_SITE.Common.$(T_A) -# CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A) - -# CHECK_RELEASE controls the consistency checking of the support -# applications pointed to by the RELEASE* files. -# Normally CHECK_RELEASE should be set to YES. -# Set CHECK_RELEASE to NO to disable checking completely. -# Set CHECK_RELEASE to WARN to perform consistency checking but -# continue building anyway if conflicts are found. -CHECK_RELEASE = YES - -# Set this when you only want to compile this application -# for a subset of the cross-compiled target architectures -# that Base is built for. -#CROSS_COMPILER_TARGET_ARCHS = $(EPICS_HOST_ARCH)-debug -#CROSS_COMPILER_TARGET_ARCHS += win32-x86-mingw - -# To install files into a location other than $(TOP) define -# INSTALL_LOCATION here. -#INSTALL_LOCATION= - -# Set this when your IOC and the host use different paths -# to access the application. This will be needed to boot -# from a Microsoft FTP server or with some NFS mounts. -# You must rebuild in the iocBoot directory for this to -# take effect. -#IOCS_APPL_TOP = - -USR_CXXFLAGS += -DUSE_TYPED_RSET - -# These allow developers to override the CONFIG_SITE variable -# settings without having to modify the configure/CONFIG_SITE -# file itself. -# To keep the same depth of other EPICS modules, we have to add -# the additional `/../`, because of `client` directory. --include $(TOP)/../../CONFIG_SITE.local --include $(TOP)/../../configure/CONFIG_SITE.local --include $(TOP)/configure/CONFIG_SITE.local diff --git a/client/configure/Makefile b/client/configure/Makefile deleted file mode 100644 index 92543094..00000000 --- a/client/configure/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -TOP=.. - -include $(TOP)/configure/CONFIG - -TARGETS = $(CONFIG_TARGETS) -CONFIGS += $(subst ../,,$(wildcard $(CONFIG_INSTALLS))) - -include $(TOP)/configure/RULES diff --git a/client/configure/RELEASE b/client/configure/RELEASE deleted file mode 100644 index c1d193fe..00000000 --- a/client/configure/RELEASE +++ /dev/null @@ -1,37 +0,0 @@ -# RELEASE - Location of external support modules -# -# IF YOU MAKE ANY CHANGES to this file you must subsequently -# do a "gnumake rebuild" in this application's top level -# directory. -# -# The build process does not check dependencies against files -# that are outside this application, thus you should do a -# "gnumake rebuild" in the top level directory after EPICS_BASE -# or any other external module pointed to below is rebuilt. -# -# Host- or target-specific settings can be given in files named -# RELEASE.$(EPICS_HOST_ARCH).Common -# RELEASE.Common.$(T_A) -# RELEASE.$(EPICS_HOST_ARCH).$(T_A) -# -# This file should ONLY define paths to other support modules, -# or include statements that pull in similar RELEASE files. -# Build settings that are NOT module paths should appear in a -# CONFIG_SITE file. - -#TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top - -# EPICS_BASE usually appears last so other apps can override stuff: -#EPICS_BASE=/path/to/epics-base - -# Set RULES here if you want to take build rules from somewhere -# other than EPICS_BASE: -#RULES=/path/to/epics/support/module/rules/x-y - -# These allow developers to override the RELEASE variable settings -# without having to modify the configure/RELEASE file itself. -# To keep the same depth of other EPICS modules, we have to add -# the additional `/../`, because of `client` directory. --include $(TOP)/../../RELEASE.local --include $(TOP)/../../configure/RELEASE.local --include $(TOP)/configure/RELEASE.local diff --git a/client/configure/RULES b/client/configure/RULES deleted file mode 100644 index 6d56e14e..00000000 --- a/client/configure/RULES +++ /dev/null @@ -1,6 +0,0 @@ -# RULES - -include $(CONFIG)/RULES - -# Library should be rebuilt because LIBOBJS may have changed. -$(LIBNAME): ../Makefile diff --git a/client/configure/RULES.ioc b/client/configure/RULES.ioc deleted file mode 100644 index 901987c6..00000000 --- a/client/configure/RULES.ioc +++ /dev/null @@ -1,2 +0,0 @@ -#RULES.ioc -include $(CONFIG)/RULES.ioc diff --git a/client/configure/RULES_DIRS b/client/configure/RULES_DIRS deleted file mode 100644 index 3ba269dc..00000000 --- a/client/configure/RULES_DIRS +++ /dev/null @@ -1,2 +0,0 @@ -#RULES_DIRS -include $(CONFIG)/RULES_DIRS diff --git a/client/configure/RULES_TOP b/client/configure/RULES_TOP deleted file mode 100644 index 2b8cbc6d..00000000 --- a/client/configure/RULES_TOP +++ /dev/null @@ -1,2 +0,0 @@ -#RULES_TOP -include $(CONFIG)/RULES_TOP diff --git a/client/demoApp/Db/Makefile b/client/demoApp/Db/Makefile deleted file mode 100644 index 858424cb..00000000 --- a/client/demoApp/Db/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP=../.. -include $(TOP)/configure/CONFIG -#---------------------------------------- -# ADD MACRO DEFINITIONS AFTER THIS LINE - -#---------------------------------------------------- -# Optimization of db files using dbst (DEFAULT: NO) -#DB_OPT = YES - -#---------------------------------------------------- -# Create and install (or just install) into /db -# databases, templates, substitutions like this -DB += somerecords.db -#---------------------------------------------------- -# If .db template is not named *.template add -# _template = - -include $(TOP)/configure/RULES -#---------------------------------------- -# ADD RULES AFTER THIS LINE diff --git a/client/demoApp/Db/somerecords.db b/client/demoApp/Db/somerecords.db deleted file mode 100644 index 1d1b4fd8..00000000 --- a/client/demoApp/Db/somerecords.db +++ /dev/null @@ -1,12 +0,0 @@ - -record(longin, "$(P)li") { - alias("$(P)lix1") - alias("$(P)lix2") - info("test", "testing") -} - -record(longout, "$(P)lo") { - info("test", "testing") - info("hello", "world") - field(DESC, "testdesc") -} diff --git a/client/demoApp/Makefile b/client/demoApp/Makefile deleted file mode 100644 index ab15bfb1..00000000 --- a/client/demoApp/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -TOP = .. -include $(TOP)/configure/CONFIG -DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *src*)) -DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *Src*)) -DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *db*)) -DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *Db*)) -include $(TOP)/configure/RULES_DIRS diff --git a/client/demoApp/src/Makefile b/client/demoApp/src/Makefile deleted file mode 100644 index 2d41d769..00000000 --- a/client/demoApp/src/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -TOP=../.. - -include $(TOP)/configure/CONFIG -#---------------------------------------- -# ADD MACRO DEFINITIONS AFTER THIS LINE -#============================= - -#============================= -# Build the IOC application - -PROD_IOC = demo -# demo.dbd will be created and installed -DBD += demo.dbd - -# demo.dbd will be made up from these files: -demo_DBD += base.dbd -demo_DBD += reccaster.dbd - -# Add all the support libraries needed by this IOC -demo_LIBS += reccaster - -# demo_registerRecordDeviceDriver.cpp derives from demo.dbd -demo_SRCS += demo_registerRecordDeviceDriver.cpp - -# Build the main IOC entry point on workstation OSs. -demo_SRCS_DEFAULT += demoMain.cpp -demo_SRCS_vxWorks += -nil- - -# Add support from base/src/vxWorks if needed -#demo_OBJS_vxWorks += $(EPICS_BASE_BIN)/vxComLibrary - -# Finally link to the EPICS Base libraries -demo_LIBS += $(EPICS_BASE_IOC_LIBS) - -#=========================== - -include $(TOP)/configure/RULES -#---------------------------------------- -# ADD RULES AFTER THIS LINE diff --git a/client/demoApp/src/demoMain.cpp b/client/demoApp/src/demoMain.cpp deleted file mode 100644 index 5e60ea97..00000000 --- a/client/demoApp/src/demoMain.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* demoMain.cpp */ -/* Author: Marty Kraimer Date: 17MAR2000 */ - -#include -#include -#include -#include -#include - -#include "epicsExit.h" -#include "epicsThread.h" -#include "iocsh.h" - -int main(int argc,char *argv[]) -{ - if(argc>=2) { - iocsh(argv[1]); - epicsThreadSleep(.2); - } - iocsh(NULL); - epicsExit(0); - return(0); -} diff --git a/client/docker/RELEASE.local b/client/docker/RELEASE.local deleted file mode 100644 index ab218ca8..00000000 --- a/client/docker/RELEASE.local +++ /dev/null @@ -1 +0,0 @@ -EPICS_BASE=/epics/base diff --git a/client/iocBoot/Makefile b/client/iocBoot/Makefile deleted file mode 100644 index 1a4139a0..00000000 --- a/client/iocBoot/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -TOP = .. -include $(TOP)/configure/CONFIG -DIRS += $(wildcard *ioc*) -DIRS += $(wildcard as*) -include $(CONFIG)/RULES_DIRS diff --git a/client/iocBoot/iocdemo/Makefile b/client/iocBoot/iocdemo/Makefile deleted file mode 100644 index 89d66d02..00000000 --- a/client/iocBoot/iocdemo/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -TOP = ../.. -include $(TOP)/configure/CONFIG -ARCH = linux-x86_64-debug -TARGETS = envPaths -include $(TOP)/configure/RULES.ioc diff --git a/client/iocBoot/iocdemo/st.cmd b/client/iocBoot/iocdemo/st.cmd deleted file mode 100755 index 85594c30..00000000 --- a/client/iocBoot/iocdemo/st.cmd +++ /dev/null @@ -1,33 +0,0 @@ -#!../../bin/linux-x86_64-debug/demo - -## You may have to change demo to something else -## everywhere it appears in this file - -< envPaths - -## Register all support components -dbLoadDatabase("../../dbd/demo.dbd",0,0) -demo_registerRecordDeviceDriver(pdbbase) - -var(reccastTimeout, 5.0) -var(reccastMaxHoldoff, 5.0) - -epicsEnvSet("IOCNAME", "$(IOCSH_NAME)") -epicsEnvSet("ENGINEER", "myself") -epicsEnvSet("LOCATION", "myplace") - -epicsEnvSet("CONTACT", "mycontact") -epicsEnvSet("BUILDING", "mybuilding") -epicsEnvSet("SECTOR", "mysector") - -addReccasterEnvVars("CONTACT", "SECTOR") -addReccasterEnvVars("BUILDING") - -addReccasterExcludePattern("*_", "*__") -addReccasterExcludePattern("*exclude_this") - -## Load record instances -dbLoadRecords("../../db/reccaster.db", "P=$(IOCSH_NAME):") -dbLoadRecords("../../db/somerecords.db","P=$(IOCSH_NAME):") - -iocInit() diff --git a/client/ioc-compose.yml b/server/tests/integration/resources/docker-compose/ioc-compose.yml similarity index 75% rename from client/ioc-compose.yml rename to server/tests/integration/resources/docker-compose/ioc-compose.yml index 881c4f56..b19df7b8 100644 --- a/client/ioc-compose.yml +++ b/server/tests/integration/resources/docker-compose/ioc-compose.yml @@ -1,7 +1,7 @@ services: ioc1: - build: ../client + image: ghcr.io/channelfinder/reccaster:master environment: - IOCSH_NAME=IOC1 tty: true diff --git a/server/tests/integration/resources/docker-compose/test-bash-ioc.yml b/server/tests/integration/resources/docker-compose/test-bash-ioc.yml index 2eb929fa..9a112393 100644 --- a/server/tests/integration/resources/docker-compose/test-bash-ioc.yml +++ b/server/tests/integration/resources/docker-compose/test-bash-ioc.yml @@ -16,7 +16,7 @@ services: - net-2-cf ioc1-1: extends: - file: ../../../../../client/ioc-compose.yml + file: ./ioc-compose.yml service: ioc1 environment: - IOCSH_NAME=IOC1-1 diff --git a/server/tests/integration/resources/docker-compose/test-multi-recc.yml b/server/tests/integration/resources/docker-compose/test-multi-recc.yml index 172f6fb6..d93b505f 100644 --- a/server/tests/integration/resources/docker-compose/test-multi-recc.yml +++ b/server/tests/integration/resources/docker-compose/test-multi-recc.yml @@ -16,7 +16,7 @@ services: - net-2-cf ioc1-1: extends: - file: ../../../../../client/ioc-compose.yml + file: ./ioc-compose.yml service: ioc1 depends_on: recc1: diff --git a/server/tests/integration/resources/docker-compose/test-single-ioc.yml b/server/tests/integration/resources/docker-compose/test-single-ioc.yml index 1a79cb97..b0a5e828 100644 --- a/server/tests/integration/resources/docker-compose/test-single-ioc.yml +++ b/server/tests/integration/resources/docker-compose/test-single-ioc.yml @@ -16,7 +16,7 @@ services: - net-2-cf ioc1-1: extends: - file: ../../../../../client/ioc-compose.yml + file: ./ioc-compose.yml service: ioc1 depends_on: recc1: