root / src / charon / encoding / payloads / cp_payload.h @ b5a2055fb1b88ea4abb97334d89e311c9ceaa7d4
History | View | Annotate | Download (2.5 KB)
| 1 | /*
|
|---|---|
| 2 | * Copyright (C) 2005-2009 Martin Willi |
| 3 | * Copyright (C) 2005 Jan Hutter |
| 4 | * Hochschule fuer Technik Rapperswil |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the |
| 8 | * Free Software Foundation; either version 2 of the License, or (at your |
| 9 | * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 | * for more details. |
| 15 | */ |
| 16 | |
| 17 | /**
|
| 18 | * @defgroup cp_payload cp_payload |
| 19 | * @{ @ingroup payloads
|
| 20 | */ |
| 21 | |
| 22 | #ifndef CP_PAYLOAD_H_
|
| 23 | #define CP_PAYLOAD_H_
|
| 24 | |
| 25 | typedef enum config_type_t config_type_t; |
| 26 | typedef struct cp_payload_t cp_payload_t; |
| 27 | |
| 28 | #include <library.h> |
| 29 | #include <encoding/payloads/payload.h> |
| 30 | #include <encoding/payloads/configuration_attribute.h> |
| 31 | #include <utils/enumerator.h> |
| 32 | |
| 33 | /**
|
| 34 | * CP_PAYLOAD length in bytes without any proposal substructure. |
| 35 | */ |
| 36 | #define CP_PAYLOAD_HEADER_LENGTH 8 |
| 37 | |
| 38 | /**
|
| 39 | * Config Type of an Configuration Payload. |
| 40 | */ |
| 41 | enum config_type_t {
|
| 42 | CFG_REQUEST = 1,
|
| 43 | CFG_REPLY = 2,
|
| 44 | CFG_SET = 3,
|
| 45 | CFG_ACK = 4,
|
| 46 | }; |
| 47 | |
| 48 | /**
|
| 49 | * enum name for config_type_t. |
| 50 | */ |
| 51 | extern enum_name_t *config_type_names;
|
| 52 | |
| 53 | /**
|
| 54 | * Class representing an IKEv2-CP Payload. |
| 55 | * |
| 56 | * The CP Payload format is described in RFC section 3.15. |
| 57 | */ |
| 58 | struct cp_payload_t {
|
| 59 | |
| 60 | /**
|
| 61 | * The payload_t interface. |
| 62 | */ |
| 63 | payload_t payload_interface; |
| 64 | |
| 65 | /**
|
| 66 | * Creates an iterator of stored configuration_attribute_t objects. |
| 67 | * |
| 68 | * @return enumerator over configration_attribute_T |
| 69 | */ |
| 70 | enumerator_t *(*create_attribute_enumerator) (cp_payload_t *this); |
| 71 | |
| 72 | /**
|
| 73 | * Adds a configuration attribute to the configuration payload. |
| 74 | * |
| 75 | * @param attribute attribute to add |
| 76 | */ |
| 77 | void (*add_attribute)(cp_payload_t *this,
|
| 78 | configuration_attribute_t *attribute); |
| 79 | |
| 80 | /**
|
| 81 | * Get the configuration payload type. |
| 82 | * |
| 83 | * @return type of configuration payload |
| 84 | */ |
| 85 | config_type_t (*get_type) (cp_payload_t *this); |
| 86 | |
| 87 | /**
|
| 88 | * Destroys an cp_payload_t object. |
| 89 | */ |
| 90 | void (*destroy) (cp_payload_t *this);
|
| 91 | }; |
| 92 | |
| 93 | /**
|
| 94 | * Creates an empty configuration payload |
| 95 | * |
| 96 | * @return empty configuration payload |
| 97 | */ |
| 98 | cp_payload_t *cp_payload_create(); |
| 99 | |
| 100 | /**
|
| 101 | * Creates an cp_payload_t with type and value |
| 102 | * |
| 103 | * @param type type of configuration payload to create |
| 104 | * @return created configuration payload |
| 105 | */ |
| 106 | cp_payload_t *cp_payload_create_type(config_type_t config_type); |
| 107 | |
| 108 | #endif /** CP_PAYLOAD_H_ @}*/ |