Implemented IF-M segmentation
[strongswan.git] / src / libimcv / seg / seg_env.h
1 /*
2 * Copyright (C) 2014 Andreas Steffen
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 seg_env seg_env
18 * @{ @ingroup libimcv
19 */
20
21 #ifndef SEG_ENV_H_
22 #define SEG_ENV_H_
23
24 typedef struct seg_env_t seg_env_t;
25 typedef enum seg_env_flags_t seg_env_flags_t;
26
27 #include <library.h>
28
29 #include <pa_tnc/pa_tnc_attr.h>
30
31 /**
32 * Segment Envelope flags
33 */
34 enum seg_env_flags_t {
35 SEG_ENV_FLAG_NONE = 0,
36 SEG_ENV_FLAG_MORE = (1<<7),
37 SEG_ENV_FLAG_START = (1<<6)
38 };
39
40 /**
41 * Interface for a PA-TNC attribute segment envelope object
42 */
43 struct seg_env_t {
44
45 /**
46 * Get Base Attribute ID
47 *
48 * @return Base Attribute ID
49 */
50 uint32_t (*get_base_attr_id)(seg_env_t *this);
51
52 /**
53 * Get Base Attribute
54 *
55 * @param error Error attribute if an error occurred or NULL
56 * @return Base Attribute (must be destroyed) or NULL
57 */
58 pa_tnc_attr_t* (*get_base_attr)(seg_env_t *this, pa_tnc_attr_t **error);
59
60 /**
61 * Generate the first segment envelope of the base attribute
62 *
63 * @return First attribute segment envelope
64 */
65 pa_tnc_attr_t* (*first_segment)(seg_env_t *this);
66
67 /**
68 * Generate the next segment envelope of the base attribute
69 *
70 * @param last TRUE if last segment
71 * @return Next attribute segment envelope
72 */
73 pa_tnc_attr_t* (*next_segment)(seg_env_t *this, bool *last);
74
75 /**
76 * Generate the first segment envelope of the base attribute
77 *
78 * @param segment Attribute segment to be added
79 */
80 void (*add_segment)(seg_env_t *this, chunk_t segment);
81
82 /**
83 * Destroys a seg_env_t object.
84 */
85 void (*destroy)(seg_env_t *this);
86 };
87
88 /**
89 * Create a PA-TNC attribute segment envelope object
90 *
91 * @param base_attr_id Base Attribute ID
92 * @param base_attr Base Attribute to be segmented
93 * @param max_seg_size Maximum segment size
94 */
95 seg_env_t* seg_env_create(uint32_t base_attr_id, pa_tnc_attr_t *base_attr,
96 uint32_t max_seg_size);
97
98 /**
99 * Create a PA-TNC attribute segment envelope object
100 *
101 * @param base_attr_id Base Attribute ID
102 * @param data First attribute segment
103 * @param max_seg_size Maximum segment size
104 */
105 seg_env_t* seg_env_create_from_data(uint32_t base_attr_id, chunk_t data,
106 uint32_t max_seg_size);
107
108 #endif /** SEG_ENV_H_ @}*/