libmongo-client  0.1.6.1
Data Structures | Functions
Packets
Mongo Wire Protocol
Collaboration diagram for Packets:

Data Structures

struct  mongo_packet_header
 Mongo packet header. More...

Functions

mongo_packet * mongo_wire_packet_new (void)
 Create an empty packet.
gboolean mongo_wire_packet_get_header (const mongo_packet *p, mongo_packet_header *header)
 Get the header data of a packet.
gboolean mongo_wire_packet_set_header (mongo_packet *p, const mongo_packet_header *header)
 Set the header data of a packet.
gint32 mongo_wire_packet_get_data (const mongo_packet *p, const guint8 **data)
 Get the data part of a packet.
gboolean mongo_wire_packet_set_data (mongo_packet *p, const guint8 *data, gint32 size)
 Set the data part of a packet.
void mongo_wire_packet_free (mongo_packet *p)
 Free up a mongo packet.

Function Documentation

void mongo_wire_packet_free ( mongo_packet *  p)

Free up a mongo packet.

Parameters:
pis the packet to free.
Note:
The packet shall not be used afterwards.
gint32 mongo_wire_packet_get_data ( const mongo_packet *  p,
const guint8 **  data 
)

Get the data part of a packet.

Retrieve the raw binary blob of the mongo packet's data.

Parameters:
pis the packet which header we seek.
datais a pointer to a variable which will hold the data.
Note:
The data parameter will point to an internal structure, which shall not be freed or written to.
Returns:
The size of the data, or -1 on error.
gboolean mongo_wire_packet_get_header ( const mongo_packet *  p,
mongo_packet_header header 
)

Get the header data of a packet.

Retrieve the mongo packet's header data.

Parameters:
pis the packet which header we seek.
headeris a pointer to a variable which will hold the data.
Note:
Allocating the header is the responsibility of the caller.
Returns:
TRUE on success, FALSE otherwise.
mongo_packet* mongo_wire_packet_new ( void  )

Create an empty packet.

Creates an empty packet to be filled in later with mongo_wire_packet_set_header() and mongo_packet_set_data().

Returns:
A newly allocated packet, or NULL on error.
gboolean mongo_wire_packet_set_data ( mongo_packet *  p,
const guint8 *  data,
gint32  size 
)

Set the data part of a packet.

Overrides the data part of a packet, adjusting the packet length in the header too.

Note:
No sanity checks are performed on the data, it is the caller's responsibility to supply valid information.
Parameters:
pis the packet whose data is to be set.
datais the data to set.
sizeis the size of the data.
Returns:
TRUE on success, FALSE otherwise.
gboolean mongo_wire_packet_set_header ( mongo_packet *  p,
const mongo_packet_header header 
)

Set the header data of a packet.

Override the mongo packet's header data.

Note:
No sanity checks are done, use this function with great care.
Parameters:
pis the packet whose header we want to override.
headeris the header structure to use.
Returns:
TRUE on success, FALSE otherwise.
 All Data Structures Variables