query.h File Reference
`#include "config.h"`
`#include "status.h"`
`#include "signer/zone.h"`
`#include "wire/buffer.h"`
`#include "wire/edns.h"`
`#include "wire/tsig.h"`

Go to the source code of this file.

## Data Structures

struct | query_struct
struct | response_struct

## Macros

#define | UDP_MAX_MESSAGE_LEN 512
#define | TCP_MAX_MESSAGE_LEN 65535
#define | QUERY_RESPONSE_MAX_RRSET 10 /* should be enough */

## Typedefs

typedef enum query_enum | query_state
typedef struct query_struct | query_type
typedef struct response_struct | response_type

## Enumerations

enum | query_enum { QUERY_PROCESSED = 0 , QUERY_DISCARDED , QUERY_AXFR , QUERY_IXFR }

## Functions

query_type * | query_create (void)
void | query_prepare (query_type *q)
query_state | query_process (query_type *q, engine_type *engine)
void | query_reset (query_type *q, size_t maxlen, int is_tcp)
void | query_add_optional (query_type *q, engine_type *engine)
int | query_add_rr (query_type *q, ldns_rr *rr)
void | query_cleanup (query_type *q)

## Macro Definition Documentation

## QUERY_RESPONSE_MAX_RRSET

#define QUERY_RESPONSE_MAX_RRSET 10 /* should be enough */

Definition at line 44 of file query.h.

## TCP_MAX_MESSAGE_LEN

#define TCP_MAX_MESSAGE_LEN 65535

Definition at line 43 of file query.h.

Referenced by sock_handle_tcp_read().

## UDP_MAX_MESSAGE_LEN

#define UDP_MAX_MESSAGE_LEN 512

Query.

Definition at line 42 of file query.h.

Referenced by query_create(), and sock_handle_udp().

## Typedef Documentation

## query_state

typedef enum query_enum query_state

Definition at line 52 of file query.h.

## query_type

typedef struct query_struct query_type

Query.

Definition at line 58 of file query.h.

## response_type

typedef struct response_struct response_type

Response.

Definition at line 95 of file query.h.

## Enumeration Type Documentation

## query_enum

enum query_enum

Enumerator
QUERY_PROCESSED |
QUERY_DISCARDED |
QUERY_AXFR |
QUERY_IXFR |

Definition at line 46 of file query.h.

## Function Documentation

## query_add_optional()

void query_add_optional | ( | query_type * | q,
|  | engine_type * | engine )

extern

Add optional RRs to query.

Parameters

  [in] | q | query
  [in] | engine | signer engine

Add optional RRs to query.

First EDNS

Then TSIG

Definition at line 962 of file query.c.

References query_struct::buffer, buffer_pkt_arcount(), buffer_pkt_set_arcount(), buffer_position(), buffer_write(), edns_rr_struct::dnssec_ok, EDNS_ERROR, EDNS_NOT_PRESENT, EDNS_OK, query_struct::edns_rr, edns_data_struct::error, tsig_rr_struct::error_code, edns_data_struct::ok, OPT_LEN, OPT_RDATA, query_str, edns_data_struct::rdata_none, edns_rr_struct::status, tsig_rr_struct::status, TSIG_ERROR, TSIG_NOT_PRESENT, TSIG_OK, query_struct::tsig_prepare_it, query_struct::tsig_rr, tsig_rr_append(), tsig_rr_error(), tsig_rr_prepare(), tsig_rr_sign(), tsig_rr_update(), query_struct::tsig_sign_it, and query_struct::tsig_update_it.

Referenced by sock_handle_tcp_read(), sock_handle_tcp_write(), and sock_handle_udp().

## query_add_rr()

int query_add_rr | ( | query_type * | q,
|  | ldns_rr * | rr )

extern

Add RR to query.

Parameters

  [in] | q | query
  [in] | rr | RR

Returns
  int 1 if ok, 0 if overflow.

Add RR to query.

Definition at line 1041 of file query.c.

References query_struct::buffer, buffer_available(), buffer_position(), buffer_set_position(), buffer_skip(), buffer_write_rdf(), buffer_write_u16(), buffer_write_u16_at(), and buffer_write_u32().

Referenced by axfr(), ixfr(), and soa_request().

## query_cleanup()

void query_cleanup | ( | query_type * | q | ) |

extern

Cleanup query.

Parameters

  [in] | q | query

Cleanup query.

Definition at line 1098 of file query.c.

References query_struct::axfr_fd, query_struct::buffer, buffer_cleanup(), query_struct::edns_rr, edns_rr_cleanup(), query_struct::tsig_rr, and tsig_rr_cleanup().

Referenced by dnshandler_cleanup(), query_create(), and sock_handle_tcp_accept().

## query_create()

query_type * query_create | ( | void |  | ) |

extern

Create query.

Returns
  query_type* query

Create query.

Definition at line 48 of file query.c.

References query_struct::axfr_fd, query_struct::buffer, buffer_create(), query_struct::edns_rr, edns_rr_create(), PACKET_BUFFER_SIZE, query_cleanup(), query_reset(), query_struct::tsig_rr, tsig_rr_create(), and UDP_MAX_MESSAGE_LEN.

Referenced by dnshandler_create(), and sock_handle_tcp_accept().

## query_prepare()

void query_prepare | ( | query_type * | q | ) |

extern

Prepare response.

Parameters

  [in] | q | query

Prepare response.

Definition at line 612 of file query.c.

References query_struct::buffer, buffer_capacity(), buffer_clear(), buffer_limit(), buffer_pkt_flags(), buffer_pkt_set_flags(), buffer_set_limit(), buffer_set_position(), query_struct::edns_rr, edns_rr_reserved_space(), query_struct::reserved_space, query_struct::tsig_rr, and tsig_rr_reserved_space().

Referenced by axfr(), and ixfr().

## query_process()

query_state query_process | ( | query_type * | q,
|  | engine_type * | engine )

extern

Process query.

Parameters

  [in] | q | query
  [in] | engine | signer engine

Returns
  query_state state of the query

Process query.

Definition at line 842 of file query.c.

References query_struct::buffer, buffer_current(), buffer_limit(), BUFFER_PKT_HEADER_SIZE, buffer_pkt_qr(), buffer_remaining(), zone_struct::name, QUERY_DISCARDED, QUERY_PROCESSED, query_str, tsig_rr_struct::status, query_struct::tsig_rr, tsig_status2str(), zone_struct::zl_status, query_struct::zone, ZONE_ZL_ADDED, and zonelist_lookup_zone_by_dname().

Referenced by sock_handle_tcp_read(), and sock_handle_udp().

## query_reset()

void query_reset | ( | query_type * | q,
|  | size_t | maxlen,
|  | int | is_tcp )

extern

Reset query.

Parameters

  [in] | q | query
  [in] | maxlen | maximum message length
  [in] | is_tcp | 1 if tcp query

Reset query.

Definition at line 80 of file query.c.

References query_struct::addr, query_struct::addrlen, query_struct::axfr_fd, query_struct::axfr_is_done, query_struct::buffer, buffer_clear(), query_struct::edns_rr, edns_rr_reset(), query_struct::maxlen, query_struct::reserved_space, query_struct::serial, query_struct::startpos, query_struct::tcp, query_struct::tsig_prepare_it, query_struct::tsig_rr, tsig_rr_reset(), query_struct::tsig_sign_it, query_struct::tsig_update_it, and query_struct::zone.

Referenced by query_create(), sock_handle_tcp_read(), and sock_handle_udp().