#pragma once #include #include #include #include #include /** * The possible values for a packet id. */ extern enum { PACKET_GET_HELLO, //! Packet id for get hello. PACKET_SEND_FRAME, //! Packet id for send frame. PACKETS_NUMBER //! The number of recognized packets. }; /** * Struct representing a generic packet. */ struct msPacket { //! The id of the packet. size_t id; //! The size of the data contained in the packet. size_t size; //! The data as a byte array. (Not null terminated.) char *raw_data; }; /** * Asks the code to handle a concrete packet comming from a client. */ bool msPacketHandle(struct msPacket *packet, int client_fd, struct msClientConnectionData *const data); /** * When done with a packet it must be destroyed using this method. */ void msPacketDestroy(struct msPacket **packet); /** * Tries to retrieve a packet from the client, returns NULL in case of error. * Blocks the current thread. */ struct msPacket * msPacketRead(int client_fd);