394e645905c16d812efb05df60e8223b1f775414
[strongswan.git] / src / libcharon / plugins / tnccs_11 / messages / tnccs_tncs_contact_info_msg.c
1 /*
2 * Copyright (C) 2010 Andreas Steffen, HSR Hochschule fuer Technik Rapperswil
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 */
14
15 #include "tnccs_tncs_contact_info_msg.h"
16
17 #include <debug.h>
18
19 typedef struct private_tnccs_tncs_contact_info_msg_t private_tnccs_tncs_contact_info_msg_t;
20
21 /**
22 * Private data of a tnccs_tncs_contact_info_msg_t object.
23 *
24 */
25 struct private_tnccs_tncs_contact_info_msg_t {
26 /**
27 * Public tnccs_tncs_contact_info_msg_t interface.
28 */
29 tnccs_tncs_contact_info_msg_t public;
30
31 /**
32 * TNCCS message type
33 */
34 tnccs_msg_type_t type;
35
36 /**
37 * XML-encoded message node
38 */
39 xmlNodePtr node;
40 };
41
42 METHOD(tnccs_msg_t, get_type, tnccs_msg_type_t,
43 private_tnccs_tncs_contact_info_msg_t *this)
44 {
45 return this->type;
46 }
47
48 METHOD(tnccs_msg_t, get_node, xmlNodePtr,
49 private_tnccs_tncs_contact_info_msg_t *this)
50 {
51 return this->node;
52 }
53
54 METHOD(tnccs_msg_t, process, status_t,
55 private_tnccs_tncs_contact_info_msg_t *this)
56 {
57 return SUCCESS;
58 }
59 METHOD(tnccs_msg_t, destroy, void,
60 private_tnccs_tncs_contact_info_msg_t *this)
61 {
62 free(this);
63 }
64
65 /**
66 * See header
67 */
68 tnccs_msg_t *tnccs_tncs_contact_info_msg_create_from_node(xmlNodePtr node)
69 {
70 private_tnccs_tncs_contact_info_msg_t *this;
71
72 INIT(this,
73 .public = {
74 .tnccs_msg_interface = {
75 .get_type = _get_type,
76 .get_node = _get_node,
77 .process = _process,
78 .destroy = _destroy,
79 },
80 },
81 .type = TNCCS_MSG_TNCS_CONTACT_INFO,
82 .node = node,
83 );
84
85 return &this->public.tnccs_msg_interface;
86 }
87
88 /**
89 * See header
90 */
91 tnccs_msg_t *tnccs_tncs_contact_info_msg_create(void)
92 {
93 private_tnccs_tncs_contact_info_msg_t *this;
94 xmlNodePtr n, n2;
95
96 INIT(this,
97 .public = {
98 .tnccs_msg_interface = {
99 .get_type = _get_type,
100 .get_node = _get_node,
101 .process = _process,
102 .destroy = _destroy,
103 },
104 },
105 .type = TNCCS_MSG_TNCS_CONTACT_INFO,
106 .node = xmlNewNode(NULL, BAD_CAST "TNCC-TNCS-Message"),
107 );
108
109 /* add the message type number in hex */
110 n = xmlNewNode(NULL, BAD_CAST "Type");
111 xmlNodeSetContent(n, BAD_CAST "00000005");
112 xmlAddChild(this->node, n);
113
114 n = xmlNewNode(NULL, BAD_CAST "XML");
115 xmlAddChild(this->node, n);
116
117 /* TODO
118 n2 = xmlNewNode(NULL, BAD_CAST enum_to_name(tnccs_msg_type_names, this->type));
119 xmlNodeSetContent(n2, BAD_CAST language);
120 xmlAddChild(n, n2);
121 */
122
123 return &this->public.tnccs_msg_interface;
124 }