generalized tls_eap_t to support EAP_TNC wrapping the TNC_IF_TNCCS protocol
[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 /* TODO */
47 return NEED_MORE;
48 }
49
50 METHOD(tls_t, build, status_t,
51 private_tnc_if_tnccs_t *this, void *buf, size_t *buflen, size_t *msglen)
52 {
53 char output[] = "Hello World";
54 size_t len = strlen(output);
55
56 /* TODO */
57 *buflen = len;
58 *msglen = len;
59 memcpy(buf, output, len);
60
61 return ALREADY_DONE;
62 }
63
64 METHOD(tls_t, is_server, bool,
65 private_tnc_if_tnccs_t *this)
66 {
67 return this->is_server;
68 }
69
70 METHOD(tls_t, get_purpose, tls_purpose_t,
71 private_tnc_if_tnccs_t *this)
72 {
73 return this->purpose;
74 }
75
76 METHOD(tls_t, is_complete, bool,
77 private_tnc_if_tnccs_t *this)
78 {
79 /* TODO */
80 return TRUE;
81 }
82
83 METHOD(tls_t, get_eap_msk, chunk_t,
84 private_tnc_if_tnccs_t *this)
85 {
86 return chunk_empty;
87 }
88
89 METHOD(tls_t, destroy, void,
90 private_tnc_if_tnccs_t *this)
91 {
92 free(this);
93 }
94
95 /**
96 * See header
97 */
98 tls_t *tnc_if_tnccs_create(bool is_server, tls_purpose_t purpose)
99 {
100 private_tnc_if_tnccs_t *this;
101
102 switch (purpose)
103 {
104 case TLS_PURPOSE_EAP_TNC:
105 break;
106 default:
107 return NULL;
108 }
109
110 INIT(this,
111 .public = {
112 .process = _process,
113 .build = _build,
114 .is_server = _is_server,
115 .get_purpose = _get_purpose,
116 .is_complete = _is_complete,
117 .get_eap_msk = _get_eap_msk,
118 .destroy = _destroy,
119 },
120 .is_server = is_server,
121 .purpose = purpose,
122 );
123
124 return &this->public;
125 }