implemented IF-IMC/IMV 1.3 attributes
[strongswan.git] / src / libcharon / plugins / tnccs_20 / tnccs_20.c
1 /*
2 * Copyright (C) 2010 Sansar Choinyanbuu
3 * Copyright (C) 2010-2011 Andreas Steffen
4 * HSR Hochschule fuer Technik Rapperswil
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 "tnccs_20.h"
18 #include "batch/pb_tnc_batch.h"
19 #include "messages/pb_tnc_msg.h"
20 #include "messages/pb_pa_msg.h"
21 #include "messages/pb_error_msg.h"
22 #include "messages/pb_assessment_result_msg.h"
23 #include "messages/pb_access_recommendation_msg.h"
24 #include "messages/pb_remediation_parameters_msg.h"
25 #include "messages/pb_reason_string_msg.h"
26 #include "messages/pb_language_preference_msg.h"
27 #include "state_machine/pb_tnc_state_machine.h"
28
29 #include <tncif_names.h>
30 #include <tncif_pa_subtypes.h>
31
32 #include <tnc/tnc.h>
33 #include <tnc/tnccs/tnccs_manager.h>
34 #include <tnc/imc/imc_manager.h>
35 #include <tnc/imv/imv_manager.h>
36
37 #include <debug.h>
38 #include <threading/mutex.h>
39 #include <pen/pen.h>
40
41 typedef struct private_tnccs_20_t private_tnccs_20_t;
42
43 /**
44 * Private data of a tnccs_20_t object.
45 */
46 struct private_tnccs_20_t {
47
48 /**
49 * Public tls_t interface.
50 */
51 tls_t public;
52
53 /**
54 * TNCC if TRUE, TNCS if FALSE
55 */
56 bool is_server;
57
58 /**
59 * PB-TNC State Machine
60 */
61 pb_tnc_state_machine_t *state_machine;
62
63 /**
64 * Connection ID assigned to this TNCCS connection
65 */
66 TNC_ConnectionID connection_id;
67
68 /**
69 * PB-TNC batch being constructed
70 */
71 pb_tnc_batch_t *batch;
72
73 /**
74 * Mutex locking the batch in construction
75 */
76 mutex_t *mutex;
77
78 /**
79 * Flag set while processing
80 */
81 bool fatal_error;
82
83 /**
84 * Flag set by IMC/IMV RequestHandshakeRetry() function
85 */
86 bool request_handshake_retry;
87
88 /**
89 * SendMessage() by IMC/IMV only allowed if flag is set
90 */
91 bool send_msg;
92
93 /**
94 * Set of IMV recommendations (TNC Server only)
95 */
96 recommendations_t *recs;
97
98 };
99
100 METHOD(tnccs_t, send_msg, TNC_Result,
101 private_tnccs_20_t* this, TNC_IMCID imc_id, TNC_IMVID imv_id,
102 TNC_UInt32 msg_flags,
103 TNC_BufferReference msg,
104 TNC_UInt32 msg_len,
105 TNC_VendorID msg_vid,
106 TNC_MessageSubtype msg_subtype)
107 {
108 pb_tnc_msg_t *pb_tnc_msg;
109 pb_tnc_batch_type_t batch_type;
110 enum_name_t *pa_subtype_names;
111 bool excl;
112
113 if (!this->send_msg)
114 {
115 DBG1(DBG_TNC, "%s %u not allowed to call SendMessage()",
116 this->is_server ? "IMV" : "IMC",
117 this->is_server ? imv_id : imc_id);
118 return TNC_RESULT_ILLEGAL_OPERATION;
119 }
120 excl = (msg_flags & TNC_MESSAGE_FLAGS_EXCLUSIVE) != 0;
121
122 pb_tnc_msg = pb_pa_msg_create(msg_vid, msg_subtype, imc_id, imv_id,
123 excl, chunk_create(msg, msg_len));
124
125 pa_subtype_names = get_pa_subtype_names(msg_vid);
126 if (pa_subtype_names)
127 {
128 DBG2(DBG_TNC, "creating PB-PA message type '%N/%N' 0x%06x/0x%08x",
129 pen_names, msg_vid, pa_subtype_names, msg_subtype,
130 msg_vid, msg_subtype);
131 }
132 else
133 {
134 DBG2(DBG_TNC, "creating PB-PA message type '%N' 0x%06x/0x%08x",
135 pen_names, msg_vid, msg_vid, msg_subtype);
136 }
137
138 /* adding PA message to SDATA or CDATA batch only */
139 batch_type = this->is_server ? PB_BATCH_SDATA : PB_BATCH_CDATA;
140 this->mutex->lock(this->mutex);
141 if (!this->batch)
142 {
143 this->batch = pb_tnc_batch_create(this->is_server, batch_type);
144 }
145 if (this->batch->get_type(this->batch) == batch_type)
146 {
147 this->batch->add_msg(this->batch, pb_tnc_msg);
148 }
149 else
150 {
151 pb_tnc_msg->destroy(pb_tnc_msg);
152 }
153 this->mutex->unlock(this->mutex);
154 return TNC_RESULT_SUCCESS;
155 }
156
157 /**
158 * Handle a single PB-TNC message according to its type
159 */
160 static void handle_message(private_tnccs_20_t *this, pb_tnc_msg_t *msg)
161 {
162 switch (msg->get_type(msg))
163 {
164 case PB_MSG_EXPERIMENTAL:
165 /* nothing to do */
166 break;
167 case PB_MSG_PA:
168 {
169 pb_pa_msg_t *pa_msg;
170 u_int32_t msg_vid, msg_subtype;
171 u_int16_t imc_id, imv_id;
172 chunk_t msg_body;
173 bool excl;
174 enum_name_t *pa_subtype_names;
175
176 pa_msg = (pb_pa_msg_t*)msg;
177 msg_vid = pa_msg->get_vendor_id(pa_msg, &msg_subtype);
178 msg_body = pa_msg->get_body(pa_msg);
179 imc_id = pa_msg->get_collector_id(pa_msg);
180 imv_id = pa_msg->get_validator_id(pa_msg);
181 excl = pa_msg->get_exclusive_flag(pa_msg);
182
183 pa_subtype_names = get_pa_subtype_names(msg_vid);
184 if (pa_subtype_names)
185 {
186 DBG2(DBG_TNC, "handling PB-PA message type '%N/%N' 0x%06x/0x%08x",
187 pen_names, msg_vid, pa_subtype_names, msg_subtype,
188 msg_vid, msg_subtype);
189 }
190 else
191 {
192 DBG2(DBG_TNC, "handling PB-PA message type '%N' 0x%06x/0x%08x",
193 pen_names, msg_vid, msg_vid, msg_subtype);
194 }
195
196 this->send_msg = TRUE;
197 if (this->is_server)
198 {
199 tnc->imvs->receive_message(tnc->imvs, this->connection_id,
200 excl, msg_body.ptr, msg_body.len,
201 msg_vid, msg_subtype, imc_id, imv_id);
202 }
203 else
204 {
205 tnc->imcs->receive_message(tnc->imcs, this->connection_id,
206 excl, msg_body.ptr, msg_body.len,
207 msg_vid, msg_subtype, imv_id, imc_id);
208 }
209 this->send_msg = FALSE;
210 break;
211 }
212 case PB_MSG_ASSESSMENT_RESULT:
213 {
214 pb_assessment_result_msg_t *assess_msg;
215 u_int32_t result;
216
217 assess_msg = (pb_assessment_result_msg_t*)msg;
218 result = assess_msg->get_assessment_result(assess_msg);
219 DBG1(DBG_TNC, "PB-TNC assessment result is '%N'",
220 TNC_IMV_Evaluation_Result_names, result);
221 break;
222 }
223 case PB_MSG_ACCESS_RECOMMENDATION:
224 {
225 pb_access_recommendation_msg_t *rec_msg;
226 pb_access_recommendation_code_t rec;
227 TNC_ConnectionState state = TNC_CONNECTION_STATE_ACCESS_NONE;
228
229 rec_msg = (pb_access_recommendation_msg_t*)msg;
230 rec = rec_msg->get_access_recommendation(rec_msg);
231 DBG1(DBG_TNC, "PB-TNC access recommendation is '%N'",
232 pb_access_recommendation_code_names, rec);
233 switch (rec)
234 {
235 case PB_REC_ACCESS_ALLOWED:
236 state = TNC_CONNECTION_STATE_ACCESS_ALLOWED;
237 break;
238 case PB_REC_ACCESS_DENIED:
239 state = TNC_CONNECTION_STATE_ACCESS_NONE;
240 break;
241 case PB_REC_QUARANTINED:
242 state = TNC_CONNECTION_STATE_ACCESS_ISOLATED;
243 }
244 tnc->imcs->notify_connection_change(tnc->imcs, this->connection_id,
245 state);
246 break;
247 }
248 case PB_MSG_REMEDIATION_PARAMETERS:
249 {
250 /* TODO : Remediation parameters message processing */
251 break;
252 }
253 case PB_MSG_ERROR:
254 {
255 pb_error_msg_t *err_msg;
256 bool fatal;
257 u_int32_t vendor_id;
258 u_int16_t error_code;
259
260 err_msg = (pb_error_msg_t*)msg;
261 fatal = err_msg->get_fatal_flag(err_msg);
262 vendor_id = err_msg->get_vendor_id(err_msg);
263 error_code = err_msg->get_error_code(err_msg);
264
265 if (fatal)
266 {
267 this->fatal_error = TRUE;
268 }
269
270 if (vendor_id == PEN_IETF)
271 {
272 switch (error_code)
273 {
274 case PB_ERROR_INVALID_PARAMETER:
275 case PB_ERROR_UNSUPPORTED_MANDATORY_MSG:
276 DBG1(DBG_TNC, "received %s PB-TNC error '%N' "
277 "(offset %u bytes)",
278 fatal ? "fatal" : "non-fatal",
279 pb_tnc_error_code_names, error_code,
280 err_msg->get_offset(err_msg));
281 break;
282 case PB_ERROR_VERSION_NOT_SUPPORTED:
283 DBG1(DBG_TNC, "received %s PB-TNC error '%N' "
284 "caused by bad version 0x%02x",
285 fatal ? "fatal" : "non-fatal",
286 pb_tnc_error_code_names, error_code,
287 err_msg->get_bad_version(err_msg));
288 break;
289 case PB_ERROR_UNEXPECTED_BATCH_TYPE:
290 case PB_ERROR_LOCAL_ERROR:
291 default:
292 DBG1(DBG_TNC, "received %s PB-TNC error '%N'",
293 fatal ? "fatal" : "non-fatal",
294 pb_tnc_error_code_names, error_code);
295 break;
296 }
297 }
298 else
299 {
300 DBG1(DBG_TNC, "received %s PB-TNC error (%u) "
301 "with Vendor ID 0x%06x",
302 fatal ? "fatal" : "non-fatal",
303 error_code, vendor_id);
304 }
305 break;
306 }
307 case PB_MSG_LANGUAGE_PREFERENCE:
308 {
309 pb_language_preference_msg_t *lang_msg;
310 chunk_t lang;
311
312 lang_msg = (pb_language_preference_msg_t*)msg;
313 lang = lang_msg->get_language_preference(lang_msg);
314
315 DBG2(DBG_TNC, "setting language preference to '%.*s'",
316 lang.len, lang.ptr);
317 this->recs->set_preferred_language(this->recs, lang);
318 break;
319 }
320 case PB_MSG_REASON_STRING:
321 {
322 pb_reason_string_msg_t *reason_msg;
323 chunk_t reason_string, language_code;
324
325 reason_msg = (pb_reason_string_msg_t*)msg;
326 reason_string = reason_msg->get_reason_string(reason_msg);
327 language_code = reason_msg->get_language_code(reason_msg);
328 DBG2(DBG_TNC, "reason string is '%.*s'", reason_string.len,
329 reason_string.ptr);
330 DBG2(DBG_TNC, "language code is '%.*s'", language_code.len,
331 language_code.ptr);
332 break;
333 }
334 default:
335 break;
336 }
337 }
338
339 /**
340 * Build a CRETRY or SRETRY batch
341 */
342 static void build_retry_batch(private_tnccs_20_t *this)
343 {
344 pb_tnc_batch_type_t batch_retry_type;
345
346 batch_retry_type = this->is_server ? PB_BATCH_SRETRY : PB_BATCH_CRETRY;
347 if (this->batch)
348 {
349 if (this->batch->get_type(this->batch) == batch_retry_type)
350 {
351 /* retry batch has already been created */
352 return;
353 }
354 DBG1(DBG_TNC, "cancelling PB-TNC %N batch",
355 pb_tnc_batch_type_names, this->batch->get_type(this->batch));
356 this->batch->destroy(this->batch);
357 }
358 if (this->is_server)
359 {
360 tnc->imvs->notify_connection_change(tnc->imvs, this->connection_id,
361 TNC_CONNECTION_STATE_HANDSHAKE);
362 }
363 this->batch = pb_tnc_batch_create(this->is_server, batch_retry_type);
364 }
365
366 METHOD(tls_t, process, status_t,
367 private_tnccs_20_t *this, void *buf, size_t buflen)
368 {
369 chunk_t data;
370 pb_tnc_batch_t *batch;
371 pb_tnc_msg_t *msg;
372 enumerator_t *enumerator;
373 status_t status;
374
375 if (this->is_server && !this->connection_id)
376 {
377 this->connection_id = tnc->tnccs->create_connection(tnc->tnccs,
378 TNCCS_2_0, (tnccs_t*)this, _send_msg,
379 &this->request_handshake_retry, &this->recs);
380 if (!this->connection_id)
381 {
382 return FAILED;
383 }
384 tnc->imvs->notify_connection_change(tnc->imvs, this->connection_id,
385 TNC_CONNECTION_STATE_CREATE);
386 tnc->imvs->notify_connection_change(tnc->imvs, this->connection_id,
387 TNC_CONNECTION_STATE_HANDSHAKE);
388 }
389
390 data = chunk_create(buf, buflen);
391 DBG1(DBG_TNC, "received TNCCS batch (%u bytes) for Connection ID %u",
392 data.len, this->connection_id);
393 DBG3(DBG_TNC, "%B", &data);
394 batch = pb_tnc_batch_create_from_data(this->is_server, data);
395 status = batch->process(batch, this->state_machine);
396
397 if (status != FAILED)
398 {
399 enumerator_t *enumerator;
400 pb_tnc_msg_t *msg;
401 pb_tnc_batch_type_t batch_type;
402 bool empty = TRUE;
403
404 batch_type = batch->get_type(batch);
405
406 if (batch_type == PB_BATCH_CRETRY)
407 {
408 /* Send an SRETRY batch in response */
409 this->mutex->lock(this->mutex);
410 build_retry_batch(this);
411 this->mutex->unlock(this->mutex);
412 }
413 else if (batch_type == PB_BATCH_SRETRY)
414 {
415 /* Restart the measurements */
416 tnc->imcs->notify_connection_change(tnc->imcs,
417 this->connection_id, TNC_CONNECTION_STATE_HANDSHAKE);
418 this->send_msg = TRUE;
419 tnc->imcs->begin_handshake(tnc->imcs, this->connection_id);
420 this->send_msg = FALSE;
421 }
422
423 enumerator = batch->create_msg_enumerator(batch);
424 while (enumerator->enumerate(enumerator, &msg))
425 {
426 handle_message(this, msg);
427 empty = FALSE;
428 }
429 enumerator->destroy(enumerator);
430
431 /* received an empty CLOSE batch from PB-TNC client */
432 if (this->is_server && batch_type == PB_BATCH_CLOSE && empty)
433 {
434 batch->destroy(batch);
435 if (this->fatal_error)
436 {
437 DBG1(DBG_TNC, "a fatal PB-TNC error occurred, "
438 "terminating connection");
439 return FAILED;
440 }
441 else
442 {
443 return SUCCESS;
444 }
445 }
446
447 this->send_msg = TRUE;
448 if (this->is_server)
449 {
450 tnc->imvs->batch_ending(tnc->imvs, this->connection_id);
451 }
452 else
453 {
454 tnc->imcs->batch_ending(tnc->imcs, this->connection_id);
455 }
456 this->send_msg = FALSE;
457 }
458
459 switch (status)
460 {
461 case FAILED:
462 this->fatal_error = TRUE;
463 this->mutex->lock(this->mutex);
464 if (this->batch)
465 {
466 DBG1(DBG_TNC, "cancelling PB-TNC %N batch",
467 pb_tnc_batch_type_names, this->batch->get_type(this->batch));
468 this->batch->destroy(this->batch);
469 }
470 this->batch = pb_tnc_batch_create(this->is_server, PB_BATCH_CLOSE);
471 this->mutex->unlock(this->mutex);
472 /* fall through to add error messages to outbound batch */
473 case VERIFY_ERROR:
474 enumerator = batch->create_error_enumerator(batch);
475 while (enumerator->enumerate(enumerator, &msg))
476 {
477 this->mutex->lock(this->mutex);
478 this->batch->add_msg(this->batch, msg->get_ref(msg));
479 this->mutex->unlock(this->mutex);
480 }
481 enumerator->destroy(enumerator);
482 break;
483 case SUCCESS:
484 default:
485 break;
486 }
487 batch->destroy(batch);
488
489 return NEED_MORE;
490 }
491
492 /**
493 * Build a RESULT batch if a final recommendation is available
494 */
495 static void check_and_build_recommendation(private_tnccs_20_t *this)
496 {
497 TNC_IMV_Action_Recommendation rec;
498 TNC_IMV_Evaluation_Result eval;
499 TNC_IMVID id;
500 chunk_t reason, language;
501 enumerator_t *enumerator;
502 pb_tnc_msg_t *msg;
503 pb_access_recommendation_code_t pb_rec;
504
505 if (!this->recs->have_recommendation(this->recs, &rec, &eval))
506 {
507 tnc->imvs->solicit_recommendation(tnc->imvs, this->connection_id);
508 }
509 if (this->recs->have_recommendation(this->recs, &rec, &eval))
510 {
511 this->batch = pb_tnc_batch_create(this->is_server, PB_BATCH_RESULT);
512
513 msg = pb_assessment_result_msg_create(eval);
514 this->batch->add_msg(this->batch, msg);
515
516 /**
517 * Map IMV Action Recommendation codes to PB Access Recommendation codes
518 */
519 switch (rec)
520 {
521 case TNC_IMV_ACTION_RECOMMENDATION_ALLOW:
522 pb_rec = PB_REC_ACCESS_ALLOWED;
523 break;
524 case TNC_IMV_ACTION_RECOMMENDATION_ISOLATE:
525 pb_rec = PB_REC_QUARANTINED;
526 break;
527 case TNC_IMV_ACTION_RECOMMENDATION_NO_ACCESS:
528 case TNC_IMV_ACTION_RECOMMENDATION_NO_RECOMMENDATION:
529 default:
530 pb_rec = PB_REC_ACCESS_DENIED;
531 }
532 msg = pb_access_recommendation_msg_create(pb_rec);
533 this->batch->add_msg(this->batch, msg);
534
535 enumerator = this->recs->create_reason_enumerator(this->recs);
536 while (enumerator->enumerate(enumerator, &id, &reason, &language))
537 {
538 msg = pb_reason_string_msg_create(reason, language);
539 this->batch->add_msg(this->batch, msg);
540 }
541 enumerator->destroy(enumerator);
542 this->recs->clear_reasons(this->recs);
543 }
544 }
545
546 METHOD(tls_t, build, status_t,
547 private_tnccs_20_t *this, void *buf, size_t *buflen, size_t *msglen)
548 {
549 status_t status;
550 pb_tnc_state_t state;
551
552 /* Initialize the connection */
553 if (!this->is_server && !this->connection_id)
554 {
555 pb_tnc_msg_t *msg;
556 char *pref_lang;
557
558 this->connection_id = tnc->tnccs->create_connection(tnc->tnccs,
559 TNCCS_2_0, (tnccs_t*)this, _send_msg,
560 &this->request_handshake_retry, NULL);
561 if (!this->connection_id)
562 {
563 return FAILED;
564 }
565
566 /* Create PB-TNC Language Preference message */
567 pref_lang = tnc->imcs->get_preferred_language(tnc->imcs);
568 msg = pb_language_preference_msg_create(chunk_create(pref_lang,
569 strlen(pref_lang)));
570 this->mutex->lock(this->mutex);
571 this->batch = pb_tnc_batch_create(this->is_server, PB_BATCH_CDATA);
572 this->batch->add_msg(this->batch, msg);
573 this->mutex->unlock(this->mutex);
574
575 tnc->imcs->notify_connection_change(tnc->imcs, this->connection_id,
576 TNC_CONNECTION_STATE_CREATE);
577 tnc->imcs->notify_connection_change(tnc->imcs, this->connection_id,
578 TNC_CONNECTION_STATE_HANDSHAKE);
579 this->send_msg = TRUE;
580 tnc->imcs->begin_handshake(tnc->imcs, this->connection_id);
581 this->send_msg = FALSE;
582 }
583
584 state = this->state_machine->get_state(this->state_machine);
585
586 if (this->is_server && this->fatal_error && state == PB_STATE_END)
587 {
588 DBG1(DBG_TNC, "a fatal PB-TNC error occurred, terminating connection");
589 return FAILED;
590 }
591
592 /* Do not allow any asynchronous IMCs or IMVs to add additional messages */
593 this->mutex->lock(this->mutex);
594
595 if (this->request_handshake_retry)
596 {
597 if (state != PB_STATE_INIT)
598 {
599 build_retry_batch(this);
600 }
601
602 /* Reset the flag for the next handshake retry request */
603 this->request_handshake_retry = FALSE;
604 }
605
606 if (!this->batch)
607 {
608 if (this->is_server)
609 {
610 if (state == PB_STATE_SERVER_WORKING)
611 {
612 check_and_build_recommendation(this);
613 }
614 }
615 else
616 {
617 /**
618 * if the DECIDED state has been reached and no CRETRY is under way
619 * or if a CLOSE batch with error messages has been received,
620 * a PB-TNC client replies with an empty CLOSE batch.
621 */
622 if (state == PB_STATE_DECIDED || state == PB_STATE_END)
623 {
624 this->batch = pb_tnc_batch_create(this->is_server, PB_BATCH_CLOSE);
625 }
626 }
627 }
628
629 if (this->batch)
630 {
631 pb_tnc_batch_type_t batch_type;
632 chunk_t data;
633
634 batch_type = this->batch->get_type(this->batch);
635
636 if (this->state_machine->send_batch(this->state_machine, batch_type))
637 {
638 this->batch->build(this->batch);
639 data = this->batch->get_encoding(this->batch);
640 DBG1(DBG_TNC, "sending PB-TNC %N batch (%d bytes) for Connection ID %u",
641 pb_tnc_batch_type_names, batch_type, data.len,
642 this->connection_id);
643 DBG3(DBG_TNC, "%B", &data);
644 *msglen = data.len;
645
646 if (data.len > *buflen)
647 {
648 DBG1(DBG_TNC, "fragmentation of PB-TNC batch not supported yet");
649 }
650 else
651 {
652 *buflen = data.len;
653 }
654 memcpy(buf, data.ptr, *buflen);
655 status = ALREADY_DONE;
656 }
657 else
658 {
659 DBG1(DBG_TNC, "cancelling unexpected PB-TNC batch type: %N",
660 pb_tnc_batch_type_names, batch_type);
661 status = INVALID_STATE;
662 }
663
664 this->batch->destroy(this->batch);
665 this->batch = NULL;
666 }
667 else
668 {
669 DBG1(DBG_TNC, "no PB-TNC batch to send");
670 status = INVALID_STATE;
671 }
672 this->mutex->unlock(this->mutex);
673
674 return status;
675 }
676
677 METHOD(tls_t, is_server, bool,
678 private_tnccs_20_t *this)
679 {
680 return this->is_server;
681 }
682
683 METHOD(tls_t, get_purpose, tls_purpose_t,
684 private_tnccs_20_t *this)
685 {
686 return TLS_PURPOSE_EAP_TNC;
687 }
688
689 METHOD(tls_t, is_complete, bool,
690 private_tnccs_20_t *this)
691 {
692 TNC_IMV_Action_Recommendation rec;
693 TNC_IMV_Evaluation_Result eval;
694
695 if (this->recs && this->recs->have_recommendation(this->recs, &rec, &eval))
696 {
697 return tnc->imvs->enforce_recommendation(tnc->imvs, rec, eval);
698 }
699 else
700 {
701 return FALSE;
702 }
703 }
704
705 METHOD(tls_t, get_eap_msk, chunk_t,
706 private_tnccs_20_t *this)
707 {
708 return chunk_empty;
709 }
710
711 METHOD(tls_t, destroy, void,
712 private_tnccs_20_t *this)
713 {
714 tnc->tnccs->remove_connection(tnc->tnccs, this->connection_id,
715 this->is_server);
716 this->state_machine->destroy(this->state_machine);
717 this->mutex->destroy(this->mutex);
718 DESTROY_IF(this->batch);
719 free(this);
720 }
721
722 /**
723 * See header
724 */
725 tls_t *tnccs_20_create(bool is_server)
726 {
727 private_tnccs_20_t *this;
728
729 INIT(this,
730 .public = {
731 .process = _process,
732 .build = _build,
733 .is_server = _is_server,
734 .get_purpose = _get_purpose,
735 .is_complete = _is_complete,
736 .get_eap_msk = _get_eap_msk,
737 .destroy = _destroy,
738 },
739 .is_server = is_server,
740 .state_machine = pb_tnc_state_machine_create(is_server),
741 .mutex = mutex_create(MUTEX_TYPE_DEFAULT),
742 );
743
744 return &this->public;
745 }