Skip to content
Snippets Groups Projects
Commit 46ba6b44 authored by Lubos Slovak's avatar Lubos Slovak
Browse files

Setting ID and setting random ID to the packet.

- Random ID not implemented yet (merge required).
parent bab178f6
No related branches found
No related tags found
No related merge requests found
......@@ -933,6 +933,24 @@ uint16_t knot_packet_id(const knot_packet_t *packet)
/*----------------------------------------------------------------------------*/
void knot_packet_set_id(knot_packet_t *packet, uint16_t id)
{
if (packet == NULL) {
return KNOT_EBADARG;
}
packet->header.id = id;
}
/*----------------------------------------------------------------------------*/
void knot_packet_set_random_id(knot_packet_t *packet)
{
/*! \todo Implement. */
}
/*----------------------------------------------------------------------------*/
uint8_t knot_packet_opcode(const knot_packet_t *packet)
{
assert(packet != NULL);
......@@ -1259,6 +1277,13 @@ int knot_packet_to_wire(knot_packet_t *packet,
/*----------------------------------------------------------------------------*/
const uint8_t *knot_packet_wireformat(const knot_packet_t *packet)
{
return packet->wireformat;
}
/*----------------------------------------------------------------------------*/
void knot_packet_free(knot_packet_t **packet)
{
if (packet == NULL || *packet == NULL) {
......
......@@ -303,6 +303,10 @@ int knot_packet_set_max_size(knot_packet_t *packet, int max_size);
uint16_t knot_packet_id(const knot_packet_t *packet);
void knot_packet_set_id(knot_packet_t *packet, uint16_t id);
void knot_packet_set_random_id(knot_packet_t *packet);
/*!
* \brief Returns the OPCODE of the packet.
*
......@@ -480,6 +484,8 @@ int knot_packet_edns_to_wire(knot_packet_t *packet);
int knot_packet_to_wire(knot_packet_t *packet, uint8_t **wire,
size_t *wire_size);
const uint8_t *knot_packet_wireformat(const knot_packet_t *packet);
/*!
* \brief Properly destroys the packet structure.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment