2012-12-12 17:16:58 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 Tobias Brunner
|
2018-05-23 14:04:50 +00:00
|
|
|
* HSR Hochschule fuer Technik Rapperswil
|
2012-12-12 17:16:58 +00:00
|
|
|
*
|
|
|
|
* 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 fragment_payload fragment_payload
|
|
|
|
* @{ @ingroup payloads
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FRAGMENT_PAYLOAD_H_
|
|
|
|
#define FRAGMENT_PAYLOAD_H_
|
|
|
|
|
|
|
|
typedef struct fragment_payload_t fragment_payload_t;
|
|
|
|
|
|
|
|
#include <library.h>
|
|
|
|
#include <encoding/payloads/payload.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Object representing an IKEv1 fragment payload.
|
|
|
|
*/
|
|
|
|
struct fragment_payload_t {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The payload_t interface.
|
|
|
|
*/
|
|
|
|
payload_t payload_interface;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the fragment ID. Identifies the fragments for a particular IKE
|
|
|
|
* message.
|
|
|
|
*
|
|
|
|
* @return fragment ID
|
|
|
|
*/
|
2016-03-22 12:22:01 +00:00
|
|
|
uint16_t (*get_id)(fragment_payload_t *this);
|
2012-12-12 17:16:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the fragment number. Defines the order of the fragments.
|
|
|
|
*
|
|
|
|
* @return fragment number
|
|
|
|
*/
|
2016-03-22 12:22:01 +00:00
|
|
|
uint8_t (*get_number)(fragment_payload_t *this);
|
2012-12-12 17:16:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if this is the last fragment.
|
|
|
|
*
|
|
|
|
* @return TRUE if this is the last fragment
|
|
|
|
*/
|
|
|
|
bool (*is_last)(fragment_payload_t *this);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the fragment data.
|
|
|
|
*
|
2020-02-05 04:30:52 +00:00
|
|
|
* @return chunk to internal fragment data
|
2012-12-12 17:16:58 +00:00
|
|
|
*/
|
|
|
|
chunk_t (*get_data)(fragment_payload_t *this);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroys an fragment_payload_t object.
|
|
|
|
*/
|
|
|
|
void (*destroy)(fragment_payload_t *this);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates an empty fragment_payload_t object.
|
|
|
|
*
|
|
|
|
* @return fragment_payload_t object
|
|
|
|
*/
|
|
|
|
fragment_payload_t *fragment_payload_create();
|
|
|
|
|
2012-12-20 15:04:38 +00:00
|
|
|
/**
|
|
|
|
* Creates a fragment payload from the given data. All fragments currently
|
|
|
|
* have the same fragment ID (1), which seems what other implementations are
|
|
|
|
* doing.
|
|
|
|
*
|
|
|
|
* @param num fragment number (first one should be 1)
|
|
|
|
* @param last TRUE to indicate that this is the last fragment
|
|
|
|
* @param data fragment data (gets cloned)
|
|
|
|
* @return fragment_payload_t object
|
|
|
|
*/
|
2016-03-22 12:22:01 +00:00
|
|
|
fragment_payload_t *fragment_payload_create_from_data(uint8_t num, bool last,
|
2012-12-20 15:04:38 +00:00
|
|
|
chunk_t data);
|
|
|
|
|
2012-12-12 17:16:58 +00:00
|
|
|
#endif /** FRAGMENT_PAYLOAD_H_ @}*/
|