2005-11-08 16:19:06 +00:00
|
|
|
/**
|
|
|
|
* @file generator.h
|
2005-11-10 09:35:28 +00:00
|
|
|
*
|
2005-11-10 09:31:07 +00:00
|
|
|
* @brief Generic generator class used to generate IKEv2-header and payloads.
|
2005-11-10 09:35:28 +00:00
|
|
|
*
|
2005-11-08 16:19:06 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2005 Jan Hutter, Martin Willi
|
|
|
|
* Hochschule fuer Technik Rapperswil
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GENERATOR_H_
|
|
|
|
#define GENERATOR_H_
|
|
|
|
|
2005-11-23 09:24:35 +00:00
|
|
|
#include <types.h>
|
|
|
|
#include <payloads/encodings.h>
|
|
|
|
#include <payloads/payload.h>
|
2005-11-08 16:19:06 +00:00
|
|
|
|
2005-11-09 08:40:33 +00:00
|
|
|
/**
|
2005-11-10 09:31:07 +00:00
|
|
|
* Generating is done in a data buffer.
|
|
|
|
* This is thehe start size of this buffer in Bytes.
|
2005-11-09 08:40:33 +00:00
|
|
|
*/
|
2005-11-17 13:47:49 +00:00
|
|
|
#define GENERATOR_DATA_BUFFER_SIZE 500
|
2005-11-09 08:40:33 +00:00
|
|
|
|
2005-11-09 13:34:36 +00:00
|
|
|
/**
|
2005-11-10 09:31:07 +00:00
|
|
|
* Number of bytes to increase the buffer, if it is to small.
|
2005-11-09 13:34:36 +00:00
|
|
|
*/
|
2005-11-17 13:47:49 +00:00
|
|
|
#define GENERATOR_DATA_BUFFER_INCREASE_VALUE 500
|
2005-11-09 13:34:36 +00:00
|
|
|
|
2005-11-08 16:19:06 +00:00
|
|
|
/**
|
2005-11-10 09:54:09 +00:00
|
|
|
*A generator_t object which generates payloads of specific type.
|
2005-11-08 16:19:06 +00:00
|
|
|
*/
|
|
|
|
typedef struct generator_s generator_t;
|
|
|
|
|
2005-11-10 09:35:28 +00:00
|
|
|
struct generator_s {
|
2005-11-10 17:17:46 +00:00
|
|
|
|
|
|
|
/**
|
2005-11-14 08:12:59 +00:00
|
|
|
* @brief Generates a specific payload from given payload object.
|
2005-11-10 09:35:28 +00:00
|
|
|
*
|
2005-11-10 09:54:09 +00:00
|
|
|
* Remember: Header and substructures are also handled as payloads.
|
2005-11-10 09:35:28 +00:00
|
|
|
*
|
2005-11-14 08:12:59 +00:00
|
|
|
* @param this generator_t object
|
|
|
|
* @param[in] payload interface payload_t implementing object
|
2005-11-10 09:54:09 +00:00
|
|
|
* @return
|
|
|
|
* - SUCCESSFUL if succeeded
|
|
|
|
* - OUT_OF_RES if out of ressources
|
2005-11-08 16:19:06 +00:00
|
|
|
*/
|
2005-11-14 08:12:59 +00:00
|
|
|
status_t (*generate_payload) (generator_t *this,payload_t *payload);
|
2005-11-10 17:17:46 +00:00
|
|
|
|
|
|
|
/**
|
2005-11-14 08:12:59 +00:00
|
|
|
* Writes all generated data of current generator context to a chunk
|
2005-11-10 17:17:46 +00:00
|
|
|
*
|
|
|
|
* @param this generator_t object
|
|
|
|
* * @param[out] data chunk to write the data to
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
* - SUCCESSFUL if succeeded
|
|
|
|
* - OUT_OF_RES otherwise
|
|
|
|
*/
|
2005-11-14 08:12:59 +00:00
|
|
|
status_t (*write_to_chunk) (generator_t *this,chunk_t *data);
|
2005-11-08 16:19:06 +00:00
|
|
|
|
|
|
|
/**
|
2005-11-10 09:54:09 +00:00
|
|
|
* @brief Destroys a generator_t object.
|
2005-11-10 09:35:28 +00:00
|
|
|
*
|
2005-11-10 17:17:46 +00:00
|
|
|
* @param this generator_t object
|
2005-11-10 09:54:09 +00:00
|
|
|
*
|
|
|
|
* @return always success
|
2005-11-08 16:19:06 +00:00
|
|
|
*/
|
|
|
|
status_t (*destroy) (generator_t *this);
|
|
|
|
};
|
|
|
|
|
2005-11-09 08:40:33 +00:00
|
|
|
/**
|
|
|
|
* Constructor to create a generator
|
2005-11-10 09:35:28 +00:00
|
|
|
*
|
2005-11-09 08:40:33 +00:00
|
|
|
*/
|
2005-11-14 06:55:51 +00:00
|
|
|
generator_t * generator_create();
|
2005-11-08 16:19:06 +00:00
|
|
|
|
|
|
|
#endif /*GENERATOR_H_*/
|