clodbuster/packet.h
1 /*
2  * Player - One Hell of a Robot Server
3  * Copyright (C) 2000
4  * Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard
5  *
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  */
22 
23 /*
24  * $Id: packet.h 1949 2004-01-30 19:21:15Z section314 $
25  * GRASP version of the P2OS packet class. this class has methods
26  * for building, printing, sending and receiving GRASP Board packets.
27  *
28  */
29 
30 #ifndef _PACKET_H
31 #define _PACKET_H
32 
33 #include <string.h>
34 
35 #define PACKET_LEN 12
36 
38 {
39  public:
40  unsigned char packet[PACKET_LEN];
41  unsigned int size;
42  unsigned int retsize;
43  void Print();
44  void PrintHex();
45  int Build(unsigned char command, unsigned char data);
46  int Build(unsigned char command);
47 
48  int Send( int fd );
49  int Receive( int fd,unsigned char command );
50 
51  bool operator!= ( GRASPPacket p ) {
52  if ( size != p.size) return(true);
53 
54  if ( memcmp( packet, p.packet, size ) != 0 ) return (true);
55 
56  return(false);
57  }
58 };
59 
60 #endif

Last updated 12 September 2005 21:38:45