/build/ldns-BsTNRO/ldns-1.9.2/host2wire.c File Reference

Go to the source code of this file.

## Functions

ldns_status | ldns_dname2buffer_wire (ldns_buffer *buffer, const ldns_rdf *name)
| Copies the dname data to the buffer in wire format.
ldns_status | ldns_dname2buffer_wire_compress (ldns_buffer *buffer, const ldns_rdf *name, ldns_rbtree_t *compression_data)
| Copies the dname data to the buffer in wire format.
ldns_status | ldns_rdf2buffer_wire (ldns_buffer *buffer, const ldns_rdf *rdf)
| Copies the rdata data to the buffer in wire format.
ldns_status | ldns_rdf2buffer_wire_compress (ldns_buffer *buffer, const ldns_rdf *rdf, ldns_rbtree_t *compression_data)
| Copies the rdata data to the buffer in wire format.
ldns_status | ldns_rdf2buffer_wire_canonical (ldns_buffer *buffer, const ldns_rdf *rdf)
| Copies the rdata data to the buffer in wire format If the rdata is a dname, the letters will be lowercased during the conversion.
ldns_status | ldns_rr_list2buffer_wire (ldns_buffer *buffer, const ldns_rr_list *rr_list)
| Copies the rr_list data to the buffer in wire format.
ldns_status | ldns_rr2buffer_wire_canonical (ldns_buffer *buffer, const ldns_rr *rr, int section)
| Copies the rr data to the buffer in wire format, in canonical format according to RFC3597 (every dname in rdata fields of RR's mentioned in that RFC will be lowercased).
ldns_status | ldns_rr2buffer_wire (ldns_buffer *buffer, const ldns_rr *rr, int section)
| Copies the rr data to the buffer in wire format.
ldns_status | ldns_rr2buffer_wire_compress (ldns_buffer *buffer, const ldns_rr *rr, int section, ldns_rbtree_t *compression_data)
| Copies the rr data to the buffer in wire format while doing DNAME compression.
ldns_status | ldns_rrsig2buffer_wire (ldns_buffer *buffer, const ldns_rr *rr)
| Converts a rrsig to wireformat BUT EXCLUDE the rrsig rdata This is needed in DNSSEC verification.
ldns_status | ldns_rr_rdata2buffer_wire (ldns_buffer *buffer, const ldns_rr *rr)
| Converts an rr's rdata to wireformat, while excluding the ownername and all the stuff before the rdata.
ldns_status | ldns_pkt2buffer_wire (ldns_buffer *buffer, const ldns_pkt *packet)
| Copies the packet data to the buffer in wire format.
ldns_status | ldns_pkt2buffer_wire_compress (ldns_buffer *buffer, const ldns_pkt *packet, ldns_rbtree_t *compression_data)
| Copies the packet data to the buffer in wire format.
ldns_status | ldns_rdf2wire (uint8_t **dest, const ldns_rdf *rdf, size_t *result_size)
| Allocates an array of uint8_t at dest, and puts the wireformat of the given rdf in that array.
ldns_status | ldns_rr2wire (uint8_t **dest, const ldns_rr *rr, int section, size_t *result_size)
| Allocates an array of uint8_t at dest, and puts the wireformat of the given rr in that array.
ldns_status | ldns_pkt2wire (uint8_t **dest, const ldns_pkt *packet, size_t *result_size)
| Allocates an array of uint8_t at dest, and puts the wireformat of the given packet in that array.

## Function Documentation

## ldns_dname2buffer_wire()

ldns_status ldns_dname2buffer_wire | ( | ldns_buffer * | buffer,
|  | const ldns_rdf * | name )

Copies the dname data to the buffer in wire format.

Parameters

  [out] | *buffer | buffer to append the result to
  [in] | *name | rdata dname to convert

Returns
  ldns_status

Definition at line 20 of file host2wire.c.

References ldns_dname2buffer_wire_compress().

## ldns_dname2buffer_wire_compress()

ldns_status ldns_dname2buffer_wire_compress | ( | ldns_buffer * | buffer,
|  | const ldns_rdf * | name,
|  | ldns_rbtree_t * | compression_data )

Copies the dname data to the buffer in wire format.

Parameters

  [out] | *buffer | buffer to append the result to
  [in] | *name | rdata dname to convert
  [out] | *compression_data | data structure holding state for compression

Returns
  ldns_status

Definition at line 26 of file host2wire.c.

References ldns_rbnode_t::data, ldns_rbnode_t::key, ldns_buffer_reserve(), ldns_dname2buffer_wire_compress(), ldns_dname_label(), ldns_dname_label_count(), ldns_dname_left_chop(), LDNS_FREE, LDNS_MALLOC, ldns_rbtree_insert(), ldns_rbtree_search(), ldns_rdf_clone(), ldns_rdf_data(), ldns_rdf_deep_free(), ldns_rdf_size(), and LDNS_STATUS_MEM_ERR.

## ldns_rdf2buffer_wire()

ldns_status ldns_rdf2buffer_wire | ( | ldns_buffer * | output,
|  | const ldns_rdf * | rdf )

Copies the rdata data to the buffer in wire format.

Parameters

  [out] | *output | buffer to append the result to
  [in] | *rdf | rdata to convert

Returns
  ldns_status

Definition at line 109 of file host2wire.c.

References ldns_rdf2buffer_wire_compress().

## ldns_rdf2buffer_wire_compress()

ldns_status ldns_rdf2buffer_wire_compress | ( | ldns_buffer * | output,
|  | const ldns_rdf * | rdf,
|  | ldns_rbtree_t * | compression_data )

Copies the rdata data to the buffer in wire format.

Parameters

  [out] | *output | buffer to append the result to
  [in] | *rdf | rdata to convert
  [out] | *compression_data | data structure holding state for compression

Returns
  ldns_status

Definition at line 115 of file host2wire.c.

References ldns_buffer_reserve(), ldns_dname2buffer_wire_compress(), ldns_rdf_data(), ldns_rdf_get_type(), ldns_rdf_size(), and LDNS_RDF_TYPE_DNAME.

## ldns_rdf2buffer_wire_canonical()

ldns_status ldns_rdf2buffer_wire_canonical | ( | ldns_buffer * | output,
|  | const ldns_rdf * | rdf )

Copies the rdata data to the buffer in wire format If the rdata is a dname, the letters will be lowercased during the conversion.

Parameters

  [out] | *output | buffer to append the result to
  [in] | *rdf | rdata to convert

Returns
  ldns_status

Definition at line 130 of file host2wire.c.

References ldns_buffer_reserve(), LDNS_DNAME_NORMALIZE, ldns_rdf_data(), ldns_rdf_get_type(), ldns_rdf_size(), and LDNS_RDF_TYPE_DNAME.

## ldns_rr_list2buffer_wire()

ldns_status ldns_rr_list2buffer_wire | ( | ldns_buffer * | output,
|  | const ldns_rr_list * | rrlist )

Copies the rr_list data to the buffer in wire format.

Parameters

  [out] | *output | buffer to append the result to
  [in] | *rrlist | rr_list to to convert

Returns
  ldns_status

Definition at line 156 of file host2wire.c.

References ldns_rr2buffer_wire(), ldns_rr_list_rr(), ldns_rr_list_rr_count(), and LDNS_SECTION_ANY.

## ldns_rr2buffer_wire_canonical()

ldns_status ldns_rr2buffer_wire_canonical | ( | ldns_buffer * | output,
|  | const ldns_rr * | rr,
|  | int | section )

Copies the rr data to the buffer in wire format, in canonical format according to RFC3597 (every dname in rdata fields of RR's mentioned in that RFC will be lowercased).

Parameters

  [out] | *output | buffer to append the result to
  [in] | *rr | resource record to convert
  [in] | section | the section in the packet this rr is supposed to be in (to determine whether to add rdata or not)

Returns
  ldns_status

Definition at line 171 of file host2wire.c.

References ldns_buffer_reserve(), ldns_rdf2buffer_wire(), ldns_rdf2buffer_wire_canonical(), ldns_rr_get_class(), ldns_rr_get_type(), ldns_rr_owner(), ldns_rr_rd_count(), ldns_rr_rdf(), ldns_rr_ttl(), LDNS_RR_TYPE_A6, LDNS_RR_TYPE_AFSDB, LDNS_RR_TYPE_CNAME, LDNS_RR_TYPE_DNAME, LDNS_RR_TYPE_HINFO, LDNS_RR_TYPE_KX, LDNS_RR_TYPE_MB, LDNS_RR_TYPE_MD, LDNS_RR_TYPE_MF, LDNS_RR_TYPE_MG, LDNS_RR_TYPE_MINFO, LDNS_RR_TYPE_MR, LDNS_RR_TYPE_MX, LDNS_RR_TYPE_NAPTR, LDNS_RR_TYPE_NS, LDNS_RR_TYPE_NXT, LDNS_RR_TYPE_PTR, LDNS_RR_TYPE_PX, LDNS_RR_TYPE_RP, LDNS_RR_TYPE_RRSIG, LDNS_RR_TYPE_RT, LDNS_RR_TYPE_SIG, LDNS_RR_TYPE_SOA, LDNS_RR_TYPE_SRV, and LDNS_SECTION_QUESTION.

## ldns_rr2buffer_wire()

ldns_status ldns_rr2buffer_wire | ( | ldns_buffer * | output,
|  | const ldns_rr * | rr,
|  | int | section )

Copies the rr data to the buffer in wire format.

Parameters

  [out] | *output | buffer to append the result to
  [in] | *rr | resource record to convert
  [in] | section | the section in the packet this rr is supposed to be in (to determine whether to add rdata or not)

Returns
  ldns_status

Definition at line 244 of file host2wire.c.

References ldns_rr2buffer_wire_compress().

## ldns_rr2buffer_wire_compress()

ldns_status ldns_rr2buffer_wire_compress | ( | ldns_buffer * | output,
|  | const ldns_rr * | rr,
|  | int | section,
|  | ldns_rbtree_t * | compression_data )

Copies the rr data to the buffer in wire format while doing DNAME compression.

Parameters

  [out] | *output | buffer to append the result to
  [in] | *rr | resource record to convert
  [in] | section | the section in the packet this rr is supposed to be in (to determine whether to add rdata or not)
  [out] | *compression_data | data structure holding state information for compression

Returns
  ldns_status

Definition at line 250 of file host2wire.c.

References ldns_buffer_reserve(), ldns_dname2buffer_wire_compress(), ldns_rdf2buffer_wire(), ldns_rdf2buffer_wire_compress(), LDNS_RR_COMPRESS, ldns_rr_descript(), ldns_rr_get_class(), ldns_rr_get_type(), ldns_rr_owner(), ldns_rr_rd_count(), ldns_rr_rdf(), ldns_rr_ttl(), and LDNS_SECTION_QUESTION.

## ldns_rrsig2buffer_wire()

ldns_status ldns_rrsig2buffer_wire | ( | ldns_buffer * | output,
|  | const ldns_rr * | sigrr )

Converts a rrsig to wireformat BUT EXCLUDE the rrsig rdata This is needed in DNSSEC verification.

Parameters

  [out] | output | buffer to append the result to
  [in] | sigrr | signature rr to operate on

Returns
  ldns_status

Definition at line 294 of file host2wire.c.

References ldns_rdf2buffer_wire_canonical(), ldns_rr_get_type(), ldns_rr_rd_count(), ldns_rr_rdf(), LDNS_RR_TYPE_RRSIG, and LDNS_STATUS_ERR.

## ldns_rr_rdata2buffer_wire()

ldns_status ldns_rr_rdata2buffer_wire | ( | ldns_buffer * | output,
|  | const ldns_rr * | rr )

Converts an rr's rdata to wireformat, while excluding the ownername and all the stuff before the rdata.

This is needed in DNSSEC keytag calculation, the ds calculation from the key and maybe elsewhere.

Parameters

  [out] | *output | buffer where to put the result
  [in] | *rr | rr to operate on

Returns
  ldns_status

Definition at line 314 of file host2wire.c.

References ldns_rdf2buffer_wire(), ldns_rr_rd_count(), and ldns_rr_rdf().

## ldns_pkt2buffer_wire()

ldns_status ldns_pkt2buffer_wire | ( | ldns_buffer * | output,
|  | const ldns_pkt * | pkt )

Copies the packet data to the buffer in wire format.

Parameters

  [out] | *output | buffer to append the result to
  [in] | *pkt | packet to convert

Returns
  ldns_status

Definition at line 376 of file host2wire.c.

References ldns_dname_compare_v(), ldns_pkt2buffer_wire_compress(), ldns_rbtree_create(), ldns_rbtree_free(), and ldns_traverse_postorder().

## ldns_pkt2buffer_wire_compress()

ldns_status ldns_pkt2buffer_wire_compress | ( | ldns_buffer * | output,
|  | const ldns_pkt * | pkt,
|  | ldns_rbtree_t * | compression_data )

Copies the packet data to the buffer in wire format.

Parameters

  [out] | *output | buffer to append the result to
  [in] | *pkt | packet to convert
  [out] | *compression_data | data structure holding state for compression

Returns
  ldns_status

Definition at line 390 of file host2wire.c.

References ldns_struct_pkt::_edns_data, ldns_struct_pkt::_edns_list, ldns_buffer_export(), ldns_buffer_free(), ldns_edns_option_list2wireformat_buffer(), ldns_pkt_additional(), ldns_pkt_answer(), ldns_pkt_authority(), ldns_pkt_edns(), ldns_pkt_edns_extended_rcode(), ldns_pkt_edns_udp_size(), ldns_pkt_edns_version(), ldns_pkt_edns_z(), ldns_pkt_question(), ldns_pkt_tsig(), ldns_rdf_new(), ldns_rdf_new_frm_str(), LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_UNKNOWN, ldns_rr2buffer_wire_compress(), ldns_rr_free(), ldns_rr_list_rr(), ldns_rr_list_rr_count(), ldns_rr_new(), ldns_rr_pop_rdf(), ldns_rr_push_rdf(), ldns_rr_set_class(), ldns_rr_set_owner(), ldns_rr_set_ttl(), ldns_rr_set_type(), LDNS_RR_TYPE_OPT, LDNS_SECTION_ADDITIONAL, LDNS_SECTION_ANSWER, LDNS_SECTION_AUTHORITY, LDNS_SECTION_QUESTION, LDNS_STATUS_MEM_ERR, and LDNS_STATUS_OK.

## ldns_rdf2wire()

ldns_status ldns_rdf2wire | ( | uint8_t ** | dest,
|  | const ldns_rdf * | rdf,
|  | size_t * | size )

Allocates an array of uint8_t at dest, and puts the wireformat of the given rdf in that array.

The result_size value contains the length of the array, if it succeeds, and 0 otherwise (in which case the function also returns NULL)

Parameters

  [out] | dest | pointer to the array of bytes to be created
  [in] | rdf | the rdata field to convert
  [out] | size | the size of the converted result

Definition at line 476 of file host2wire.c.

References ldns_buffer_export(), ldns_buffer_free(), ldns_buffer_new(), LDNS_MAX_PACKETLEN, ldns_rdf2buffer_wire(), LDNS_STATUS_MEM_ERR, and LDNS_STATUS_OK.

## ldns_rr2wire()

ldns_status ldns_rr2wire | ( | uint8_t ** | dest,
|  | const ldns_rr * | rr,
|  | int | section,
|  | size_t * | size )

Allocates an array of uint8_t at dest, and puts the wireformat of the given rr in that array.

The result_size value contains the length of the array, if it succeeds, and 0 otherwise (in which case the function also returns NULL)

If the section argument is LDNS_SECTION_QUESTION, data like ttl and rdata are not put into the result

Parameters

  [out] | dest | pointer to the array of bytes to be created
  [in] | rr | the rr to convert
  [in] | section | the rr section, determines how the rr is written.
  [out] | size | the size of the converted result

Definition at line 494 of file host2wire.c.

References ldns_buffer_export(), ldns_buffer_free(), ldns_buffer_new(), LDNS_MAX_PACKETLEN, ldns_rr2buffer_wire(), LDNS_STATUS_MEM_ERR, and LDNS_STATUS_OK.

## ldns_pkt2wire()

ldns_status ldns_pkt2wire | ( | uint8_t ** | dest,
|  | const ldns_pkt * | p,
|  | size_t * | size )

Allocates an array of uint8_t at dest, and puts the wireformat of the given packet in that array.

The result_size value contains the length of the array, if it succeeds, and 0 otherwise (in which case the function also returns NULL)

Parameters

  [out] | dest | pointer to the array of bytes to be created
  [in] | p | the packet to convert
  [out] | size | the size of the converted result

Definition at line 512 of file host2wire.c.

References ldns_buffer_export(), ldns_buffer_free(), ldns_buffer_new(), LDNS_MAX_PACKETLEN, ldns_pkt2buffer_wire(), LDNS_STATUS_MEM_ERR, and LDNS_STATUS_OK.