Return to fragment_payload.h CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / strongswan / src / libcharon / encoding / payloads |
1.1 misho 1: /* 2: * Copyright (C) 2012 Tobias Brunner 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: /** 17: * @defgroup fragment_payload fragment_payload 18: * @{ @ingroup payloads 19: */ 20: 21: #ifndef FRAGMENT_PAYLOAD_H_ 22: #define FRAGMENT_PAYLOAD_H_ 23: 24: typedef struct fragment_payload_t fragment_payload_t; 25: 26: #include <library.h> 27: #include <encoding/payloads/payload.h> 28: 29: /** 30: * Object representing an IKEv1 fragment payload. 31: */ 32: struct fragment_payload_t { 33: 34: /** 35: * The payload_t interface. 36: */ 37: payload_t payload_interface; 38: 39: /** 40: * Get the fragment ID. Identifies the fragments for a particular IKE 41: * message. 42: * 43: * @return fragment ID 44: */ 45: uint16_t (*get_id)(fragment_payload_t *this); 46: 47: /** 48: * Get the fragment number. Defines the order of the fragments. 49: * 50: * @return fragment number 51: */ 52: uint8_t (*get_number)(fragment_payload_t *this); 53: 54: /** 55: * Check if this is the last fragment. 56: * 57: * @return TRUE if this is the last fragment 58: */ 59: bool (*is_last)(fragment_payload_t *this); 60: 61: /** 62: * Get the fragment data. 63: * 64: * @return chunk to internal fragment data 65: */ 66: chunk_t (*get_data)(fragment_payload_t *this); 67: 68: /** 69: * Destroys an fragment_payload_t object. 70: */ 71: void (*destroy)(fragment_payload_t *this); 72: }; 73: 74: /** 75: * Creates an empty fragment_payload_t object. 76: * 77: * @return fragment_payload_t object 78: */ 79: fragment_payload_t *fragment_payload_create(); 80: 81: /** 82: * Creates a fragment payload from the given data. All fragments currently 83: * have the same fragment ID (1), which seems what other implementations are 84: * doing. 85: * 86: * @param num fragment number (first one should be 1) 87: * @param last TRUE to indicate that this is the last fragment 88: * @param data fragment data (gets cloned) 89: * @return fragment_payload_t object 90: */ 91: fragment_payload_t *fragment_payload_create_from_data(uint8_t num, bool last, 92: chunk_t data); 93: 94: #endif /** FRAGMENT_PAYLOAD_H_ @}*/