2 * Copyright (C) 2014-2022 Andreas Steffen
4 * Copyright (C) secunet Security Networks AG
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>.
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
18 * @defgroup seg_contract seg_contract
19 * @{ @ingroup libimcv_seg
22 #ifndef SEG_CONTRACT_H_
23 #define SEG_CONTRACT_H_
25 typedef struct seg_contract_t seg_contract_t
;
27 #include "pa_tnc/pa_tnc_attr.h"
34 #define SEG_CONTRACT_NO_MSG_SIZE_LIMIT 0xffffffff
35 #define SEG_CONTRACT_NO_SEGMENTATION 0xffffffff
38 * Interface for a PA-TNC message segmentation contract
41 struct seg_contract_t
{
44 * Get the PA-TNC message type.
46 * @return PA-TNC Message type
48 pen_type_t (*get_msg_type
)(seg_contract_t
*this);
51 * Set maximum PA-TNC message and segment size in octets
53 * @param max_msg_size Maximum PA-TNC message size in octets
54 * @param max_seg_size Maximum PA-TNC message segment size in octets
56 void (*set_max_size
)(seg_contract_t
*this, uint32_t max_msg_size
,
57 uint32_t max_seg_size
);
60 * Get maximum PA-TNC message and segment size in octets
62 * @param max_msg_size Maximum PA-TNC attribute size in octets
63 * @param max_seg_size Maximum PA-TNC attribute segment size in octets
65 void (*get_max_size
)(seg_contract_t
*this, uint32_t *max_msg_size
,
66 uint32_t *max_seg_size
);
69 * Check if a PA-TNC attribute must be segmented or is oversized
71 * @param attr PA-TNC attribute to be checked
72 * @param oversize PA-TNC attribute is larger than maximum size
73 * @return TRUE if PA-TNC attribute must be segmented
75 bool (*check_size
)(seg_contract_t
*this, pa_tnc_attr_t
*attr
,
79 * Generate first segment of a PA-TNC attribute according to the contract
81 * @param attr PA-TNC attribute to be segmented
82 * @param max_attr_len Maximum size of first segment envelope attribute
83 * @return First segment envelope attribute
85 pa_tnc_attr_t
* (*first_segment
)(seg_contract_t
*this, pa_tnc_attr_t
*attr
,
89 * Generate next segment of a PA-TNC message according to the contract
91 * @param base_msg_id Base Message ID
92 * @return Next segment envelope attribute
94 pa_tnc_attr_t
* (*next_segment
)(seg_contract_t
*this, uint32_t base_msg_id
);
97 * Add segments until the PA-TNC attribute is reconstructed
99 * @param attr Segment envelope attribute
100 * @param error Error attribute if an error occurred or NULL
101 * @param more Need more segments
102 * @return Completed PA-TNC attribute or NULL
104 pa_tnc_attr_t
* (*add_segment
)(seg_contract_t
*this,
105 pa_tnc_attr_t
*attr
, pa_tnc_attr_t
**error
,
111 * @return TRUE: contracting party (issuer),
112 * FALSE: contracted party
114 bool (*is_issuer
)(seg_contract_t
*this);
117 * Is this a null contract ?
119 * @return TRUE if null contract
121 bool (*is_null
)(seg_contract_t
*this);
124 * Set the responder ID
126 * @param responder IMC or IMV ID of responder
128 void (*set_responder
)(seg_contract_t
*this, TNC_UInt32 responder
);
131 * Get the responder ID
133 * @return IMC or IMV ID of responder
135 TNC_UInt32 (*get_responder
)(seg_contract_t
*this);
140 * @return IMC or IMV ID of issuer
142 TNC_UInt32 (*get_issuer
)(seg_contract_t
*this);
147 * @return Cloned contract
149 seg_contract_t
* (*clone
)(seg_contract_t
*this);
152 * Get an info string about the contract
154 * @param buf String buffer of at least size len
155 * @param len Size of string buffer
156 * @param request TRUE if contract request, FALSE if response
158 void (*get_info_string
)(seg_contract_t
*this, char *buf
, size_t len
,
162 * Destroys a seg_contract_t object.
164 void (*destroy
)(seg_contract_t
*this);
168 * Create a PA-TNC attribute segmentation contract
170 * @param msg_type PA-TNC message type
171 * @param max_msg_size Maximum PA-TNC message size in octets
172 * @param max_seg_size Maximum PA-TNC message segment size in octets
173 * @param is_issuer TRUE if issuer of the contract
174 * @param issuer_id IMC or IMV ID of issuer
175 * @param is_imc TRUE if IMC, FALSE if IMV
177 seg_contract_t
* seg_contract_create(pen_type_t msg_type
,
178 uint32_t max_msg_size
,
179 uint32_t max_seg_size
,
180 bool is_issuer
, TNC_UInt32 issuer_id
,
183 #endif /** SEG_CONTRACT_H_ @}*/