Open SCAP Library
Loading...
Searching...
No Matches
probe-api.h
Go to the documentation of this file.
1
35/*
36 * Copyright 2009 Red Hat Inc., Durham, North Carolina.
37 * All Rights Reserved.
38 *
39 * This library is free software; you can redistribute it and/or
40 * modify it under the terms of the GNU Lesser General Public
41 * License as published by the Free Software Foundation; either
42 * version 2.1 of the License, or (at your option) any later version.
43 *
44 * This library is distributed in the hope that it will be useful,
45 * but WITHOUT ANY WARRANTY; without even the implied warranty of
46 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
47 * Lesser General Public License for more details.
48 *
49 * You should have received a copy of the GNU Lesser General Public
50 * License along with this library; if not, write to the Free Software
51 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
52 *
53 * Authors:
54 * Daniel Kopecek <dkopecek@redhat.com>
55 */
56
57#pragma once
58#ifndef PROBE_API_H
59#define PROBE_API_H
60
61#include <stdarg.h>
62#include <stdint.h>
63#include <stdbool.h>
64#include <pthread.h>
65#include <oval_definitions.h>
67#include <oval_results.h>
68#include <oval_types.h>
69#include "sexp-types.h"
70#include "oscap_export.h"
71
72/*
73 * items
74 */
75
87OSCAP_API SEXP_t *probe_item_creat(const char *name, SEXP_t * attrs, ...);
88
94OSCAP_API SEXP_t *probe_item_new(const char *name, SEXP_t * attrs);
95
103OSCAP_API SEXP_t *probe_item_attr_add(SEXP_t * item, const char *name, SEXP_t * val);
104
113OSCAP_API SEXP_t *probe_item_ent_add(SEXP_t * item, const char *name, SEXP_t * attrs, SEXP_t * val);
114
120OSCAP_API int probe_item_setstatus(SEXP_t * obj, oval_syschar_status_t status);
121
129OSCAP_API int probe_itement_setstatus(SEXP_t * obj, const char *name, uint32_t n, oval_syschar_status_t status);
130
134struct id_desc_t;
135
140OSCAP_API void probe_item_resetidctr(struct id_desc_t *id_desc);
141
142#define probe_item_getent(item, name, n) probe_obj_getent (item, name, n)
143
144/*
145 * attributes
146 */
147
155OSCAP_API SEXP_t *probe_attr_creat(const char *name, const SEXP_t * val, ...);
156
157/*
158 * objects
159 */
160
172OSCAP_API SEXP_t *probe_obj_creat(const char *name, SEXP_t * attrs, ...);
173
180OSCAP_API SEXP_t *probe_obj_new(const char *name, SEXP_t * attrs);
181
188OSCAP_API SEXP_t *probe_obj_getent(const SEXP_t * obj, const char *name, uint32_t n);
189
197OSCAP_API SEXP_t *probe_obj_getentval(const SEXP_t * obj, const char *name, uint32_t n);
198
208OSCAP_API int probe_obj_getentvals(const SEXP_t * obj, const char *name, uint32_t n, SEXP_t ** res);
209
215OSCAP_API SEXP_t *probe_obj_getattrval(const SEXP_t * obj, const char *name);
216
222OSCAP_API bool probe_obj_attrexists(const SEXP_t * obj, const char *name);
223
229OSCAP_API int probe_obj_setstatus(SEXP_t * obj, oval_syschar_status_t status);
230
235OSCAP_API char *probe_obj_getname(const SEXP_t * obj);
236
244OSCAP_API size_t probe_obj_getname_r(const SEXP_t * obj, char *buffer, size_t buflen);
245
246/*
247 * collected objects
248 */
249
250OSCAP_API SEXP_t *probe_cobj_new(oval_syschar_collection_flag_t flag, SEXP_t *msg_list, SEXP_t *item_list, SEXP_t *mask_list);
251OSCAP_API int probe_cobj_add_msg(SEXP_t *cobj, const SEXP_t *msg);
252OSCAP_API SEXP_t *probe_cobj_get_msgs(const SEXP_t *cobj);
253OSCAP_API SEXP_t *probe_cobj_get_mask(const SEXP_t *cobj);
254OSCAP_API int probe_cobj_add_item(SEXP_t *cobj, const SEXP_t *item);
255OSCAP_API SEXP_t *probe_cobj_get_items(const SEXP_t *cobj);
256OSCAP_API void probe_cobj_set_flag(SEXP_t *cobj, oval_syschar_collection_flag_t flag);
257OSCAP_API oval_syschar_collection_flag_t probe_cobj_get_flag(const SEXP_t *cobj);
261OSCAP_API oval_syschar_collection_flag_t probe_cobj_compute_flag(SEXP_t *cobj);
262
263/*
264 * messages
265 */
266
272OSCAP_API SEXP_t *probe_msg_creat(oval_message_level_t level, char *message);
273
280OSCAP_API SEXP_t *probe_msg_creatf(oval_message_level_t level, const char *fmt, ...) __attribute__((format(printf, 2, 3), nonnull(2)));
281
282/*
283 * entities
284 */
285
294OSCAP_API SEXP_t *probe_ent_creat(const char *name, SEXP_t * attrs, SEXP_t * val, ...);
295
303OSCAP_API SEXP_t *probe_ent_creat1(const char *name, SEXP_t * attrs, SEXP_t * val);
304
312OSCAP_API SEXP_t *probe_ent_attr_add(SEXP_t * ent, const char *name, SEXP_t * val);
313
319OSCAP_API SEXP_t *probe_ent_getval(const SEXP_t * ent);
320
328OSCAP_API int probe_ent_getvals(const SEXP_t * ent, SEXP_t ** res);
329
335OSCAP_API SEXP_t *probe_ent_getattrval(const SEXP_t * ent, const char *name);
336
342OSCAP_API bool probe_ent_attrexists(const SEXP_t * ent, const char *name);
343
349OSCAP_API int probe_ent_setdatatype(SEXP_t * ent, oval_datatype_t type);
350
355OSCAP_API oval_datatype_t probe_ent_getdatatype(const SEXP_t * ent);
356
362OSCAP_API int probe_ent_setmask(SEXP_t * ent, bool mask);
363
368OSCAP_API bool probe_ent_getmask(const SEXP_t * ent);
369
375OSCAP_API int probe_ent_setstatus(SEXP_t * ent, oval_syschar_status_t status);
376
382
387OSCAP_API char *probe_ent_getname(const SEXP_t * ent);
388
396OSCAP_API size_t probe_ent_getname_r(const SEXP_t * ent, char *buffer, size_t buflen);
397
402OSCAP_API void probe_free(SEXP_t * obj);
403
410OSCAP_API void probe_filebehaviors_canonicalize(SEXP_t **behaviors);
411
418OSCAP_API void probe_tfc54behaviors_canonicalize(SEXP_t **behaviors);
419
420#define PROBE_EINVAL 1
421#define PROBE_ENOELM 2
422#define PROBE_ENOVAL 3
423#define PROBE_ENOATTR 4
424#define PROBE_EINIT 5
425#define PROBE_ENOMEM 6
426#define PROBE_EOPNOTSUPP 7
427#define PROBE_ERANGE 8
428#define PROBE_EDOM 9
429#define PROBE_EFAULT 10
430#define PROBE_EACCESS 11
431#define PROBE_ESETEVAL 12
432#define PROBE_ENOENT 13
433#define PROBE_ENOOBJ 14
434#define PROBE_ECONNABORTED 15
435#define PROBE_ESYSTEM 253
436#define PROBE_EFATAL 254
437#define PROBE_EUNKNOWN 255
439#define PROBECMD_STE_FETCH 1
440#define PROBECMD_OBJ_EVAL 2
441#define PROBECMD_RESET 3
443typedef struct probe_ctx probe_ctx;
444
445OSCAP_API bool probe_item_filtered(const SEXP_t *item, const SEXP_t *filters);
446
454OSCAP_API int probe_item_collect(probe_ctx *ctx, SEXP_t *item);
455
462OSCAP_API SEXP_t *probe_ctx_getobject(probe_ctx *ctx);
463
469OSCAP_API SEXP_t *probe_ctx_getresult(probe_ctx *ctx);
470
471typedef struct {
472 oval_datatype_t type;
473 void *value;
475
476OSCAP_API SEXP_t *probe_item_create(oval_subtype_t item_subtype, probe_elmatr_t *item_attributes[], ...);
477
478#define PROBE_ENT_AREF(ent, dst, attr_name, invalid_exp) \
479 do { \
480 if (((dst) = probe_ent_getattrval(ent, attr_name)) == NULL) { \
481 dE("Attribute `%s' is missing!", attr_name); \
482 invalid_exp \
483 } \
484 } while(0)
485
486#define PROBE_ENT_STRVAL(ent, dst, dstlen, invalid_exp, zerolen_exp) \
487 do { \
488 SEXP_t *___r; \
489 \
490 if ((___r = probe_ent_getval(ent)) == NULL) { \
491 invalid_exp \
492 } else { \
493 if (!SEXP_stringp(___r)) { \
494 SEXP_free(___r); \
495 invalid_exp \
496 } \
497 else if (SEXP_string_length(___r) == 0) { \
498 SEXP_free(___r); \
499 zerolen_exp \
500 } else { \
501 SEXP_string_cstr_r(___r, dst, dstlen); \
502 SEXP_free(___r); \
503 } \
504 } \
505 } while (0)
506
507#define PROBE_ENT_I32VAL(ent, dst, invalid_exp, nil_exp) \
508 do { \
509 SEXP_t *___r; \
510 \
511 if ((___r = probe_ent_getval(ent)) == NULL) { \
512 nil_exp; \
513 } else { \
514 if (!SEXP_numberp(___r)) { \
515 SEXP_free(___r); \
516 invalid_exp; \
517 } else { \
518 dst = SEXP_number_geti_32(___r); \
519 SEXP_free(___r); \
520 } \
521 } \
522 } while (0)
523
524#endif /* PROBE_API_H */
525
526OSCAP_API oval_operation_t probe_ent_getoperation(SEXP_t *entity, oval_operation_t op);
527
528OSCAP_API int probe_item_add_msg(SEXP_t *item, oval_message_level_t msglvl, char *msgfmt, ...);
529
530OSCAP_API SEXP_t *probe_entval_from_cstr(oval_datatype_t type, const char *value, size_t vallen);
531OSCAP_API SEXP_t *probe_ent_from_cstr(const char *name, oval_datatype_t type, const char *value, size_t vallen);
532
533OSCAP_API oval_schema_version_t probe_obj_get_platform_schema_version(const SEXP_t *obj);
534
539OSCAP_API SEXP_t *probe_obj_getmask(SEXP_t *obj);
540
oval_operation_t
Operations.
Definition: oval_definitions.h:84
oval_setobject_operation_t
Set operations.
Definition: oval_definitions.h:184
oval_datatype_t
Datatypes.
Definition: oval_definitions.h:149
oval_syschar_collection_flag_t
System characteristics result flag.
Definition: oval_system_characteristics.h:50
oval_message_level_t
Message level.
Definition: oval_system_characteristics.h:70
oval_syschar_status_t
System characteristics status.
Definition: oval_system_characteristics.h:61
oval_subtype_t
Unknown subtypes.
Definition: oval_types.h:127
int probe_ent_setdatatype(SEXP_t *ent, oval_datatype_t type)
Set the OVAL data type of an entity.
Definition: probe-api.c:1126
SEXP_t * probe_obj_getentval(const SEXP_t *obj, const char *name, uint32_t n)
Get the value of an object's entity.
Definition: probe-api.c:454
int probe_itement_setstatus(SEXP_t *obj, const char *name, uint32_t n, oval_syschar_status_t status)
Set status of an item's entity.
Definition: probe-api.c:206
SEXP_t * probe_ent_attr_add(SEXP_t *ent, const char *name, SEXP_t *val)
Add a new attribute to an entity.
Definition: probe-api.c:1027
SEXP_t * probe_ent_creat1(const char *name, SEXP_t *attrs, SEXP_t *val)
Create a new entity.
Definition: probe-api.c:999
SEXP_t * probe_ent_creat(const char *name, SEXP_t *attrs, SEXP_t *val,...)
Create a new list of entities.
Definition: probe-api.c:975
int probe_ent_setmask(SEXP_t *ent, bool mask)
Set entity's mask.
Definition: probe-api.c:1198
SEXP_t * probe_attr_creat(const char *name, const SEXP_t *val,...)
Create a new list of attributes.
Definition: probe-api.c:311
oval_datatype_t probe_ent_getdatatype(const SEXP_t *ent)
Get the OVAL data type of an entity.
Definition: probe-api.c:1172
SEXP_t * probe_obj_getattrval(const SEXP_t *obj, const char *name)
Get the value of an object's attribute.
Definition: probe-api.c:501
char * probe_obj_getname(const SEXP_t *obj)
Get the name of an object.
Definition: probe-api.c:604
SEXP_t * probe_item_creat(const char *name, SEXP_t *attrs,...)
Create a new item consisting of a name, optional attributes argument and an arbitrary number of entit...
Definition: probe-api.c:67
int probe_ent_getvals(const SEXP_t *ent, SEXP_t **res)
Get the list of values of an entity.
Definition: probe-api.c:1032
void probe_tfc54behaviors_canonicalize(SEXP_t **behaviors)
Set all of the missing attributes of the 'behaviors' entity to default values.
Definition: probe-api.c:1366
char * probe_ent_getname(const SEXP_t *ent)
Get the name of an entity.
Definition: probe-api.c:1237
oval_syschar_status_t probe_ent_getstatus(const SEXP_t *ent)
Get entity status.
Definition: probe-api.c:1220
SEXP_t * probe_item_new(const char *name, SEXP_t *attrs)
Create a new item with just a name and optional attributes argument.
Definition: probe-api.c:111
size_t probe_obj_getname_r(const SEXP_t *obj, char *buffer, size_t buflen)
Get the name of an object.
Definition: probe-api.c:609
void probe_item_resetidctr(struct id_desc_t *id_desc)
Reset the item id generator.
Definition: probe-api.c:222
SEXP_t * probe_ent_getval(const SEXP_t *ent)
Get the value of an entity.
Definition: probe-api.c:1051
size_t probe_ent_getname_r(const SEXP_t *ent, char *buffer, size_t buflen)
Get the name of an entity.
Definition: probe-api.c:1281
OSCAP_API int probe_item_collect(probe_ctx *ctx, SEXP_t *item)
Collect generated item (i.e.
Definition: icache.c:538
OSCAP_API SEXP_t * probe_ctx_getresult(probe_ctx *ctx)
Return reference to the output object (aka collected object).
Definition: probe.c:36
OSCAP_API SEXP_t * probe_ctx_getobject(probe_ctx *ctx)
Return reference to the input object.
Definition: probe.c:31
bool probe_ent_attrexists(const SEXP_t *ent, const char *name)
Check whether the specified attribute exists.
Definition: probe-api.c:1121
void probe_free(SEXP_t *obj)
Free the memory allocated by the probe_* functions.
Definition: probe-api.c:1325
int probe_ent_setstatus(SEXP_t *ent, oval_syschar_status_t status)
Set entity's status.
Definition: probe-api.c:1210
int probe_obj_getentvals(const SEXP_t *obj, const char *name, uint32_t n, SEXP_t **res)
Get the list of values of an object's entity.
Definition: probe-api.c:466
SEXP_t * probe_item_create(oval_subtype_t item_subtype, probe_elmatr_t *item_attributes[],...)
The order of (value_name, value_type, *value) argument tuples passed as e.g.
Definition: probe-api.c:1413
SEXP_t * probe_item_attr_add(SEXP_t *item, const char *name, SEXP_t *val)
Add a new attribute to an item.
Definition: probe-api.c:137
int probe_item_setstatus(SEXP_t *obj, oval_syschar_status_t status)
Set item's status.
Definition: probe-api.c:194
int probe_obj_setstatus(SEXP_t *obj, oval_syschar_status_t status)
Set objects's status.
Definition: probe-api.c:594
SEXP_t * probe_obj_creat(const char *name, SEXP_t *attrs,...)
Create a new object consisting of a name, optional attributes argument and an arbitrary number of ent...
Definition: probe-api.c:344
SEXP_t * probe_msg_creat(oval_message_level_t level, char *message)
Create a new message that can be added to a collected object.
Definition: probe-api.c:920
SEXP_t * probe_obj_getmask(SEXP_t *obj)
Get object entity mask.
Definition: probe-api.c:1767
SEXP_t * probe_obj_new(const char *name, SEXP_t *attrs)
Create a new object with just a name and optional attributes argument.
Definition: probe-api.c:387
SEXP_t * probe_item_ent_add(SEXP_t *item, const char *name, SEXP_t *attrs, SEXP_t *val)
Add a new entity to an item.
Definition: probe-api.c:183
void probe_filebehaviors_canonicalize(SEXP_t **behaviors)
Set all of the missing attributes of the 'behaviors' entity to default values.
Definition: probe-api.c:1330
SEXP_t * probe_msg_creatf(oval_message_level_t level, const char *fmt,...)
Create a new message that can be added to a collected object.
Definition: probe-api.c:934
bool probe_ent_getmask(const SEXP_t *ent)
Get entity's mask.
Definition: probe-api.c:1204
SEXP_t * probe_ent_getattrval(const SEXP_t *ent, const char *name)
Get the value of an entity's attribute.
Definition: probe-api.c:1076
SEXP_t * probe_obj_getent(const SEXP_t *obj, const char *name, uint32_t n)
Get an entity from an object.
Definition: probe-api.c:411
bool probe_obj_attrexists(const SEXP_t *obj, const char *name)
Check whether the specified attribute exists.
Definition: probe-api.c:547
Definition: sexp-types.h:82
Holds information for item ids generation.
Definition: _probe-api.h:44
Definition: oval_schema_version.h:41
Definition: probe.h:80
SEXP_t * filters
object filters (OVAL 5.8 and higher)
Definition: probe.h:83
Definition: probe-api.h:471