326b550cd872cc17f0e25e2f46accab221b2aa25
[strongswan.git] / src / libcharon / encoding / payloads / unknown_payload.h
1 /*
2 * Copyright (C) 2005-2006 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 unknown_payload unknown_payload
19 * @{ @ingroup payloads
20 */
21
22 #ifndef UNKNOWN_PAYLOAD_H_
23 #define UNKNOWN_PAYLOAD_H_
24
25 typedef struct unknown_payload_t unknown_payload_t;
26
27 #include <library.h>
28 #include <encoding/payloads/payload.h>
29
30 /**
31 * Payload which can't be processed further.
32 *
33 * When the parser finds an unknown payload, he builds an instance of
34 * this class. This allows further processing of this payload, such as
35 * a check for the critical bit in the header.
36 */
37 struct unknown_payload_t {
38
39 /**
40 * The payload_t interface.
41 */
42 payload_t payload_interface;
43
44 /**
45 * Get the raw data of this payload, without
46 * the generic payload header.
47 *
48 * Returned data are NOT copied and must not be freed.
49 *
50 * @return data as chunk_t
51 */
52 chunk_t (*get_data) (unknown_payload_t *this);
53
54 /**
55 * Get the critical flag.
56 *
57 * @return TRUE if payload is critical, FALSE if not
58 */
59 bool (*is_critical) (unknown_payload_t *this);
60
61 /**
62 * Destroys an unknown_payload_t object.
63 */
64 void (*destroy) (unknown_payload_t *this);
65 };
66
67 /**
68 * Creates an empty unknown_payload_t.
69 *
70 * @param type of the payload
71 * @return unknown_payload_t object
72 */
73 unknown_payload_t *unknown_payload_create(payload_type_t type);
74
75 /**
76 * Create an unknown payload with data.
77 *
78 * @param type type of payload to create
79 * @param critical TRUE to set critical bit
80 * @param data data to set for this payload, gets owned by payload
81 * @return payload object
82 */
83 unknown_payload_t *unknown_payload_create_data(payload_type_t type,
84 bool critical, chunk_t data);
85
86 #endif /** UNKNOWN_PAYLOAD_H_ @}*/