Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend osp with target's alive test option. #312

Merged
merged 3 commits into from
Jan 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added
- Add nvti_get_tag() [#285](https://github.com/greenbone/gvm-libs/pull/285)
- Add nvti_solution_method() and nvti_set_solution_method() [#283](https://github.com/greenbone/gvm-libs/pull/283)
- Extend osp with target's alive test option.[#312](https://github.com/greenbone/gvm-libs/pull/312)

[20.4]: https://github.com/greenbone/gvm-libs/compare/gvm-libs-11.0...master

Expand Down
11 changes: 10 additions & 1 deletion osp/osp.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ struct osp_target
gchar *hosts; /** String defining one or many hosts to scan */
gchar *ports; /** String defining the ports to scan */
gchar *finished_hosts; /** String defining hosts to exclude as finished */
int alive_test; /** Value defining an alive test method */
};

/**
Expand Down Expand Up @@ -866,6 +867,11 @@ target_append_as_xml (osp_target_t *target, GString *xml_string)
target->finished_hosts ? target->finished_hosts : "",
target->ports ? target->ports : "");

if (target->alive_test > 0)
xml_string_append (xml_string,
"<alive_test>%d</alive_test>",
target->alive_test);

if (target->credentials)
{
g_string_append (xml_string, "<credentials>");
Expand Down Expand Up @@ -1388,13 +1394,15 @@ osp_credential_set_auth_data (osp_credential_t *credential,
* @param[in] hosts The hostnames of the target.
* @param[in] ports The ports of the target.
* @param[in] exclude_hosts The excluded hosts of the target.
* @param[in] alive_test The alive test method of the target.
*
* @return The newly allocated osp_target_t.
*/
osp_target_t *
osp_target_new (const char *hosts,
const char *ports,
const char *exclude_hosts)
const char *exclude_hosts,
int alive_test)
{
osp_target_t *new_target;
new_target = g_malloc0 (sizeof (osp_target_t));
Expand All @@ -1403,6 +1411,7 @@ osp_target_new (const char *hosts,
new_target->hosts = hosts ? g_strdup (hosts) : NULL;
new_target->ports = ports ? g_strdup (ports) : NULL;
new_target->finished_hosts = NULL;
new_target->alive_test = alive_test ? alive_test : 0;

return new_target;
}
Expand Down
2 changes: 1 addition & 1 deletion osp/osp.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ osp_credential_set_auth_data (osp_credential_t *, const char*, const char*);
/* OSP targets handling */

osp_target_t *
osp_target_new (const char *, const char *, const char *);
osp_target_new (const char *, const char *, const char *, int);

void
osp_target_set_finished_hosts (osp_target_t *, const char *);
Expand Down