]> git.ipfire.org Git - people/ms/strongswan.git/blob - src/libimcv/seg/seg_env.h
Fixed a memory leak in the attribute segmentation code
[people/ms/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_seg
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 if it contains processed [incremental] data
54 *
55 * @return Base Attribute (must be destroyed) or NULL
56 */
57 pa_tnc_attr_t* (*get_base_attr)(seg_env_t *this);
58
59 /**
60 * Base Attribute Info to be used by PA-TNC error messages
61 *
62 * @return Message info string
63 */
64 chunk_t (*get_base_attr_info)(seg_env_t *this);
65
66 /**
67 * Generate the first segment envelope of the base attribute
68 *
69 * @return First attribute segment envelope
70 */
71 pa_tnc_attr_t* (*first_segment)(seg_env_t *this);
72
73 /**
74 * Generate the next segment envelope of the base attribute
75 *
76 * @param last TRUE if last segment
77 * @return Next attribute segment envelope
78 */
79 pa_tnc_attr_t* (*next_segment)(seg_env_t *this, bool *last);
80
81 /**
82 * Generate the first segment envelope of the base attribute
83 *
84 * @param segment Attribute segment to be added
85 * @param error Error attribute if a parsing error occurred
86 * return TRUE if segment was successfully added
87 */
88 bool (*add_segment)(seg_env_t *this, chunk_t segment,
89 pa_tnc_attr_t** error);
90
91 /**
92 * Destroys a seg_env_t object.
93 */
94 void (*destroy)(seg_env_t *this);
95 };
96
97 /**
98 * Create a PA-TNC attribute segment envelope object
99 *
100 * @param base_attr_id Base Attribute ID
101 * @param base_attr Base Attribute to be segmented, owned by seg_env_t
102 * @param max_seg_size Maximum segment size
103 */
104 seg_env_t* seg_env_create(uint32_t base_attr_id, pa_tnc_attr_t *base_attr,
105 uint32_t max_seg_size);
106
107 /**
108 * Create a PA-TNC attribute segment envelope object
109 *
110 * @param base_attr_id Base Attribute ID
111 * @param data First attribute segment
112 * @param max_seg_size Maximum segment size
113 * @param error Error attribute if a parsing error occurred
114 */
115 seg_env_t* seg_env_create_from_data(uint32_t base_attr_id, chunk_t data,
116 uint32_t max_seg_size,
117 pa_tnc_attr_t** error);
118
119 #endif /** SEG_ENV_H_ @}*/