| 1 | /** |
| 2 | * @addtogroup OVAL |
| 3 | * @{ |
| 4 | * @addtogroup OVALAGENT |
| 5 | * OVAL Agent interface |
| 6 | * |
| 7 | * This is a high level API for system probing and OVAL Definition content evaluation. |
| 8 | * @{ |
| 9 | * |
| 10 | * @file |
| 11 | * |
| 12 | * @author "David Niemoller" <[email protected]> |
| 13 | * @author "Peter Vrabec" <[email protected]> |
| 14 | */ |
| 15 | |
| 16 | /* |
| 17 | * Copyright 2009,2010 Red Hat Inc., Durham, North Carolina. |
| 18 | * All Rights Reserved. |
| 19 | * |
| 20 | * This library is free software; you can redistribute it and/or |
| 21 | * modify it under the terms of the GNU Lesser General Public |
| 22 | * License as published by the Free Software Foundation; either |
| 23 | * version 2.1 of the License, or (at your option) any later version. |
| 24 | * |
| 25 | * This library is distributed in the hope that it will be useful, |
| 26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 28 | * Lesser General Public License for more details. |
| 29 | * |
| 30 | * You should have received a copy of the GNU Lesser General Public |
| 31 | * License along with this library; if not, write to the Free Software |
| 32 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 33 | * |
| 34 | */ |
| 35 | |
| 36 | |
| 37 | #ifndef OVAL_AGENT_API_H_ |
| 38 | #define OVAL_AGENT_API_H_ |
| 39 | |
| 40 | #include "oval_definitions.h" |
| 41 | #include "oval_system_characteristics.h" |
| 42 | #include "oval_results.h" |
| 43 | #include "oval_variables.h" |
| 44 | #include "oscap_export.h" |
| 45 | //#include "oval_probe.h" |
| 46 | |
| 47 | struct oval_agent_session; |
| 48 | |
| 49 | /** |
| 50 | * @var oval_agent_session_t |
| 51 | * Agent session consists of connection to system checking engine, |
| 52 | * definition model, system characteristics model and results model. |
| 53 | */ |
| 54 | typedef struct oval_agent_session oval_agent_session_t; |
| 55 | |
| 56 | /** |
| 57 | * Create new session for OVAL agent from OVAL definition model |
| 58 | * @param model OVAL Definition model |
| 59 | * @param name Name of file that can be referenced from XCCDF Benchmark |
| 60 | */ |
| 61 | OSCAP_API oval_agent_session_t * oval_agent_new_session(struct oval_definition_model * model, const char * name); |
| 62 | |
| 63 | /** |
| 64 | * Retrieves OVAL definition model associated with given session |
| 65 | */ |
| 66 | OSCAP_API struct oval_definition_model* oval_agent_get_definition_model(oval_agent_session_t* ag_sess); |
| 67 | |
| 68 | /** |
| 69 | * Set a product name for the provided agent session. The |
| 70 | * product name should be used for all newly created OVAL documents. If |
| 71 | * there already are some models in the session, they are modified as |
| 72 | * well. |
| 73 | */ |
| 74 | OSCAP_API void oval_agent_set_product_name(oval_agent_session_t *, char *); |
| 75 | |
| 76 | /** |
| 77 | * Probe the system and evaluate specified definition |
| 78 | * @return 0 on success; -1 error; 1 warning |
| 79 | */ |
| 80 | OSCAP_API int oval_agent_eval_definition(oval_agent_session_t *, const char *); |
| 81 | |
| 82 | /** |
| 83 | * Get the OVAL result of a definition from an agent session |
| 84 | * @return 0 on success; -1 error |
| 85 | */ |
| 86 | OSCAP_API int oval_agent_get_definition_result(oval_agent_session_t *, const char *, oval_result_t *); |
| 87 | |
| 88 | /** |
| 89 | * Get the OVAL result definition from an agent session |
| 90 | * @return NULL if not found |
| 91 | */ |
| 92 | OSCAP_API struct oval_result_definition * oval_agent_get_result_definition(oval_agent_session_t *ag_sess, const char *id); |
| 93 | |
| 94 | /** |
| 95 | * Clean resuls that were generated in this agent session |
| 96 | */ |
| 97 | OSCAP_API int oval_agent_reset_session(oval_agent_session_t * ag_sess); |
| 98 | |
| 99 | /** |
| 100 | * Clean system characteristics that were generated in this agent session |
| 101 | */ |
| 102 | OSCAP_API void oval_agent_reset_syschar(oval_agent_session_t * ag_sess); |
| 103 | |
| 104 | /** |
| 105 | * Clean results that were generated in this agent session |
| 106 | */ |
| 107 | OSCAP_API void oval_agent_reset_results(oval_agent_session_t * ag_sess); |
| 108 | |
| 109 | /** |
| 110 | * Abort a running probe session |
| 111 | */ |
| 112 | OSCAP_API int oval_agent_abort_session(oval_agent_session_t *ag_sess); |
| 113 | |
| 114 | typedef int (*agent_reporter)(const struct oval_result_definition * res_def, void *arg); |
| 115 | |
| 116 | /** |
| 117 | * Probe and evaluate all definitions from the content, call the callback functions upon single evaluation |
| 118 | * @return 0 on success; -1 error; 1 warning |
| 119 | */ |
| 120 | OSCAP_API int oval_agent_eval_system(oval_agent_session_t * ag_sess, agent_reporter cb, void *arg); |
| 121 | |
| 122 | /** |
| 123 | * Get a result model from agent session |
| 124 | */ |
| 125 | OSCAP_API struct oval_results_model * oval_agent_get_results_model(oval_agent_session_t * ag_sess); |
| 126 | /** |
| 127 | * Get a filename under which was created |
| 128 | */ |
| 129 | OSCAP_API const char * oval_agent_get_filename(oval_agent_session_t * ag_sess); |
| 130 | |
| 131 | /** |
| 132 | * Finish OVAL agent session |
| 133 | */ |
| 134 | OSCAP_API void oval_agent_destroy_session(oval_agent_session_t * ag_sess); |
| 135 | |
| 136 | |
| 137 | /** |
| 138 | * @} END OVALDEF |
| 139 | * @} END OVALAGENT |
| 140 | */ |
| 141 | #endif /**OVAL_AGENT_API_H_ */ |
| 142 | |
| 143 |