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