strongswan/src/libcharon/encoding/generator.h

84 lines
2.4 KiB
C
Raw Normal View History

2005-11-08 16:19:06 +00:00
/*
2009-05-18 12:06:48 +00:00
* Copyright (C) 2005-2009 Martin Willi
2006-07-07 08:49:06 +00:00
* Copyright (C) 2005 Jan Hutter
2005-11-08 16:19:06 +00:00
* 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.
*/
/**
* @defgroup generator generator
* @{ @ingroup encoding
2005-11-08 16:19:06 +00:00
*/
#ifndef GENERATOR_H_
#define GENERATOR_H_
typedef struct generator_t generator_t;
#include <library.h>
2005-11-23 09:57:18 +00:00
#include <encoding/payloads/encodings.h>
#include <encoding/payloads/payload.h>
2005-11-08 16:19:06 +00:00
/**
* A generator_t class used to generate IKEv2 payloads.
*
2005-12-06 13:44:22 +00:00
* After creation, multiple payloads can be generated with the generate_payload
* method. The generated bytes are appended. After all payloads are added,
2005-12-06 13:44:22 +00:00
* the write_to_chunk method writes out all generated data since
* the creation of the generator.
2005-12-06 13:44:22 +00:00
* The generater uses a set of encoding rules, which it can get from
* the supplied payload. With this rules, the generater can generate
* the payload and all substructures automatically.
2005-11-08 16:19:06 +00:00
*/
2005-11-24 09:17:51 +00:00
struct generator_t {
/**
* Generates a specific payload from given payload object.
*
* @param payload interface payload_t implementing object
2005-11-08 16:19:06 +00:00
*/
void (*generate_payload) (generator_t *this,payload_t *payload);
/**
* Return a chunk for the currently generated data.
*
* The returned length pointer must be filled in with the length of
* the generated chunk (in network order).
*
* @param lenpos receives a pointer to fill in length value
* @param return chunk to internal buffer.
*/
2016-03-22 12:22:01 +00:00
chunk_t (*get_chunk) (generator_t *this, uint32_t **lenpos);
2005-11-08 16:19:06 +00:00
/**
* Destroys a generator_t object.
2005-11-08 16:19:06 +00:00
*/
void (*destroy) (generator_t *this);
2005-11-08 16:19:06 +00:00
};
2005-11-09 08:40:33 +00:00
/**
* Constructor to create a generator.
*
2005-12-06 13:44:22 +00:00
* @return generator_t object.
2005-11-09 08:40:33 +00:00
*/
generator_t *generator_create(void);
2005-11-08 16:19:06 +00:00
/**
* Constructor to create a generator that does not log any debug messages > 1.
*
* @return generator_t object.
*/
generator_t *generator_create_no_dbg(void);
#endif /** GENERATOR_H_ @}*/