2 * FILE: $Header: /home/egg/src/RCS/ipproto.c,v 1.1 1998/07/21 11:37:21 ghn Exp $
3 * PURPOSE: Declarations/definitions of IP data protocols for Egg
7 * REVISED: $Log: ipproto.c,v $
8 * REVISED: Revision 1.1 1998/07/21 11:37:21 ghn
9 * REVISED: Initial revision
11 * Copyright 1998 - Greg Nelson
12 * Redistributable under the terms of the GNU Public Licence (GPL)
19 int32 PackPacket(char *buf, uint32 bufsize, EggCarton *cart) {
20 int32 rec, ntrl, llen;
23 if (bufsize < sizeof(EggHeader)) return -1;
25 memcpy(buf, &(cart->hdr), sizeof(EggHeader));
26 buf += sizeof(EggHeader);
28 ntrl = card->hdr.reclen;
29 llen = sizeof(uint32) + ntrl * sizeof(trial);
31 for (rec = 0; rec < cart->hdr.numrec; rec++) {
32 memcpy(buf, &(card->records[rec].timestamp), sizeof(uint32));
33 memcpy(buf + sizeof(uint32),
34 &(card->records[rec].trials), ntrl * sizeof(trial));
35 crc = BlockCRC16((byte *)buf, llen);
36 memcpy(buf + llen, &crc, sizeof(uint16));
37 buf += llen + sizeof(uint16);