/build/ldns-eVLWSH/ldns-1.8.4/zone.c File Reference

Go to the source code of this file.

## Functions

ldns_rr * | ldns_zone_soa (const ldns_zone *z)
| Return the soa record of a zone.
size_t | ldns_zone_rr_count (const ldns_zone *z)
| Returns the number of resource records in the zone, NOT counting the SOA record.
void | ldns_zone_set_soa (ldns_zone *z, ldns_rr *soa)
| Set the zone's soa record.
ldns_rr_list * | ldns_zone_rrs (const ldns_zone *z)
| Get a list of a zone's content.
void | ldns_zone_set_rrs (ldns_zone *z, ldns_rr_list *rrlist)
| Set the zone's contents.
signed char | ldns_zone_push_rr_list (ldns_zone *z, const ldns_rr_list *list)
| push an rrlist to a zone structure.
signed char | ldns_zone_push_rr (ldns_zone *z, ldns_rr *rr)
| push an single rr to a zone structure.
ldns_rr_list * | ldns_zone_glue_rr_list (const ldns_zone *z)
| Retrieve all resource records from the zone that are glue records.
ldns_zone * | ldns_zone_new (void)
| create a new ldns_zone structure
ldns_status | ldns_zone_new_frm_fp (ldns_zone **z, FILE *fp, const ldns_rdf *origin, uint32_t ttl, ldns_rr_class c)
| Create a new zone from a file.
ldns_status | _ldns_rr_new_frm_fp_l_internal (ldns_rr **newrr, FILE *fp, uint32_t *default_ttl, ldns_rdf **origin, ldns_rdf **prev, int *line_nr, signed char *explicit_ttl)
ldns_status | ldns_zone_new_frm_fp_l (ldns_zone **z, FILE *fp, const ldns_rdf *origin, uint32_t default_ttl, ldns_rr_class c __attribute__((unused)), int *line_nr)
void | ldns_zone_sort (ldns_zone *zone)
| Sort the rrs in a zone, with the current impl.
void | ldns_zone_free (ldns_zone *zone)
| Frees the allocated memory for the zone, and the rr_list structure in it.
void | ldns_zone_deep_free (ldns_zone *zone)
| Frees the allocated memory for the zone, the soa rr in it, and the rr_list structure in it, including the rr's in that.

## Function Documentation

## ldns_zone_soa()

ldns_rr * ldns_zone_soa | ( | const ldns_zone * | z | ) |

Return the soa record of a zone.

Parameters

  [in] | z | the zone to read from

Returns
  the soa record in the zone

Definition at line 17 of file zone.c.

References ldns_struct_zone::_soa.

## ldns_zone_rr_count()

size_t ldns_zone_rr_count | ( | const ldns_zone * | z | ) |

Returns the number of resource records in the zone, NOT counting the SOA record.

Parameters

  [in] | z | the zone to read from

Returns
  the number of rr's in the zone

Definition at line 23 of file zone.c.

References ldns_struct_zone::_rrs, and ldns_rr_list_rr_count().

## ldns_zone_set_soa()

void ldns_zone_set_soa | ( | ldns_zone * | z,
|  | ldns_rr * | soa )

Set the zone's soa record.

Parameters

  [in] | z | the zone to put the new soa in
  [in] | soa | the soa to set

Definition at line 29 of file zone.c.

References ldns_struct_zone::_soa.

## ldns_zone_rrs()

ldns_rr_list * ldns_zone_rrs | ( | const ldns_zone * | z | ) |

Get a list of a zone's content.

Note that the SOA isn't included in this list. You need to get the with ldns_zone_soa.

Parameters

  [in] | z | the zone to read from

Returns
  the rrs from this zone

Definition at line 35 of file zone.c.

References ldns_struct_zone::_rrs.

## ldns_zone_set_rrs()

void ldns_zone_set_rrs | ( | ldns_zone * | z,
|  | ldns_rr_list * | rrlist )

Set the zone's contents.

Parameters

  [in] | z | the zone to put the new soa in
  [in] | rrlist | the rrlist to use

Definition at line 41 of file zone.c.

References ldns_struct_zone::_rrs.

## ldns_zone_push_rr_list()

signed char ldns_zone_push_rr_list | ( | ldns_zone * | z,
|  | const ldns_rr_list * | list )

push an rrlist to a zone structure.

This function use pointer copying, so the rr_list structure inside z is modified!

Parameters

  [in] | z | the zone to add to
  [in] | list | the list to add

Returns
  a true on success otherwise false

Definition at line 47 of file zone.c.

References ldns_rr_list_cat(), and ldns_zone_rrs().

## ldns_zone_push_rr()

signed char ldns_zone_push_rr | ( | ldns_zone * | z,
|  | ldns_rr * | rr )

push an single rr to a zone structure.

This function use pointer copying, so the rr_list structure inside z is modified!

Parameters

  [in] | z | the zone to add to
  [in] | rr | the rr to add

Returns
  a true on success otherwise false

Definition at line 53 of file zone.c.

References ldns_rr_list_push_rr(), and ldns_zone_rrs().

## ldns_zone_glue_rr_list()

ldns_rr_list * ldns_zone_glue_rr_list | ( | const ldns_zone * | z | ) |

Retrieve all resource records from the zone that are glue records.

The resulting list does are pointer references to the zone's data.

Due to the current zone implementation (as a list of rr's), this function is extremely slow. Another (probably better) way to do this is to use an ldns_dnssec_zone structure and the ldns_dnssec_mark_and_get_glue() function.

Parameters

  [in] | z | the zone to look for glue

Returns
  the rr_list with the glue

Definition at line 65 of file zone.c.

References ldns_dname_compare(), ldns_dname_is_subdomain(), LDNS_FREE, ldns_rdf_compare(), ldns_rr_get_type(), ldns_rr_list_free(), ldns_rr_list_new(), ldns_rr_list_push_rr(), ldns_rr_list_rr(), ldns_rr_list_rr_count(), ldns_rr_owner(), LDNS_RR_TYPE_A, LDNS_RR_TYPE_AAAA, LDNS_RR_TYPE_NS, ldns_zone_rr_count(), ldns_zone_rrs(), and ldns_zone_soa().

## ldns_zone_new()

ldns_zone * ldns_zone_new | ( | void |  | ) |

create a new ldns_zone structure

Returns
  a pointer to a ldns_zone structure

Definition at line 165 of file zone.c.

References ldns_struct_zone::_rrs, LDNS_FREE, LDNS_MALLOC, ldns_rr_list_new(), and ldns_zone_set_soa().

## ldns_zone_new_frm_fp()

ldns_status ldns_zone_new_frm_fp | ( | ldns_zone ** | z,
|  | FILE * | fp,
|  | const ldns_rdf * | origin,
|  | uint32_t | ttl,
|  | ldns_rr_class | c )

Create a new zone from a file.

Parameters

  [out] | z | the new zone
  [in] | *fp | the filepointer to use
  [in] | *origin | the zones' origin
  [in] | ttl | default ttl to use
  [in] | c | default class to use (IN)

Returns
  ldns_status mesg with an error or LDNS_STATUS_OK

Definition at line 187 of file zone.c.

References ldns_zone_new_frm_fp_l().

## _ldns_rr_new_frm_fp_l_internal()

ldns_status _ldns_rr_new_frm_fp_l_internal | ( | ldns_rr ** | newrr,
|  | FILE * | fp,
|  | uint32_t * | default_ttl,
|  | ldns_rdf ** | origin,
|  | ldns_rdf ** | prev,
|  | int * | line_nr,
|  | signed char * | explicit_ttl )

Definition at line 729 of file rr.c.

References ldns_fget_token_l_st(), LDNS_FREE, LDNS_PARSE_SKIP_SPACE, ldns_rdf_deep_free(), ldns_rdf_new_frm_str(), LDNS_RDF_TYPE_DNAME, ldns_rr_free(), LDNS_STATUS_OK, LDNS_STATUS_SYNTAX_DNAME_ERR, LDNS_STATUS_SYNTAX_EMPTY, LDNS_STATUS_SYNTAX_INCLUDE, LDNS_STATUS_SYNTAX_ORIGIN, LDNS_STATUS_SYNTAX_TTL, and ldns_str2period().

## ldns_zone_new_frm_fp_l()

ldns_status ldns_zone_new_frm_fp_l | ( | ldns_zone ** | z,
|  | FILE * | fp,
|  | const ldns_rdf * | origin,
|  | uint32_t | default_ttl,
|  | ldns_rr_class c | __attribute__(unused),
|  | int * | line_nr )

Definition at line 198 of file zone.c.

References _ldns_rr_new_frm_fp_l_internal(), ldns_dname_compare(), ldns_rdf2native_int32(), ldns_rdf_clone(), ldns_rdf_deep_free(), ldns_rdf_get_type(), LDNS_RDF_TYPE_INT32, ldns_rr_free(), ldns_rr_get_type(), ldns_rr_owner(), ldns_rr_rd_count(), ldns_rr_rdf(), ldns_rr_set_ttl(), ldns_rr_ttl(), LDNS_RR_TYPE_RRSIG, LDNS_RR_TYPE_SIG, LDNS_RR_TYPE_SOA, LDNS_STATUS_MEM_ERR, LDNS_STATUS_OK, LDNS_STATUS_SYNTAX_EMPTY, LDNS_STATUS_SYNTAX_INCLUDE, LDNS_STATUS_SYNTAX_INCLUDE_ERR_NOTIMPL, LDNS_STATUS_SYNTAX_ORIGIN, LDNS_STATUS_SYNTAX_TTL, ldns_zone_free(), ldns_zone_new(), ldns_zone_push_rr(), and ldns_zone_set_soa().

## ldns_zone_sort()

void ldns_zone_sort | ( | ldns_zone * | zone | ) |

Sort the rrs in a zone, with the current impl.

this is slow

Parameters

  [in] | zone | the zone to sort

Definition at line 359 of file zone.c.

References ldns_rr_list_sort(), and ldns_zone_rrs().

## ldns_zone_free()

void ldns_zone_free | ( | ldns_zone * | zone | ) |

Frees the allocated memory for the zone, and the rr_list structure in it.

Parameters

  [in] | zone | the zone to free

Definition at line 369 of file zone.c.

References ldns_struct_zone::_rrs, LDNS_FREE, and ldns_rr_list_free().

## ldns_zone_deep_free()

void ldns_zone_deep_free | ( | ldns_zone * | zone | ) |

Frees the allocated memory for the zone, the soa rr in it, and the rr_list structure in it, including the rr's in that.

etc.

Parameters

  [in] | zone | the zone to free

Definition at line 376 of file zone.c.

References ldns_struct_zone::_rrs, ldns_struct_zone::_soa, LDNS_FREE, ldns_rr_free(), and ldns_rr_list_deep_free().