"Fossies" - the Fresh Open Source Software Archive

Member "gvm-libs-11.0.0/gmp/gmp.h" (11 Oct 2019, 13138 Bytes) of package /linux/misc/openvas/gvm-libs-11.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "gmp.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 1.0-beta2_vs_1.0.0.

    1 /* Copyright (C) 2009-2019 Greenbone Networks GmbH
    2  *
    3  * SPDX-License-Identifier: GPL-2.0-or-later
    4  *
    5  * This program is free software; you can redistribute it and/or
    6  * modify it under the terms of the GNU General Public License
    7  * as published by the Free Software Foundation; either version 2
    8  * of the License, or (at your option) any later version.
    9  *
   10  * This program is distributed in the hope that it will be useful,
   11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13  * GNU General Public License for more details.
   14  *
   15  * You should have received a copy of the GNU General Public License
   16  * along with this program; if not, write to the Free Software
   17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   18  */
   19 
   20 /**
   21  * @file
   22  * @brief API for Greenbone Management Protocol communication.
   23  */
   24 
   25 #ifndef _GVM_GMP_H
   26 #define _GVM_GMP_H
   27 
   28 #include "../base/array.h"       /* for array_t */
   29 #include "../util/serverutils.h" /* for gvm_connection_t */
   30 #include "../util/xmlutils.h"    /* for entity_t */
   31 
   32 #include <glib.h>          /* for gchar */
   33 #include <glib/gtypes.h>   /* for gsize */
   34 #include <gnutls/gnutls.h> /* for gnutls_session_t */
   35 #include <stddef.h>        /* for NULL */
   36 
   37 /**
   38  * @brief Struct holding options for authentication.
   39  */
   40 typedef struct
   41 {
   42   int timeout;          ///< Timeout for authentication.
   43   const char *username; ///< Password.
   44   const char *password; ///< Username.
   45   char **role;          ///< [out] Role.
   46   char **severity;      ///< [out] Severity class setting.
   47   char **timezone;      ///< [out] Timezone if any, else NULL.
   48   char **pw_warning;    ///< [out] Password warning, NULL if password is okay.
   49 } gmp_authenticate_info_opts_t;
   50 
   51 /**
   52  * @brief Sensible default values for gmp_authenticate_info_opts_t
   53  */
   54 static const gmp_authenticate_info_opts_t gmp_authenticate_info_opts_defaults =
   55   {0, NULL, NULL, NULL, NULL, NULL, NULL};
   56 
   57 /**
   58  * @brief Struct holding options for gmp get_report command.
   59  */
   60 typedef struct
   61 {
   62   const char *sort_field;
   63   const char *sort_order;
   64   const char *format_id; ///< ID of required report format.
   65   const char *levels;    ///< Result levels to include.
   66   const char *report_id; ///< ID of single report to get.
   67   int first_result;      ///< First result to get.
   68   int max_results;       ///< Maximum number of results to return.
   69   int timeout;           ///< Timeout for GMP response.
   70   int host_first_result; ///< Skip over results before this result number.
   71   int host_max_results;  ///< Maximum number of results to return.
   72   int autofp; ///< Whether to trust vendor security updates. 0 No, 1 full match,
   73               ///< 2 partial.
   74   char *type; ///< Type of report.
   75   char *filter;          ///< Term to filter results.
   76   char *filt_id;         ///< ID of filter, to filter results.
   77   char *host;            ///< Host for asset report.
   78   char *pos;             ///< Position of report from end.
   79   char *timezone;        ///< Timezone.
   80   char *alert_id;        ///< ID of alert.
   81   char *delta_report_id; ///< ID of report to compare single report to.
   82   char *delta_states;    ///< Delta states (Changed Gone New Same) to include.
   83   char *host_levels;     ///< Letter encoded threat level filter, for hosts.
   84   char *search_phrase;   ///< Search phrase result filter.
   85   char *host_search_phrase; ///< Search phrase result filter.
   86   char *min_cvss_base;      ///< Minimum CVSS base filter.
   87   char *min_qod;            ///< Minimum QoD filter.
   88   /* Boolean flags: */
   89   int notes;             ///< Whether to include associated notes.
   90   int notes_details;     ///< Whether to include details of above.
   91   int overrides;         ///< Whether to include overrides in the report.
   92   int override_details;  ///< If overrides, whether to include details.
   93   int apply_overrides;   ///< Whether overrides are applied.
   94   int result_hosts_only; ///< Whether to include only hosts that have results.
   95   int ignore_pagination; ///< Whether to ignore pagination filters.
   96 } gmp_get_report_opts_t;
   97 
   98 /**
   99  * @brief Sensible default values for gmp_get_report_opts_t.
  100  */
  101 static const gmp_get_report_opts_t gmp_get_report_opts_defaults = {
  102   "ROWID",
  103   "ascending",
  104   "a994b278-1f62-11e1-96ac-406186ea4fc5",
  105   "hmlgd",
  106   NULL,
  107   1,
  108   -1,
  109   0,
  110   0,
  111   0,
  112   0,
  113   NULL,
  114   NULL,
  115   NULL,
  116   NULL,
  117   NULL,
  118   NULL,
  119   NULL,
  120   NULL,
  121   NULL,
  122   NULL,
  123   NULL,
  124   NULL,
  125   NULL,
  126   NULL,
  127   0,
  128   0,
  129   0,
  130   0,
  131   0,
  132   0,
  133   0};
  134 
  135 /**
  136  * @brief Struct holding options for gmp get_tasks command.
  137  */
  138 typedef struct
  139 {
  140   const char *filter;  ///< Filter argument.
  141   int timeout;         ///< Timeout for GMP response.
  142   const char *actions; ///< Actions argument.
  143   /* Boolean flags: */
  144   int details; ///< Whether to include overrides in the tasks.
  145   int rcfile;  ///< Ignored.  Removed since GMP 6.0.
  146 } gmp_get_tasks_opts_t;
  147 
  148 /**
  149  * @brief Sensible default values for gmp_get_tasks_opts_t.
  150  */
  151 static const gmp_get_tasks_opts_t gmp_get_tasks_opts_defaults = {"", 0, NULL, 0,
  152                                                                  0};
  153 
  154 /**
  155  * @brief Struct holding options for gmp get_tasks command.
  156  */
  157 typedef struct
  158 {
  159   const char *actions; ///< Actions argument.
  160   const char *task_id; ///< ID of single task to get.
  161   /* Boolean flags: */
  162   int details; ///< Whether to include overrides in the tasks.
  163   int rcfile;  ///< Ignored.  Removed since GMP 6.0.
  164 } gmp_get_task_opts_t;
  165 
  166 /**
  167  * @brief Sensible default values for gmp_get_tasks_opts_t.
  168  */
  169 static const gmp_get_task_opts_t gmp_get_task_opts_defaults = {NULL, NULL, 0,
  170                                                                0};
  171 
  172 /**
  173  * @brief Struct holding options for gmp create_task command.
  174  */
  175 typedef struct
  176 {
  177   array_t *alert_ids;         ///< Array of alert IDs.
  178   const char *config_id;      ///< ID of config.
  179   const char *scanner_id;     ///< ID of task scanner.
  180   const char *schedule_id;    ///< ID of task schedule.
  181   const char *slave_id;       ///< ID of task schedule.
  182   const char *target_id;      ///< ID of target.
  183   const char *name;           ///< Name of task.
  184   const char *comment;        ///< Comment on task.
  185   const char *hosts_ordering; ///< Order for scanning target hosts.
  186   const char *observers;      ///< Comma-separated string of observer users.
  187   array_t *observer_groups;   ///< IDs of observer groups.
  188   int schedule_periods;       ///< Number of periods the schedule must run for.
  189   /* Preferences */
  190   const char *in_assets;    ///< In assets preference.
  191   const char *max_hosts;    ///< Max hosts preference.
  192   const char *max_checks;   ///< Max checks preference.
  193   const char *source_iface; ///< Source iface preference.
  194   /* Boolean flags: */
  195   int alterable; ///< Whether the task is alterable.
  196 } gmp_create_task_opts_t;
  197 
  198 /**
  199  * @brief Sensible default values for gmp_get_report_opts_t.
  200  */
  201 static const gmp_create_task_opts_t gmp_create_task_opts_defaults = {
  202   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  203   NULL, NULL, 0,    NULL, NULL, NULL, NULL, 0};
  204 
  205 /**
  206  * @brief Struct holding options for gmp create_target command.
  207  */
  208 typedef struct
  209 {
  210   int ssh_credential_port;        ///< Port for SSH access.
  211   const char *ssh_credential_id;  ///< ID of SSH credential.
  212   const char *smb_credential_id;  ///< ID of SMB credential.
  213   const char *esxi_credential_id; ///< ID of ESXi credential.
  214   const char *snmp_credential_id; ///< ID of SNMP credential.
  215   const char *port_range;         ///< Port range.
  216   const char *name;               ///< Name of target.
  217   const char *comment;            ///< Comment on target.
  218   const char *hosts;              ///< Name of target.
  219   const char *exclude_hosts;      ///< Hosts to exclude.
  220   const char *alive_tests;        ///< Alive tests.
  221   /* Boolean flags: */
  222   int reverse_lookup_only;  ///< Scanner pref reverse_lookup_only.
  223   int reverse_lookup_unify; ///< Scanner pref reverse_lookup_unify.
  224 } gmp_create_target_opts_t;
  225 
  226 /**
  227  * @brief Sensible default values for gmp_get_report_opts_t.
  228  */
  229 static const gmp_create_target_opts_t gmp_create_target_opts_defaults = {
  230   0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0};
  231 
  232 /**
  233  * @brief Struct holding options for gmp get_system_reports command.
  234  */
  235 typedef struct
  236 {
  237   const char *name;       ///< Name of report.
  238   const char *duration;   ///< Duration.
  239   const char *start_time; ///< Time of first data point.
  240   const char *end_time;   ///< Time of last data point.
  241   const char *slave_id;   ///< ID of the slave to get report from.
  242   int brief;              ///< Brief flag.
  243 } gmp_get_system_reports_opts_t;
  244 
  245 /**
  246  * @brief Sensible default values for gmp_get_report_opts_t.
  247  */
  248 static const gmp_get_system_reports_opts_t
  249   gmp_get_system_reports_opts_defaults = {NULL, NULL, NULL, NULL, NULL, 0};
  250 
  251 /**
  252  * @brief Struct holding options for gmp create_lsc_credential command.
  253  */
  254 typedef struct
  255 {
  256   const char *name;              ///< Name of LSC credential.
  257   const char *community;         ///< SNMP community.
  258   const char *login;             ///< Login.
  259   const char *passphrase;        ///< Passphrase.
  260   const char *private_key;       ///< Private key.
  261   const char *auth_algorithm;    ///< SNMP authentication algorithm.
  262   const char *privacy_password;  ///< SNMP privacy password.
  263   const char *privacy_algorithm; ///< SNMP privacy algorithm.
  264   const char *comment;           ///< Comment on LSC credential.
  265 } gmp_create_lsc_credential_opts_t;
  266 
  267 /**
  268  * @brief Sensible default values for gmp_create_lsc_credential_opts_t.
  269  */
  270 static const gmp_create_lsc_credential_opts_t
  271   gmp_create_lsc_credential_opts_defaults = {NULL, NULL, NULL, NULL, NULL,
  272                                              NULL, NULL, NULL, NULL};
  273 
  274 /**
  275  * @brief Struct holding options for various gmp delete_[...] commands.
  276  */
  277 typedef struct
  278 {
  279   int ultimate; /// Whether to delete ultimately.
  280 } gmp_delete_opts_t;
  281 
  282 /**
  283  * @brief Sensible default values for gmp_get_report_opts_t.
  284  */
  285 static const gmp_delete_opts_t gmp_delete_opts_defaults = {0};
  286 
  287 /**
  288  * @brief Default values for gmp_get_report_opts_t for ultimate deletion.
  289  */
  290 static const gmp_delete_opts_t gmp_delete_opts_ultimate_defaults = {1};
  291 
  292 int
  293 gmp_read_create_response (gnutls_session_t *, gchar **);
  294 
  295 const char *
  296 gmp_task_status (entity_t status_response);
  297 
  298 int
  299 gmp_ping (gnutls_session_t *, int);
  300 
  301 int
  302 gmp_ping_c (gvm_connection_t *, int, gchar **);
  303 
  304 int
  305 gmp_authenticate (gnutls_session_t *session, const char *username,
  306                   const char *password);
  307 
  308 int
  309 gmp_authenticate_info_ext (gnutls_session_t *, gmp_authenticate_info_opts_t);
  310 
  311 int
  312 gmp_authenticate_info_ext_c (gvm_connection_t *, gmp_authenticate_info_opts_t);
  313 
  314 int
  315 gmp_create_task (gnutls_session_t *, const char *, const char *, const char *,
  316                  const char *, gchar **);
  317 
  318 int
  319 gmp_create_task_ext (gnutls_session_t *, gmp_create_task_opts_t, gchar **);
  320 
  321 int
  322 gmp_start_task_report (gnutls_session_t *, const char *, char **);
  323 
  324 int
  325 gmp_start_task_report_c (gvm_connection_t *, const char *, char **);
  326 
  327 int
  328 gmp_stop_task (gnutls_session_t *, const char *);
  329 
  330 int
  331 gmp_stop_task_c (gvm_connection_t *, const char *);
  332 
  333 int
  334 gmp_resume_task_report (gnutls_session_t *, const char *, char **);
  335 
  336 int
  337 gmp_resume_task_report_c (gvm_connection_t *, const char *, char **);
  338 
  339 int
  340 gmp_get_tasks (gnutls_session_t *, const char *, int, int, entity_t *);
  341 
  342 int
  343 gmp_get_tasks_ext (gnutls_session_t *, gmp_get_tasks_opts_t, entity_t *);
  344 
  345 int
  346 gmp_get_task_ext (gnutls_session_t *, gmp_get_task_opts_t, entity_t *);
  347 
  348 int
  349 gmp_get_targets (gnutls_session_t *, const char *, int, int, entity_t *);
  350 
  351 int
  352 gmp_get_report_ext (gnutls_session_t *, gmp_get_report_opts_t, entity_t *);
  353 
  354 int
  355 gmp_delete_port_list_ext (gnutls_session_t *, const char *, gmp_delete_opts_t);
  356 
  357 int
  358 gmp_delete_task (gnutls_session_t *, const char *);
  359 
  360 int
  361 gmp_delete_task_ext (gnutls_session_t *, const char *, gmp_delete_opts_t);
  362 
  363 int
  364 gmp_modify_task_file (gnutls_session_t *, const char *, const char *,
  365                       const void *, gsize);
  366 
  367 int
  368 gmp_delete_report (gnutls_session_t *, const char *);
  369 
  370 int
  371 gmp_create_target_ext (gnutls_session_t *, gmp_create_target_opts_t, gchar **);
  372 
  373 int
  374 gmp_delete_target_ext (gnutls_session_t *, const char *, gmp_delete_opts_t);
  375 
  376 int
  377 gmp_delete_config_ext (gnutls_session_t *, const char *, gmp_delete_opts_t);
  378 
  379 int
  380 gmp_create_lsc_credential_ext (gnutls_session_t *,
  381                                gmp_create_lsc_credential_opts_t, gchar **);
  382 
  383 int
  384 gmp_create_lsc_credential (gnutls_session_t *, const char *, const char *,
  385                            const char *, const char *, gchar **);
  386 
  387 int
  388 gmp_create_lsc_credential_key (gnutls_session_t *, const char *, const char *,
  389                                const char *, const char *, const char *,
  390                                gchar **);
  391 
  392 int
  393 gmp_delete_lsc_credential_ext (gnutls_session_t *, const char *,
  394                                gmp_delete_opts_t);
  395 
  396 int
  397 gmp_get_system_reports (gnutls_session_t *, const char *, int, entity_t *);
  398 
  399 int
  400 gmp_get_system_reports_ext (gnutls_session_t *, gmp_get_system_reports_opts_t,
  401                             entity_t *);
  402 
  403 #endif /* not _GVM_GMP_H */