contrib/ldns/dnssec_sign.c
ldns_status
ldns_dnssec_zone_mark_and_get_glue(ldns_dnssec_zone *zone, 
	ldns_rr_list *glue_list)
{
	ldns_rbnode_t    *node;
	ldns_dnssec_name *name;
	ldns_rdf         *owner;
	ldns_rdf         *cut = NULL; /* keeps track of zone cuts */
	/* When the cut is caused by a delegation, below_delegation will be 1.
	 * When caused by a DNAME, below_delegation will be 0.
	 */
	int below_delegation = -1; /* init suppresses comiler warning */
	ldns_status s;

	if (!zone || !zone->names) {
		return LDNS_STATUS_NULL;
	}
	for (node = ldns_rbtree_first(zone->names); 
			node != LDNS_RBTREE_NULL; 
			node = ldns_rbtree_next(node)) {
		name = (ldns_dnssec_name *) node->data;
		owner = ldns_dnssec_name_name(name);

		if (cut) { 
			/* The previous node was a zone cut, or a subdomain
			 * below a zone cut. Is this node (still) a subdomain
			 * below the cut? Then the name is occluded. Unless
			 * the name contains a SOA, after which we are 
			 * authoritative again.
			 *
			 * FIXME! If there are labels in between the SOA and
			 * the cut, going from the authoritative space (below
			 * the SOA) up into occluded space again, will not be
			 * detected with the contruct below!
			 */
			if (ldns_dname_is_subdomain(owner, cut) &&
					!ldns_dnssec_rrsets_contains_type(
					name->rrsets, LDNS_RR_TYPE_SOA)) {

				if (below_delegation && glue_list) {
					s = ldns_dnssec_addresses_on_glue_list(
						name->rrsets, glue_list);
					if (s != LDNS_STATUS_OK) {
						return s;
					}
				}
				name->is_glue = true; /* Mark occluded name! */
				continue;
			} else {
				cut = NULL;
			}
		}

		/* The node is not below a zone cut. Is it a zone cut itself?
		 * Everything below a SOA is authoritative of course; Except
		 * when the name also contains a DNAME :).
		 */
		if (ldns_dnssec_rrsets_contains_type(
				name->rrsets, LDNS_RR_TYPE_NS)
			    && !ldns_dnssec_rrsets_contains_type(
				name->rrsets, LDNS_RR_TYPE_SOA)) {
			cut = owner;
			below_delegation = 1;
			if (glue_list) { /* record glue on the zone cut */
				s = ldns_dnssec_addresses_on_glue_list(
					name->rrsets, glue_list);
				if (s != LDNS_STATUS_OK) {
					return s;
				}
			}
		} else if (ldns_dnssec_rrsets_contains_type(
				name->rrsets, LDNS_RR_TYPE_DNAME)) {
			cut = owner;
			below_delegation = 0;
		}
	}
	return LDNS_STATUS_OK;
}
/**
 * Marks the names in the zone that are occluded. Those names will be skipped
 * when walking the tree with the ldns_dnssec_name_node_next_nonglue()
 * function. But watch out! Names that are partially occluded (like glue with
 * the same name as the delegation) will not be marked and should specifically 
 * be taken into account seperately.
 *
 * When glue_list is given (not NULL), in the process of marking the names, all
 * glue resource records will be pushed to that list, even glue at delegation names.
 *
 * \param[in] zone the zone in which to mark the names
 * \param[in] glue_list the list to which to push the glue rrs
 * \return LDNS_STATUS_OK on success, an error code otherwise
 */
Marks the names in the zone that are occluded. Those names will be skipped
when walking the tree with the ldns_dnssec_name_node_next_nonglue()
function. But watch out. Names that are partially occluded (like glue with
the same name as the delegation) will not be marked and should specifically
be taken into account seperately.

When glue_list is given (not NULL), in the process of marking the names, all
glue resource records will be pushed to that list, even glue at delegation names.

\param[in] zone the zone in which to mark the names
\param[in] glue_list the list to which to push the glue rrs
\return LDNS_STATUS_OK on success, an error code otherwise
Marks the names in the zone that are occluded . Those names will be skipped when walking the tree with the ldns_dnssec_name_node_next_nonglue () function . But watch out . Names that are partially occluded ( like glue with the same name as the delegation ) will not be marked and should specifically be taken into account seperately . When glue_list is given ( not NULL ) in the process of marking the names all glue resource records will be pushed to that list even glue at delegation names . \ param [ in ] zone the zone in which to mark the names \ param [ in ] glue_list the list to which to push the glue rrs \ return LDNS_STATUS_OK on success an error code otherwise
ldns_status
ldns_dnssec_zone_mark_and_get_glue(ldns_dnssec_zone *zone, 
	ldns_rr_list *glue_list)
{
	ldns_rbnode_t    *node;
	ldns_dnssec_name *name;
	ldns_rdf         *owner;
	ldns_rdf         *cut = NULL; 
	int below_delegation = -1; 
	ldns_status s;
	if (!zone || !zone->names) {
		return LDNS_STATUS_NULL;
	}
	for (node = ldns_rbtree_first(zone->names); 
			node != LDNS_RBTREE_NULL; 
			node = ldns_rbtree_next(node)) {
		name = (ldns_dnssec_name *) node->data;
		owner = ldns_dnssec_name_name(name);
		if (cut) { 
			if (ldns_dname_is_subdomain(owner, cut) &&
					!ldns_dnssec_rrsets_contains_type(
					name->rrsets, LDNS_RR_TYPE_SOA)) {
				if (below_delegation && glue_list) {
					s = ldns_dnssec_addresses_on_glue_list(
						name->rrsets, glue_list);
					if (s != LDNS_STATUS_OK) {
						return s;
					}
				}
				name->is_glue = true; 
				continue;
			} else {
				cut = NULL;
			}
		}
		if (ldns_dnssec_rrsets_contains_type(
				name->rrsets, LDNS_RR_TYPE_NS)
			    && !ldns_dnssec_rrsets_contains_type(
				name->rrsets, LDNS_RR_TYPE_SOA)) {
			cut = owner;
			below_delegation = 1;
			if (glue_list) { 
				s = ldns_dnssec_addresses_on_glue_list(
					name->rrsets, glue_list);
				if (s != LDNS_STATUS_OK) {
					return s;
				}
			}
		} else if (ldns_dnssec_rrsets_contains_type(
				name->rrsets, LDNS_RR_TYPE_DNAME)) {
			cut = owner;
			below_delegation = 0;
		}
	}
	return LDNS_STATUS_OK;
}
ldns_status ldns_dnssec_zone_mark_and_get_glue ( ldns_dnssec_zone * zone , ldns_rr_list * glue_list ) { ldns_rbnode_t * node ; ldns_dnssec_name * name ; ldns_rdf * owner ; ldns_rdf * cut = NULL ; int below_delegation = -1 ; ldns_status s ; if ( ! zone || ! zone -> names ) { return LDNS_STATUS_NULL ; } for ( node = ldns_rbtree_first ( zone -> names ) ; node != LDNS_RBTREE_NULL ; node = ldns_rbtree_next ( node ) ) { name = ( ldns_dnssec_name * ) node -> data ; owner = ldns_dnssec_name_name ( name ) ; if ( cut ) { if ( ldns_dname_is_subdomain ( owner , cut ) && ! ldns_dnssec_rrsets_contains_type ( name -> rrsets , LDNS_RR_TYPE_SOA ) ) { if ( below_delegation && glue_list ) { s = ldns_dnssec_addresses_on_glue_list ( name -> rrsets , glue_list ) ; if ( s != LDNS_STATUS_OK ) { return s ; } } name -> is_glue = true ; continue ; } else { cut = NULL ; } } if ( ldns_dnssec_rrsets_contains_type ( name -> rrsets , LDNS_RR_TYPE_NS ) && ! ldns_dnssec_rrsets_contains_type ( name -> rrsets , LDNS_RR_TYPE_SOA ) ) { cut = owner ; below_delegation = 1 ; if ( glue_list ) { s = ldns_dnssec_addresses_on_glue_list ( name -> rrsets , glue_list ) ; if ( s != LDNS_STATUS_OK ) { return s ; } } } else if ( ldns_dnssec_rrsets_contains_type ( name -> rrsets , LDNS_RR_TYPE_DNAME ) ) { cut = owner ; below_delegation = 0 ; } } return LDNS_STATUS_OK ; }
Marks the names in the zone that are occluded.
Marks the names in the zone that are occluded .
/* keeps track of zone cuts */ /* When the cut is caused by a delegation, below_delegation will be 1.
	 * When caused by a DNAME, below_delegation will be 0.
	 */ /* init suppresses comiler warning */ /* The previous node was a zone cut, or a subdomain
			 * below a zone cut. Is this node (still) a subdomain
			 * below the cut? Then the name is occluded. Unless
			 * the name contains a SOA, after which we are 
			 * authoritative again.
			 *
			 * FIXME! If there are labels in between the SOA and
			 * the cut, going from the authoritative space (below
			 * the SOA) up into occluded space again, will not be
			 * detected with the contruct below!
			 */ /* Mark occluded name! */ /* The node is not below a zone cut. Is it a zone cut itself?
		 * Everything below a SOA is authoritative of course; Except
		 * when the name also contains a DNAME :).
		 */ /* record glue on the zone cut */