summaryrefslogtreecommitdiff
path: root/src/libimcv/pa_tnc/pa_tnc_attr_manager.h
blob: 1fec8e3f938d0af2fd63314e39229db1edab3106 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
 * Copyright (C) 2011-2014 Andreas Steffen
 * HSR Hochschule fuer Technik Rapperswil
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */

/**
 * @defgroup pa_tnc_attr_manager pa_tnc_attr_manager
 * @{ @ingroup pa_tnc
 */

#ifndef PA_TNC_ATTR_MANAGER_H_
#define PA_TNC_ATTR_MANAGER_H_

typedef struct pa_tnc_attr_manager_t pa_tnc_attr_manager_t;

#include "pa_tnc_attr.h"

#include <library.h>
#include <bio/bio_reader.h>

typedef pa_tnc_attr_t* (*pa_tnc_attr_create_t)(uint32_t type, size_t length,
											   chunk_t value);

/**
 * Manages PA-TNC attributes for arbitrary PENs
 */
struct pa_tnc_attr_manager_t {

	/**
	 * Add vendor-specific attribute names and creation method
	 *
	 * @param vendor_id		Private Enterprise Number (PEN)
	 * @param attr_create	Vendor-specific attribute create method
	 * @param attr_names	Vendor-specific attribute names
	 */
	void (*add_vendor)(pa_tnc_attr_manager_t *this, pen_t vendor_id,
					   pa_tnc_attr_create_t attr_create,
					   enum_name_t *attr_names);

	/**
	 * Remove vendor-specific attribute names and creation method
	 *
	 * @param vendor_id		Private Enterprise Number (PEN)
	 */
	void (*remove_vendor)(pa_tnc_attr_manager_t *this, pen_t vendor_id);

	/*
	 * Return the PA-TNC attribute names for a given vendor ID
	 *
	 * @param vendor_id		Private Enterprise Number (PEN)
	 * @return				PA-TNC attribute names if found, NULL else
	 */
	enum_name_t* (*get_names)(pa_tnc_attr_manager_t *this, pen_t vendor_id);

	/**
	 * Create and pre-parse a PA-TNC attribute object from data
	 *
	 * @param reader		PA-TNC attribute as encoded data
	 * @param segmented		TRUE if attribute is segmented
	 * @param offset		Offset in bytes where an error has been found
	 * @param msg_info		Message info added to an error attribute
	 * @param error			Error attribute if an error occurred
	 * @return				PA-TNC attribute object if supported, NULL else
	 */
	pa_tnc_attr_t* (*create)(pa_tnc_attr_manager_t *this, bio_reader_t *reader,
							 bool segmented, uint32_t *offset, chunk_t msg_info,
							 pa_tnc_attr_t **error);

	/**
	 * Generically construct a PA-TNC attribute from type and data
	 *
	 * @param vendor_id		Private Enterprise Number (PEN)
	 * @param type			PA-TNC attribute type
	 * @param value			PA-TNC attribute value as encoded data
	 * @return				PA-TNC attribute object if supported, NULL else
	 */
	pa_tnc_attr_t* (*construct)(pa_tnc_attr_manager_t *this, pen_t vendor_id,
								uint32_t type, chunk_t value);

	/**
	 * Destroys a pa_tnc_attr_manager_t object.
	 */
	void (*destroy)(pa_tnc_attr_manager_t *this);
};

/**
 * Create a PA-TNC attribute manager
 */
pa_tnc_attr_manager_t* pa_tnc_attr_manager_create(void);

#endif /** PA_TNC_ATTR_MANAGER_H_ @}*/