dfp.h (3210B)
1 /* $Id: //depot/blt/util/dfp.h#2 $ 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 char sint8; 49 #endif 50 51 #define DFP_VERSION 0x0201 52 53 #define DEFAULT_DFP_PORT 5049 54 55 #define DFP_MIN_SUBTANK_X 0 56 #define DFP_MAX_SUBTANK_X 3 57 #define DFP_MIN_SUBTANK_Y 0 58 #define DFP_MAX_SUBTANK_Y 3 59 60 #define DFP_PKT_PING 0 61 #define DFP_PKT_PONG 1 62 #define DFP_PKT_SEND_FISH 2 63 #define DFP_PKT_ACK_FISH 3 64 #define DFP_PKT_NACK_FISH 4 65 #define DFP_PKT_SYNC_FISH 5 66 67 /* pack everything along byte boundaries */ 68 #pragma pack( 1 ) 69 70 typedef struct 71 { 72 uint16 version; 73 uint8 src_tank_x; 74 uint8 src_tank_y; 75 uint8 dst_tank_x; 76 uint8 dst_tank_y; 77 uint8 type; /* one of DFP_PKT_* */ 78 uint8 pad; /* should be 0 */ 79 uint16 size; /* size of entire packet */ 80 } dfp_base; 81 82 typedef struct 83 { 84 uint8 creator_tank_x; 85 uint8 creator_tank_y; 86 uint8 timestamp[4]; 87 } dfp_uid; 88 89 typedef struct 90 { 91 uint8 x; 92 uint8 y; 93 sint8 dx; 94 sint8 dy; 95 uint16 ttl; 96 uint8 name[16]; 97 } dfp_fish; 98 99 100 #define DFP_SIZE_LOCATE 10 101 #define DFP_SIZE_CONFIRM 16 102 #define DFP_SIZE_TRANSFER 38 103 104 105 typedef struct 106 { 107 dfp_base base; 108 } dfp_pkt_locate; 109 110 typedef struct 111 { 112 dfp_base base; 113 dfp_uid uid; 114 } dfp_pkt_confirm; 115 116 typedef struct 117 { 118 dfp_base base; 119 dfp_uid uid; 120 dfp_fish fish; 121 } dfp_pkt_transfer; 122 123 /* restore default packing */ 124 #pragma pack() 125 126 #endif /* __DFP_H */