handle zero size Base64 conversions
[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, destroy, void,
55 private_tnccs_tncs_contact_info_msg_t *this)
56 {
57 free(this);
58 }
59
60 /**
61 * See header
62 */
63 tnccs_msg_t *tnccs_tncs_contact_info_msg_create_from_node(xmlNodePtr node,
64 linked_list_t *errors)
65 {
66 private_tnccs_tncs_contact_info_msg_t *this;
67
68 INIT(this,
69 .public = {
70 .tnccs_msg_interface = {
71 .get_type = _get_type,
72 .get_node = _get_node,
73 .destroy = _destroy,
74 },
75 },
76 .type = TNCCS_MSG_TNCS_CONTACT_INFO,
77 .node = node,
78 );
79
80 return &this->public.tnccs_msg_interface;
81 }
82
83 /**
84 * See header
85 */
86 tnccs_msg_t *tnccs_tncs_contact_info_msg_create(void)
87 {
88 private_tnccs_tncs_contact_info_msg_t *this;
89 xmlNodePtr n, n2;
90
91 INIT(this,
92 .public = {
93 .tnccs_msg_interface = {
94 .get_type = _get_type,
95 .get_node = _get_node,
96 .destroy = _destroy,
97 },
98 },
99 .type = TNCCS_MSG_TNCS_CONTACT_INFO,
100 .node = xmlNewNode(NULL, BAD_CAST "TNCC-TNCS-Message"),
101 );
102
103 /* add the message type number in hex */
104 n = xmlNewNode(NULL, BAD_CAST "Type");
105 xmlNodeSetContent(n, BAD_CAST "00000005");
106 xmlAddChild(this->node, n);
107
108 n = xmlNewNode(NULL, BAD_CAST "XML");
109 xmlAddChild(this->node, n);
110
111 /* TODO
112 n2 = xmlNewNode(NULL, BAD_CAST enum_to_name(tnccs_msg_type_names, this->type));
113 xmlNodeSetContent(n2, BAD_CAST language);
114 xmlAddChild(n, n2);
115 */
116
117 return &this->public.tnccs_msg_interface;
118 }