]> git.ipfire.org Git - thirdparty/strongswan.git/blob - src/libtnccs/plugins/tnccs_20/messages/ietf/pb_experimental_msg.c
Update copyright headers after acquisition by secunet
[thirdparty/strongswan.git] / src / libtnccs / plugins / tnccs_20 / messages / ietf / pb_experimental_msg.c
1 /*
2 * Copyright (C) 2010 Andreas Steffen
3 *
4 * Copyright (C) secunet Security Networks AG
5 *
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 #include "pb_experimental_msg.h"
18
19 typedef struct private_pb_experimental_msg_t private_pb_experimental_msg_t;
20
21 /**
22 * Private data of a pb_experimental_msg_t object.
23 *
24 */
25 struct private_pb_experimental_msg_t {
26 /**
27 * Public pb_experimental_msg_t interface.
28 */
29 pb_experimental_msg_t public;
30
31 /**
32 * PB-TNC message type
33 */
34 pen_type_t type;
35
36 /**
37 * Encoded message
38 */
39 chunk_t encoding;
40 };
41
42 METHOD(pb_tnc_msg_t, get_type, pen_type_t,
43 private_pb_experimental_msg_t *this)
44 {
45 return this->type;
46 }
47
48 METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
49 private_pb_experimental_msg_t *this)
50 {
51 return this->encoding;
52 }
53
54 METHOD(pb_tnc_msg_t, build, void,
55 private_pb_experimental_msg_t *this)
56 {
57 /* nothing to do since message contents equal encoding */
58 }
59
60 METHOD(pb_tnc_msg_t, process, status_t,
61 private_pb_experimental_msg_t *this, uint32_t *offset)
62 {
63 return SUCCESS;
64 }
65
66 METHOD(pb_tnc_msg_t, destroy, void,
67 private_pb_experimental_msg_t *this)
68 {
69 free(this->encoding.ptr);
70 free(this);
71 }
72
73 /**
74 * See header
75 */
76 pb_tnc_msg_t *pb_experimental_msg_create_from_data(chunk_t data)
77 {
78 private_pb_experimental_msg_t *this;
79
80 INIT(this,
81 .public = {
82 .pb_interface = {
83 .get_type = _get_type,
84 .get_encoding = _get_encoding,
85 .build = _build,
86 .process = _process,
87 .destroy = _destroy,
88 },
89 },
90 .type = { PEN_IETF, PB_MSG_EXPERIMENTAL },
91 .encoding = chunk_clone(data),
92 );
93
94 return &this->public.pb_interface;
95 }
96
97 /**
98 * See header
99 */
100 pb_tnc_msg_t *pb_experimental_msg_create(chunk_t body)
101 {
102 return pb_experimental_msg_create_from_data(body);
103 }