]> git.ipfire.org Git - people/ms/strongswan.git/blame - src/libtnccs/plugins/tnccs_20/messages/pb_tnc_msg.h
Fix years in some copyright statements
[people/ms/strongswan.git] / src / libtnccs / plugins / tnccs_20 / messages / pb_tnc_msg.h
CommitLineData
7828bd1b 1/*
d1e7b31e 2 * Copyright (C) 2010-2013 Andreas Steffen
7828bd1b
AS
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/**
54eb669d 17 * @defgroup pb_tnc_msg pb_tnc_msg
7828bd1b
AS
18 * @{ @ingroup tnccs_20
19 */
20
54eb669d
AS
21#ifndef PB_TNC_MSG_H_
22#define PB_TNC_MSG_H_
23
24typedef enum pb_tnc_msg_type_t pb_tnc_msg_type_t;
25typedef struct pb_tnc_msg_info_t pb_tnc_msg_info_t;
26typedef struct pb_tnc_msg_t pb_tnc_msg_t;
7828bd1b
AS
27
28#include <library.h>
ddfc5896 29#include <pen/pen.h>
7828bd1b 30
54eb669d 31#define PB_TNC_VERSION 2
4333c48a
AS
32
33/**
34 * PB-TNC Message Types as defined in section 4.3 of RFC 5793
35 */
36enum pb_tnc_msg_type_t {
37 PB_MSG_EXPERIMENTAL = 0,
38 PB_MSG_PA = 1,
39 PB_MSG_ASSESSMENT_RESULT = 2,
40 PB_MSG_ACCESS_RECOMMENDATION = 3,
41 PB_MSG_REMEDIATION_PARAMETERS = 4,
42 PB_MSG_ERROR = 5,
43 PB_MSG_LANGUAGE_PREFERENCE = 6,
44 PB_MSG_REASON_STRING = 7,
45 PB_MSG_ROOF = 7
46};
47
48/**
49 * enum name for pb_tnc_msg_type_t.
50 */
51extern enum_name_t *pb_tnc_msg_type_names;
52
ddfc5896
AS
53/**
54 * PB-TNC Message Type defined in the TCG namespace
55 */
56enum pb_tnc_tcg_msg_type_t {
883c11ca 57 PB_TCG_MSG_RESERVED = 0,
ddfc5896
AS
58 PB_TCG_MSG_PDP_REFERRAL = 1,
59 PB_TCG_MSG_ROOF = 1
60};
61
62/**
63 * enum name for pb_tnc_tcg_msg_type_t.
64 */
65extern enum_name_t *pb_tnc_tcg_msg_type_names;
66
c6aed8aa
AS
67/**
68 * PB-TNC Message Type defined in the ITA namespace
69 */
70enum pb_tnc_ita_msg_type_t {
883c11ca 71 PB_ITA_MSG_NOSKIP_TEST = 0,
c6aed8aa
AS
72 PB_ITA_MSG_MUTUAL_CAPABILITY = 1,
73 PB_ITA_MSG_ROOF = 1
74};
75
76/**
77 * enum name for pb_tnc_tcg_msg_type_t.
78 */
79extern enum_name_t *pb_tnc_ita_msg_type_names;
80
54eb669d
AS
81/**
82 * Information entry describing a PB-TNC Message Type
83 */
84struct pb_tnc_msg_info_t {
85 u_int32_t min_size;
6ccb23e8
MW
86 bool exact_size;
87 bool in_result_batch;
41d344e8 88 signed char has_noskip_flag;
54eb669d
AS
89};
90
91#define TRUE_OR_FALSE 2
92
93/**
94 * Information on PB-TNC Message Types
95 */
96extern pb_tnc_msg_info_t pb_tnc_msg_infos[];
7828bd1b 97
ddfc5896
AS
98/**
99 * Information on PB-TNC TCG Message Types
100 */
101extern pb_tnc_msg_info_t pb_tnc_tcg_msg_infos[];
102
c6aed8aa
AS
103/**
104 * Information on PB-TNC ITA Message Types
105 */
106extern pb_tnc_msg_info_t pb_tnc_ita_msg_infos[];
107
7828bd1b
AS
108/**
109 * Generic interface for all PB-TNC message types.
110 *
111 * To handle all messages in a generic way, this interface
112 * must be implemented by each message type.
113 */
54eb669d 114struct pb_tnc_msg_t {
7828bd1b
AS
115
116 /**
117 * Get the PB-TNC Message Type
118 *
119 * @return PB-TNC Message Type
120 */
ddfc5896 121 pen_type_t (*get_type)(pb_tnc_msg_t *this);
7828bd1b
AS
122
123 /**
124 * Get the encoding of the PB-TNC Message Value
125 *
126 * @return encoded PB-TNC Message Value
127 */
54eb669d 128 chunk_t (*get_encoding)(pb_tnc_msg_t *this);
7828bd1b
AS
129
130 /**
131 * Build the PB-TNC Message Value
132 */
54eb669d 133 void (*build)(pb_tnc_msg_t *this);
7828bd1b
AS
134
135 /**
136 * Process the PB-TNC Message Value
137 *
54eb669d 138 * @param relative offset where an error occurred
7828bd1b
AS
139 * @return return processing status
140 */
54eb669d 141 status_t (*process)(pb_tnc_msg_t *this, u_int32_t *offset);
7828bd1b 142
4333c48a
AS
143 /**
144 * Get a new reference to the message.
145 *
146 * @return this, with an increased refcount
147 */
54eb669d 148 pb_tnc_msg_t* (*get_ref)(pb_tnc_msg_t *this);
4333c48a 149
7828bd1b 150 /**
54eb669d 151 * Destroys a pb_tnc_msg_t object.
7828bd1b 152 */
54eb669d 153 void (*destroy)(pb_tnc_msg_t *this);
7828bd1b
AS
154};
155
156/**
157 * Create an unprocessed PB-TNC message
158 *
159 * Useful for the parser which wants a generic constructor for all
160 * pb_tnc_message_t types.
161 *
dd438ee2 162 * @param msg_type PB-TNC message type
ddfc5896 163 * @param value PB-TNC message value
7828bd1b 164 */
ddfc5896 165pb_tnc_msg_t* pb_tnc_msg_create_from_data(pen_type_t msg_type, chunk_t value);
7828bd1b 166
54eb669d 167#endif /** PB_TNC_MSG_H_ @}*/