Robot Agent  1.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
protocol.h
Go to the documentation of this file.
1 
12 #ifndef __PROTOCOL_H
13 #define __PROTOCOL_H
14 
15 /* -- Includes -- */
16 
17 /* -- Types -- */
18 
22 typedef struct s_PROTOCOL_STRUCT
23 {
24  int recv_id; // Receiver ID
25  int send_id; // Sender ID
26  int send_team; // Sender Team
27  char type; // Packet type
28  int send_time;
29  int pkt_seqno; //Sequence number of the packet
30  int pkt_seqid; //Sequence id of the packet.
31  int seq_last_id; //The last id of the sequence
32  char data_type; // Data type
33  void *data; // Pointer to data structure
34 
35 } protocol_t;
36 
37 /* -- Constants -- */
38 
39 /* Protocol Addresses */
40 #define s_PROTOCOL_ADDR_SERVER 0
41 #define s_PROTOCOL_ADDR_BROADCAST 99
42 
43 /* Packet types */
44 #define s_PROTOCOL_TYPE_ACK 'a'
45 #define s_PROTOCOL_TYPE_DATA 'd'
46 #define s_PROTOCOL_TYPE_GO_AHEAD 'g'
47 
48 /* -- Function Prototypes -- */
49 int protocol_encode(char *udp_packet,
50  int *len,
51  int recv_id,
52  int send_id,
53  int send_team,
54  char type,
55  int seqno,
56  int seqid,
57  int seq_lid,
58  int data_type,
59  void *data); // Encode data structure into string to be sent through UDP
60 
61 /* Decode the data structure contanied in the udp packet */
62 int protocol_decode(protocol_t *packet, char *udp_packet, int len, int robot_id, int robot_team);
63 
64 
65 
66  #endif /* __PROTOCOL_H */
int protocol_decode(protocol_t *packet, char *udp_packet, int len, int robot_id, int robot_team)
Definition: protocol.c:169
struct s_PROTOCOL_STRUCT protocol_t
UDP structure.
UDP structure.
Definition: protocol.h:22
int protocol_encode(char *udp_packet, int *len, int recv_id, int send_id, int send_team, char type, int seqno, int seqid, int seq_lid, int data_type, void *data)
Definition: protocol.c:43