typedef struct player_devaddr
{
/** The "host" on which the device resides. Transport-dependent. */
uint32_t host;
/** The "robot" or device collection in which the device resides.
Transport-dependent */
uint32_t robot;
/** The interface provided by the device; must be one of PLAYER_*_CODE */
uint16_t interf;
/** Which device of that interface */
uint16_t index;
} player_devaddr_t;
// Generic message header.
typedef struct player_msghdr
{
/** Origin address */
player_devaddr_t from;
/** Destination address */
player_devaddr_t to;
/** Message type; interface-specific */
uint8_t type;
/** Time associated with message contents (seconds since epoch) */
double timestamp;
/** For keeping track of associated messages. Transport-specific. */
uint32_t seq;
/** Whether an acknowledgement is requeested */
uint8_t ack;
/** Size in bytes of the payload to follow */
uint32_t size;
} player_msghdr_t;
// An acknowledgement message
typedef struct player_player_ack
{
uint8_t value;
} player_player_ack_t;
typedef struct player_msgqueue
{
// A linked list gets implemented here, using glib
} player_msgqueue_t;
typedef struct player_cache
{
// A dictionary of messages, keyed by message signature, goes here
// (use glib). New messages overwrite old ones with the same signature.
} player_cache_t;
// Insert data, with signature hdr, into the cache
int player_cache_insert(player_cache_t* cache,
player_msghdr_t* hdr,
void* data);
// Retrieve message with signature hdr, and put it in data.
int player_cache_retrieve(player_cache_t* cache,
player_msghdr_t* hdr,
void* data);
// Similar to player_cache_retrieve, but deletes message from the cache
// after retrieval
int player_cache_remove(player_cache_t* cache,
player_msghdr_t* hdr,
void* data);