Skip to content

Commit

Permalink
Add osp_get_performance()
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnicola committed Sep 2, 2019
1 parent debeb36 commit cec3c5b
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 4 deletions.
47 changes: 47 additions & 0 deletions osp/osp.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,53 @@ osp_delete_scan (osp_connection_t *connection, const char *scan_id)
return ret;
}

/**
* @brief Get performance graphics from an OSP server.
*
* @param[in] connection Connection to an OSP server.
* @param[in] opts Struct containing the options to apply.
* @param[out] graph Graphic base64 encoded.
* @param[out] error Pointer to error, if any.
*
* @return 0 if success, 1 if error.
*/
int
osp_get_performance_ext (osp_connection_t *connection,
osp_get_performance_opts_t opts,
char **graph, char **error)
{
entity_t entity;
int rc;

assert (connection);
rc = osp_send_command (connection, &entity,
"<get_performance start='%d' "
"end='%d' titles='%s'/>",
opts.start, opts.end, opts.titles);

if (rc)
{
if (error)
*error = g_strdup ("Couldn't send get_performance command to scanner");
return 1;
}

if (graph && entity_text (entity) && strcmp (entity_text(entity),"\0"))
*graph = g_strdup (entity_text (entity));
else
{
const char *text = entity_attribute (entity, "status_text");

assert (text);
if (error)
*error = g_strdup (text);
free_entity (entity);
return 1;
}

free_entity (entity);
return 0;
}

/**
* @brief Get a scan status from an OSP server
Expand Down
22 changes: 18 additions & 4 deletions osp/osp.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ typedef enum
OSP_SCAN_STATUS_FINISHED, /**< Finished status. */
} osp_scan_status_t;


typedef struct {
const char *scan_id; ///< UUID of the scan which get the status from.
} osp_get_scan_status_opts_t;

typedef struct {
int start; /**< Start interval. */
int end; /**< End interval. */
char *titles; /**< Graph title. */
} osp_get_performance_opts_t;

typedef struct osp_param osp_param_t;

/* OSP Connection handling */
Expand Down Expand Up @@ -123,10 +134,6 @@ osp_get_scan_pop (osp_connection_t *,
int,
char **);

typedef struct {
const char *scan_id; ///< UUID of the scan which get the status from.
} osp_get_scan_status_opts_t;

osp_scan_status_t
osp_get_scan_status_ext (osp_connection_t *,
osp_get_scan_status_opts_t,
Expand All @@ -141,6 +148,13 @@ osp_stop_scan (osp_connection_t *, const char *, char **);
int
osp_get_scanner_details (osp_connection_t *, char **, GSList **);


int
osp_get_performance_ext (osp_connection_t *,
osp_get_performance_opts_t,
char **,
char **);

/* OSP scanner parameters handling */

osp_param_t *
Expand Down

0 comments on commit cec3c5b

Please sign in to comment.