Loading...
Searching...
No Matches
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.

## Detailed Description

## Function Documentation

## mongo_wire_packet_free()

void mongo_wire_packet_free | ( | mongo_packet * | p | ) |

Free up a mongo packet.

Parameters

  p | is the packet to free.

Note
  The packet shall not be used afterwards.

## mongo_wire_packet_get_data()

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

  p | is the packet which header we seek.
  data | is 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.

## mongo_wire_packet_get_header()

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

  p | is the packet which header we seek.
  header | is 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_wire_packet_new()

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.

## mongo_wire_packet_set_data()

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

  p | is the packet whose data is to be set.
  data | is the data to set.
  size | is the size of the data.

Returns
  TRUE on success, FALSE otherwise.

## mongo_wire_packet_set_header()

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

  p | is the packet whose header we want to override.
  header | is the header structure to use.

Returns
  TRUE on success, FALSE otherwise.