22 * Every packet can be at most SEND_MTU bytes. Overflowing this |
22 * Every packet can be at most SEND_MTU bytes. Overflowing this |
23 * limit will give an assertion when sending (i.e. writing) the |
23 * limit will give an assertion when sending (i.e. writing) the |
24 * packet. Reading past the size of the packet when receiving |
24 * packet. Reading past the size of the packet when receiving |
25 * will return all 0 values and "" in case of the string. |
25 * will return all 0 values and "" in case of the string. |
26 */ |
26 */ |
27 typedef struct Packet { |
27 struct Packet { |
28 /** The next packet. Used for queueing packets before sending. */ |
28 /** The next packet. Used for queueing packets before sending. */ |
29 struct Packet *next; |
29 Packet *next; |
30 /** The size of the whole packet for received packets. For packets |
30 /** The size of the whole packet for received packets. For packets |
31 * that will be sent, the value is filled in just before the |
31 * that will be sent, the value is filled in just before the |
32 * actual transmission. */ |
32 * actual transmission. */ |
33 PacketSize size; |
33 PacketSize size; |
34 /** The current read/write position in the packet */ |
34 /** The current read/write position in the packet */ |
35 PacketSize pos; |
35 PacketSize pos; |
36 /** The buffer of this packet */ |
36 /** The buffer of this packet */ |
37 byte buffer[SEND_MTU]; |
37 byte buffer[SEND_MTU]; |
38 } Packet; |
38 }; |
39 |
39 |
40 |
40 |
41 Packet *NetworkSend_Init(const PacketType type); |
41 Packet *NetworkSend_Init(const PacketType type); |
42 void NetworkSend_FillPacketSize(Packet *packet); |
42 void NetworkSend_FillPacketSize(Packet *packet); |
43 void NetworkSend_uint8 (Packet *packet, uint8 data); |
43 void NetworkSend_uint8 (Packet *packet, uint8 data); |