| 1 | /** |
| 2 | * @file routingtable_probe.c |
| 3 | * @brief routingtable probe |
| 4 | * @author "Daniel Kopecek <[email protected]>" |
| 5 | */ |
| 6 | |
| 7 | /* |
| 8 | * Copyright 2009-2012 Red Hat Inc., Durham, North Carolina. |
| 9 | * All Rights Reserved. |
| 10 | * |
| 11 | * This library is free software; you can redistribute it and/or |
| 12 | * modify it under the terms of the GNU Lesser General Public |
| 13 | * License as published by the Free Software Foundation; either |
| 14 | * version 2.1 of the License, or (at your option) any later version. |
| 15 | * |
| 16 | * This library is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 19 | * Lesser General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU Lesser General Public |
| 22 | * License along with this library; if not, write to the Free Software |
| 23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 24 | * |
| 25 | * Authors: |
| 26 | * Daniel Kopecek <[email protected]> |
| 27 | */ |
| 28 | |
| 29 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`! |
| 30 | #include <config.h>cxx . . $ `<file>/build/config.h`/ |
| 31 | #endif |
| 32 | |
| 33 | #include <stdlib.h> |
| 34 | #include <string.h> |
| 35 | #include <stdio.h> |
| 36 | #include <errno.h> |
| 37 | #if defined(OS_APPLE) |
| 38 | #include <machine/endian.h> |
| 39 | #elif defined(OS_FREEBSD) |
| 40 | #include <sys/endian.h> |
| 41 | #include <sys/socket.h> |
| 42 | #else |
| 43 | #include <endian.h> |
| 44 | #endif |
| 45 | #include <netinet/in.h> |
| 46 | #include <netinet/ip.h> |
| 47 | #include <netinet/ip6.h> |
| 48 | #include <net/route.h> |
| 49 | #include <arpa/inet.h> |
| 50 | |
| 51 | #include "probe-api.h"cxx . . $ `<file>/src/OVAL/probes/public/probe-api.h`/ |
| 52 | #include "probe/entcmp.h"cxx . . $ `<file>/src/OVAL/probes/probe/entcmp.h`/ |
| 53 | #include "util.h"cxx . . $ `<file>/src/common/util.h`/ |
| 54 | #include "debug_priv.h"cxx . . $ `<file>/src/common/debug_priv.h`/ |
| 55 | #include "SEAP/generic/strto.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/generic/strto.h`/ |
| 56 | #include "routingtable_probe.h"cxx . . $ `<file>/src/OVAL/probes/unix/routingtable_probe.h`/ |
| 57 | |
| 58 | #ifndef RT_FLAGS_MAX |
| 59 | #define RT_FLAGS_MAXcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:59:9`! 10 |
| 60 | #endif |
| 61 | |
| 62 | #ifndef IF_NAME_MAXLEN |
| 63 | #define IF_NAME_MAXLENcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:63:9`! 128 |
| 64 | #endif |
| 65 | |
| 66 | #define RT_INFO_DELIMITERScxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:66:9`! " \t" |
| 67 | |
| 68 | #ifndef htobe32cxx . . $ `<external>/15855202785537844739/endian.h:44:11`! |
| 69 | #ifdef OS_APPLE |
| 70 | #include <libkern/OSByteOrder.h> |
| 71 | #define __bswap_16 OSSwapInt16 |
| 72 | #define __bswap_32 OSSwapInt32 |
| 73 | #define __bswap_64 OSSwapInt64 |
| 74 | #else |
| 75 | #include <byteswap.h> |
| 76 | #endif |
| 77 | # if BYTE_ORDER == LITTLE_ENDIAN |
| 78 | # define htobe32(x) __bswap_32 (x) |
| 79 | # else |
| 80 | # define htobe32(x) (x) |
| 81 | # endif |
| 82 | #endif |
| 83 | |
| 84 | struct route_infocxx . . $ route_info# { |
| 85 | SEXP_tcxx . . $ SEXP_t# *ip_dst_entcxx . . $ route_info#ip_dst_ent.; |
| 86 | char ip_dstcxx . . $ route_info#ip_dst.[INET6_ADDRSTRLENcxx . . $ `<external>/9581057695539925927/in.h:245:9`!+1]; |
| 87 | char ip_gwcxx . . $ route_info#ip_gw.[INET6_ADDRSTRLENcxx . . $ `<external>/9581057695539925927/in.h:245:9`!+1]; |
| 88 | char *rt_flagscxx . . $ route_info#rt_flags.[RT_FLAGS_MAXcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:59:9`!+1]; |
| 89 | char if_namecxx . . $ route_info#if_name.[IF_NAME_MAXLENcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:63:9`!+1]; |
| 90 | int ip_versioncxx . . $ route_info#ip_version.; |
| 91 | }; |
| 92 | |
| 93 | static int hexstring2bincxx . . $ hexstring2bin(775d45c77b2f56b1).(const char *hexstr, size_t hexlen, uint8_tcxx . . $ uint8_t# *binbuf, size_t binlen) |
| 94 | { |
| 95 | register size_t i, l; |
| 96 | |
| 97 | if (hexlen % 2 != 0) { |
| 98 | return -1; |
| 99 | } |
| 100 | if (binlen * 2 < hexlen) { |
| 101 | return -1; |
| 102 | } |
| 103 | |
| 104 | for (l = 0, i = 0; i < hexlen; ++i,++i,++l) { |
| 105 | binbuf[l] = strto_uint8_hexcxx . . $ strto_uint8_hex(bed8015c5369ce1c).(hexstr + i, 2, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 106 | if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != 0) |
| 107 | return -1; |
| 108 | } |
| 109 | |
| 110 | return 0; |
| 111 | } |
| 112 | |
| 113 | static int collect_itemcxx . . $ collect_item(7e6adc4e6c998463).(struct route_infocxx . . $ route_info# *rt, probe_ctxcxx . . $ probe_ctx# *ctx) |
| 114 | { |
| 115 | SEXP_tcxx . . $ SEXP_t# *item, *rt_dst; |
| 116 | oval_datatype_tcxx . . $ oval_datatype_t# addr_type; |
| 117 | |
| 118 | rt_dst = SEXP_string_newcxx . . $ SEXP_string_new(a588a58d7514eee2).(rt->ip_dstcxx . . $ route_info#ip_dst., strlencxx . . $ strlen(751346f8406fd082).(rt->ip_dstcxx . . $ route_info#ip_dst.)); |
| 119 | |
| 120 | if (probe_entobj_cmpcxx . . $ probe_entobj_cmp(e245451a1311e799).(rt->ip_dst_entcxx . . $ route_info#ip_dst_ent., rt_dst) != OVAL_RESULT_TRUEcxx . . $ OVAL_RESULT_TRUE.) { |
| 121 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(rt_dst); |
| 122 | return 0; |
| 123 | } |
| 124 | |
| 125 | addr_type = rt->ip_versioncxx . . $ route_info#ip_version. == 4 ? OVAL_DATATYPE_IPV4ADDRcxx . . $ OVAL_DATATYPE_IPV4ADDR. : OVAL_DATATYPE_IPV6ADDRcxx . . $ OVAL_DATATYPE_IPV6ADDR.; |
| 126 | |
| 127 | /* create the item */ |
| 128 | item = probe_item_createcxx . . $ probe_item_create(36b16a6622050a9c).(OVAL_UNIX_ROUTINGTABLEcxx . . $ OVAL_UNIX_ROUTINGTABLE., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 129 | "destination", addr_type, rt->ip_dstcxx . . $ route_info#ip_dst., |
| 130 | "gateway", addr_type, rt->ip_gwcxx . . $ route_info#ip_gw., |
| 131 | "flags", OVAL_DATATYPE_STRING_Mcxx . . $ OVAL_DATATYPE_STRING_M., rt->rt_flagscxx . . $ route_info#rt_flags., |
| 132 | "interface_name", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., rt->if_namecxx . . $ route_info#if_name., |
| 133 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 134 | |
| 135 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(rt_dst); |
| 136 | return probe_item_collectcxx . . $ probe_item_collect(11bb80e0c30650d7).(ctx, item) == 2 ? 1 : 0; |
| 137 | } |
| 138 | |
| 139 | static int proc_ip4_to_stringcxx . . $ proc_ip4_to_string(73d11290252f426c).(const char *proc_ip, size_t proc_iplen, char *strbuf, size_t strbuflen) |
| 140 | { |
| 141 | uint8_tcxx . . $ uint8_t# bb[4]; |
| 142 | uint32_tcxx . . $ uint32_t# *addr = (uint32_tcxx . . $ uint32_t# *)bb; |
| 143 | struct in_addrcxx . . $ in_addr# ip4; |
| 144 | |
| 145 | if (strbuf == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 146 | return -1; |
| 147 | } |
| 148 | if (proc_ip == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || proc_iplen <= 0) { |
| 149 | return -1; |
| 150 | } |
| 151 | |
| 152 | if (hexstring2bincxx . . $ hexstring2bin(775d45c77b2f56b1).(proc_ip, proc_iplen, bb, sizeof bb) != 0) |
| 153 | return -1; |
| 154 | |
| 155 | ip4.s_addrcxx . . $ in_addr#s_addr. = htobe32cxx . . $ `<external>/15855202785537844739/endian.h:44:11`!(*addr); |
| 156 | |
| 157 | if (inet_ntopcxx . . $ inet_ntop(6a923972b45bea03).(AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!, &ip4, strbuf, strbuflen) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 158 | return -1; |
| 159 | return 0; |
| 160 | } |
| 161 | |
| 162 | static int proc_ip6_to_stringcxx . . $ proc_ip6_to_string(73d11290252f426c).(const char *proc_ip, size_t proc_iplen, char *strbuf, size_t strbuflen) |
| 163 | { |
| 164 | struct in6_addrcxx . . $ in6_addr# ip6; |
| 165 | |
| 166 | if (strbuf == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 167 | return -1; |
| 168 | } |
| 169 | if (proc_ip == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || proc_iplen <= 0) { |
| 170 | return -1; |
| 171 | } |
| 172 | |
| 173 | if (hexstring2bincxx . . $ hexstring2bin(775d45c77b2f56b1).(proc_ip, proc_iplen, (uint8_tcxx . . $ uint8_t# *)&ip6, sizeof ip6) != 0) |
| 174 | return -1; |
| 175 | if (inet_ntopcxx . . $ inet_ntop(6a923972b45bea03).(AF_INET6cxx . . $ `<external>/8962547315054503424/socket.h:105:9`!, &ip6, strbuf, strbuflen) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 176 | return -1; |
| 177 | return 0; |
| 178 | } |
| 179 | |
| 180 | static int process_line_ip4cxx . . $ process_line_ip4(b2e9ace46ff5f6ac).(char *line, struct route_infocxx . . $ route_info# *rt) |
| 181 | { |
| 182 | char *token[8]; |
| 183 | char *save; |
| 184 | uint16_tcxx . . $ uint16_t# rt_flags; |
| 185 | register int i; |
| 186 | |
| 187 | if (line == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || rt == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 188 | return -1; |
| 189 | } |
| 190 | |
| 191 | save = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 192 | token[0] = strtok_rcxx . . $ strtok_r(a42394c85d6397dd).(line, RT_INFO_DELIMITERScxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:66:9`!, &save); |
| 193 | |
| 194 | for (i = 1; i < 4; ++i) { |
| 195 | token[i] = strtok_rcxx . . $ strtok_r(a42394c85d6397dd).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, RT_INFO_DELIMITERScxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:66:9`!, &save); |
| 196 | if (token[i] == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 197 | return -1; |
| 198 | } |
| 199 | /* Tokens |
| 200 | * 0 - interface name |
| 201 | * 1 - destination |
| 202 | * 2 - gateway |
| 203 | * 3 - flags |
| 204 | * 7 - netmask |
| 205 | */ |
| 206 | #define TOK_dstcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:206:9`! token[1] |
| 207 | #define TOK_gwcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:207:9`! token[2] |
| 208 | #define TOK_flagscxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:208:9`! token[3] |
| 209 | #define TOK_ifnamecxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:209:9`! token[0] |
| 210 | |
| 211 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("name=%s, dst=%s, gw=%s, flags=%s", TOK_ifnamecxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:209:9`!, TOK_dstcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:206:9`!, TOK_gwcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:207:9`!, TOK_flagscxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:208:9`!); |
| 212 | |
| 213 | if (proc_ip4_to_stringcxx . . $ proc_ip4_to_string(73d11290252f426c).(TOK_dstcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:206:9`!, strlencxx . . $ strlen(751346f8406fd082).(TOK_dstcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:206:9`!), rt->ip_dstcxx . . $ route_info#ip_dst., sizeof rt->ip_dstcxx . . $ route_info#ip_dst.) != 0 || |
| 214 | proc_ip4_to_stringcxx . . $ proc_ip4_to_string(73d11290252f426c).(TOK_gwcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:207:9`!, strlencxx . . $ strlen(751346f8406fd082).(TOK_gwcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:207:9`!), rt->ip_gwcxx . . $ route_info#ip_gw., sizeof rt->ip_gwcxx . . $ route_info#ip_gw.) != 0) |
| 215 | return -1; |
| 216 | |
| 217 | strncpycxx . . $ strncpy(255158a415b673b0).(rt->if_namecxx . . $ route_info#if_name., TOK_ifnamecxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:209:9`!, IF_NAME_MAXLENcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:63:9`!); /* interface name */ |
| 218 | rt_flags = strto_uint16_hexcxx . . $ strto_uint16_hex(f59bab64af29db4).(TOK_flagscxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:208:9`!, strlencxx . . $ strlen(751346f8406fd082).(TOK_flagscxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:208:9`!), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 219 | |
| 220 | if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != 0) |
| 221 | return -1; |
| 222 | |
| 223 | #define RT_COND_ADD_FLAGcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:223:9`!(flag, value) if (rt_flags & (flag)) rt->rt_flags[i++] = (value) |
| 224 | |
| 225 | i = 0; |
| 226 | RT_COND_ADD_FLAGcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:223:9`!(RTF_UPcxx . . $ `<external>/1775280733820361975/route.h:72:9`!, "UP"); |
| 227 | RT_COND_ADD_FLAGcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:223:9`!(RTF_GATEWAYcxx . . $ `<external>/1775280733820361975/route.h:73:9`!, "GATEWAY"); |
| 228 | RT_COND_ADD_FLAGcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:223:9`!(RTF_HOSTcxx . . $ `<external>/1775280733820361975/route.h:75:9`!, "HOST"); |
| 229 | #if !defined(OS_APPLE) && !defined(OS_FREEBSD) |
| 230 | RT_COND_ADD_FLAGcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:223:9`!(RTF_REINSTATEcxx . . $ `<external>/1775280733820361975/route.h:76:9`!, "REINSTATE"); |
| 231 | #endif |
| 232 | RT_COND_ADD_FLAGcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:223:9`!(RTF_DYNAMICcxx . . $ `<external>/1775280733820361975/route.h:77:9`!, "DYNAMIC"); |
| 233 | RT_COND_ADD_FLAGcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:223:9`!(RTF_MODIFIEDcxx . . $ `<external>/1775280733820361975/route.h:78:9`!, "MODIFIED"); |
| 234 | RT_COND_ADD_FLAGcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:223:9`!(RTF_REJECTcxx . . $ `<external>/1775280733820361975/route.h:83:9`!, "REJECT"); |
| 235 | rt->rt_flagscxx . . $ route_info#rt_flags.[i] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 236 | |
| 237 | #undef TOK_dstcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:206:9`! |
| 238 | #undef TOK_gwcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:207:9`! |
| 239 | #undef TOK_flagscxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:208:9`! |
| 240 | #undef TOK_ifnamecxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:209:9`! |
| 241 | rt->ip_versioncxx . . $ route_info#ip_version. = 4; |
| 242 | return 0; |
| 243 | } |
| 244 | |
| 245 | static int process_line_ip6cxx . . $ process_line_ip6(b2e9ace46ff5f6ac).(char *line, struct route_infocxx . . $ route_info# *rt) |
| 246 | { |
| 247 | char *token[10]; |
| 248 | char *save; |
| 249 | uint32_tcxx . . $ uint32_t# rt_flags; |
| 250 | register int i; |
| 251 | |
| 252 | if (line == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || rt == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 253 | return -1; |
| 254 | } |
| 255 | |
| 256 | save = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 257 | token[0] = strtok_rcxx . . $ strtok_r(a42394c85d6397dd).(line, RT_INFO_DELIMITERScxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:66:9`!, &save); |
| 258 | |
| 259 | for (i = 1; i < 10; ++i) { |
| 260 | token[i] = strtok_rcxx . . $ strtok_r(a42394c85d6397dd).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, RT_INFO_DELIMITERScxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:66:9`!, &save); |
| 261 | if (token[i] == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 262 | return -1; |
| 263 | } |
| 264 | |
| 265 | /* Tokens |
| 266 | * 0 - destination |
| 267 | * 4 - gateway |
| 268 | * 8 - flags |
| 269 | * 9 - interface name |
| 270 | */ |
| 271 | #define TOK_dstcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:271:9`! token[0] |
| 272 | #define TOK_gwcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:272:9`! token[4] |
| 273 | #define TOK_flagscxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:273:9`! token[8] |
| 274 | #define TOK_ifnamecxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:274:9`! token[9] |
| 275 | |
| 276 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("name=%s, dst=%s, gw=%s, flags=%s", TOK_ifnamecxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:274:9`!, TOK_dstcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:271:9`!, TOK_gwcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:272:9`!, TOK_flagscxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:273:9`!); |
| 277 | |
| 278 | if (proc_ip6_to_stringcxx . . $ proc_ip6_to_string(73d11290252f426c).(TOK_dstcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:271:9`!, strlencxx . . $ strlen(751346f8406fd082).(TOK_dstcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:271:9`!), rt->ip_dstcxx . . $ route_info#ip_dst., sizeof rt->ip_dstcxx . . $ route_info#ip_dst.) != 0 || |
| 279 | proc_ip6_to_stringcxx . . $ proc_ip6_to_string(73d11290252f426c).(TOK_gwcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:272:9`!, strlencxx . . $ strlen(751346f8406fd082).(TOK_gwcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:272:9`!), rt->ip_gwcxx . . $ route_info#ip_gw., sizeof rt->ip_gwcxx . . $ route_info#ip_gw.) != 0) |
| 280 | return -1; |
| 281 | |
| 282 | strncpycxx . . $ strncpy(255158a415b673b0).(rt->if_namecxx . . $ route_info#if_name., TOK_ifnamecxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:274:9`!, IF_NAME_MAXLENcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:63:9`!); /* interface name */ |
| 283 | rt_flags = strto_uint32_hexcxx . . $ strto_uint32_hex(1de33d2aa378899).(TOK_flagscxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:273:9`!, strlencxx . . $ strlen(751346f8406fd082).(TOK_flagscxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:273:9`!), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 284 | if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != 0) |
| 285 | return -1; |
| 286 | |
| 287 | i = 0; |
| 288 | RT_COND_ADD_FLAGcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:223:9`!(RTF_UPcxx . . $ `<external>/1775280733820361975/route.h:72:9`!, "UP"); |
| 289 | RT_COND_ADD_FLAGcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:223:9`!(RTF_GATEWAYcxx . . $ `<external>/1775280733820361975/route.h:73:9`!, "GATEWAY"); |
| 290 | RT_COND_ADD_FLAGcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:223:9`!(RTF_HOSTcxx . . $ `<external>/1775280733820361975/route.h:75:9`!, "HOST"); |
| 291 | RT_COND_ADD_FLAGcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:223:9`!(RTF_DYNAMICcxx . . $ `<external>/1775280733820361975/route.h:77:9`!, "DYNAMIC"); |
| 292 | RT_COND_ADD_FLAGcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:223:9`!(RTF_MODIFIEDcxx . . $ `<external>/1775280733820361975/route.h:78:9`!, "MODIFIED"); |
| 293 | RT_COND_ADD_FLAGcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:223:9`!(RTF_REJECTcxx . . $ `<external>/1775280733820361975/route.h:83:9`!, "REJECT"); |
| 294 | #if !defined(OS_APPLE) && !defined(OS_FREEBSD) |
| 295 | RT_COND_ADD_FLAGcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:223:9`!(RTF_REINSTATEcxx . . $ `<external>/1775280733820361975/route.h:76:9`!, "REINSTATE"); |
| 296 | RT_COND_ADD_FLAGcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:223:9`!(RTF_ADDRCONFcxx . . $ `<external>/1775280733820361975/route.h:93:9`!, "ADDRCONF"); |
| 297 | RT_COND_ADD_FLAGcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:223:9`!(RTF_CACHEcxx . . $ `<external>/1775280733820361975/route.h:98:9`!, "CACHE"); |
| 298 | #endif |
| 299 | rt->rt_flagscxx . . $ route_info#rt_flags.[i] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 300 | |
| 301 | #undef TOK_dstcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:271:9`! |
| 302 | #undef TOK_gwcxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:272:9`! |
| 303 | #undef TOK_flagscxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:273:9`! |
| 304 | #undef TOK_ifnamecxx . . $ `src/OVAL/probes/unix/routingtable_probe.c:274:9`! |
| 305 | rt->ip_versioncxx . . $ route_info#ip_version. = 6; |
| 306 | return 0; |
| 307 | } |
| 308 | |
| 309 | int routingtable_probe_maincxx . . $ routingtable_probe_main(470536d3ffacaf10).(probe_ctxcxx . . $ probe_ctx# *ctx, void *arg) |
| 310 | { |
| 311 | SEXP_tcxx . . $ SEXP_t# *probe_in, *dst_ent; |
| 312 | FILEcxx . . $ FILE# *fp; |
| 313 | char *line_buf; |
| 314 | size_t line_len; |
| 315 | struct route_infocxx . . $ route_info# rt; |
| 316 | int probe_ret = 0; |
| 317 | |
| 318 | probe_in = probe_ctx_getobjectcxx . . $ probe_ctx_getobject(4299b6b53fa804a5).(ctx); |
| 319 | dst_ent = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "destination", 1); |
| 320 | |
| 321 | if (dst_ent == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 322 | return (PROBE_ENOENTcxx . . $ `src/OVAL/probes/public/probe-api.h:433:9`!); |
| 323 | |
| 324 | rt.ip_dst_entcxx . . $ route_info#ip_dst_ent. = dst_ent; |
| 325 | line_len = 0; |
| 326 | line_buf = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 327 | fp = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 328 | |
| 329 | switch(probe_ent_getdatatypecxx . . $ probe_ent_getdatatype(576ef4d818d367a9).(dst_ent)) { |
| 330 | case OVAL_DATATYPE_IPV4ADDRcxx . . $ OVAL_DATATYPE_IPV4ADDR.: |
| 331 | fp = fopencxx . . $ fopen(82ec0787cd37e0a3).("/proc/net/route", "r"); |
| 332 | /* Skip the header line */ |
| 333 | if (getlinecxx . . $ getline(960b3da7d5d5ad33).(&line_buf, &line_len, fp) != -1) { |
| 334 | while(getlinecxx . . $ getline(960b3da7d5d5ad33).(&line_buf, &line_len, fp) != -1) { |
| 335 | if (process_line_ip4cxx . . $ process_line_ip4(b2e9ace46ff5f6ac).(line_buf, &rt) != 0) |
| 336 | break; |
| 337 | if (collect_itemcxx . . $ collect_item(7e6adc4e6c998463).(&rt, ctx) != 0) |
| 338 | break; |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | if (!feofcxx . . $ feof(89bc1efcdac0ca22).(fp)) { |
| 343 | /* error */ |
| 344 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("An error ocured while reading /proc/net/route: %s", strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 345 | } |
| 346 | break; |
| 347 | case OVAL_DATATYPE_IPV6ADDRcxx . . $ OVAL_DATATYPE_IPV6ADDR.: |
| 348 | fp = fopencxx . . $ fopen(82ec0787cd37e0a3).("/proc/net/ipv6_route", "r"); |
| 349 | |
| 350 | while(getlinecxx . . $ getline(960b3da7d5d5ad33).(&line_buf, &line_len, fp) != -1) { |
| 351 | if (process_line_ip6cxx . . $ process_line_ip6(b2e9ace46ff5f6ac).(line_buf, &rt) != 0) |
| 352 | break; |
| 353 | if (collect_itemcxx . . $ collect_item(7e6adc4e6c998463).(&rt, ctx) != 0) |
| 354 | break; |
| 355 | } |
| 356 | |
| 357 | if (!feofcxx . . $ feof(89bc1efcdac0ca22).(fp)) { |
| 358 | /* error */ |
| 359 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("An error ocured while reading /proc/net/ipv6_route: %s", strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 360 | } |
| 361 | break; |
| 362 | default: |
| 363 | probe_ret = EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!; |
| 364 | } |
| 365 | |
| 366 | if (fp != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 367 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(fp); |
| 368 | if (line_buf != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 369 | freecxx . . $ free(5d22bdacc48458e8).(line_buf); |
| 370 | |
| 371 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(dst_ent); |
| 372 | |
| 373 | return (probe_ret); |
| 374 | } |