]> git.ipfire.org Git - thirdparty/strongswan.git/blame - src/libimcv/seg/seg_env.h
Update copyright headers after acquisition by secunet
[thirdparty/strongswan.git] / src / libimcv / seg / seg_env.h
CommitLineData
e911ac9a 1/*
19ef2aec 2 * Copyright (C) 2014-2022 Andreas Steffen
e911ac9a 3 *
19ef2aec 4 * Copyright (C) secunet Security Networks AG
3f19a951 5 *
e911ac9a
AS
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 seg_env seg_env
17eed801 19 * @{ @ingroup libimcv_seg
e911ac9a
AS
20 */
21
22#ifndef SEG_ENV_H_
23#define SEG_ENV_H_
24
25typedef struct seg_env_t seg_env_t;
26typedef enum seg_env_flags_t seg_env_flags_t;
27
28#include <library.h>
29
30#include <pa_tnc/pa_tnc_attr.h>
31
32/**
33 * Segment Envelope flags
34 */
35enum seg_env_flags_t {
36 SEG_ENV_FLAG_NONE = 0,
37 SEG_ENV_FLAG_MORE = (1<<7),
38 SEG_ENV_FLAG_START = (1<<6)
39};
40
41/**
42 * Interface for a PA-TNC attribute segment envelope object
43 */
44struct seg_env_t {
45
46 /**
3f19a951 47 * Get Base Message ID
e911ac9a 48 *
3f19a951 49 * @return Base Message ID
e911ac9a 50 */
3f19a951 51 uint32_t (*get_base_msg_id)(seg_env_t *this);
e911ac9a
AS
52
53 /**
eba0cbce 54 * Get Base Attribute if it contains processed [incremental] data
e911ac9a 55 *
e911ac9a
AS
56 * @return Base Attribute (must be destroyed) or NULL
57 */
eba0cbce
AS
58 pa_tnc_attr_t* (*get_base_attr)(seg_env_t *this);
59
60 /**
61 * Base Attribute Info to be used by PA-TNC error messages
62 *
63 * @return Message info string
64 */
65 chunk_t (*get_base_attr_info)(seg_env_t *this);
e911ac9a
AS
66
67 /**
68 * Generate the first segment envelope of the base attribute
69 *
10f25a3d 70 * @param max_attr_len Maximum size of first attribute segment envelope
e911ac9a
AS
71 * @return First attribute segment envelope
72 */
10f25a3d 73 pa_tnc_attr_t* (*first_segment)(seg_env_t *this, size_t max_attr_len);
e911ac9a
AS
74
75 /**
76 * Generate the next segment envelope of the base attribute
77 *
78 * @param last TRUE if last segment
79 * @return Next attribute segment envelope
80 */
81 pa_tnc_attr_t* (*next_segment)(seg_env_t *this, bool *last);
82
83 /**
84 * Generate the first segment envelope of the base attribute
85 *
86 * @param segment Attribute segment to be added
eba0cbce
AS
87 * @param error Error attribute if a parsing error occurred
88 * return TRUE if segment was successfully added
e911ac9a 89 */
eba0cbce
AS
90 bool (*add_segment)(seg_env_t *this, chunk_t segment,
91 pa_tnc_attr_t** error);
e911ac9a
AS
92
93 /**
94 * Destroys a seg_env_t object.
95 */
96 void (*destroy)(seg_env_t *this);
97};
98
99/**
100 * Create a PA-TNC attribute segment envelope object
101 *
3f19a951
AS
102 * @param base_msg_id Base Message ID
103 * @param base_attr Base Message to be segmented, owned by seg_env_t
e911ac9a
AS
104 * @param max_seg_size Maximum segment size
105 */
3f19a951 106seg_env_t* seg_env_create(uint32_t base_msg_id, pa_tnc_attr_t *base_attr,
e911ac9a
AS
107 uint32_t max_seg_size);
108
109/**
110 * Create a PA-TNC attribute segment envelope object
111 *
3f19a951 112 * @param base_msg_id Base Message ID
e911ac9a
AS
113 * @param data First attribute segment
114 * @param max_seg_size Maximum segment size
eba0cbce 115 * @param error Error attribute if a parsing error occurred
e911ac9a 116 */
3f19a951 117seg_env_t* seg_env_create_from_data(uint32_t base_msg_id, chunk_t data,
eba0cbce
AS
118 uint32_t max_seg_size,
119 pa_tnc_attr_t** error);
e911ac9a
AS
120
121#endif /** SEG_ENV_H_ @}*/