debug output of inbound and outbound TNCCS batches
[strongswan.git] / src / libcharon / plugins / eap_tnc / tnc_if_tnccs.c
1 /*
2 * Copyright (C) 2010 Andreas Steffen
3 * Copyright (C) 2010 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 "tnc_if_tnccs.h"
17
18 #include <debug.h>
19
20 typedef struct private_tnc_if_tnccs_t private_tnc_if_tnccs_t;
21
22 /**
23 * Private data of a tnc_if_tnccs_t object.
24 */
25 struct private_tnc_if_tnccs_t {
26
27 /**
28 * Public tls_t interface.
29 */
30 tls_t public;
31
32 /**
33 * Role this TNC IF-TNCCS stack acts as.
34 */
35 bool is_server;
36
37 /**
38 * TLS stack purpose, as given to constructor
39 */
40 tls_purpose_t purpose;
41 };
42
43 METHOD(tls_t, process, status_t,
44 private_tnc_if_tnccs_t *this, void *buf, size_t buflen)
45 {
46 chunk_t in = { buf, buflen };
47
48 /* TODO */
49 DBG1(DBG_IKE, "received TNCCS-Batch: %B", &in);
50 return NEED_MORE;
51 }
52
53 METHOD(tls_t, build, status_t,
54 private_tnc_if_tnccs_t *this, void *buf, size_t *buflen, size_t *msglen)
55 {
56 char output[] =
57 "<?xml version=\"1.0\"?>\n"
58 "<TNCCS-Batch BatchId=\"1\" Recipient=\"TNCS\"\n"
59 "xmlns=\"http://www.trustedcomputinggroup.org/IWG/TNC/1_0/IF_TNCCS#\"\n"
60 "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
61 "xsi:schemaLocation=\"http://www.trustedcomputinggroup.org/IWG/TNC/1_0/IF_TNCCS#\n"
62 "https://www.trustedcomputinggroup.org/XML/SCHEMA/TNCCS_1.0.xsd\">\n"
63 "</TNCCS-Batch>\n";
64
65 size_t len = strlen(output);
66 chunk_t out = { output, len };
67
68 /* TODO */
69 DBG1(DBG_IKE, "sending TNCCS-Batch: %B", &out);
70 *buflen = len;
71 *msglen = len;
72 memcpy(buf, output, len);
73
74 return ALREADY_DONE;
75 }
76
77 METHOD(tls_t, is_server, bool,
78 private_tnc_if_tnccs_t *this)
79 {
80 return this->is_server;
81 }
82
83 METHOD(tls_t, get_purpose, tls_purpose_t,
84 private_tnc_if_tnccs_t *this)
85 {
86 return this->purpose;
87 }
88
89 METHOD(tls_t, is_complete, bool,
90 private_tnc_if_tnccs_t *this)
91 {
92 /* TODO */
93 return FALSE;
94 }
95
96 METHOD(tls_t, get_eap_msk, chunk_t,
97 private_tnc_if_tnccs_t *this)
98 {
99 return chunk_empty;
100 }
101
102 METHOD(tls_t, destroy, void,
103 private_tnc_if_tnccs_t *this)
104 {
105 free(this);
106 }
107
108 /**
109 * See header
110 */
111 tls_t *tnc_if_tnccs_create(bool is_server, tls_purpose_t purpose)
112 {
113 private_tnc_if_tnccs_t *this;
114
115 switch (purpose)
116 {
117 case TLS_PURPOSE_EAP_TNC:
118 break;
119 default:
120 return NULL;
121 }
122
123 INIT(this,
124 .public = {
125 .process = _process,
126 .build = _build,
127 .is_server = _is_server,
128 .get_purpose = _get_purpose,
129 .is_complete = _is_complete,
130 .get_eap_msk = _get_eap_msk,
131 .destroy = _destroy,
132 },
133 .is_server = is_server,
134 .purpose = purpose,
135 );
136
137 return &this->public;
138 }