openblt

a hobby OS from the late 90s
git clone http://frotz.net/git/openblt.git
Log | Files | Refs | LICENSE

dfp.h (3255B)


      1 /* $Id: //depot/blt/srv/fish/dfp.h#3 $
      2 **
      3 ** Copyright 1998 Brian J. Swetland
      4 ** All rights reserved.
      5 **
      6 ** Redistribution and use in source and binary forms, with or without
      7 ** modification, are permitted provided that the following conditions
      8 ** are met:
      9 ** 1. Redistributions of source code must retain the above copyright
     10 **    notice, this list of conditions, and the following disclaimer.
     11 ** 2. Redistributions in binary form must reproduce the above copyright
     12 **    notice, this list of conditions, and the following disclaimer in the
     13 **    documentation and/or other materials provided with the distribution.
     14 ** 3. The name of the author may not be used to endorse or promote products
     15 **    derived from this software without specific prior written permission.
     16 **
     17 ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18 ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19 ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20 ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21 ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22 ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26 ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
     28 /*
     29 ** Distributed Fish Protocol
     30 ** Version 1.0
     31 **
     32 ** Special Interest Group for Operating Systems
     33 ** Association for Computing Machinery
     34 ** University of Illinios at Urbana-Champaign
     35 */
     36 
     37 #ifndef _DFP_H
     38 #define _DFP_H
     39 
     40 #ifdef _WIN32
     41 #include <sys/types.h>
     42 #include <winsock.h>
     43 #endif
     44 
     45 #ifdef NEED_TYPES
     46 typedef unsigned char  uint8;
     47 typedef unsigned short uint16;
     48 typedef unsigned int   uint32;
     49 #endif
     50 typedef char           sint8;
     51 
     52 #define DFP_VERSION	        0x0201
     53 
     54 #define DEFAULT_DFP_PORT	5049
     55 
     56 #define DFP_MIN_SUBTANK_X	0
     57 #define DFP_MAX_SUBTANK_X	3
     58 #define DFP_MIN_SUBTANK_Y	0
     59 #define DFP_MAX_SUBTANK_Y	3
     60 
     61 #define DFP_PKT_PING		0
     62 #define DFP_PKT_PONG		1
     63 #define DFP_PKT_SEND_FISH	2
     64 #define DFP_PKT_ACK_FISH	3
     65 #define	DFP_PKT_NACK_FISH	4
     66 #define DFP_PKT_SYNC_FISH	5
     67 
     68 /* pack everything along byte boundaries */	
     69 #pragma pack( 1 )
     70 
     71 typedef struct 
     72 {
     73     uint16  version;
     74     uint8   src_tank_x;
     75     uint8   src_tank_y;
     76     uint8   dst_tank_x;
     77     uint8   dst_tank_y;
     78     uint8   type;         /* one of DFP_PKT_* */
     79     uint8   pad;          /* should be 0 */
     80     uint16  size;         /* size of entire packet */
     81 } dfp_base;
     82 
     83 typedef struct
     84 {
     85     uint8  creator_tank_x;
     86     uint8  creator_tank_y;
     87     uint8  timestamp[4];
     88 } dfp_uid;
     89 
     90 typedef struct
     91 {
     92     uint8  x;
     93     uint8  y;
     94     sint8  dx;
     95     sint8  dy;
     96     uint16 ttl;
     97     uint8  name[16];
     98 } dfp_fish;
     99 
    100 
    101 #define DFP_SIZE_LOCATE   10
    102 #define DFP_SIZE_CONFIRM  16
    103 #define DFP_SIZE_TRANSFER 38
    104 
    105 
    106 typedef struct
    107 {
    108     dfp_base base;
    109 } dfp_pkt_locate;
    110 
    111 typedef struct 
    112 {
    113     dfp_base base;
    114     dfp_uid  uid;
    115 } dfp_pkt_confirm;
    116 
    117 typedef struct 
    118 {
    119     dfp_base base;
    120     dfp_uid  uid;
    121     dfp_fish fish;
    122 } dfp_pkt_transfer;
    123 
    124 /* restore default packing */
    125 #pragma pack()
    126 
    127 #endif /* __DFP_H */