File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / strongswan / src / libstrongswan / resolver / rr_set.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Jun 3 09:46:43 2020 UTC (4 years, 3 months ago) by misho
Branches: strongswan, MAIN
CVS tags: v5_9_2p0, v5_8_4p7, HEAD
Strongswan

    1: /*
    2:  * Copyright (C) 2012 Reto Guadagnini
    3:  * HSR Hochschule fuer Technik Rapperswil
    4:  *
    5:  * This program is free software; you can redistribute it and/or modify it
    6:  * under the terms of the GNU General Public License as published by the
    7:  * Free Software Foundation; either version 2 of the License, or (at your
    8:  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
    9:  *
   10:  * This program is distributed in the hope that it will be useful, but
   11:  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   12:  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   13:  * for more details.
   14:  */
   15: 
   16: #include "rr_set.h"
   17: 
   18: #include <library.h>
   19: #include <utils/debug.h>
   20: 
   21: typedef struct private_rr_set_t private_rr_set_t;
   22: 
   23: /**
   24: * private data of the rr_set
   25: */
   26: struct private_rr_set_t {
   27: 
   28: 	/**
   29: 	 * public functions
   30: 	 */
   31: 	rr_set_t public;
   32: 
   33: 	/**
   34: 	 * List of Resource Records which form the RRset
   35: 	 */
   36: 	linked_list_t *rr_list;
   37: 
   38: 	/**
   39: 	 * List of the signatures (RRSIGs) of the Resource Records contained in
   40: 	 * this set
   41: 	 */
   42: 	linked_list_t *rrsig_list;
   43: };
   44: 
   45: METHOD(rr_set_t, create_rr_enumerator, enumerator_t*,
   46: 	private_rr_set_t *this)
   47: {
   48: 	return this->rr_list->create_enumerator(this->rr_list);
   49: }
   50: 
   51: METHOD(rr_set_t, create_rrsig_enumerator, enumerator_t*,
   52: 	private_rr_set_t *this)
   53: {
   54: 	if (this->rrsig_list)
   55: 	{
   56: 		return this->rrsig_list->create_enumerator(this->rrsig_list);
   57: 	}
   58: 	return NULL;
   59: }
   60: 
   61: METHOD(rr_set_t, destroy, void,
   62: 	private_rr_set_t *this)
   63: {
   64: 	this->rr_list->destroy_offset(this->rr_list,
   65: 								  offsetof(rr_t, destroy));
   66: 	if (this->rrsig_list)
   67: 	{
   68: 		this->rrsig_list->destroy_offset(this->rrsig_list,
   69: 										 offsetof(rr_t, destroy));
   70: 	}
   71: 	free(this);
   72: }
   73: 
   74: /*
   75:  * see header
   76:  */
   77: rr_set_t *rr_set_create(linked_list_t *list_of_rr, linked_list_t *list_of_rrsig)
   78: {
   79: 	private_rr_set_t *this;
   80: 
   81: 	INIT(this,
   82: 		.public = {
   83: 			.create_rr_enumerator = _create_rr_enumerator,
   84: 			.create_rrsig_enumerator = _create_rrsig_enumerator,
   85: 			.destroy = _destroy,
   86: 		},
   87: 	);
   88: 
   89: 	if (list_of_rr == NULL)
   90: 	{
   91: 		DBG1(DBG_LIB, "could not create a rr_set without a list_of_rr");
   92: 		_destroy(this);
   93: 		return NULL;
   94: 	}
   95: 	this->rr_list = list_of_rr;
   96: 	this->rrsig_list = list_of_rrsig;
   97: 
   98: 	return &this->public;
   99: }
  100: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>