| 1 | /** |
| 2 | * @file oval_sysInterface.c |
| 3 | * \brief Open Vulnerability and Assessment Language |
| 4 | * |
| 5 | * See more details at http://oval.mitre.org/ |
| 6 | */ |
| 7 | |
| 8 | /* |
| 9 | * Copyright 2009--2013 Red Hat Inc., Durham, North Carolina. |
| 10 | * All Rights Reserved. |
| 11 | * |
| 12 | * This library is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU Lesser General Public |
| 14 | * License as published by the Free Software Foundation; either |
| 15 | * version 2.1 of the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This library is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 20 | * Lesser General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU Lesser General Public |
| 23 | * License along with this library; if not, write to the Free Software |
| 24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 25 | * |
| 26 | * Authors: |
| 27 | * "David Niemoller" <[email protected]> |
| 28 | */ |
| 29 | |
| 30 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`! |
| 31 | #include <config.h>cxx . . $ `<file>/build/config.h`/ |
| 32 | #endif |
| 33 | |
| 34 | #include <stdlib.h> |
| 35 | #include <stdio.h> |
| 36 | #include <string.h> |
| 37 | |
| 38 | #include "oval_system_characteristics_impl.h"cxx . . $ `<file>/src/OVAL/oval_system_characteristics_impl.h`/ |
| 39 | #include "adt/oval_collection_impl.h"cxx . . $ `<file>/src/OVAL/adt/oval_collection_impl.h`/ |
| 40 | #include "oval_agent_api_impl.h"cxx . . $ `<file>/src/OVAL/oval_agent_api_impl.h`/ |
| 41 | #include "common/util.h"cxx . . $ `<file>/src/common/util.h`/ |
| 42 | #include "common/debug_priv.h"cxx . . $ `<file>/src/common/debug_priv.h`/ |
| 43 | #include "common/elements.h"cxx . . $ `<file>/src/common/elements.h`/ |
| 44 | |
| 45 | typedef struct oval_sysintcxx . . $ oval_sysint# { |
| 46 | struct oval_syschar_modelcxx . . $ oval_syschar_model# *modelcxx . . $ oval_sysint#model.; |
| 47 | char *namecxx . . $ oval_sysint#name.; |
| 48 | char *ipAddresscxx . . $ oval_sysint#ipAddress.; |
| 49 | char *macAddresscxx . . $ oval_sysint#macAddress.; |
| 50 | } oval_sysint_tcxx . . $ oval_sysint_t#; |
| 51 | |
| 52 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oval_sysint_iterator_has_morecxx . . $ oval_sysint_iterator_has_more(82c7feae2a9cd430).(struct oval_sysint_iteratorcxx . . $ oval_sysint_iterator# *oc_sysint) |
| 53 | { |
| 54 | return oval_collection_iterator_has_morecxx . . $ oval_collection_iterator_has_more(de0650ab9b639739).((struct oval_iteratorcxx . . $ oval_iterator# *) |
| 55 | oc_sysint); |
| 56 | } |
| 57 | |
| 58 | struct oval_sysintcxx . . $ oval_sysint# *oval_sysint_iterator_nextcxx . . $ oval_sysint_iterator_next(101f83f3fa1031d3).(struct oval_sysint_iteratorcxx . . $ oval_sysint_iterator# *oc_sysint) |
| 59 | { |
| 60 | return (struct oval_sysintcxx . . $ oval_sysint# *) |
| 61 | oval_collection_iterator_nextcxx . . $ oval_collection_iterator_next(344074693c9690a9).((struct oval_iteratorcxx . . $ oval_iterator# *)oc_sysint); |
| 62 | } |
| 63 | |
| 64 | void oval_sysint_iterator_freecxx . . $ oval_sysint_iterator_free(743dd6c60b6d8a68).(struct oval_sysint_iteratorcxx . . $ oval_sysint_iterator# *oc_sysint) |
| 65 | { |
| 66 | oval_collection_iterator_freecxx . . $ oval_collection_iterator_free(ee496816570b41f7).((struct oval_iteratorcxx . . $ oval_iterator# *)oc_sysint); |
| 67 | } |
| 68 | |
| 69 | char *oval_sysint_get_namecxx . . $ oval_sysint_get_name(a961f0d91592921c).(struct oval_sysintcxx . . $ oval_sysint# *sysint) |
| 70 | { |
| 71 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(sysint); |
| 72 | |
| 73 | return sysint->namecxx . . $ oval_sysint#name.; |
| 74 | } |
| 75 | |
| 76 | void oval_sysint_set_namecxx . . $ oval_sysint_set_name(aa1f755b9dc07b7d).(struct oval_sysintcxx . . $ oval_sysint# *sysint, char *name) |
| 77 | { |
| 78 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(sysint); |
| 79 | if (sysint->namecxx . . $ oval_sysint#name. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 80 | freecxx . . $ free(5d22bdacc48458e8).(sysint->namecxx . . $ oval_sysint#name.); |
| 81 | sysint->namecxx . . $ oval_sysint#name. = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(name); |
| 82 | } |
| 83 | |
| 84 | char *oval_sysint_get_ip_addresscxx . . $ oval_sysint_get_ip_address(a961f0d91592921c).(struct oval_sysintcxx . . $ oval_sysint# *sysint) |
| 85 | { |
| 86 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(sysint); |
| 87 | |
| 88 | return ((struct oval_sysintcxx . . $ oval_sysint# *)sysint)->ipAddresscxx . . $ oval_sysint#ipAddress.; |
| 89 | } |
| 90 | |
| 91 | void oval_sysint_set_ip_addresscxx . . $ oval_sysint_set_ip_address(aa1f755b9dc07b7d).(struct oval_sysintcxx . . $ oval_sysint# *sysint, char *ip_address) |
| 92 | { |
| 93 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(sysint); |
| 94 | if (sysint->ipAddresscxx . . $ oval_sysint#ipAddress. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 95 | freecxx . . $ free(5d22bdacc48458e8).(sysint->ipAddresscxx . . $ oval_sysint#ipAddress.); |
| 96 | sysint->ipAddresscxx . . $ oval_sysint#ipAddress. = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(ip_address); |
| 97 | } |
| 98 | |
| 99 | char *oval_sysint_get_mac_addresscxx . . $ oval_sysint_get_mac_address(a961f0d91592921c).(struct oval_sysintcxx . . $ oval_sysint# *sysint) |
| 100 | { |
| 101 | return ((struct oval_sysintcxx . . $ oval_sysint# *)sysint)->macAddresscxx . . $ oval_sysint#macAddress.; |
| 102 | } |
| 103 | |
| 104 | void oval_sysint_set_mac_addresscxx . . $ oval_sysint_set_mac_address(aa1f755b9dc07b7d).(struct oval_sysintcxx . . $ oval_sysint# *sysint, char *mac_address) |
| 105 | { |
| 106 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(sysint); |
| 107 | if (sysint->macAddresscxx . . $ oval_sysint#macAddress. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 108 | freecxx . . $ free(5d22bdacc48458e8).(sysint->macAddresscxx . . $ oval_sysint#macAddress.); |
| 109 | sysint->macAddresscxx . . $ oval_sysint#macAddress. = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(mac_address); |
| 110 | } |
| 111 | |
| 112 | struct oval_sysintcxx . . $ oval_sysint# *oval_sysint_newcxx . . $ oval_sysint_new(c6d52d0a5f55bfef).(struct oval_syschar_modelcxx . . $ oval_syschar_model# *model) |
| 113 | { |
| 114 | oval_sysint_tcxx . . $ oval_sysint_t# *sysint = (oval_sysint_tcxx . . $ oval_sysint_t# *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(oval_sysint_tcxx . . $ oval_sysint_t#)); |
| 115 | if (sysint == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 116 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 117 | |
| 118 | sysint->ipAddresscxx . . $ oval_sysint#ipAddress. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 119 | sysint->macAddresscxx . . $ oval_sysint#macAddress. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 120 | sysint->namecxx . . $ oval_sysint#name. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 121 | sysint->modelcxx . . $ oval_sysint#model. = model; |
| 122 | return sysint; |
| 123 | } |
| 124 | |
| 125 | struct oval_sysintcxx . . $ oval_sysint# *oval_sysint_clonecxx . . $ oval_sysint_clone(d2e9490a5e3bc825).(struct oval_syschar_modelcxx . . $ oval_syschar_model# *new_model, struct oval_sysintcxx . . $ oval_sysint# *old_sysint) |
| 126 | { |
| 127 | struct oval_sysintcxx . . $ oval_sysint# *new_sysint = oval_sysint_newcxx . . $ oval_sysint_new(c6d52d0a5f55bfef).(new_model); |
| 128 | char *ip_address = oval_sysint_get_ip_addresscxx . . $ oval_sysint_get_ip_address(a961f0d91592921c).(old_sysint); |
| 129 | if (ip_address) { |
| 130 | oval_sysint_set_ip_addresscxx . . $ oval_sysint_set_ip_address(aa1f755b9dc07b7d).(new_sysint, ip_address); |
| 131 | } |
| 132 | char *mac_address = oval_sysint_get_mac_addresscxx . . $ oval_sysint_get_mac_address(a961f0d91592921c).(old_sysint); |
| 133 | if (mac_address) { |
| 134 | oval_sysint_set_mac_addresscxx . . $ oval_sysint_set_mac_address(aa1f755b9dc07b7d).(new_sysint, mac_address); |
| 135 | } |
| 136 | char *name = oval_sysint_get_namecxx . . $ oval_sysint_get_name(a961f0d91592921c).(old_sysint); |
| 137 | if (name) { |
| 138 | oval_sysint_set_namecxx . . $ oval_sysint_set_name(aa1f755b9dc07b7d).(new_sysint, name); |
| 139 | } |
| 140 | return new_sysint; |
| 141 | } |
| 142 | |
| 143 | void oval_sysint_freecxx . . $ oval_sysint_free(70dc35ae4d1efae1).(struct oval_sysintcxx . . $ oval_sysint# *sysint) |
| 144 | { |
| 145 | if (sysint == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 146 | return; |
| 147 | |
| 148 | if (sysint->ipAddresscxx . . $ oval_sysint#ipAddress. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 149 | freecxx . . $ free(5d22bdacc48458e8).(sysint->ipAddresscxx . . $ oval_sysint#ipAddress.); |
| 150 | if (sysint->macAddresscxx . . $ oval_sysint#macAddress. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 151 | freecxx . . $ free(5d22bdacc48458e8).(sysint->macAddresscxx . . $ oval_sysint#macAddress.); |
| 152 | if (sysint->namecxx . . $ oval_sysint#name. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 153 | freecxx . . $ free(5d22bdacc48458e8).(sysint->namecxx . . $ oval_sysint#name.); |
| 154 | |
| 155 | sysint->ipAddresscxx . . $ oval_sysint#ipAddress. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 156 | sysint->macAddresscxx . . $ oval_sysint#macAddress. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 157 | sysint->namecxx . . $ oval_sysint#name. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 158 | |
| 159 | freecxx . . $ free(5d22bdacc48458e8).(sysint); |
| 160 | } |
| 161 | |
| 162 | static void oval_consume_interface_namecxx . . $ oval_consume_interface_name(75961c4613ebf8f5).(char *text, void *sysint) |
| 163 | { |
| 164 | oval_sysint_set_namecxx . . $ oval_sysint_set_name(aa1f755b9dc07b7d).(sysint, text); |
| 165 | } |
| 166 | |
| 167 | static void oval_consume_ip_addresscxx . . $ oval_consume_ip_address(75961c4613ebf8f5).(char *text, void *sysint) |
| 168 | { |
| 169 | oval_sysint_set_ip_addresscxx . . $ oval_sysint_set_ip_address(aa1f755b9dc07b7d).(sysint, text); |
| 170 | } |
| 171 | |
| 172 | static void oval_consume_mac_addresscxx . . $ oval_consume_mac_address(75961c4613ebf8f5).(char *text, void *sysint) |
| 173 | { |
| 174 | oval_sysint_set_mac_addresscxx . . $ oval_sysint_set_mac_address(aa1f755b9dc07b7d).(sysint, text); |
| 175 | } |
| 176 | |
| 177 | static int _oval_sysint_parse_tagcxx . . $ _oval_sysint_parse_tag(cf369959597901d1).(xmlTextReaderPtrcxx . . $ xmlTextReaderPtr# reader, struct oval_parser_contextcxx . . $ oval_parser_context# *context, void *user) |
| 178 | { |
| 179 | struct oval_sysintcxx . . $ oval_sysint# *sysint = (struct oval_sysintcxx . . $ oval_sysint# *)user; |
| 180 | char *tagname = (char *)xmlTextReaderLocalNamecxx . . $ xmlTextReaderLocalName(3322afb275581432).(reader); |
| 181 | char *namespace = (char *)xmlTextReaderNamespaceUricxx . . $ xmlTextReaderNamespaceUri(3322afb275581432).(reader); |
| 182 | int return_code = 0; |
| 183 | |
| 184 | int is_ovalsys = 0; |
| 185 | if (namespace != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 186 | is_ovalsys = strcmpcxx . . $ strcmp(5ae29d726ae57f88).((const char *)OVAL_SYSCHAR_NAMESPACEcxx . . $ `src/OVAL/oval_agent_api_impl.h:43:9`!, namespace) == 0; |
| 187 | } |
| 188 | if (is_ovalsys && (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(tagname, "interface_name") == 0)) { |
| 189 | return_code = oscap_parser_text_valuecxx . . $ oscap_parser_text_value(23cd2d9646b6359b).(reader, &oval_consume_interface_namecxx . . $ oval_consume_interface_name(75961c4613ebf8f5)., sysint); |
| 190 | } else if (is_ovalsys && (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(tagname, "ip_address") == 0)) { |
| 191 | return_code = oscap_parser_text_valuecxx . . $ oscap_parser_text_value(23cd2d9646b6359b).(reader, &oval_consume_ip_addresscxx . . $ oval_consume_ip_address(75961c4613ebf8f5)., sysint); |
| 192 | } else if (is_ovalsys && (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(tagname, "mac_address") == 0)) { |
| 193 | return_code = oscap_parser_text_valuecxx . . $ oscap_parser_text_value(23cd2d9646b6359b).(reader, &oval_consume_mac_addresscxx . . $ oval_consume_mac_address(75961c4613ebf8f5)., sysint); |
| 194 | } else { |
| 195 | dWcxx . . $ `src/common/debug_priv.h:62:9`!("Skipping tag: <%s:%s>.", namespace, tagname); |
| 196 | oval_parser_skip_tagcxx . . $ oval_parser_skip_tag(b61d4daae99e998a).(reader, context); |
| 197 | } |
| 198 | |
| 199 | freecxx . . $ free(5d22bdacc48458e8).(tagname); |
| 200 | freecxx . . $ free(5d22bdacc48458e8).(namespace); |
| 201 | |
| 202 | return return_code; |
| 203 | } |
| 204 | |
| 205 | int oval_sysint_parse_tagcxx . . $ oval_sysint_parse_tag(2c2f409365e8510f).(xmlTextReaderPtrcxx . . $ xmlTextReaderPtr# reader, |
| 206 | struct oval_parser_contextcxx . . $ oval_parser_context# *context, oval_sysint_consumercxx . . $ oval_sysint_consumer# consumer, void *user) |
| 207 | { |
| 208 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(context); |
| 209 | |
| 210 | struct oval_sysintcxx . . $ oval_sysint# *sysint = oval_sysint_newcxx . . $ oval_sysint_new(c6d52d0a5f55bfef).(context->syschar_modelcxx . . $ oval_parser_context#syschar_model.); |
| 211 | char *tagname = (char *)xmlTextReaderLocalNamecxx . . $ xmlTextReaderLocalName(3322afb275581432).(reader); |
| 212 | char *namespace = (char *)xmlTextReaderNamespaceUricxx . . $ xmlTextReaderNamespaceUri(3322afb275581432).(reader); |
| 213 | int return_code = 0; |
| 214 | |
| 215 | int is_ovalsys = 0; |
| 216 | if (namespace != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 217 | is_ovalsys = strcmpcxx . . $ strcmp(5ae29d726ae57f88).((const char *)OVAL_SYSCHAR_NAMESPACEcxx . . $ `src/OVAL/oval_agent_api_impl.h:43:9`!, namespace) == 0; |
| 218 | } |
| 219 | if (is_ovalsys && (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(tagname, "interface") == 0)) { |
| 220 | return_code = oval_parser_parse_tagcxx . . $ oval_parser_parse_tag(4eaaf867ce26f59b).(reader, context, &_oval_sysint_parse_tagcxx . . $ _oval_sysint_parse_tag(cf369959597901d1)., sysint); |
| 221 | } else { |
| 222 | dWcxx . . $ `src/common/debug_priv.h:62:9`!("Skipping tag: <%s:%s>.", namespace, tagname); |
| 223 | oval_parser_skip_tagcxx . . $ oval_parser_skip_tag(b61d4daae99e998a).(reader, context); |
| 224 | } |
| 225 | |
| 226 | (*consumer) (sysint, user); |
| 227 | |
| 228 | freecxx . . $ free(5d22bdacc48458e8).(tagname); |
| 229 | freecxx . . $ free(5d22bdacc48458e8).(namespace); |
| 230 | |
| 231 | return return_code; |
| 232 | } |
| 233 | |
| 234 | void oval_sysint_to_domcxx . . $ oval_sysint_to_dom(458b3e60bc6ae3a7).(struct oval_sysintcxx . . $ oval_sysint# *sysint, xmlDoccxx . . $ xmlDoc# * doc, xmlNodecxx . . $ xmlNode# * tag_parent) |
| 235 | { |
| 236 | if (sysint) { |
| 237 | xmlNscxx . . $ xmlNs# *ns_syschar = xmlSearchNsByHrefcxx . . $ xmlSearchNsByHref(d0fb0b6b99319c4).(doc, tag_parent, OVAL_SYSCHAR_NAMESPACEcxx . . $ `src/OVAL/oval_agent_api_impl.h:43:9`!); |
| 238 | xmlNodecxx . . $ xmlNode# *tag_sysint = xmlNewTextChildcxx . . $ xmlNewTextChild(4c74f4d7754e7bc8).(tag_parent, ns_syschar, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "interface", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 239 | xmlNewTextChildcxx . . $ xmlNewTextChild(4c74f4d7754e7bc8).(tag_sysint, ns_syschar, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "interface_name", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! oval_sysint_get_namecxx . . $ oval_sysint_get_name(a961f0d91592921c).(sysint)); |
| 240 | xmlNewTextChildcxx . . $ xmlNewTextChild(4c74f4d7754e7bc8).(tag_sysint, ns_syschar, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "ip_address", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! oval_sysint_get_ip_addresscxx . . $ oval_sysint_get_ip_address(a961f0d91592921c).(sysint)); |
| 241 | xmlNewTextChildcxx . . $ xmlNewTextChild(4c74f4d7754e7bc8). |
| 242 | (tag_sysint, ns_syschar, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "mac_address", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! oval_sysint_get_mac_addresscxx . . $ oval_sysint_get_mac_address(a961f0d91592921c).(sysint)); |
| 243 | } |
| 244 | } |