--- gcpegg-5.1.orig/basket.c +++ gcpegg-5.1/basket.c @@ -42,6 +42,7 @@ #include #include #include +#include #include "global.h" #include "genlib.h" #include "storage.h" @@ -90,6 +91,7 @@ int i; static uint32 lastHtml = 0; uint32 now = getzulutime(NULL); + time_t now_val; char udate[256], ustime[256]; static char timeFormat[] = "%Y-%m-%d %T"; @@ -113,9 +115,11 @@ htmlFile[0] = 0; /* Suppress further updates */ return; } - - strftime(udate, sizeof udate, timeFormat, gmtime((time_t *) &now)); - strftime(ustime, sizeof ustime, timeFormat, gmtime((time_t *) &upsince)); + + now_val = now; + strftime(udate, sizeof udate, timeFormat, gmtime(&now_val)); + time_t upsince_val = upsince; + strftime(ustime, sizeof ustime, timeFormat, gmtime(&upsince_val)); fprintf(hf, "\ \n\ @@ -146,8 +150,10 @@ strcpy(udate, "Never contacted"); strcpy(ustime, ""); } else { - strftime(udate, sizeof udate, "%Y-%m-%d %T", gmtime((time_t *) &eggtable[i].lastupd)); - strftime(ustime, sizeof ustime, "%Y-%m-%d %T", gmtime((time_t *) &eggStatistics[i].firstPacket)); + time_t lastupd_val = eggtable[i].lastupd; + strftime(udate, sizeof udate, "%Y-%m-%d %T", gmtime(&lastupd_val)); + time_t firstPacket_val = eggStatistics[i].firstPacket; + strftime(ustime, sizeof ustime, "%Y-%m-%d %T", gmtime(&firstPacket_val)); } if (eggtable[i].url == NULL) { url1[0] = url2[0] = 0; @@ -181,7 +187,7 @@ coverage = 100; } - fprintf(hf, "%ld%ld%ld%%%.3f\n", + fprintf(hf, "%d%d%d%%%.3f\n", eggStatistics[i].trials, eggStatistics[i].missing, coverage, @@ -213,8 +219,9 @@ \n"); fclose(hf); #ifdef DEBUG + now_val = now; fprintf(stderr, "Updating HTML file %s at %s", - htmlFile, asctime(gmtime((time_t *) &now))); + htmlFile, asctime(gmtime(&now_val))); #endif } } @@ -436,9 +443,10 @@ memcpy(&egg_now_time, pktbuf + 6, sizeof egg_now_time); egg_now_time = ntohl(egg_now_time); - fprintf(stderr, "Awake egg %d (%s) at its %lu: %s", + time_t egg_now_time_val = egg_now_time; + fprintf(stderr, "Awake egg %d (%s) at its %u: %s", pkt_eggid, eggtable[thisegg].name, egg_now_time, - asctime(gmtime((time_t *) &egg_now_time))); + asctime(gmtime(&egg_now_time_val))); } #endif @@ -617,14 +625,14 @@ EggHeader packet. */ dpktp = &dpk; - unpackShort(dpk.type); - unpackShort(dpk.pktsize); - unpackShort(dpk.eggid); - unpackShort(dpk.samp_rec); - unpackShort(dpk.sec_rec); - unpackShort(dpk.rec_pkt); - unpackByte(dpk.trialsz); - unpackShort(dpk.numrec); + unpack16(dpk.type); + unpack16(dpk.pktsize); + unpack16(dpk.eggid); + unpack16(dpk.samp_rec); + unpack16(dpk.sec_rec); + unpack16(dpk.rec_pkt); + unpack8(dpk.trialsz); + unpack16(dpk.numrec); /* This spoofing test is probably completely redundant now. */ #ifndef EGG_DYNAMIC @@ -647,7 +655,7 @@ char *spktp = pktP; if (result.hdr.numrec > 0) { - unpackLong(stamp); + unpack32(stamp); } pktP = spktp; fprintf(stderr, "Received packet: %d records from egg %d (%s).\n", @@ -659,19 +667,20 @@ transcribe to the result EggCarton. */ for (latest = 0, rec = 0; rec < result.hdr.numrec; rec++) { - unpackLong(result.records[rec].timestamp); /* Record timestamp */ + unpack32(result.records[rec].timestamp); /* Record timestamp */ if (result.records[rec].timestamp > latest) latest = result.records[rec].timestamp; #ifdef DEBUG - fprintf(stderr, " %10lu ", result.records[rec].timestamp); + fprintf(stderr, " %10u ", result.records[rec].timestamp); #endif /* Assumes sizeof(trial) = 1 */ - unpackBytes(&(result.records[rec].trials), result.hdr.samp_rec); + unpack8s(&(result.records[rec].trials), result.hdr.samp_rec); #ifdef DEBUG for (i = 0; i < result.hdr.samp_rec; i++) { fprintf(stderr, "%3d ", result.records[rec].trials[i]); } - fprintf(stderr, "%s", asctime(gmtime((time_t *) &result.records[rec].timestamp))); + time_t timestamp_val = result.records[rec].timestamp; + fprintf(stderr, "%s", asctime(gmtime(×tamp_val))); #endif } @@ -748,10 +757,10 @@ static void MakeRequest(ReqPacket *pkt, uint16 eggid, uint32 whence) { char *pktP = (char *) pkt; - packShort(REQ_PACKET); - packShort((4 * sizeof(uint16)) + sizeof(uint32)); - packShort(eggid); - packLong(whence); + pack16(REQ_PACKET); + pack16((4 * sizeof(uint16)) + sizeof(uint32)); + pack16(eggid); + pack32(whence); } /* MakeSettings -- Create a settings packet. This packet, @@ -761,14 +770,14 @@ static void MakeSettings(SettingsPacket *pkt, uint16 eggid) { char *pktP = (char *) pkt; - packShort(SETTINGS_PACKET); - packShort((7 * sizeof(uint16)) + sizeof(uint32) + sizeof(trial)); - packShort(eggid); - packLong(getzulutime(NULL)); - packShort(protocol.samp_rec); - packShort(protocol.sec_rec); - packShort(protocol.rec_pkt); - packByte(protocol.trialsz); + pack16(SETTINGS_PACKET); + pack16((7 * sizeof(uint16)) + sizeof(uint32) + sizeof(trial)); + pack16(eggid); + pack32(getzulutime(NULL)); + pack16(protocol.samp_rec); + pack16(protocol.sec_rec); + pack16(protocol.rec_pkt); + pack8(protocol.trialsz); } /* LoadEggStats -- Initialise in-memory egg status table @@ -827,7 +836,7 @@ fprintf(fp, "# Status lines of form:\n"); fprintf(fp, "# STAT \n"); for (i = 0; i < numeggs; i++) { - fprintf(fp, "STAT %s %d %ld %d\n", + fprintf(fp, "STAT %s %d %u %d\n", eggtable[i].name, eggtable[i].id, eggtable[i].lastupd, --- gcpegg-5.1.orig/byteorder.h +++ gcpegg-5.1/byteorder.h @@ -12,25 +12,25 @@ on RISC machines which typically require values to be aligned at an even multiple of their length. */ -#define packShort(x) { \ - short s = htons((short) (x)); \ - memcpy(pktP, &s, sizeof(short)); \ - pktP += sizeof(short); \ +#define pack16(x) { \ + uint16 s = htons((uint16) (x)); \ + memcpy(pktP, &s, sizeof(uint16)); \ + pktP += sizeof(uint16); \ } -#define packLong(x) { \ - long l = htonl((long) (x)); \ - memcpy(pktP, &l, sizeof(long)); \ - pktP += sizeof(long); \ +#define pack32(x) { \ + uint32 i = htonl((uint32) (x)); \ + memcpy(pktP, &i, sizeof(uint32)); \ + pktP += sizeof(uint32); \ } -#define packByte(x) { \ +#define pack8(x) { \ char c = (x); \ memcpy(pktP, &c, sizeof(char)); \ pktP += sizeof(char); \ } -#define packBytes(x, n) { \ +#define pack8s(x, n) { \ memcpy(pktP, x, n); \ pktP += n; \ } @@ -40,25 +40,25 @@ pktP. Note that the argument of these macros must be an lvalue. */ -#define unpackShort(x) { \ - short s; \ - memcpy(&s, pktP, sizeof(short)); \ - pktP += sizeof(short); \ +#define unpack16(x) { \ + uint16 s; \ + memcpy(&s, pktP, sizeof(uint16)); \ + pktP += sizeof(uint16); \ x = ntohs(s); \ } -#define unpackLong(x) { \ - long l; \ - memcpy(&l, pktP, sizeof(long)); \ - pktP += sizeof(long); \ - x = ntohl(l); \ +#define unpack32(x) { \ + uint32 i; \ + memcpy(&i, pktP, sizeof(uint32)); \ + pktP += sizeof(uint32); \ + x = ntohl(i); \ } -#define unpackByte(x) { \ +#define unpack8(x) { \ *((char *) &x) = (char) *pktP++; \ } -#define unpackBytes(x, n) { \ +#define unpack8s(x, n) { \ memcpy(x, pktP, n); \ pktP += n; \ } --- gcpegg-5.1.orig/debian/.eggprotocolrc +++ gcpegg-5.1/debian/.eggprotocolrc @@ -0,0 +1,5 @@ +# +# Current protocol for egg +# +# PROTOCOL +PROTOCOL 10 10 30 200 --- gcpegg-5.1.orig/debian/README.debian +++ gcpegg-5.1/debian/README.debian @@ -0,0 +1,23 @@ +The upstream source assumes you will use a traditional hard-wired serial +port, but those are getting rare. Rather than refactor the code, I've just +made the Debian package always open the device /dev/REG. All you need to +do is symlink this to whatever your actual serial port is with something like: + + cd /dev + ln -s ttyUSB0 REG + +The 'port' field in the REG line of the eggrc file will be ignored, so just +leave it set to '0'. + + - - - - - + +If the EGG computer is behind a firewall, it must be programmed +to allow UDP packets on port 2510 outgoing packet and UDP port +1105 for an incoming connection. + +This allows the bidirectional communication required for the data +to be transmitted. What happens is that your program sends an +"awake" packet when it has unsent data. The server in Princeton +responds with a "data request" packet, and then the EGG program +will send the data. + --- gcpegg-5.1.orig/debian/changelog +++ gcpegg-5.1/debian/changelog @@ -0,0 +1,109 @@ +gcpegg (5.1-13build1) xenial; urgency=medium + + * No-change rebuild for ncurses6 transition. + + -- Matthias Klose Sat, 06 Feb 2016 20:52:33 +0000 + +gcpegg (5.1-13) unstable; urgency=low + + * merge 64-bit fixes from Fernando Lucas Rodriguez , + closes: #680014 + * fix additional 64-bit isms in the UI code + * revise dependency to be kbd | console-tools to ease backport support + * unqualify openvt path in init.d to tolerate /bin or /usr/bin + * enable the use of USB serial ports, etc, by making eggsh always open + /dev/REG, which is now assumed to be a symlink to the actual device + + -- Bdale Garbee Tue, 03 Jul 2012 15:21:57 -0600 + +gcpegg (5.1-12) unstable; urgency=low + + * change dep to get 'open' from console-tools to kbd, closes: #671082 + + -- Bdale Garbee Thu, 03 May 2012 11:43:39 -0600 + +gcpegg (5.1-11) unstable; urgency=low + + * add Vcs entries to the control file + * change dep from open to console-tools + * change arch to linux-any to avoid kfreebsd folk thinking this package + is worth spending any time on, closes: #648362 + + -- Bdale Garbee Thu, 10 Nov 2011 13:49:00 -0700 + +gcpegg (5.1-10) unstable; urgency=low + + * add a purge target to the init.d script, closes: #367123 + * merge patch that adds support for Debian/kfreebsd, closes: #414405 + * rename 'basket' to 'gcpbasket' to avoid package conflict, closes: #420632 + * add LSB structure to init.d + * update standards version + + -- Bdale Garbee Sat, 28 Apr 2007 11:01:23 -0600 + +gcpegg (5.1-9) unstable; urgency=low + + * use fully qualified pathnames in init.d, addresses another part of 347778 + + -- Bdale Garbee Fri, 14 Apr 2006 23:36:52 -0600 + +gcpegg (5.1-8) unstable; urgency=low + + * move to newer debhelper compatibility level, closes: #328793, #359417 + * add -f to openvt invocation in init.d, and create a README.debian with + firewalling information, at suggestion of Fernando Lucas Rodriguez + * improve the existence check in init.d, addresses part of 347778 + * add text to README.debian about know problems on at least amd64 + + -- Bdale Garbee Fri, 14 Apr 2006 23:32:30 -0600 + +gcpegg (5.1-7) unstable; urgency=low + + * change build dependency to use libncurses-dev, closes: #101655 + * various packaging cleanups for things lintian discovered + * augment list of header files included, to eliminate implicit declarations + + -- Bdale Garbee Sun, 22 Jul 2001 23:59:25 -0600 + +gcpegg (5.1-6) unstable; urgency=low + + * use 'openvt' instead of 'open' in init.d since that's canonical now, + closes: #53180 + * update sample eggrc file to reflect current protocol, closes: #79545 + + -- Bdale Garbee Wed, 20 Dec 2000 12:24:57 -0700 + +gcpegg (5.1-5) unstable; urgency=low + + * fix inconsistent virtual terminal number in init.d script + + -- Bdale Garbee Wed, 15 Dec 1999 17:39:17 -0700 + +gcpegg (5.1-4) unstable; urgency=low + + * add a missing item to build dependencies + + -- Bdale Garbee Sun, 5 Dec 1999 20:41:31 -0700 + +gcpegg (5.1-3) unstable; urgency=low + + * update to current policy + + -- Bdale Garbee Wed, 1 Dec 1999 23:48:50 -0700 + +gcpegg (5.1-2) unstable; urgency=low + + * move the display to virtual terminal 8, which is unlikely to get in + the way of anthing else going on. Thanks to Craig Sanders for the + suggestion. + + -- Bdale Garbee Mon, 10 May 1999 07:38:23 -0600 + +gcpegg (5.1-1) unstable; urgency=low + + * Initial Release. + * add init.d fragment to auto-launch, uses 'open' and puts the program + on virtual terminal 2. This may not make everyone happy, but is good + enough for now. + + -- Bdale Garbee Sun, 9 May 1999 20:06:40 -0600 --- gcpegg-5.1.orig/debian/compat +++ gcpegg-5.1/debian/compat @@ -0,0 +1 @@ +5 --- gcpegg-5.1.orig/debian/control +++ gcpegg-5.1/debian/control @@ -0,0 +1,24 @@ +Source: gcpegg +Section: misc +Priority: optional +Maintainer: Bdale Garbee +Build-Depends: debhelper (>= 5), libncurses-dev +Standards-Version: 3.9.3 +Vcs-Git: git://git.gag.com/debian/gcpegg +Vcs-Browser: http://git.gag.com/?p=debian/gcpegg + +Package: gcpegg +Architecture: linux-any +Depends: ${shlibs:Depends}, ${misc:Depends}, kbd | console-tools +Description: Global Consciousness Project EGG Software + The GCP studies data from random event generators in widely distributed + locations, to discern non-random patterns that may result from the + interaction of human consciousness with the generators. + . + This package provides the software required to operate a random event + generator and return data to the project. Unless you are registered + with the GCP and have received event generator hardware, this package + will be useless to you. If you have no idea what this means, don't + bother installing this package! + . + More GCP information is available at http://global-mind.org --- gcpegg-5.1.orig/debian/copyright +++ gcpegg-5.1/debian/copyright @@ -0,0 +1,24 @@ +This package was debianized by Bdale Garbee bdale@gag.com on +Wed, 28 Apr 1999 20:43:12 -0600. + +It was downloaded from http://noosphere.princeton.edu/ + +Upstream Author: Greg Nelson + +Copyright: + + The author indicated the GPL, version 2 or later. The current text in + the sourcecode is a bit confused, and will be fixed in a future + release. Here's what's there now: + + Copyright 1998 - Greg Nelson + + Source code in this directory is in the public domain and may be + used in any manner whatsoever without permission, restriction, + compensation, or attribution, whether for commercial or noncommercial + purposes. For details, see the GNU General Public License; a copy is + present in this directory in the file gnu.html. + +On Debian GNU/Linux systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. + --- gcpegg-5.1.orig/debian/dirs +++ gcpegg-5.1/debian/dirs @@ -0,0 +1,5 @@ +etc +usr/share/man/man1 +usr/sbin +usr/share/lintian/overrides +var/spool/gcpegg --- gcpegg-5.1.orig/debian/docs +++ gcpegg-5.1/debian/docs @@ -0,0 +1 @@ +README --- gcpegg-5.1.orig/debian/gbp.conf +++ gcpegg-5.1/debian/gbp.conf @@ -0,0 +1,46 @@ +# Configuration file for git-buildpackage and friends + +[DEFAULT] +# the default build command: +#builder = debuild -i\.git/ -I.git +# the default clean command: +#cleaner = debuild clean +# the default branch for upstream sources: +upstream-branch = upstream +# the default branch for the debian patch: +debian-branch = master +# the default tag formats used: +#upstream-tag = upstream/%(version)s +#debian-tag = debian/%(version)s +# use pristine-tar: +pristine-tar = True + +# Options only affecting git-buildpackage +[git-buildpackage] +#upstream-branch = dfsgclean +# uncomment this to automatically GPG sign tags +#sign-tags = True +# keyid to GPG sign tags with +#keyid = 0xdeadbeef +# push to a remote repository after a successful tag: +#posttag = git-push git.example.com +# use this for more svn-buildpackage like behaviour: +export-dir = ../build-area/gcpegg/ +#tarball-dir = ../tarballs/ + +# Options only affecting git-import-orig +[git-import-orig] +#upstream-branch = newupstream +#debian-branch = dfsgclean +#filter = .svn + +# Options only affecting git-import-dsc +[git-import-dsc] +#upstream-branch = svn-upstream +#filter = [ 'CVS', '.cvsignore' ] + +# Options only affecting git-dch +[git-dch] +#git-log = --no-merges +#snapshot-number = snapshot + 1 + --- gcpegg-5.1.orig/debian/gcpegg.1 +++ gcpegg-5.1/debian/gcpegg.1 @@ -0,0 +1,35 @@ +.TH GCPEGG 1 +.SH NAME +gcpegg \- Global Consciousness Project REG Software +.SH SYNOPSIS +.B gcpbasket +.br +.B eggsh +.br +.B regtest +.br +.SH "DESCRIPTION" +These programs are the pieces needed to host a REG for the Global +Consciousness Project. The sourcecode ships with essentially no +documentation, this manual page has been written for Debian GNU/Linux +to provide the briefest of overviews. + +.SH "COMMANDS" + +The +.BR eggsh +program is the main data collection and transmission program. It is +launched at boot and runs persistently. Is is configured using the +/etc/eggrc file. + +The +.B gcpbasket +command is the data collector, and is not normally needed by an EGG +site. + +The +.B regtest +command provides a simple test of REG operation. + +.SH "SEE ALSO" +.B http://noosphere.princeton.edu --- gcpegg-5.1.orig/debian/init.d +++ gcpegg-5.1/debian/init.d @@ -0,0 +1,47 @@ +#!/bin/sh + +### BEGIN INIT INFO +# Provides: gcpegg +# Required-Start: $local_fs $remote_fs +# Required-Stop: $local_fs $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start GCP EGG software on virtual terminal 8 +### END INIT INFO + +set -e + +test -x /usr/sbin/eggsh || exit 0 +test -d /var/spool/gcpegg || exit 0 + +cd /var/spool/gcpegg + +case "$1" in + start) + echo -n "Starting GCP EGG software on virtual terminal 8: eggsh" + openvt -f -c 8 /usr/sbin/eggsh + echo "." + ;; + stop) + echo -n "Stopping GCP EGG software: eggsh" + start-stop-daemon --stop --quiet --oknodo --exec /usr/sbin/eggsh + echo "." + ;; + reload|force-reload|restart) + echo -n "Restarting GCP EGG software on virtual terminal 8..." + start-stop-daemon --stop --quiet --oknodo --exec /usr/sbin/eggsh + openvt -f -c 8 /usr/sbin/eggsh + echo "done." + ;; + purge) + echo -n "Purging all previously generated data by GCP EGG" + rm -r /var/spool/gcpegg/* + echo "done." + ;; + *) + echo "Usage: /etc/init.d/gcpegg {start|stop|reload|force-reload|restart|purge}" + exit 1 + ;; +esac + +exit 0 --- gcpegg-5.1.orig/debian/rules +++ gcpegg-5.1/debian/rules @@ -0,0 +1,67 @@ +#!/usr/bin/make -f + +export DH_VERBOSE=1 + +build: build-arch build-indep +build-arch: build-stamp +build-indep: build-stamp +build-stamp: + dh_testdir + $(MAKE) + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp install-stamp + [ ! -f Makefile ] || $(MAKE) clean + dh_clean + +install: install-stamp +install-stamp: build-stamp + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + /usr/bin/install -o root -g root -m 0755 eggsh debian/gcpegg/usr/sbin + /usr/bin/install -o root -g root -m 0755 regtest debian/gcpegg/usr/sbin + /usr/bin/install -o root -g root -m 0755 basket \ + debian/gcpegg/usr/sbin/gcpbasket + /usr/bin/install -o root -g root -m 0644 eggrc.sample \ + debian/gcpegg/etc/eggrc + /usr/bin/install -o root -g root -m 0644 debian/gcpegg.1 \ + debian/gcpegg/usr/share/man/man1/gcpegg.1 + gzip -9 debian/gcpegg/usr/share/man/man1/gcpegg.1 + ( cd debian/gcpegg/usr/share/man/man1 ; \ + ln gcpegg.1.gz gcpbasket.1.gz ;\ + ln gcpegg.1.gz eggsh.1.gz ;\ + ln gcpegg.1.gz regtest.1.gz ) + touch install-stamp + +# Build architecture-independent files here. +binary-indep: build install + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installdocs + dh_installexamples + dh_installmenu + dh_installinit + dh_installcron + dh_installchangelogs + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +source diff: + @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false + +binary: binary-indep binary-arch +.PHONY: build build-arch build-indep clean binary binary-arch binary-indep --- gcpegg-5.1.orig/egg.c +++ gcpegg-5.1/egg.c @@ -49,6 +49,7 @@ #include #include #include +#include #include "global.h" #include "genlib.h" @@ -94,7 +95,7 @@ char *pgmname; /* Program name from argv[0] */ char *myaddr; /* Interface to bind */ int16 myport; /* Service port to bind */ -int32 lastDataSent = 0; /* Time last packet sent to basket */ +uint32 lastDataSent = 0; /* Time last packet sent to basket */ /* If no priority increment has been specified at compile time, set to our default of ±10. [+/- 10, for folks without 8bit editors] */ @@ -106,7 +107,7 @@ /* Status exported to user interface. */ -int32 time_latency = 0, time_housekeeping = 0; +uint32 time_latency = 0, time_housekeeping = 0; #ifdef ALT_UI static double mean_Packet = 0.0, mean_Grand = 0.0; @@ -292,7 +293,7 @@ } #ifdef DEBUG else { - printf("REG configured: %s = %d, %d, %ld\n", configuredREG ->reg_name, + printf("REG configured: %s = %d, %d, %d\n", configuredREG ->reg_name, devopts.type, devopts.port, devopts.baud); } #endif @@ -463,7 +464,7 @@ totalTrials += ptrials; mean_Grand = totalGrand / totalTrials; total_Packets++; - printf("Packets sent: %ld Packet mean: %6.2f Grand mean: %6.2f\n", + printf("Packets sent: %d Packet mean: %6.2f Grand mean: %6.2f\n", total_Packets, mean_Packet, mean_Grand); #endif } @@ -489,7 +490,7 @@ /* But let's be sure it really *is* in the interval. */ if (t.tv_sec < savebuffer.records[0].timestamp || t.tv_sec >= (savebuffer.records[0].timestamp + savebuffer.hdr.sec_rec * savebuffer.hdr.rec_pkt)) { - fprintf(stderr, "***Sample, collected at %ld, is not within packet starting at %ld.\n", + fprintf(stderr, "***Sample, collected at %ld, is not within packet starting at %u.\n", t.tv_sec, savebuffer.records[0].timestamp); exit(-1); } @@ -605,11 +606,12 @@ uint32 stime; char *pktP = pktbuf + (2 * sizeof(uint16)); - unpackShort(reggid); - unpackLong(stime); + unpack16(reggid); + unpack32(stime); #ifdef PACKETDUMP - fprintf(stderr, "Request: eggid = %d, starttm = %ld: %s", - reggid, stime, asctime(gmtime((time_t *) &stime))); + time_t stime_val = stime; + fprintf(stderr, "Request: eggid = %d, starttm = %u: %s\n", + reggid, stime, asctime(gmtime(&stime_val))); #endif res = LoadPacket(stime, reggid, &retrcart); } @@ -639,10 +641,10 @@ { char *pktP = pktbuf + (3 * sizeof(uint16)) + sizeof(uint32); - unpackShort(protocol.samp_rec); - unpackShort(protocol.sec_rec); - unpackShort(protocol.rec_pkt); - unpackByte(protocol.trialsz); + unpack16(protocol.samp_rec); + unpack16(protocol.sec_rec); + unpack16(protocol.rec_pkt); + unpack8(protocol.trialsz); } #ifdef PACKETDUMP fprintf(stderr, "Settings: samp_rec = %d, sec_rec = %d, rec_pkt = %d, trialsz = %d\n", @@ -672,12 +674,12 @@ usec = time_latency; msec = usec / 1000; usec %= 1000; - printf("Sampling latency: %ld.%03ld msec", msec, usec); + printf("Sampling latency: %d.%03d msec", msec, usec); usec = time_housekeeping; msec = usec / 1000; usec %= 1000; - printf(" Housekeeping time: %ld.%03ld msec\n", msec, usec); + printf(" Housekeeping time: %d.%03d msec\n", msec, usec); #endif lt = ct; sleeptime = ((1000000 - SLACK) - ct.tv_usec); @@ -845,10 +847,10 @@ static void MakeAwake(AwakePacket *pkt) { char *pktP = (char *) pkt; - packShort(AWAKE_PACKET); - packShort((4 * sizeof(uint16)) + sizeof(uint32)); - packShort(eggtable[0].id); - packLong(getzulutime(NULL)); + pack16(AWAKE_PACKET); + pack16((4 * sizeof(uint16)) + sizeof(uint32)); + pack16(eggtable[0].id); + pack32(getzulutime(NULL)); } /* MakeDataPkt -- Build a canonical network byte order data packet @@ -866,20 +868,20 @@ /* Assemble header fields into data packet. */ - packShort(src->hdr.type = DATA_PACKET); - packShort(src->hdr.pktsize = pktsize); - packShort(src->hdr.eggid); - packShort(src->hdr.samp_rec); - packShort(src->hdr.sec_rec); - packShort(src->hdr.rec_pkt); - packByte(src->hdr.trialsz); - packShort(src->hdr.numrec); + pack16(src->hdr.type = DATA_PACKET); + pack16(src->hdr.pktsize = pktsize); + pack16(src->hdr.eggid); + pack16(src->hdr.samp_rec); + pack16(src->hdr.sec_rec); + pack16(src->hdr.rec_pkt); + pack8(src->hdr.trialsz); + pack16(src->hdr.numrec); /* Append data records to packet. */ for (rec = 0; rec < src->hdr.numrec; rec++) { - packLong(src->records[rec].timestamp); - packBytes(&(src->records[rec].trials), src->hdr.samp_rec); + pack32(src->records[rec].timestamp); + pack8s(&(src->records[rec].trials), src->hdr.samp_rec); } /* No need to calculate CRC -- NetTalk does that for us. --- gcpegg-5.1.orig/eggrc.sample +++ gcpegg-5.1/eggrc.sample @@ -58,8 +58,8 @@ #BASKET diesse 193.8.230.134 # noosphere -> diesse -EGG noosphere 28 128.112.35.133 diesse PERM 1 -BASKET diesse 193.8.230.134 +#EGG noosphere 28 128.112.35.133 diesse PERM 1 +#BASKET diesse 193.8.230.134 # throop -> diesse #EGG throop 1003 193.8.230.132 diesse PERM 1 http://www.fourmilab.ch/ @@ -78,9 +78,16 @@ #BASKET tonga 209.157.90.137 #BASKET tonga1 209.157.90.138 -PROTOCOL 10 10 6 200 +#PROTOCOL 10 10 6 200 #REG PEAR 2 9600 -REG PSEUDO 1 9600 +#REG PSEUDO 1 9600 #REG ORION 1 9600 -NETUP pppscript up -NETDOWN pppscript down +#NETUP pppscript up +#NETDOWN pppscript down + +egg.host.name ID# IP_address noosphere PERM 1 +BASKET noosphere 128.112.35.133 +PROTOCOL 10 10 30 200 +REG ORION 0 9600 +#REG PEAR 0 9600 + --- gcpegg-5.1.orig/eggui.c +++ gcpegg-5.1/eggui.c @@ -37,6 +37,8 @@ #include #include #include +#include +#include /* Curses takes it upon itself to define TRUE and FALSE, incompatibly, as it happens, with the definitions in @@ -55,11 +57,11 @@ #include "version.h" #ifndef NO_UI -static int32 inittm = 0; +static uint32 inittm = 0; #endif -extern int32 lastDataSent; -extern int32 time_latency, time_housekeeping; +extern uint32 lastDataSent; +extern uint32 time_latency, time_housekeeping; /* Initialize user interface, as needed. */ int32 UIInit(void) { @@ -110,10 +112,10 @@ if (coll->sampct == 1) { line = 11; - move(line++, 5); printw("Samples per record: %3d", (int)coll->opts.samp_rec); - move(line++, 5); printw("Seconds per record: %3d", (int)coll->opts.sec_rec); - move(line++, 5); printw("Records per packet: %3d", (int)coll->opts.rec_pkt); - move(line++, 5); printw("Bits per trial: %3d", (int)coll->opts.trialsz); + move(line++, 5); printw("Samples per record: %3d", coll->opts.samp_rec); + move(line++, 5); printw("Seconds per record: %3d", coll->opts.sec_rec); + move(line++, 5); printw("Records per packet: %3d", coll->opts.rec_pkt); + move(line++, 5); printw("Bits per trial: %3d", coll->opts.trialsz); refresh(); } @@ -124,17 +126,20 @@ printw("EGG %s ID %d REG %s %s", eggtable[0].name, eggtable[0].id, configuredREG->reg_name, Version); - tmstr = ctime(&inittm); tmstr[strlen(tmstr)-1] = 0; + time_t inittm_val = inittm; + tmstr = ctime(&inittm_val); tmstr[strlen(tmstr)-1] = 0; move(line++, 5); printw("Up since %25s", tmstr); move(line++, 5); now = getzulutime(NULL); - tmstr = ctime(&now); tmstr[strlen(tmstr)-1] = 0; + time_t now_val = now; + tmstr = ctime(&now_val); tmstr[strlen(tmstr)-1] = 0; printw("Last sample at %25s", tmstr); move(line++, 5); - tmstr = ctime(&lastDataSent); + time_t lastDataSent_val = lastDataSent; + tmstr = ctime(&lastDataSent_val); tmstr[strlen(tmstr)-1] = 0; printw("Last packet at %25s", lastDataSent == 0 ? "Never" : tmstr); --- gcpegg-5.1.orig/genlib.c +++ gcpegg-5.1/genlib.c @@ -38,7 +38,7 @@ #include "global.h" #include "genlib.h" -int32 getzulutime(struct timeval *ztv) { +uint32 getzulutime(struct timeval *ztv) { struct timeval ttv; if (ztv) { @@ -86,31 +86,33 @@ /* Assemble header fields into data packet. */ - packShort(src->hdr.type = DATA_PACKET); - packShort(src->hdr.pktsize = pktsize); - packShort(src->hdr.eggid); - packShort(src->hdr.samp_rec); - packShort(src->hdr.sec_rec); - packShort(src->hdr.rec_pkt); - packByte(0); /* Pad byte in case we want to expand trialsz */ - packByte(src->hdr.trialsz); - packShort(src->hdr.numrec); + pack16(src->hdr.type = DATA_PACKET); + pack16(src->hdr.pktsize = pktsize); + pack16(src->hdr.eggid); + pack16(src->hdr.samp_rec); + pack16(src->hdr.sec_rec); + pack16(src->hdr.rec_pkt); + pack8(0); /* Pad byte in case we want to expand trialsz */ + pack8(src->hdr.trialsz); + pack16(src->hdr.numrec); /* Append data records to packet. */ for (rec = 0; rec < src->hdr.numrec; rec++) { - packLong(src->records[rec].timestamp); - packBytes(&(src->records[rec].trials), src->hdr.samp_rec); + pack32(src->records[rec].timestamp); + pack8s(&(src->records[rec].trials), src->hdr.samp_rec); } + /* Get CRC, pack into base(32,32,64) notation, and add tag byte (0xFF) */ lbuf = BlockCRC16((byte *) rbuf, pktP - rbuf); lbuf = ((lbuf & 0xF800) << 13) | ((lbuf & 0x07C0) << 10) | ((lbuf & 0x003F) << 8) | (0x00FF); - packLong(lbuf); + pack32(lbuf); + if ((pktP - rbuf) != pktsize) { - fprintf(stderr, "Length mismatch assembling packet. Computed: %d, actually packed: %d.\n", + fprintf(stderr, "Length mismatch assembling packet. Computed: %d, actually packed: %ld.\n", pktsize, pktP - rbuf); } return rbuf; @@ -125,15 +127,15 @@ /* Unpack the portable header into a host-order and aligned EggHeader packet. */ - unpackShort(dst->hdr.type); - unpackShort(dst->hdr.pktsize); - unpackShort(dst->hdr.eggid); - unpackShort(dst->hdr.samp_rec); - unpackShort(dst->hdr.sec_rec); - unpackShort(dst->hdr.rec_pkt); - unpackByte(pad); /* Pad in case we later grow trialsz */ - unpackByte(dst->hdr.trialsz); - unpackShort(dst->hdr.numrec); + unpack16(dst->hdr.type); + unpack16(dst->hdr.pktsize); + unpack16(dst->hdr.eggid); + unpack16(dst->hdr.samp_rec); + unpack16(dst->hdr.sec_rec); + unpack16(dst->hdr.rec_pkt); + unpack8(pad); /* Pad in case we later grow trialsz */ + unpack8(dst->hdr.trialsz); + unpack16(dst->hdr.numrec); if (dst->hdr.type != DATA_PACKET) { #ifdef DEBUG @@ -145,9 +147,9 @@ /* Unpack the data records from the file packet. */ for (rec = 0; rec < dst->hdr.numrec; rec++) { - unpackLong(dst->records[rec].timestamp); + unpack32(dst->records[rec].timestamp); /* Assumes sizeof(trial) = 1 */ - unpackBytes(&(dst->records[rec].trials), dst->hdr.samp_rec); + unpack8s(&(dst->records[rec].trials), dst->hdr.samp_rec); } /* Compute the CRC, reassemble into record terminator, @@ -159,18 +161,18 @@ ((lbuf & 0x003F) << 8) | (0x00FF); - unpackLong(filecrc); + unpack32(filecrc); if (lbuf != filecrc) { #ifdef DEBUG - fprintf(stderr, "Bad CRC in packet read from file. Read 0x%08lX, computed 0x%08lX.\n", filecrc, lbuf); + fprintf(stderr, "Bad CRC in packet read from file. Read 0x%08X, computed 0x%08X.\n", filecrc, lbuf); #endif return -2; } if (dst->hdr.pktsize != (pktP - src)) { #ifdef DEBUG - fprintf(stderr, "Length mismatch decoding packet. Header: %d, length decoded: %d.\n", + fprintf(stderr, "Length mismatch decoding packet. Header: %d, length decoded: %ld.\n", dst->hdr.pktsize, pktP - src); #endif return -1; @@ -210,7 +212,7 @@ void dquad2sockaddr(struct sockaddr_in *sinp, int16 *mask, char *dquad) { char *tp, *loser; - long saddr; + uint32 saddr; short qcount; loser = mallocpy(dquad); @@ -237,16 +239,16 @@ } char *sockaddr2dquad(struct sockaddr_in *sinp) { - long saddr; + uint32 saddr; saddr = ntohl(sinp->sin_addr.s_addr); return hl2dquad(saddr); } -char *hl2dquad(long addr) { +char *hl2dquad(uint32 addr) { static char resout[16]; - sprintf(resout, "%ld.%ld.%ld.%ld", + sprintf(resout, "%u.%u.%u.%u", (addr >> 24) & 0xFF, (addr >> 16) & 0xFF, (addr >> 8) & 0xFF, addr & 0xFF); --- gcpegg-5.1.orig/genlib.h +++ gcpegg-5.1/genlib.h @@ -37,7 +37,7 @@ /* Get time in GMT reference frame. If ztv is NULL, simply returns seconds. Otherwise, returns complete timeval in ztv as well. */ -extern int32 getzulutime(struct timeval *ztv); +extern uint32 getzulutime(struct timeval *ztv); /* Get difference in msec between two tvs. */ extern int32 deltams(struct timeval *tv1, struct timeval *tv2); @@ -59,7 +59,7 @@ extern char *mallocpy(char *input); extern void dquad2sockaddr(struct sockaddr_in *sinp, int16 *mask, char *dquad); extern char *sockaddr2dquad(struct sockaddr_in *sinp); /* Static buffer! */ -extern char *hl2dquad(long addr); /* Static buffer! */ +extern char *hl2dquad(uint32 addr); /* Static buffer! */ /* Access to system or emulated usleep(). */ --- gcpegg-5.1.orig/global.h +++ gcpegg-5.1/global.h @@ -32,13 +32,35 @@ #include "byteorder.h" /* Build byte-order independent version */ /* Good for i386, but be careful... */ -typedef unsigned char byte; -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned long uint32; -typedef char int8; -typedef short int16; -typedef long int32; +/* +#ifdef linux +#include + typedef __u8 byte; + typedef __u8 uint8; + typedef __u16 uint16; + typedef __u32 uint32; + typedef __s8 int8; + typedef __s16 int16; + typedef __s32 int32; +#else + typedef unsigned char byte; + typedef unsigned char uint8; + typedef unsigned ushort uint16; + typedef unsigned uint uint32; + typedef char int8; + typedef short int16; + typedef int int32; +#endif +*/ + +#include +typedef uint8_t byte; +typedef uint8_t uint8; +typedef uint16_t uint16; +typedef uint32_t uint32; +typedef int8_t int8; +typedef int16_t int16; +typedef int32_t int32; /* Some fixed assumptions: Trial type is always bitsum. @@ -157,7 +179,7 @@ char *primbasket; int16 conntype; int16 connival; /* Connect interval in minutes */ - int32 lastupd; /* Zulutime of last update received */ + uint32 lastupd; /* Zulutime of last update received */ int16 setup; /* Does setup match config file? */ char *upcmd; /* Command to bring net up (req if conntype == DND) */ char *dncmd; /* Command to bring net down */ --- gcpegg-5.1.orig/hw_pear.c +++ gcpegg-5.1/hw_pear.c @@ -87,7 +87,7 @@ designating /dev/term/a. */ sprintf(ttydev, "/dev/term/%c", 'a' + (opts->port - 1)); #else - sprintf(ttydev, "/dev/ttyS%d", opts->port); + sprintf(ttydev, "/dev/REG", opts->port); #endif switch(opts->baud) { --- gcpegg-5.1.orig/network.c +++ gcpegg-5.1/network.c @@ -237,7 +237,7 @@ size = sizeof(*sin); count = recvfrom(sd, buffer, MAXBUFSIZE, 0, - (struct sockaddr *)sin, (int *)&size); + (struct sockaddr *)sin, (socklen_t *)&size); if (count < 0) { /* Don't wait for it. */ if (errno == EWOULDBLOCK) return ERR_COMM_TMOUT; @@ -246,7 +246,7 @@ } #ifdef HEXDUMP - fprintf(stderr, "Received %ld bytes from %s\n", count, + fprintf(stderr, "Received %d bytes from %s\n", count, inet_ntoa(sin->sin_addr)); xd(stderr, buffer, count, FALSE); #endif @@ -274,7 +274,7 @@ pktsize = ntohs(rpktsize); if (pktsize != count) { #ifdef DEBUG - fprintf(stderr, "** Bad packet length: pktsize = %d, count = %ld.\n", + fprintf(stderr, "** Bad packet length: pktsize = %d, count = %d.\n", pktsize, count); #endif return ERR_PKT_BADLEN; --- gcpegg-5.1.orig/reg_orion.c +++ gcpegg-5.1/reg_orion.c @@ -97,7 +97,7 @@ sprintf(ttydev, "/dev/term/%c", 'a' + (opts->port - 1)); #endif #else - sprintf(ttydev, "/dev/ttyS%d", opts->port); + sprintf(ttydev, "/dev/REG", opts->port); #endif switch(opts->baud) { @@ -111,11 +111,11 @@ case 115200: baudcon = B115200; break; #endif default: - printf("%s: Baud rate %ld not supported.\n", pgmname, opts->baud); + printf("%s: Baud rate %d not supported.\n", pgmname, opts->baud); return -1; } - fprintf(stderr, "Opening %s at %ld\n", ttydev, opts->baud); + fprintf(stderr, "Opening %s at %d\n", ttydev, opts->baud); if ((TTY_fd = open(ttydev, O_RDONLY #ifdef CPU_BOUND | O_NDELAY @@ -147,8 +147,10 @@ #else res = cfsetospeed(&tt, baudcon); cfmakeraw(&tt); +#if !defined(__FreeBSD_kernel__) tt.c_oflag &= (~(TABDLY | ONLCR)); #endif +#endif res = tcsetattr(TTY_fd, TCSANOW, &tt); oldbits[TTY_fd] = bitsleft[TTY_fd] = 0; --- gcpegg-5.1.orig/reg_pear.c +++ gcpegg-5.1/reg_pear.c @@ -77,7 +77,7 @@ sprintf(ttydev, "/dev/term/%c", 'a' + (opts->port - 1)); #endif #else - sprintf(ttydev, "/dev/ttyS%d", opts->port); + sprintf(ttydev, "/dev/REG", opts->port); #endif switch(opts->baud) { @@ -91,11 +91,11 @@ case 115200: baudcon = B115200; break; #endif default: - printf("%s: Baud rate %ld not supported.\n", pgmname, opts->baud); + printf("%s: Baud rate %d not supported.\n", pgmname, opts->baud); return -1; } - fprintf(stderr, "Opening %s at %ld\n", ttydev, opts->baud); + fprintf(stderr, "Opening %s at %d\n", ttydev, opts->baud); if ((TTY_fd = open(ttydev, O_RDONLY #ifdef CPU_BOUND | O_NDELAY @@ -122,8 +122,10 @@ #else res = cfsetospeed(&tt, baudcon); cfmakeraw(&tt); +#if !defined(__FreeBSD_kernel__) tt.c_oflag &= (~(TABDLY | ONLCR)); #endif +#endif res = tcsetattr(TTY_fd, TCSANOW, &tt); oldbits[TTY_fd] = bitsleft[TTY_fd] = 0; --- gcpegg-5.1.orig/reg_pseudo.c +++ gcpegg-5.1/reg_pseudo.c @@ -27,6 +27,7 @@ #include #include +#include #include "global.h" #include "genlib.h" --- gcpegg-5.1.orig/regtest.c +++ gcpegg-5.1/regtest.c @@ -10,6 +10,10 @@ #define __USE_BSD #include #undef __USE_BSD +#if defined(__FreeBSD_kernel__) +/* Not patching the code directly, used once, in a "|" context */ +#define O_NDELAY 0 +#endif #include #include @@ -49,14 +53,16 @@ } if ((TTY_fd = open(argv[1], O_RDWR | O_NDELAY)) < 0) { - fprintf(stderr, "%s: %s\n", argv[1], sys_errlist[errno]); + fprintf(stderr, "%s: %s\n", argv[1], strerror(errno)); exit(1); } res = tcgetattr(TTY_fd, &tt); res = cfsetospeed(&tt, baud); cfmakeraw(&tt); +#if !defined(__FreeBSD_kernel__) tt.c_oflag &= (~(TABDLY | ONLCR)); +#endif res = tcsetattr(TTY_fd, TCSANOW, &tt); mean = 0; --- gcpegg-5.1.orig/sample.eggrc +++ gcpegg-5.1/sample.eggrc @@ -38,6 +38,9 @@ # this time. Port is serial port number (e.g. 1 for /dev/ttyS1); # is baud rate. # +# NOTE: in Debian, the device opened is always /dev/REG! +# Symlink that to whatever your actual serial device is. +# # NETUP