Return to eap_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: * Copyright (C) 2005-2006 Martin Willi 4: * Copyright (C) 2005 Jan Hutter 5: * HSR Hochschule fuer Technik Rapperswil 6: * 7: * This program is free software; you can redistribute it and/or modify it 8: * under the terms of the GNU General Public License as published by the 9: * Free Software Foundation; either version 2 of the License, or (at your 10: * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. 11: * 12: * This program is distributed in the hope that it will be useful, but 13: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15: * for more details. 16: */ 17: 18: /** 19: * @defgroup eap_payload eap_payload 20: * @{ @ingroup payloads 21: */ 22: 23: #ifndef EAP_PAYLOAD_H_ 24: #define EAP_PAYLOAD_H_ 25: 26: typedef struct eap_payload_t eap_payload_t; 27: 28: #include <library.h> 29: #include <eap/eap.h> 30: #include <encoding/payloads/payload.h> 31: 32: /** 33: * Class representing an IKEv2 EAP payload. 34: * 35: * The EAP payload format is described in RFC section 3.16. 36: */ 37: struct eap_payload_t { 38: 39: /** 40: * The payload_t interface. 41: */ 42: payload_t payload_interface; 43: 44: /** 45: * Set the contained EAP data. 46: * 47: * This contains the FULL EAP message starting with "code". 48: * Chunk gets cloned. 49: * 50: * @param message EAP data 51: */ 52: void (*set_data) (eap_payload_t *this, chunk_t data); 53: 54: /** 55: * Get the contained EAP data. 56: * 57: * This contains the FULL EAP message starting with "code". 58: * 59: * @return EAP data (pointer to internal data) 60: */ 61: chunk_t (*get_data) (eap_payload_t *this); 62: 63: /** 64: * Get the EAP code. 65: * 66: * @return EAP message as chunk_t 67: */ 68: eap_code_t (*get_code) (eap_payload_t *this); 69: 70: /** 71: * Get the EAP identifier. 72: * 73: * @return unique identifier 74: */ 75: uint8_t (*get_identifier) (eap_payload_t *this); 76: 77: /** 78: * Get the EAP method type. 79: * 80: * @param vendor pointer receiving vendor identifier 81: * @return EAP method type, vendor specific if vendor != 0 82: */ 83: eap_type_t (*get_type) (eap_payload_t *this, uint32_t *vendor); 84: 85: /** 86: * Enumerate the EAP method types contained in an EAP-Nak (i.e. get_type() 87: * returns EAP_NAK). 88: * 89: * @return enumerator over (eap_type_t type, uint32_t vendor) 90: */ 91: enumerator_t* (*get_types) (eap_payload_t *this); 92: 93: /** 94: * Check if the EAP method type is encoded in the Expanded Type format. 95: * 96: * @return TRUE if in Expanded Type format 97: */ 98: bool (*is_expanded) (eap_payload_t *this); 99: 100: /** 101: * Destroys an eap_payload_t object. 102: */ 103: void (*destroy) (eap_payload_t *this); 104: }; 105: 106: /** 107: * Creates an empty eap_payload_t object. 108: * 109: * @return eap_payload_t object 110: */ 111: eap_payload_t *eap_payload_create(void); 112: 113: /** 114: * Creates an eap_payload_t object with data. 115: * 116: * @param data data, gets cloned 117: * @return eap_payload_t object 118: */ 119: eap_payload_t *eap_payload_create_data(chunk_t data); 120: 121: /** 122: * Creates an eap_payload_t object with data, owning the data. 123: * 124: * @param data data on heap, gets owned and freed 125: * @return eap_payload_t object 126: */ 127: eap_payload_t *eap_payload_create_data_own(chunk_t data); 128: 129: /** 130: * Creates an eap_payload_t object with a code. 131: * 132: * Could should be either EAP_SUCCESS/EAP_FAILURE, use 133: * constructor above otherwise. 134: * 135: * @param code EAP status code 136: * @param identifier EAP identifier to use in payload 137: * @return eap_payload_t object 138: */ 139: eap_payload_t *eap_payload_create_code(eap_code_t code, uint8_t identifier); 140: 141: /** 142: * Creates an eap_payload_t EAP_RESPONSE containing an EAP_NAK. 143: * 144: * @param identifier EAP identifier to use in payload 145: * @param type preferred auth type, 0 to send all supported types 146: * @param vendor vendor identifier for auth type, 0 for default 147: * @param expanded TRUE to send an expanded Nak 148: * @return eap_payload_t object 149: */ 150: eap_payload_t *eap_payload_create_nak(uint8_t identifier, eap_type_t type, 151: uint32_t vendor, bool expanded); 152: 153: #endif /** EAP_PAYLOAD_H_ @}*/