00001 #pragma once
00002 #ifndef PROBE_API_H
00003 #define PROBE_API_H
00004
00005 #include <seap.h>
00006 #include <stdarg.h>
00007 #include <stdint.h>
00008 #include <stdbool.h>
00009 #include <pthread.h>
00010 #include "api/oval_definitions.h"
00011 #include "api/oval_system_characteristics.h"
00012 #include "api/oval_results.h"
00013
00014
00015
00016
00017
00018 SEXP_t *probe_item_build (const char *fmt, ...);
00019
00020 #define probe_item_creat(name, attrs, ...) probe_obj_creat (name, attrs, __VA_ARGS__)
00021
00022 SEXP_t *probe_item_new (const char *name, SEXP_t *attrs);
00023
00024 SEXP_t *probe_item_attr_add ();
00025 SEXP_t *probe_item_ent_add ();
00026
00027 int probe_item_setstatus (SEXP_t *obj, oval_syschar_status_t status);
00028 int probe_itement_setstatus (SEXP_t *obj, const char *name, uint32_t n, oval_syschar_status_t status);
00029
00030
00031
00032
00033
00034 SEXP_t *probe_attr_creat (const char *name, const SEXP_t *val, ...);
00035
00036
00037
00038
00039
00040 SEXP_t *probe_obj_build (const char *fmt, ...);
00041 SEXP_t *probe_obj_creat (const char *name, SEXP_t *attrs, ...);
00042 SEXP_t *probe_obj_new (const char *name, SEXP_t *attrs);
00043
00044 SEXP_t *probe_obj_getent (const SEXP_t *obj, const char *name, uint32_t n);
00045
00046 SEXP_t *probe_obj_getentval (const SEXP_t *obj, const char *name, uint32_t n);
00047 int probe_obj_getentvals (const SEXP_t *obj, const char *name, uint32_t n, SEXP_t **res);
00048
00049 SEXP_t *probe_obj_getattrval (const SEXP_t *obj, const char *name);
00050 bool probe_obj_attrexists (const SEXP_t *obj, const char *name);
00051
00052 int probe_obj_setstatus (SEXP_t *obj, oval_syschar_status_t status);
00053 int probe_objent_setstatus (SEXP_t *obj, const char *name, uint32_t n, oval_syschar_status_t status);
00054
00055
00056
00057
00058
00059 SEXP_t *probe_ent_creat (const char *name, SEXP_t *attrs, ...);
00060
00061 SEXP_t *probe_ent_attr_add (SEXP_t *ent, const char *name, SEXP_t *val);
00062
00063 SEXP_t *probe_ent_getval (const SEXP_t *ent);
00064 int probe_ent_getvals (const SEXP_t *ent, SEXP_t **res);
00065
00066 SEXP_t *probe_ent_getattrval (const SEXP_t *ent, const char *name);
00067 bool probe_ent_attrexists (const SEXP_t *ent, const char *name);
00068
00069 int probe_ent_setdatatype (SEXP_t *ent, oval_datatype_t type);
00070 oval_datatype_t probe_ent_getdatatype (const SEXP_t *ent);
00071
00072 int probe_ent_setmask (SEXP_t *ent, bool mask);
00073 bool probe_ent_getmask (const SEXP_t *ent);
00074
00075 int probe_ent_setstatus (SEXP_t *ent, oval_syschar_status_t status);
00076 oval_syschar_status_t probe_ent_getstatus (const SEXP_t *ent);
00077
00078 char *probe_ent_getname (const SEXP_t *ent);
00079 char *probe_ent_getname_r (const SEXP_t *ent, char *buffer, size_t buflen);
00080
00081 #define PROBE_EINVAL 1
00082 #define PROBE_ENOELM 2
00083 #define PROBE_ENOVAL 3
00084 #define PROBE_ENOATTR 4
00085 #define PROBE_EINIT 5
00086 #define PROBE_ENOMEM 6
00087 #define PROBE_EOPNOTSUPP 7
00088 #define PROBE_ERANGE 8
00089 #define PROBE_EDOM 9
00090 #define PROBE_EFAULT 10
00091 #define PROBE_EACCES 11
00092 #define PROBE_EUNKNOWN 255
00093
00094
00095 #define OVAL_STATUS_ERROR 1
00096 #define OVAL_STATUS_EXISTS 2
00097 #define OVAL_STATUS_DOESNOTEXIST 3
00098 #define OVAL_STATUS_NOTCOLLECTED 4
00099
00100 #define PROBECMD_STE_FETCH 1
00101 #define PROBECMD_OBJ_EVAL 2
00102
00103 #include <probe-cache.h>
00104
00105 struct id_desc_t {
00106 #ifndef HAVE_ATOMIC_FUNCTIONS
00107 pthread_mutex_t item_id_ctr_lock;
00108 #endif
00109 int item_id_ctr;
00110 };
00111
00112 SEXP_t *SEXP_OVALitem_newid(struct id_desc_t *id_desc);
00113 void SEXP_OVALitem_resetid(struct id_desc_t *id_desc);
00114
00115 typedef struct {
00116
00117 SEAP_CTX_t *ctx;
00118 int sd;
00119
00120
00121 pcache_t *pcache;
00122 pthread_rwlock_t pcache_lock;
00123
00124 struct id_desc_t id_desc;
00125
00126
00127 void *probe_arg;
00128 } globals_t;
00129
00130 #if defined(HAVE_ATOMIC_FUNCTIONS)
00131 #define GLOBALS_INITIALIZER { NULL, -1, NULL, PTHREAD_MUTEX_INITIALIZER, {1}, NULL }
00132 #else
00133 #define GLOBALS_INITIALIZER { NULL, -1, NULL, PTHREAD_MUTEX_INITIALIZER, {PTHREAD_MUTEX_INITIALIZER, 1}, NULL }
00134 #endif
00135
00136 extern globals_t global;
00137
00138 #define READER_LOCK_CACHE pthread_rwlock_rdlock (&globals.pcache_lock)
00139 #define WRITER_LOCK_CACHE pthread_rwlock_wrlock (&globals.pcache_lock)
00140 #define READER_UNLOCK_CACHE pthread_rwlock_unlock (&globals.pcache_lock)
00141 #define WRITER_UNLOCK_CACHE pthread_rwlock_unlock (&globals.pcache_lock)
00142
00143 #define SEAP_LOCK pthread_mutex_lock (&globals.seap_lock)
00144 #define SEAP_UNLOCK pthread_mutex_unlock (&globals.seap_lock)
00145
00146 #endif