|
OpenVAS Scanner 23.40.3
|
#include "nasl_http2.h"#include "../misc/plugutils.h"#include "../misc/user_agent.h"#include "exec.h"#include "nasl_debug.h"#include "nasl_func.h"#include "nasl_global_ctxt.h"#include "nasl_lex_ctxt.h"#include "nasl_socket.h"#include "nasl_tree.h"#include "nasl_var.h"#include <ctype.h>#include <curl/curl.h>#include <gnutls/gnutls.h>#include <gvm/base/prefs.h>#include <gvm/util/kb.h>#include <string.h>
Go to the source code of this file.
Data Structures | |
| struct | handle_table_s |
| Struct to store handles. More... | |
| struct | string |
| Define a string struct for storing the response. More... | |
Macros | |
| #define | G_LOG_DOMAIN "lib nasl" |
| GLib log domain. | |
| #define | MAX_HANDLES 10 |
Typedefs | |
| typedef enum KEYWORD_E | KEYWORD |
| Allowed methods. | |
Enumerations | |
| enum | KEYWORD_E { POST , GET , PUT , DELETE , HEAD } |
| Allowed methods. More... | |
Functions | |
| static int | next_handle_id (void) |
| Get the new available handle identifier. | |
| tree_cell * | nasl_http2_handle (lex_ctxt *lexic) |
| Creates a handle for http requests. | |
| tree_cell * | nasl_http2_close_handle (lex_ctxt *lexic) |
| Close a handle for http requests previously initialized. | |
| static void | init_string (struct string *s) |
| Initialize the string struct to hold the response or header. | |
| static size_t | response_callback_fn (void *ptr, size_t size, size_t nmemb, void *struct_string) |
| Call back function to stored the response. | |
| static size_t | header_callback_fn (char *buffer, size_t size, size_t nmemb, void *struct_string) |
| Call back function to stored the header. | |
| static tree_cell * | _http2_req (lex_ctxt *lexic, KEYWORD keyword) |
| Perform an HTTP request. Forcing HTTP2 if possible. | |
| tree_cell * | nasl_http2_get_response_code (lex_ctxt *lexic) |
| Get the http response code after performing a HTTP request. | |
| tree_cell * | nasl_http2_set_custom_header (lex_ctxt *lexic) |
| Set a custom header element in the header. | |
| tree_cell * | nasl_http2_get (lex_ctxt *lexic) |
| Wrapper function for GET request. See _http2_req. | |
| tree_cell * | nasl_http2_head (lex_ctxt *lexic) |
| Wrapper function for HEAD request. See _http2_req. | |
| tree_cell * | nasl_http2_post (lex_ctxt *lexic) |
| Wrapper function for POST request. See _http2_req. | |
| tree_cell * | nasl_http2_delete (lex_ctxt *lexic) |
| Wrapper function for DELETE request. See _http2_req. | |
| tree_cell * | nasl_http2_put (lex_ctxt *lexic) |
| Wrapper function for PUT request. See _http2_req. | |
Variables | |
| static struct handle_table_s * | handle_table [MAX_HANDLES] |
| Handle Table. | |
| #define G_LOG_DOMAIN "lib nasl" |
GLib log domain.
Definition at line 31 of file nasl_http2.c.
| #define MAX_HANDLES 10 |
Definition at line 55 of file nasl_http2.c.
Referenced by _http2_req(), nasl_http2_close_handle(), nasl_http2_get_response_code(), nasl_http2_handle(), and nasl_http2_set_custom_header().
| enum KEYWORD_E |
Perform an HTTP request. Forcing HTTP2 if possible.
| [in] | lexic | Lexical context of NASL interpreter. |
Definition at line 252 of file nasl_http2.c.
References alloc_typed_cell(), CONST_DATA, DELETE, GET, get_int_var_by_name(), get_str_var_by_name(), handle_table, HEAD, header_callback_fn(), hostname, init_string(), script_infos::ipc_context, MAX_HANDLES, nasl_perror(), plug_get_host_fqdn(), POST, string::ptr, PUT, response_callback_fn(), struct_lex_ctxt::script_infos, TC::size, script_infos::standalone, TC::str_val, user_agent_get(), and TC::x.
Referenced by nasl_http2_delete(), nasl_http2_get(), nasl_http2_head(), nasl_http2_post(), and nasl_http2_put().


|
static |
Call back function to stored the header.
@description The function signature is the necessary to work with libcurl. It stores the header in s. It reallocate memory if necessary.
Definition at line 211 of file nasl_http2.c.
References string::len, and string::ptr.
Referenced by _http2_req().

|
static |
Initialize the string struct to hold the response or header.
| s[in/out] | The string struct to be initialized |
Definition at line 169 of file nasl_http2.c.
References string::len, and string::ptr.
Referenced by _http2_req().

Close a handle for http requests previously initialized.
| [in] | lexic | Lexical context of NASL interpreter. |
Definition at line 129 of file nasl_http2.c.
References alloc_typed_cell(), CONST_INT, get_int_var_by_num(), handle_table_s::handle, handle_table_s::handle_id, handle_table, TC::i_val, MAX_HANDLES, and TC::x.

Wrapper function for DELETE request. See _http2_req.
Definition at line 549 of file nasl_http2.c.
References _http2_req(), and DELETE.

Wrapper function for GET request. See _http2_req.
Definition at line 525 of file nasl_http2.c.
References _http2_req(), and GET.

Get the http response code after performing a HTTP request.
| [in] | lexic | Lexical context of NASL interpreter. |
Definition at line 436 of file nasl_http2.c.
References alloc_typed_cell(), CONST_INT, get_int_var_by_name(), handle_table, TC::i_val, MAX_HANDLES, nasl_perror(), and TC::x.

Creates a handle for http requests.
| [in] | lexic | Lexical context of NASL interpreter. |
Definition at line 84 of file nasl_http2.c.
References alloc_typed_cell(), CONST_INT, handle_table_s::handle, handle_table_s::handle_id, handle_table, TC::i_val, MAX_HANDLES, next_handle_id(), and TC::x.

Wrapper function for HEAD request. See _http2_req.
Definition at line 533 of file nasl_http2.c.
References _http2_req(), and HEAD.

Wrapper function for POST request. See _http2_req.
Definition at line 541 of file nasl_http2.c.
References _http2_req(), and POST.

Wrapper function for PUT request. See _http2_req.
Definition at line 557 of file nasl_http2.c.
References _http2_req(), and PUT.

Set a custom header element in the header.
| [in] | lexic | Lexical context of NASL interpreter. |
Definition at line 482 of file nasl_http2.c.
References alloc_typed_cell(), CONST_INT, get_int_var_by_name(), get_str_var_by_name(), handle_table, TC::i_val, MAX_HANDLES, nasl_perror(), and TC::x.

|
static |
Get the new available handle identifier.
Definition at line 64 of file nasl_http2.c.
Referenced by nasl_http2_handle().

|
static |
Call back function to stored the response.
@description The function signature is the necessary to work with libcurl. It stores the response in s. It reallocate memory if necessary.
Definition at line 187 of file nasl_http2.c.
References string::len, and string::ptr.
|
static |
Handle Table.
Definition at line 59 of file nasl_http2.c.
Referenced by _http2_req(), nasl_http2_close_handle(), nasl_http2_get_response_code(), nasl_http2_handle(), and nasl_http2_set_custom_header().