Skip to content

Commit

Permalink
packet: add ldns_pkt_edns_unassigned and ldns_pkt_set_edns_unassigned
Browse files Browse the repository at this point in the history
  • Loading branch information
fcelda committed Apr 10, 2017
1 parent a184d67 commit 50b930f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ldns/packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,18 @@ bool ldns_pkt_edns_do(const ldns_pkt *packet);
*/
void ldns_pkt_set_edns_do(ldns_pkt *packet, bool value);

/**
* return the packet's EDNS header bits that are unassigned.
*/
uint16_t ldns_pkt_edns_unassigned(const ldns_pkt *packet);

/**
* Set the packet's EDNS header bits that are unassigned.
* \param[in] packet the packet
* \param[in] value the value
*/
void ldns_pkt_set_edns_unassigned(ldns_pkt *packet, uint16_t value);

/**
* returns true if this packet needs and EDNS rr to be sent.
* At the moment the only reason is an expected packet
Expand Down
14 changes: 14 additions & 0 deletions packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/

#define LDNS_EDNS_MASK_DO_BIT 0x8000
#define LDNS_EDNS_MASK_UNASSIGNED (0xFFFF & ~LDNS_EDNS_MASK_DO_BIT)

/* TODO defines for 3600 */
/* convert to and from numerical flag values */
Expand Down Expand Up @@ -242,6 +243,19 @@ ldns_pkt_set_edns_do(ldns_pkt *packet, bool value)
}
}

uint16_t
ldns_pkt_edns_unassigned(const ldns_pkt *packet)
{
return (packet->_edns_z & LDNS_EDNS_MASK_UNASSIGNED);
}

void
ldns_pkt_set_edns_unassigned(ldns_pkt *packet, uint16_t value)
{
packet->_edns_z = (packet->_edns_z & ~LDNS_EDNS_MASK_UNASSIGNED)
| (value & LDNS_EDNS_MASK_UNASSIGNED);
}

ldns_rdf *
ldns_pkt_edns_data(const ldns_pkt *packet)
{
Expand Down

0 comments on commit 50b930f

Please sign in to comment.