ldns documentation

- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

Macros | Functions
wire2host.c File Reference

Go to the source code of this file.

## Macros
#define | LDNS_STATUS_CHECK_RETURN(st) {if (st != LDNS_STATUS_OK) { return st; }}
#define | LDNS_STATUS_CHECK_GOTO(st, label) {if (st != LDNS_STATUS_OK) { /*printf("STG %s:%d: status code %d\n", __FILE__, __LINE__, st);*/ goto label; }}

## Functions
ldns_status | ldns_wire2dname (ldns_rdf **dname, const uint8_t *wire, size_t max, size_t *pos)
| converts the data on the uint8_t bytearray (in wire format) to a DNS dname rdata field. More...
ldns_status | ldns_wire2rdf (ldns_rr *rr, const uint8_t *wire, size_t max, size_t *pos)
| converts the data on the uint8_t bytearray (in wire format) to DNS rdata fields, and adds them to the list of rdfs of the given rr. More...
ldns_status | ldns_wire2rr (ldns_rr **rr_p, const uint8_t *wire, size_t max, size_t *pos, ldns_pkt_section section)
| converts the data on the uint8_t bytearray (in wire format) to a DNS resource record. More...
ldns_status | ldns_buffer2pkt_wire (ldns_pkt **packet, ldns_buffer *buffer)
| converts the data on the uint8_t bytearray (in wire format) to a DNS packet. More...
ldns_status | ldns_wire2pkt (ldns_pkt **packet_p, const uint8_t *wire, size_t max)
| converts the data on the uint8_t bytearray (in wire format) to a DNS packet. More...

## Macro Definition Documentation

#define LDNS_STATUS_CHECK_RETURN | ( |  | st | ) | {if (st != LDNS_STATUS_OK) { return st; }}

Definition at line 154 of file wire2host.c.

#define LDNS_STATUS_CHECK_GOTO | ( |  | st,
|  |  | label
| ) |  | {if (st != LDNS_STATUS_OK) { /*printf("STG %s:%d: status code %d\n", __FILE__, __LINE__, st);*/ goto label; }}

Definition at line 155 of file wire2host.c.

## Function Documentation

ldns_status ldns_wire2dname | ( | ldns_rdf ** | dname,
|  | const uint8_t * | wire,
|  | size_t | max,
|  | size_t * | pos
| ) |  |

converts the data on the uint8_t bytearray (in wire format) to a DNS dname rdata field.

This function will initialize and allocate memory space for the dname structure. The length of the wiredata of this rdf is added to the *pos value.

Parameters

  [in] | dname | pointer to the structure to hold the rdata value
  [in] | wire | pointer to the buffer with the data
  [in] | max | the length of the data buffer (in bytes)
  [in] | pos | the position of the rdf in the buffer (ie. the number of bytes from the start of the buffer)

Returns
  LDNS_STATUS_OK if everything succeeds, error otherwise

Definition at line 56 of file wire2host.c.

References LDNS_MAX_DOMAINLEN, LDNS_MAX_LABELLEN, LDNS_MAX_POINTERS, ldns_rdf_new_frm_data(), LDNS_RDF_TYPE_DNAME, LDNS_STATUS_DOMAINNAME_OVERFLOW, LDNS_STATUS_INVALID_POINTER, LDNS_STATUS_LABEL_OVERFLOW, LDNS_STATUS_MEM_ERR, LDNS_STATUS_OK, LDNS_STATUS_PACKET_OVERFLOW, and LDNS_STATUS_WIRE_RDATA_ERR.

ldns_status ldns_wire2rdf | ( | ldns_rr * | rr,
|  | const uint8_t * | wire,
|  | size_t | max,
|  | size_t * | pos
| ) |  |

converts the data on the uint8_t bytearray (in wire format) to DNS rdata fields, and adds them to the list of rdfs of the given rr.

This function will initialize and allocate memory space for the dname structures. The length of the wiredata of these rdfs is added to the *pos value.

All rdfs belonging to the RR are read; the rr should have no rdfs yet. An error is returned if the format cannot be parsed.

Parameters

  [in] | rr | pointer to the ldns_rr structure to hold the rdata value
  [in] | wire | pointer to the buffer with the data
  [in] | max | the length of the data buffer (in bytes)
  [in] | pos | the position of the rdf in the buffer (ie. the number of bytes from the start of the buffer)

Returns
  LDNS_STATUS_OK if everything succeeds, error otherwise

Definition at line 158 of file wire2host.c.

References ldns_rdf_new(), LDNS_RDF_SIZE_16BYTES, LDNS_RDF_SIZE_6BYTES, LDNS_RDF_SIZE_8BYTES, LDNS_RDF_SIZE_BYTE, LDNS_RDF_SIZE_DOUBLEWORD, LDNS_RDF_SIZE_WORD, LDNS_RDF_TYPE_A, LDNS_RDF_TYPE_AAAA, LDNS_RDF_TYPE_ALG, LDNS_RDF_TYPE_APL, LDNS_RDF_TYPE_ATMA, LDNS_RDF_TYPE_B32_EXT, LDNS_RDF_TYPE_B64, LDNS_RDF_TYPE_CERT_ALG, LDNS_RDF_TYPE_CLASS, LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_EUI48, LDNS_RDF_TYPE_EUI64, LDNS_RDF_TYPE_HEX, LDNS_RDF_TYPE_HIP, LDNS_RDF_TYPE_ILNP64, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT16_DATA, LDNS_RDF_TYPE_INT32, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_IPSECKEY, LDNS_RDF_TYPE_LOC, LDNS_RDF_TYPE_LONG_STR, LDNS_RDF_TYPE_NONE, LDNS_RDF_TYPE_NSAP, LDNS_RDF_TYPE_NSEC, LDNS_RDF_TYPE_NSEC3_NEXT_OWNER, LDNS_RDF_TYPE_NSEC3_SALT, LDNS_RDF_TYPE_PERIOD, LDNS_RDF_TYPE_SERVICE, LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_TAG, LDNS_RDF_TYPE_TIME, LDNS_RDF_TYPE_TSIGTIME, LDNS_RDF_TYPE_TYPE, LDNS_RDF_TYPE_UNKNOWN, LDNS_RDF_TYPE_WKS, ldns_rr_descript(), ldns_rr_descriptor_field_type(), ldns_rr_descriptor_maximum(), ldns_rr_get_type(), ldns_rr_push_rdf(), LDNS_STATUS_CHECK_RETURN, LDNS_STATUS_MEM_ERR, LDNS_STATUS_OK, LDNS_STATUS_PACKET_OVERFLOW, ldns_wire2dname(), and LDNS_XMALLOC.

ldns_status ldns_wire2rr | ( | ldns_rr ** | rr,
|  | const uint8_t * | wire,
|  | size_t | max,
|  | size_t * | pos,
|  | ldns_pkt_section | section
| ) |  |

converts the data on the uint8_t bytearray (in wire format) to a DNS resource record.

This function will initialize and allocate memory space for the rr structure. The length of the wiredata of this rr is added to the *pos value.

Parameters

  [in] | rr | pointer to the structure to hold the rdata value
  [in] | wire | pointer to the buffer with the data
  [in] | max | the length of the data buffer (in bytes)
  [in] | pos | the position of the rr in the buffer (ie. the number of bytes from the start of the buffer)
  [in] | section | the section in the packet the rr is meant for

Returns
  LDNS_STATUS_OK if everything succeeds, error otherwise

Definition at line 316 of file wire2host.c.

References LDNS_AA_WIRE, LDNS_AD_WIRE, LDNS_ANCOUNT, LDNS_ARCOUNT, LDNS_CD_WIRE, LDNS_HEADER_SIZE, LDNS_ID_WIRE, LDNS_NSCOUNT, LDNS_OPCODE_WIRE, ldns_pkt_set_aa(), ldns_pkt_set_ad(), ldns_pkt_set_ancount(), ldns_pkt_set_arcount(), ldns_pkt_set_cd(), ldns_pkt_set_id(), ldns_pkt_set_nscount(), ldns_pkt_set_opcode(), ldns_pkt_set_qdcount(), ldns_pkt_set_qr(), ldns_pkt_set_ra(), ldns_pkt_set_rcode(), ldns_pkt_set_rd(), ldns_pkt_set_tc(), LDNS_QDCOUNT, LDNS_QR_WIRE, LDNS_RA_WIRE, LDNS_RCODE_WIRE, LDNS_RD_WIRE, ldns_rr_free(), ldns_rr_new(), ldns_rr_set_class(), ldns_rr_set_owner(), ldns_rr_set_question(), ldns_rr_set_ttl(), ldns_rr_set_type(), LDNS_SECTION_QUESTION, LDNS_STATUS_CHECK_GOTO, LDNS_STATUS_OK, LDNS_STATUS_PACKET_OVERFLOW, LDNS_STATUS_WIRE_INCOMPLETE_HEADER, LDNS_TC_WIRE, ldns_wire2dname(), and ldns_wire2rdf().

ldns_status ldns_buffer2pkt_wire | ( | ldns_pkt ** | packet,
|  | ldns_buffer * | buffer
| ) |  |

converts the data on the uint8_t bytearray (in wire format) to a DNS packet.

This function will initialize and allocate memory space for the packet structure.

Parameters

  [in] | packet | pointer to the structure to hold the packet
  [in] | buffer | the buffer with the data

Returns
  LDNS_STATUS_OK if everything succeeds, error otherwise

Definition at line 392 of file wire2host.c.

References ldns_wire2pkt().

ldns_status ldns_wire2pkt | ( | ldns_pkt ** | packet,
|  | const uint8_t * | data,
|  | size_t | len
| ) |  |

converts the data on the uint8_t bytearray (in wire format) to a DNS packet.

This function will initialize and allocate memory space for the packet structure.

Parameters

  [in] | packet | pointer to the structure to hold the packet
  [in] | data | pointer to the buffer with the data
  [in] | len | the length of the data buffer (in bytes)

Returns
  LDNS_STATUS_OK if everything succeeds, error otherwise

Definition at line 401 of file wire2host.c.

References ldns_pkt_additional(), ldns_pkt_ancount(), ldns_pkt_answer(), ldns_pkt_arcount(), ldns_pkt_authority(), ldns_pkt_free(), ldns_pkt_new(), ldns_pkt_nscount(), ldns_pkt_qdcount(), ldns_pkt_question(), ldns_pkt_set_arcount(), ldns_pkt_set_edns_data(), ldns_pkt_set_edns_extended_rcode(), ldns_pkt_set_edns_udp_size(), ldns_pkt_set_edns_version(), ldns_pkt_set_edns_z(), ldns_pkt_set_size(), ldns_pkt_set_tsig(), ldns_rdf_clone(), ldns_rr_free(), ldns_rr_get_class(), ldns_rr_get_type(), ldns_rr_list_push_rr(), ldns_rr_rdf(), ldns_rr_ttl(), LDNS_RR_TYPE_OPT, LDNS_RR_TYPE_TSIG, LDNS_SECTION_ADDITIONAL, LDNS_SECTION_ANSWER, LDNS_SECTION_AUTHORITY, LDNS_SECTION_QUESTION, LDNS_STATUS_CHECK_GOTO, LDNS_STATUS_INTERNAL_ERR, LDNS_STATUS_OK, LDNS_STATUS_PACKET_OVERFLOW, LDNS_STATUS_WIRE_INCOMPLETE_ADDITIONAL, LDNS_STATUS_WIRE_INCOMPLETE_ANSWER, LDNS_STATUS_WIRE_INCOMPLETE_AUTHORITY, LDNS_STATUS_WIRE_INCOMPLETE_QUESTION, and ldns_wire2rr().