1 Description: <short summary of the patch>
2 TODO: Put a short summary on the line above and replace this paragraph
3 with a longer explanation of this change. Complete the meta-information
4 with other relevant fields (see below for details). To make it easier, the
5 information below has been extracted from the changelog. Adjust it or drop
8 gcpegg (5.1-15) unstable; urgency=medium
10 * stop trying to force which VT eggsh is launched on
11 Author: Bdale Garbee <bdale@gag.com>
14 The information above should follow the Patch Tagging Guidelines, please
15 checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
16 are templates for supplementary fields that you might want to add:
18 Origin: <vendor|upstream|other>, <url of original patch>
19 Bug: <url in upstream bugtracker>
20 Bug-Debian: https://bugs.debian.org/<bugnumber>
21 Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
22 Forwarded: <no|not-needed|url proving that it has been forwarded>
23 Reviewed-By: <name and email of someone who approved the patch>
24 Last-Update: 2019-10-26
26 --- gcpegg-5.1.orig/basket.c
27 +++ gcpegg-5.1/basket.c
29 #include <sys/socket.h>
31 #include <netinet/in.h>
36 @@ -90,6 +91,7 @@ static void updateHTML(void)
38 static uint32 lastHtml = 0;
39 uint32 now = getzulutime(NULL);
41 char udate[256], ustime[256];
42 static char timeFormat[] = "%Y-%m-%d %T";
44 @@ -113,9 +115,11 @@ static void updateHTML(void)
45 htmlFile[0] = 0; /* Suppress further updates */
49 - strftime(udate, sizeof udate, timeFormat, gmtime((time_t *) &now));
50 - strftime(ustime, sizeof ustime, timeFormat, gmtime((time_t *) &upsince));
53 + strftime(udate, sizeof udate, timeFormat, gmtime(&now_val));
54 + time_t upsince_val = upsince;
55 + strftime(ustime, sizeof ustime, timeFormat, gmtime(&upsince_val));
58 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n\
59 @@ -146,8 +150,10 @@ static void updateHTML(void)
60 strcpy(udate, "<td colspan=2 align=center><em>Never contacted</em>");
63 - strftime(udate, sizeof udate, "<td align=center>%Y-%m-%d %T", gmtime((time_t *) &eggtable[i].lastupd));
64 - strftime(ustime, sizeof ustime, "<td align=center>%Y-%m-%d %T", gmtime((time_t *) &eggStatistics[i].firstPacket));
65 + time_t lastupd_val = eggtable[i].lastupd;
66 + strftime(udate, sizeof udate, "<td align=center>%Y-%m-%d %T", gmtime(&lastupd_val));
67 + time_t firstPacket_val = eggStatistics[i].firstPacket;
68 + strftime(ustime, sizeof ustime, "<td align=center>%Y-%m-%d %T", gmtime(&firstPacket_val));
70 if (eggtable[i].url == NULL) {
71 url1[0] = url2[0] = 0;
72 @@ -181,7 +187,7 @@ static void updateHTML(void)
76 - fprintf(hf, "<td align=center>%ld<td align=center>%ld<td align=center>%ld%%<td align=center>%.3f\n",
77 + fprintf(hf, "<td align=center>%d<td align=center>%d<td align=center>%d%%<td align=center>%.3f\n",
78 eggStatistics[i].trials,
79 eggStatistics[i].missing,
81 @@ -213,8 +219,9 @@ static void updateHTML(void)
86 fprintf(stderr, "Updating HTML file %s at %s",
87 - htmlFile, asctime(gmtime((time_t *) &now)));
88 + htmlFile, asctime(gmtime(&now_val)));
92 @@ -436,9 +443,10 @@ int main(int argc, char *argv[]) {
94 memcpy(&egg_now_time, pktbuf + 6, sizeof egg_now_time);
95 egg_now_time = ntohl(egg_now_time);
96 - fprintf(stderr, "Awake egg %d (%s) at its %lu: %s",
97 + time_t egg_now_time_val = egg_now_time;
98 + fprintf(stderr, "Awake egg %d (%s) at its %u: %s",
99 pkt_eggid, eggtable[thisegg].name, egg_now_time,
100 - asctime(gmtime((time_t *) &egg_now_time)));
101 + asctime(gmtime(&egg_now_time_val)));
105 @@ -617,14 +625,14 @@ static int32 BasketReceiveDataPacket(cha
109 - unpackShort(dpk.type);
110 - unpackShort(dpk.pktsize);
111 - unpackShort(dpk.eggid);
112 - unpackShort(dpk.samp_rec);
113 - unpackShort(dpk.sec_rec);
114 - unpackShort(dpk.rec_pkt);
115 - unpackByte(dpk.trialsz);
116 - unpackShort(dpk.numrec);
117 + unpack16(dpk.type);
118 + unpack16(dpk.pktsize);
119 + unpack16(dpk.eggid);
120 + unpack16(dpk.samp_rec);
121 + unpack16(dpk.sec_rec);
122 + unpack16(dpk.rec_pkt);
123 + unpack8(dpk.trialsz);
124 + unpack16(dpk.numrec);
126 /* This spoofing test is probably completely redundant now. */
128 @@ -647,7 +655,7 @@ static int32 BasketReceiveDataPacket(cha
131 if (result.hdr.numrec > 0) {
136 fprintf(stderr, "Received packet: %d records from egg %d (%s).\n",
137 @@ -659,19 +667,20 @@ static int32 BasketReceiveDataPacket(cha
138 transcribe to the result EggCarton. */
140 for (latest = 0, rec = 0; rec < result.hdr.numrec; rec++) {
141 - unpackLong(result.records[rec].timestamp); /* Record timestamp */
142 + unpack32(result.records[rec].timestamp); /* Record timestamp */
143 if (result.records[rec].timestamp > latest)
144 latest = result.records[rec].timestamp;
146 - fprintf(stderr, " %10lu ", result.records[rec].timestamp);
147 + fprintf(stderr, " %10u ", result.records[rec].timestamp);
149 /* Assumes sizeof(trial) = 1 */
150 - unpackBytes(&(result.records[rec].trials), result.hdr.samp_rec);
151 + unpack8s(&(result.records[rec].trials), result.hdr.samp_rec);
153 for (i = 0; i < result.hdr.samp_rec; i++) {
154 fprintf(stderr, "%3d ", result.records[rec].trials[i]);
156 - fprintf(stderr, "%s", asctime(gmtime((time_t *) &result.records[rec].timestamp)));
157 + time_t timestamp_val = result.records[rec].timestamp;
158 + fprintf(stderr, "%s", asctime(gmtime(×tamp_val)));
162 @@ -748,10 +757,10 @@ static int32 BasketReceiveDataPacket(cha
163 static void MakeRequest(ReqPacket *pkt, uint16 eggid, uint32 whence) {
164 char *pktP = (char *) pkt;
166 - packShort(REQ_PACKET);
167 - packShort((4 * sizeof(uint16)) + sizeof(uint32));
170 + pack16(REQ_PACKET);
171 + pack16((4 * sizeof(uint16)) + sizeof(uint32));
176 /* MakeSettings -- Create a settings packet. This packet,
177 @@ -761,14 +770,14 @@ static void MakeRequest(ReqPacket *pkt,
178 static void MakeSettings(SettingsPacket *pkt, uint16 eggid) {
179 char *pktP = (char *) pkt;
181 - packShort(SETTINGS_PACKET);
182 - packShort((7 * sizeof(uint16)) + sizeof(uint32) + sizeof(trial));
184 - packLong(getzulutime(NULL));
185 - packShort(protocol.samp_rec);
186 - packShort(protocol.sec_rec);
187 - packShort(protocol.rec_pkt);
188 - packByte(protocol.trialsz);
189 + pack16(SETTINGS_PACKET);
190 + pack16((7 * sizeof(uint16)) + sizeof(uint32) + sizeof(trial));
192 + pack32(getzulutime(NULL));
193 + pack16(protocol.samp_rec);
194 + pack16(protocol.sec_rec);
195 + pack16(protocol.rec_pkt);
196 + pack8(protocol.trialsz);
199 /* LoadEggStats -- Initialise in-memory egg status table
200 @@ -827,7 +836,7 @@ static void SaveEggStats(void) {
201 fprintf(fp, "# Status lines of form:\n");
202 fprintf(fp, "# STAT <eggname> <eggid> <lastupdzulu> <setupvalid>\n");
203 for (i = 0; i < numeggs; i++) {
204 - fprintf(fp, "STAT %s %d %ld %d\n",
205 + fprintf(fp, "STAT %s %d %u %d\n",
209 --- gcpegg-5.1.orig/byteorder.h
210 +++ gcpegg-5.1/byteorder.h
212 on RISC machines which typically require values to be
213 aligned at an even multiple of their length. */
215 -#define packShort(x) { \
216 - short s = htons((short) (x)); \
217 - memcpy(pktP, &s, sizeof(short)); \
218 - pktP += sizeof(short); \
219 +#define pack16(x) { \
220 + uint16 s = htons((uint16) (x)); \
221 + memcpy(pktP, &s, sizeof(uint16)); \
222 + pktP += sizeof(uint16); \
225 -#define packLong(x) { \
226 - long l = htonl((long) (x)); \
227 - memcpy(pktP, &l, sizeof(long)); \
228 - pktP += sizeof(long); \
229 +#define pack32(x) { \
230 + uint32 i = htonl((uint32) (x)); \
231 + memcpy(pktP, &i, sizeof(uint32)); \
232 + pktP += sizeof(uint32); \
235 -#define packByte(x) { \
236 +#define pack8(x) { \
238 memcpy(pktP, &c, sizeof(char)); \
239 pktP += sizeof(char); \
242 -#define packBytes(x, n) { \
243 +#define pack8s(x, n) { \
244 memcpy(pktP, x, n); \
248 pktP. Note that the argument of these macros must be
251 -#define unpackShort(x) { \
253 - memcpy(&s, pktP, sizeof(short)); \
254 - pktP += sizeof(short); \
255 +#define unpack16(x) { \
257 + memcpy(&s, pktP, sizeof(uint16)); \
258 + pktP += sizeof(uint16); \
262 -#define unpackLong(x) { \
264 - memcpy(&l, pktP, sizeof(long)); \
265 - pktP += sizeof(long); \
267 +#define unpack32(x) { \
269 + memcpy(&i, pktP, sizeof(uint32)); \
270 + pktP += sizeof(uint32); \
274 -#define unpackByte(x) { \
275 +#define unpack8(x) { \
276 *((char *) &x) = (char) *pktP++; \
279 -#define unpackBytes(x, n) { \
280 +#define unpack8s(x, n) { \
281 memcpy(x, pktP, n); \
284 --- gcpegg-5.1.orig/egg.c
287 #include <sys/socket.h>
289 #include <netinet/in.h>
294 @@ -94,7 +95,7 @@ static EggCarton savebuffer;
295 char *pgmname; /* Program name from argv[0] */
296 char *myaddr; /* Interface to bind */
297 int16 myport; /* Service port to bind */
298 -int32 lastDataSent = 0; /* Time last packet sent to basket */
299 +uint32 lastDataSent = 0; /* Time last packet sent to basket */
301 /* If no priority increment has been specified at compile time, set to
302 our default of ±10. [+/- 10, for folks without 8bit editors] */
303 @@ -106,7 +107,7 @@ static int niceness = NICE; /* Pri
305 /* Status exported to user interface. */
307 -int32 time_latency = 0, time_housekeeping = 0;
308 +uint32 time_latency = 0, time_housekeeping = 0;
311 static double mean_Packet = 0.0, mean_Grand = 0.0;
312 @@ -292,7 +293,7 @@ int main(int argc, char *argv[]) {
316 - printf("REG configured: %s = %d, %d, %ld\n", configuredREG ->reg_name,
317 + printf("REG configured: %s = %d, %d, %d\n", configuredREG ->reg_name,
318 devopts.type, devopts.port, devopts.baud);
321 @@ -463,7 +464,7 @@ int main(int argc, char *argv[]) {
322 totalTrials += ptrials;
323 mean_Grand = totalGrand / totalTrials;
325 - printf("Packets sent: %ld Packet mean: %6.2f Grand mean: %6.2f\n",
326 + printf("Packets sent: %d Packet mean: %6.2f Grand mean: %6.2f\n",
327 total_Packets, mean_Packet, mean_Grand);
330 @@ -489,7 +490,7 @@ int main(int argc, char *argv[]) {
331 /* But let's be sure it really *is* in the interval. */
332 if (t.tv_sec < savebuffer.records[0].timestamp ||
333 t.tv_sec >= (savebuffer.records[0].timestamp + savebuffer.hdr.sec_rec * savebuffer.hdr.rec_pkt)) {
334 - fprintf(stderr, "***Sample, collected at %ld, is not within packet starting at %ld.\n",
335 + fprintf(stderr, "***Sample, collected at %ld, is not within packet starting at %u.\n",
336 t.tv_sec, savebuffer.records[0].timestamp);
339 @@ -605,11 +606,12 @@ int main(int argc, char *argv[]) {
341 char *pktP = pktbuf + (2 * sizeof(uint16));
343 - unpackShort(reggid);
348 - fprintf(stderr, "Request: eggid = %d, starttm = %ld: %s",
349 - reggid, stime, asctime(gmtime((time_t *) &stime)));
350 + time_t stime_val = stime;
351 + fprintf(stderr, "Request: eggid = %d, starttm = %u: %s\n",
352 + reggid, stime, asctime(gmtime(&stime_val)));
354 res = LoadPacket(stime, reggid, &retrcart);
356 @@ -639,10 +641,10 @@ int main(int argc, char *argv[]) {
358 { char *pktP = pktbuf + (3 * sizeof(uint16)) + sizeof(uint32);
360 - unpackShort(protocol.samp_rec);
361 - unpackShort(protocol.sec_rec);
362 - unpackShort(protocol.rec_pkt);
363 - unpackByte(protocol.trialsz);
364 + unpack16(protocol.samp_rec);
365 + unpack16(protocol.sec_rec);
366 + unpack16(protocol.rec_pkt);
367 + unpack8(protocol.trialsz);
370 fprintf(stderr, "Settings: samp_rec = %d, sec_rec = %d, rec_pkt = %d, trialsz = %d\n",
371 @@ -672,12 +674,12 @@ int main(int argc, char *argv[]) {
375 - printf("Sampling latency: %ld.%03ld msec", msec, usec);
376 + printf("Sampling latency: %d.%03d msec", msec, usec);
378 usec = time_housekeeping;
381 - printf(" Housekeeping time: %ld.%03ld msec\n", msec, usec);
382 + printf(" Housekeeping time: %d.%03d msec\n", msec, usec);
385 sleeptime = ((1000000 - SLACK) - ct.tv_usec);
386 @@ -845,10 +847,10 @@ static void LoadRCFile(char *filename) {
387 static void MakeAwake(AwakePacket *pkt) {
388 char *pktP = (char *) pkt;
390 - packShort(AWAKE_PACKET);
391 - packShort((4 * sizeof(uint16)) + sizeof(uint32));
392 - packShort(eggtable[0].id);
393 - packLong(getzulutime(NULL));
394 + pack16(AWAKE_PACKET);
395 + pack16((4 * sizeof(uint16)) + sizeof(uint32));
396 + pack16(eggtable[0].id);
397 + pack32(getzulutime(NULL));
400 /* MakeDataPkt -- Build a canonical network byte order data packet
401 @@ -866,20 +868,20 @@ static void MakeDataPkt(char **pkt, EggC
403 /* Assemble header fields into data packet. */
405 - packShort(src->hdr.type = DATA_PACKET);
406 - packShort(src->hdr.pktsize = pktsize);
407 - packShort(src->hdr.eggid);
408 - packShort(src->hdr.samp_rec);
409 - packShort(src->hdr.sec_rec);
410 - packShort(src->hdr.rec_pkt);
411 - packByte(src->hdr.trialsz);
412 - packShort(src->hdr.numrec);
413 + pack16(src->hdr.type = DATA_PACKET);
414 + pack16(src->hdr.pktsize = pktsize);
415 + pack16(src->hdr.eggid);
416 + pack16(src->hdr.samp_rec);
417 + pack16(src->hdr.sec_rec);
418 + pack16(src->hdr.rec_pkt);
419 + pack8(src->hdr.trialsz);
420 + pack16(src->hdr.numrec);
422 /* Append data records to packet. */
424 for (rec = 0; rec < src->hdr.numrec; rec++) {
425 - packLong(src->records[rec].timestamp);
426 - packBytes(&(src->records[rec].trials), src->hdr.samp_rec);
427 + pack32(src->records[rec].timestamp);
428 + pack8s(&(src->records[rec].trials), src->hdr.samp_rec);
431 /* No need to calculate CRC -- NetTalk does that for us.
432 --- gcpegg-5.1.orig/eggrc.sample
433 +++ gcpegg-5.1/eggrc.sample
435 #BASKET diesse 193.8.230.134
437 # noosphere -> diesse
438 -EGG noosphere 28 128.112.35.133 diesse PERM 1
439 -BASKET diesse 193.8.230.134
440 +#EGG noosphere 28 128.112.35.133 diesse PERM 1
441 +#BASKET diesse 193.8.230.134
444 #EGG throop 1003 193.8.230.132 diesse PERM 1 http://www.fourmilab.ch/
445 @@ -78,9 +78,16 @@ BASKET diesse 193.8.230.134
447 #BASKET tonga 209.157.90.137
448 #BASKET tonga1 209.157.90.138
449 -PROTOCOL 10 10 6 200
450 +#PROTOCOL 10 10 6 200
456 -NETDOWN pppscript down
458 +#NETDOWN pppscript down
460 +egg.host.name ID# IP_address noosphere PERM 1
461 +BASKET noosphere 128.112.35.133
462 +PROTOCOL 10 10 30 200
466 --- gcpegg-5.1.orig/eggui.c
467 +++ gcpegg-5.1/eggui.c
475 /* Curses takes it upon itself to define TRUE and FALSE,
476 incompatibly, as it happens, with the definitions in
481 -static int32 inittm = 0;
482 +static uint32 inittm = 0;
485 -extern int32 lastDataSent;
486 -extern int32 time_latency, time_housekeeping;
487 +extern uint32 lastDataSent;
488 +extern uint32 time_latency, time_housekeeping;
490 /* Initialize user interface, as needed. */
492 @@ -110,10 +112,10 @@ int32 UIUpdate(int32 cres, CollectRecord
494 if (coll->sampct == 1) {
496 - move(line++, 5); printw("Samples per record: %3d", (int)coll->opts.samp_rec);
497 - move(line++, 5); printw("Seconds per record: %3d", (int)coll->opts.sec_rec);
498 - move(line++, 5); printw("Records per packet: %3d", (int)coll->opts.rec_pkt);
499 - move(line++, 5); printw("Bits per trial: %3d", (int)coll->opts.trialsz);
500 + move(line++, 5); printw("Samples per record: %3d", coll->opts.samp_rec);
501 + move(line++, 5); printw("Seconds per record: %3d", coll->opts.sec_rec);
502 + move(line++, 5); printw("Records per packet: %3d", coll->opts.rec_pkt);
503 + move(line++, 5); printw("Bits per trial: %3d", coll->opts.trialsz);
507 @@ -124,17 +126,20 @@ int32 UIUpdate(int32 cres, CollectRecord
508 printw("EGG %s ID %d REG %s %s", eggtable[0].name, eggtable[0].id,
509 configuredREG->reg_name, Version);
511 - tmstr = ctime(&inittm); tmstr[strlen(tmstr)-1] = 0;
512 + time_t inittm_val = inittm;
513 + tmstr = ctime(&inittm_val); tmstr[strlen(tmstr)-1] = 0;
515 printw("Up since %25s", tmstr);
518 now = getzulutime(NULL);
519 - tmstr = ctime(&now); tmstr[strlen(tmstr)-1] = 0;
520 + time_t now_val = now;
521 + tmstr = ctime(&now_val); tmstr[strlen(tmstr)-1] = 0;
522 printw("Last sample at %25s", tmstr);
525 - tmstr = ctime(&lastDataSent);
526 + time_t lastDataSent_val = lastDataSent;
527 + tmstr = ctime(&lastDataSent_val);
528 tmstr[strlen(tmstr)-1] = 0;
529 printw("Last packet at %25s", lastDataSent == 0 ? "Never" : tmstr);
531 --- gcpegg-5.1.orig/genlib.c
532 +++ gcpegg-5.1/genlib.c
537 -int32 getzulutime(struct timeval *ztv) {
538 +uint32 getzulutime(struct timeval *ztv) {
542 @@ -86,31 +86,33 @@ char *Packetize(EggCarton *src) {
544 /* Assemble header fields into data packet. */
546 - packShort(src->hdr.type = DATA_PACKET);
547 - packShort(src->hdr.pktsize = pktsize);
548 - packShort(src->hdr.eggid);
549 - packShort(src->hdr.samp_rec);
550 - packShort(src->hdr.sec_rec);
551 - packShort(src->hdr.rec_pkt);
552 - packByte(0); /* Pad byte in case we want to expand trialsz */
553 - packByte(src->hdr.trialsz);
554 - packShort(src->hdr.numrec);
555 + pack16(src->hdr.type = DATA_PACKET);
556 + pack16(src->hdr.pktsize = pktsize);
557 + pack16(src->hdr.eggid);
558 + pack16(src->hdr.samp_rec);
559 + pack16(src->hdr.sec_rec);
560 + pack16(src->hdr.rec_pkt);
561 + pack8(0); /* Pad byte in case we want to expand trialsz */
562 + pack8(src->hdr.trialsz);
563 + pack16(src->hdr.numrec);
565 /* Append data records to packet. */
567 for (rec = 0; rec < src->hdr.numrec; rec++) {
568 - packLong(src->records[rec].timestamp);
569 - packBytes(&(src->records[rec].trials), src->hdr.samp_rec);
570 + pack32(src->records[rec].timestamp);
571 + pack8s(&(src->records[rec].trials), src->hdr.samp_rec);
574 /* Get CRC, pack into base(32,32,64) notation, and add tag byte (0xFF) */
575 lbuf = BlockCRC16((byte *) rbuf, pktP - rbuf);
576 lbuf = ((lbuf & 0xF800) << 13) |
577 ((lbuf & 0x07C0) << 10) |
578 ((lbuf & 0x003F) << 8) |
583 if ((pktP - rbuf) != pktsize) {
584 - fprintf(stderr, "Length mismatch assembling packet. Computed: %d, actually packed: %d.\n",
585 + fprintf(stderr, "Length mismatch assembling packet. Computed: %d, actually packed: %ld.\n",
586 pktsize, pktP - rbuf);
589 @@ -125,15 +127,15 @@ int32 Unpacketize(EggCarton *dst, char *
590 /* Unpack the portable header into a host-order and aligned
593 - unpackShort(dst->hdr.type);
594 - unpackShort(dst->hdr.pktsize);
595 - unpackShort(dst->hdr.eggid);
596 - unpackShort(dst->hdr.samp_rec);
597 - unpackShort(dst->hdr.sec_rec);
598 - unpackShort(dst->hdr.rec_pkt);
599 - unpackByte(pad); /* Pad in case we later grow trialsz */
600 - unpackByte(dst->hdr.trialsz);
601 - unpackShort(dst->hdr.numrec);
602 + unpack16(dst->hdr.type);
603 + unpack16(dst->hdr.pktsize);
604 + unpack16(dst->hdr.eggid);
605 + unpack16(dst->hdr.samp_rec);
606 + unpack16(dst->hdr.sec_rec);
607 + unpack16(dst->hdr.rec_pkt);
608 + unpack8(pad); /* Pad in case we later grow trialsz */
609 + unpack8(dst->hdr.trialsz);
610 + unpack16(dst->hdr.numrec);
612 if (dst->hdr.type != DATA_PACKET) {
614 @@ -145,9 +147,9 @@ int32 Unpacketize(EggCarton *dst, char *
615 /* Unpack the data records from the file packet. */
617 for (rec = 0; rec < dst->hdr.numrec; rec++) {
618 - unpackLong(dst->records[rec].timestamp);
619 + unpack32(dst->records[rec].timestamp);
620 /* Assumes sizeof(trial) = 1 */
621 - unpackBytes(&(dst->records[rec].trials), dst->hdr.samp_rec);
622 + unpack8s(&(dst->records[rec].trials), dst->hdr.samp_rec);
625 /* Compute the CRC, reassemble into record terminator,
626 @@ -159,18 +161,18 @@ int32 Unpacketize(EggCarton *dst, char *
627 ((lbuf & 0x003F) << 8) |
630 - unpackLong(filecrc);
633 if (lbuf != filecrc) {
635 - fprintf(stderr, "Bad CRC in packet read from file. Read 0x%08lX, computed 0x%08lX.\n", filecrc, lbuf);
636 + fprintf(stderr, "Bad CRC in packet read from file. Read 0x%08X, computed 0x%08X.\n", filecrc, lbuf);
641 if (dst->hdr.pktsize != (pktP - src)) {
643 - fprintf(stderr, "Length mismatch decoding packet. Header: %d, length decoded: %d.\n",
644 + fprintf(stderr, "Length mismatch decoding packet. Header: %d, length decoded: %ld.\n",
645 dst->hdr.pktsize, pktP - src);
648 @@ -210,7 +212,7 @@ char *mallocpy(char *input) {
650 void dquad2sockaddr(struct sockaddr_in *sinp, int16 *mask, char *dquad) {
656 loser = mallocpy(dquad);
657 @@ -237,16 +239,16 @@ void dquad2sockaddr(struct sockaddr_in *
660 char *sockaddr2dquad(struct sockaddr_in *sinp) {
664 saddr = ntohl(sinp->sin_addr.s_addr);
665 return hl2dquad(saddr);
668 -char *hl2dquad(long addr) {
669 +char *hl2dquad(uint32 addr) {
670 static char resout[16];
672 - sprintf(resout, "%ld.%ld.%ld.%ld",
673 + sprintf(resout, "%u.%u.%u.%u",
674 (addr >> 24) & 0xFF, (addr >> 16) & 0xFF,
675 (addr >> 8) & 0xFF, addr & 0xFF);
677 --- gcpegg-5.1.orig/genlib.h
678 +++ gcpegg-5.1/genlib.h
681 /* Get time in GMT reference frame. If ztv is NULL, simply returns
682 seconds. Otherwise, returns complete timeval in ztv as well. */
683 -extern int32 getzulutime(struct timeval *ztv);
684 +extern uint32 getzulutime(struct timeval *ztv);
686 /* Get difference in msec between two tvs. */
687 extern int32 deltams(struct timeval *tv1, struct timeval *tv2);
688 @@ -59,7 +59,7 @@ extern void Parse(char *input, int *argc
689 extern char *mallocpy(char *input);
690 extern void dquad2sockaddr(struct sockaddr_in *sinp, int16 *mask, char *dquad);
691 extern char *sockaddr2dquad(struct sockaddr_in *sinp); /* Static buffer! */
692 -extern char *hl2dquad(long addr); /* Static buffer! */
693 +extern char *hl2dquad(uint32 addr); /* Static buffer! */
696 /* Access to system or emulated usleep(). */
697 --- gcpegg-5.1.orig/global.h
698 +++ gcpegg-5.1/global.h
700 #include "byteorder.h" /* Build byte-order independent version */
702 /* Good for i386, but be careful... */
703 -typedef unsigned char byte;
704 -typedef unsigned char uint8;
705 -typedef unsigned short uint16;
706 -typedef unsigned long uint32;
708 -typedef short int16;
712 +#include <sys/types.h>
714 + typedef __u8 uint8;
715 + typedef __u16 uint16;
716 + typedef __u32 uint32;
718 + typedef __s16 int16;
719 + typedef __s32 int32;
721 + typedef unsigned char byte;
722 + typedef unsigned char uint8;
723 + typedef unsigned ushort uint16;
724 + typedef unsigned uint uint32;
726 + typedef short int16;
732 +typedef uint8_t byte;
733 +typedef uint8_t uint8;
734 +typedef uint16_t uint16;
735 +typedef uint32_t uint32;
736 +typedef int8_t int8;
737 +typedef int16_t int16;
738 +typedef int32_t int32;
740 /* Some fixed assumptions:
741 Trial type is always bitsum.
742 @@ -157,7 +179,7 @@ typedef struct eggentry {
745 int16 connival; /* Connect interval in minutes */
746 - int32 lastupd; /* Zulutime of last update received */
747 + uint32 lastupd; /* Zulutime of last update received */
748 int16 setup; /* Does setup match config file? */
749 char *upcmd; /* Command to bring net up (req if conntype == DND) */
750 char *dncmd; /* Command to bring net down */
751 --- gcpegg-5.1.orig/hw_pear.c
752 +++ gcpegg-5.1/hw_pear.c
753 @@ -87,7 +87,7 @@ int32 OpenDev(DevOpts *opts) {
754 designating /dev/term/a. */
755 sprintf(ttydev, "/dev/term/%c", 'a' + (opts->port - 1));
757 - sprintf(ttydev, "/dev/ttyS%d", opts->port);
758 + sprintf(ttydev, "/dev/REG", opts->port);
762 --- gcpegg-5.1.orig/network.c
763 +++ gcpegg-5.1/network.c
764 @@ -237,7 +237,7 @@ int NetListen(int sd, char **pktbuf,
767 count = recvfrom(sd, buffer, MAXBUFSIZE, 0,
768 - (struct sockaddr *)sin, (int *)&size);
769 + (struct sockaddr *)sin, (socklen_t *)&size);
771 /* Don't wait for it. */
772 if (errno == EWOULDBLOCK) return ERR_COMM_TMOUT;
773 @@ -246,7 +246,7 @@ int NetListen(int sd, char **pktbuf,
777 - fprintf(stderr, "Received %ld bytes from %s\n", count,
778 + fprintf(stderr, "Received %d bytes from %s\n", count,
779 inet_ntoa(sin->sin_addr));
780 xd(stderr, buffer, count, FALSE);
782 @@ -274,7 +274,7 @@ int NetListen(int sd, char **pktbuf,
783 pktsize = ntohs(rpktsize);
784 if (pktsize != count) {
786 - fprintf(stderr, "** Bad packet length: pktsize = %d, count = %ld.\n",
787 + fprintf(stderr, "** Bad packet length: pktsize = %d, count = %d.\n",
790 return ERR_PKT_BADLEN;
791 --- gcpegg-5.1.orig/reg_orion.c
792 +++ gcpegg-5.1/reg_orion.c
793 @@ -97,7 +97,7 @@ static int32 OpenDev(DevOpts *opts) {
794 sprintf(ttydev, "/dev/term/%c", 'a' + (opts->port - 1));
797 - sprintf(ttydev, "/dev/ttyS%d", opts->port);
798 + sprintf(ttydev, "/dev/REG", opts->port);
802 @@ -111,11 +111,11 @@ static int32 OpenDev(DevOpts *opts) {
803 case 115200: baudcon = B115200; break;
806 - printf("%s: Baud rate %ld not supported.\n", pgmname, opts->baud);
807 + printf("%s: Baud rate %d not supported.\n", pgmname, opts->baud);
811 - fprintf(stderr, "Opening %s at %ld\n", ttydev, opts->baud);
812 + fprintf(stderr, "Opening %s at %d\n", ttydev, opts->baud);
813 if ((TTY_fd = open(ttydev, O_RDONLY
816 @@ -147,8 +147,10 @@ fprintf(stderr, "Error in open(%s)\n", t
818 res = cfsetospeed(&tt, baudcon);
820 +#if !defined(__FreeBSD_kernel__)
821 tt.c_oflag &= (~(TABDLY | ONLCR));
824 res = tcsetattr(TTY_fd, TCSANOW, &tt);
826 oldbits[TTY_fd] = bitsleft[TTY_fd] = 0;
827 --- gcpegg-5.1.orig/reg_pear.c
828 +++ gcpegg-5.1/reg_pear.c
829 @@ -77,7 +77,7 @@ static int32 OpenDev(DevOpts *opts) {
830 sprintf(ttydev, "/dev/term/%c", 'a' + (opts->port - 1));
833 - sprintf(ttydev, "/dev/ttyS%d", opts->port);
834 + sprintf(ttydev, "/dev/REG", opts->port);
838 @@ -91,11 +91,11 @@ static int32 OpenDev(DevOpts *opts) {
839 case 115200: baudcon = B115200; break;
842 - printf("%s: Baud rate %ld not supported.\n", pgmname, opts->baud);
843 + printf("%s: Baud rate %d not supported.\n", pgmname, opts->baud);
847 - fprintf(stderr, "Opening %s at %ld\n", ttydev, opts->baud);
848 + fprintf(stderr, "Opening %s at %d\n", ttydev, opts->baud);
849 if ((TTY_fd = open(ttydev, O_RDONLY
852 @@ -122,8 +122,10 @@ static int32 OpenDev(DevOpts *opts) {
854 res = cfsetospeed(&tt, baudcon);
856 +#if !defined(__FreeBSD_kernel__)
857 tt.c_oflag &= (~(TABDLY | ONLCR));
860 res = tcsetattr(TTY_fd, TCSANOW, &tt);
862 oldbits[TTY_fd] = bitsleft[TTY_fd] = 0;
863 --- gcpegg-5.1.orig/reg_pseudo.c
864 +++ gcpegg-5.1/reg_pseudo.c
873 --- gcpegg-5.1.orig/regtest.c
874 +++ gcpegg-5.1/regtest.c
879 +#if defined(__FreeBSD_kernel__)
880 +/* Not patching the code directly, used once, in a "|" context */
884 #include <sys/types.h>
885 #include <sys/stat.h>
886 @@ -49,14 +53,16 @@ int main(int argc, char *argv[]) {
889 if ((TTY_fd = open(argv[1], O_RDWR | O_NDELAY)) < 0) {
890 - fprintf(stderr, "%s: %s\n", argv[1], sys_errlist[errno]);
891 + fprintf(stderr, "%s: %s\n", argv[1], strerror(errno));
895 res = tcgetattr(TTY_fd, &tt);
896 res = cfsetospeed(&tt, baud);
898 +#if !defined(__FreeBSD_kernel__)
899 tt.c_oflag &= (~(TABDLY | ONLCR));
901 res = tcsetattr(TTY_fd, TCSANOW, &tt);
904 --- gcpegg-5.1.orig/sample.eggrc
905 +++ gcpegg-5.1/sample.eggrc
907 # this time. Port is serial port number (e.g. 1 for /dev/ttyS1);
908 # <baud> is baud rate.
910 +# NOTE: in Debian, the device opened is always /dev/REG!
911 +# Symlink that to whatever your actual serial device is.
913 # NETUP <script> <args> ...
914 # NETDOWN <script> <args> ...
917 #BASKET diesse 193.8.230.134
919 # noosphere -> diesse
920 -EGG noosphere 28 128.112.35.133 diesse PERM 1
921 -BASKET diesse 193.8.230.134
922 +#EGG noosphere 28 128.112.35.133 diesse PERM 1
923 +#BASKET diesse 193.8.230.134
926 #EGG throop 1003 193.8.230.132 diesse PERM 1 http://www.fourmilab.ch/
927 @@ -78,9 +81,16 @@ BASKET diesse 193.8.230.134
929 #BASKET tonga 209.157.90.137
930 #BASKET tonga1 209.157.90.138
931 -PROTOCOL 10 10 6 200
932 +#PROTOCOL 10 10 6 200
938 -NETDOWN pppscript down
940 +#NETDOWN pppscript down
942 +egg.host.name ID# IP_address noosphere PERM 1
943 +BASKET noosphere 128.112.35.133
944 +PROTOCOL 10 10 30 200
948 --- gcpegg-5.1.orig/storage.c
949 +++ gcpegg-5.1/storage.c
951 an error on the following declaration, disable it for your
954 -extern char *strdup (const char *s1);
955 +/*extern char *strdup (const char *s1);*/
957 /* Eventually, these might deal with making a safe copy or mounting
958 and unmounting a partition. Until such time as we actually do
959 @@ -77,7 +77,7 @@ static int32 next_poss_fn(char *fn, uint
967 static struct seekopt seekOpt[SEEK_OPT_MAX];
968 @@ -217,11 +217,12 @@ int32 InitStorage(char *path) {
969 int32 SavePacket(EggCarton *cart) {
971 char *packet, datatmp[255], datafile[255], *sp;
973 + uint32 pktime, res;
975 pktime = cart->records[0].timestamp;
977 - fprintf(stderr, "SavePacket for %lu: %s", pktime, asctime(gmtime((time_t *) &pktime)));
978 + time_t pktime_val = pktime;
979 + fprintf(stderr, "SavePacket for %u: %s", pktime, asctime(gmtime(&pktime_val)));
982 /* Generate the file name corresponding to the date of
983 @@ -285,8 +286,9 @@ int32 OpenDatabase(DBRec *dbp, uint32 ti
987 - fprintf(stderr, "OpenDatabase: Egg = %d, tindex = %ld %s",
988 - eggid, tindex, asctime(gmtime((time_t *) &tindex)));
989 + time_t tindex_val = tindex;
990 + fprintf(stderr, "OpenDatabase: Egg = %d, tindex = %u %s",
991 + eggid, tindex, asctime(gmtime(&tindex_val)));
995 @@ -344,7 +346,7 @@ static int32 LoadNextPacket(DBRec *dbp,
999 - fprintf(stderr, "LoadNextPacket(%s, %lu, %d)\n", dbp->fn, tindex, eggid);
1000 + fprintf(stderr, "LoadNextPacket(%s, %u, %d)\n", dbp->fn, tindex, eggid);
1003 /* See if the start address for this request is present
1004 @@ -364,20 +366,22 @@ static int32 LoadNextPacket(DBRec *dbp,
1005 seekOpt[i].last_time == tindex) {
1006 fseek(dbp->fp, seekOpt[i].next_packet, SEEK_SET);
1007 #ifdef STORAGE_DEBUG
1008 - fprintf(stderr, "LoadNextPacket; Seek optimised [%ld] to %ld for\n file %s at %lu %s",
1009 + time_t last_time_val = seekOpt[i].last_time;
1010 + fprintf(stderr, "LoadNextPacket; Seek optimised [%d] to %d for\n file %s at %u %s",
1012 seekOpt[i].next_packet,
1013 seekOpt[i].filename,
1014 seekOpt[i].last_time,
1015 - asctime(gmtime((time_t *) &(seekOpt[i].last_time))));
1016 + asctime(gmtime(&last_time_val)));
1021 if (i == seekOptIndex) {
1022 #ifdef STORAGE_DEBUG
1023 - fprintf(stderr, "LoadNextPacket; Cannot optimise seek in file %s\n at %lu %s",
1024 - dbp->fn, tindex, asctime(gmtime((time_t *) &(tindex))));
1025 + time_t tindex_val = tindex;
1026 + fprintf(stderr, "LoadNextPacket; Cannot optimise seek in file %s\n at %u %s",
1027 + dbp->fn, tindex, asctime(gmtime(&tindex_val)));
1029 break; /* Search wrapped table--cannot optimise */
1031 @@ -396,13 +400,15 @@ static int32 LoadNextPacket(DBRec *dbp,
1032 #define SECONDS_PER_DAY (24L * 60 * 60)
1033 findex = ((findex / SECONDS_PER_DAY) + 1) * SECONDS_PER_DAY;
1034 #ifdef STORAGE_DEBUG
1035 - fprintf(stderr, "LoadNextPacket; EOF, CloseDatabase, findex = %lu: %s",
1036 - findex, asctime(gmtime((time_t *) &findex)));
1037 + time_t findex_val = findex;
1038 + fprintf(stderr, "LoadNextPacket; EOF, CloseDatabase, findex = %u: %s",
1039 + findex, asctime(gmtime(&findex_val)));
1042 #ifdef STORAGE_DEBUG
1043 - fprintf(stderr, "LoadNextPacket; EOF findex = %lu > now = %lu %s",
1044 - findex, now, asctime(gmtime((time_t *) &now)));
1045 + time_t now_val = now;
1046 + fprintf(stderr, "LoadNextPacket; EOF findex = %u > now = %u %s",
1047 + findex, now, asctime(gmtime(&now_val)));
1051 @@ -427,12 +433,13 @@ fprintf(stderr, "Eggid = %d Packet.eggid
1052 seekOpt[seekOptIndex].last_time = pktbuf.records[pktbuf.hdr.numrec - 1].timestamp;
1053 seekOpt[seekOptIndex].next_packet = ftell(dbp->fp);
1054 #ifdef STORAGE_DEBUG
1055 - fprintf(stderr, "LoadNextPacket; Seek optimisation[%d] for %s\n to address %ld for time %lu %s",
1056 + time_t last_time_val = seekOpt[seekOptIndex].last_time;
1057 + fprintf(stderr, "LoadNextPacket; Seek optimisation[%d] for %s\n to address %d for time %u %s",
1059 seekOpt[seekOptIndex].filename,
1060 seekOpt[seekOptIndex].next_packet,
1061 seekOpt[seekOptIndex].last_time,
1062 - asctime(gmtime((time_t *) &(seekOpt[seekOptIndex].last_time))));
1063 + asctime(gmtime(&last_time_val)));
1065 seekOptIndex = (seekOptIndex + 1) % SEEK_OPT_MAX;
1067 @@ -495,8 +502,9 @@ static int32 next_filename(char *fn, uin
1070 #ifdef STORAGE_DEBUG
1071 - fprintf(stderr, "next_filename: egg = %d, mustexist = %d, tindex = %lu %s",
1072 - eggid, mustexist, tindex, asctime(gmtime((time_t *) &tindex)));
1073 + time_t tindex_val = tindex;
1074 + fprintf(stderr, "next_filename: egg = %d, mustexist = %d, tindex = %u %s",
1075 + eggid, mustexist, tindex, asctime(gmtime(&tindex_val)));
1077 if (eggid < 0 && !mustexist) {
1078 #ifdef STORAGE_DEBUG
1079 @@ -557,10 +565,11 @@ static int32 next_poss_fn(char *fn, uint
1083 - tm = gmtime((time_t *) &tindex);
1084 + time_t time_index = tindex;
1085 + tm = gmtime(&time_index);
1086 strftime(datatmp, 255, datafmt, tm);
1087 #ifdef STORAGE_DEBUG
1088 - fprintf(stderr, "next_poss_fn: egg = %d, tindex = %lu %s",
1089 + fprintf(stderr, "next_poss_fn: egg = %d, tindex = %u %s",
1090 eggid, tindex, asctime(tm));
1093 --- gcpegg-5.1.orig/xdsub.c
1094 +++ gcpegg-5.1/xdsub.c
1095 @@ -20,7 +20,7 @@ static char addrformat[80] = "%6X";
1096 static char dataformat1[80] = "%02X";
1097 static int bytesperline = 16, doublechar = 0,
1099 -static unsigned long fileaddr;
1100 +static unsigned int fileaddr;
1101 static unsigned char lineecho[32];
1103 /* OUTLINE -- Edit a line of binary data into the selected output