OpenVAS Manager  7.0.3~git
ompd.c File Reference

The OpenVAS Manager OMP daemon. More...

#include "ompd.h"
#include "scanner.h"
#include "logf.h"
#include "omp.h"
#include "otp.h"
#include "ovas-mngr-comm.h"
#include <assert.h>
#include <dirent.h>
#include <errno.h>
#include <string.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <openvas/misc/openvas_server.h>
Include dependency graph for ompd.c:

Go to the source code of this file.

Macros

#define G_LOG_DOMAIN   "md main"
 GLib log domain. More...
 

Functions

int init_ompd (GSList *log_config, int nvt_cache_mode, const gchar *database, int max_ips_per_target, int max_email_attachment_size, int max_email_include_size, int max_email_message_size, void(*progress)(), int(*fork_connection)(openvas_connection_t *, gchar *), int skip_db_check)
 Initialise the OMP library for the OMP daemon. More...
 
void init_ompd_process (const gchar *database, gchar **disable)
 Initialise a process forked within the OMP daemon. More...
 
gboolean ompd_send_to_client (const char *msg, void *write_to_client_data)
 Send a response message to the client. More...
 
int serve_omp (openvas_connection_t *client_connection, const gchar *database, gchar **disable, void(*progress)())
 Serve the OpenVAS Management Protocol (OMP). More...
 

Variables

char from_client [FROM_BUFFER_SIZE]
 Buffer of input from the client. More...
 
buffer_size_t from_buffer_size = FROM_BUFFER_SIZE
 Size of from_client data buffer, in bytes. More...
 
buffer_size_t from_client_start = 0
 The start of the data in the from_client buffer. More...
 
buffer_size_t from_client_end = 0
 The end of the data in the from_client buffer. More...
 

Detailed Description

The OpenVAS Manager OMP daemon.

This file defines the OpenVAS Manager daemon. The Manager serves the OpenVAS Management Protocol (OMP) to clients such as OpenVAS-Client. The Manager and OMP give clients full access to an OpenVAS Scanner.

The library provides two functions: init_ompd and serve_omp. init_ompd initialises the daemon. serve_omp serves OMP to a single client socket until end of file is reached on the socket.

Definition in file ompd.c.

Macro Definition Documentation

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "md main"

GLib log domain.

Todo:
For scanner_init_state.

Definition at line 69 of file ompd.c.

Function Documentation

◆ init_ompd()

int init_ompd ( GSList *  log_config,
int  nvt_cache_mode,
const gchar *  database,
int  max_ips_per_target,
int  max_email_attachment_size,
int  max_email_include_size,
int  max_email_message_size,
void(*)()  progress,
int(*)(openvas_connection_t *, gchar *)  fork_connection,
int  skip_db_check 
)

Initialise the OMP library for the OMP daemon.

Parameters
[in]log_configLog configuration
[in]nvt_cache_mode0 operate normally, -1 just update NVT cache, -2 just rebuild NVT cache.
[in]databaseLocation of manage database.
[in]max_ips_per_targetMax number of IPs per target.
[in]max_email_attachment_sizeMax size of email attachments.
[in]max_email_include_sizeMax size of email inclusions.
[in]max_email_message_sizeMax size of email user message text.
[in]progressFunction to update progress, or NULL.
[in]fork_connectionFunction to fork a connection to the OMP daemon layer, or NULL.
[in]skip_db_checkSkip DB check.
Returns
0 success, -1 error, -2 database is wrong version, -3 database needs to be initialized from server, -4 max_ips_per_target out of range.

Definition at line 117 of file ompd.c.

123 {
124  return init_omp (log_config, nvt_cache_mode, database, max_ips_per_target,
125  max_email_attachment_size, max_email_include_size,
126  max_email_message_size,
127  progress, fork_connection, skip_db_check);
128 }
int init_omp(GSList *log_config, int nvt_cache_mode, const gchar *database, int max_ips_per_target, int max_email_attachment_size, int max_email_include_size, int max_email_message_size, void(*progress)(), int(*fork_connection)(openvas_connection_t *, gchar *), int skip_db_check)
Initialise OMP library.
Definition: omp.c:30814
GSList * log_config
Logging parameters, as passed to setup_log_handlers.
Definition: openvasmd.c:310
void(* progress)()
Function to mark progress.
Definition: manage_sql.c:352

◆ init_ompd_process()

void init_ompd_process ( const gchar *  database,
gchar **  disable 
)

Initialise a process forked within the OMP daemon.

Parameters
[in]databaseLocation of manage database.
[in]disableCommands to disable.

Definition at line 137 of file ompd.c.

References from_client_end, from_client_start, init_omp_process(), and openvas_scanner_fork().

138 {
140  from_client_start = 0;
141  from_client_end = 0;
142  init_omp_process (0, database, NULL, NULL, disable);
143 }
void init_omp_process(int update_nvt_cache, const gchar *database, int(*write_to_client)(const char *, void *), void *write_to_client_data, gchar **disable)
Initialise OMP library data for a process.
Definition: omp.c:30846
buffer_size_t from_client_start
The start of the data in the from_client buffer.
Definition: ompd.c:84
buffer_size_t from_client_end
The end of the data in the from_client buffer.
Definition: ompd.c:89
void openvas_scanner_fork()
Reset Scanner variables after a fork.
Definition: scanner.c:575
Here is the call graph for this function:

◆ ompd_send_to_client()

gboolean ompd_send_to_client ( const char *  msg,
void *  write_to_client_data 
)

Send a response message to the client.

Queue a message in to_client.

Parameters
[in]msgThe message, a string.
[in]write_to_client_dataArgument to write_to_client.
Returns
TRUE if write to client failed, else FALSE.

Definition at line 390 of file ompd.c.

References TO_CLIENT_BUFFER_SIZE, and to_client_end.

391 {
393  assert (msg);
394 
396  < strlen (msg))
397  {
398  buffer_size_t length;
399 
400  /* Too little space in to_client buffer for message. */
401 
402  switch (write_to_client (write_to_client_data))
403  {
404  case 0: /* Wrote everything in to_client. */
405  break;
406  case -1: /* Error. */
407  g_debug (" %s full (%i < %zu); client write failed\n",
408  __FUNCTION__,
409  ((buffer_size_t) TO_CLIENT_BUFFER_SIZE) - to_client_end,
410  strlen (msg));
411  return TRUE;
412  case -2: /* Wrote as much as client was willing to accept. */
413  break;
414  default: /* Programming error. */
415  assert (0);
416  }
417 
418  length = ((buffer_size_t) TO_CLIENT_BUFFER_SIZE) - to_client_end;
419 
420  if (length > strlen (msg))
421  break;
422 
423  memmove (to_client + to_client_end, msg, length);
424  g_debug ("-> client: %.*s\n", (int) length, msg);
425  to_client_end += length;
426  msg += length;
427  }
428 
429  if (strlen (msg))
430  {
431  assert (strlen (msg)
432  <= (((buffer_size_t) TO_CLIENT_BUFFER_SIZE) - to_client_end));
433  memmove (to_client + to_client_end, msg, strlen (msg));
434  g_debug ("-> client: %s\n", msg);
435  to_client_end += strlen (msg);
436  }
437 
438  return FALSE;
439 }
#define TO_CLIENT_BUFFER_SIZE
The size of the to_client data buffer, in bytes.
Definition: omp.h:38
char to_client[TO_CLIENT_BUFFER_SIZE]
Buffer of output to the client.
Definition: omp.c:4979
buffer_size_t to_client_end
The end of the data in the to_client buffer.
Definition: omp.c:4988
unsigned int buffer_size_t
Definition: types.h:31

◆ serve_omp()

int serve_omp ( openvas_connection_t *  client_connection,
const gchar *  database,
gchar **  disable,
void(*)()  progress 
)

Serve the OpenVAS Management Protocol (OMP).

Loop reading input from the sockets, processing the input, and writing any results to the appropriate socket. Exit the loop on reaching end of file on the client socket.

Read input from the client and scanner. Process the input with process_omp_client_input and process_otp_scanner_input. Write the results to the client.

If compiled with logging (LOG) then log all input and output with logf.

If client_socket is 0 or less, then update the NVT cache and exit.

Parameters
[in]client_connectionConnection.
[in]databaseLocation of manage database.
[in]disableCommands to disable.
[in]progressFunction to mark progress, or NULL.
Returns
0 success, 1 scanner still loading, -1 error, -2 scanner has no cert.
Todo:
Confirm and clarify complications, especially last one.
Todo:
nfds must only include a socket if it's in >= one set.
Todo:
Shutdown on failure (for example, if a read fails).
Todo:
Then should get EOF (-3).
Todo:
This may be because the scanner closed the connection at the end of a command?

Definition at line 493 of file ompd.c.

495 {
496  int nfds, scan_handler = 0, rc = 0;
497  /* True if processing of the client input is waiting for space in the
498  * to_scanner or to_client buffer. */
499  short client_input_stalled;
500  /* Client status flag. Set to 0 when the client closes the connection
501  * while the scanner is active. */
502  short client_active = client_connection->socket > 0;
503 
504  if (client_connection->socket < 0)
505  ompd_nvt_cache_mode = client_connection->socket;
506 
507  if (ompd_nvt_cache_mode)
508  g_info (" Updating NVT cache.\n");
509  else
510  g_debug (" Serving OMP.\n");
511 
512  /* Initialise the XML parser and the manage library. */
513  init_omp_process (ompd_nvt_cache_mode,
514  database,
515  (int (*) (const char*, void*)) ompd_send_to_client,
516  (void*) client_connection,
517  disable);
518 #if 0
519 
520  if (tasks) free_tasks ();
521  if (current_scanner_preference) free (current_scanner_preference);
522  free_credentials (&current_credentials);
523  maybe_free_scanner_preferences (); // old
524 #endif
525 
526  /* Setup the scanner address and try to connect. */
527  if (ompd_nvt_cache_mode && !openvas_scanner_connected ())
528  {
529  int ret;
530 
531  /* Is here because it queries the DB and needs it initialized.
532  * XXX: Move outside serve_omp ().
533  */
534 
536  if (ret)
537  return ret;
539  {
541  return -1;
542  }
543  }
544 
545  client_input_stalled = 0;
546 
548  /* Loop handling input from the sockets.
549  *
550  * That is, select on all the socket fds and then, as necessary
551  * - read from the client into buffer from_client
552  * - write to the scanner from buffer to_scanner
553  * - read from the scanner into buffer from_scanner
554  * - write to the client from buffer to_client.
555  *
556  * On reading from an fd, immediately try react to the input. On reading
557  * from the client call process_omp_client_input, which parses OMP
558  * commands and may write to to_scanner and to_client. On reading from
559  * the scanner call process_otp_scanner_input, which updates information
560  * kept about the scanner.
561  *
562  * There are a few complications here
563  * - the program must read from or write to an fd returned by select
564  * before selecting on the fd again,
565  * - the program need only select on the fds for writing if there is
566  * something to write,
567  * - similarly, the program need only select on the fds for reading
568  * if there is buffer space available,
569  * - the buffers from_client and from_scanner can become full during
570  * reading
571  * - a read from the client can be stalled by the to_scanner buffer
572  * filling up, or the to_client buffer filling up (in which case
573  * process_omp_client_input will try to write the to_client buffer
574  * itself),
575  * - a read from the scanner can, theoretically, be stalled by the
576  * to_scanner buffer filling up (during initialisation).
577  */
578 
579  nfds = openvas_scanner_get_nfds (client_connection->socket);
580  while (1)
581  {
582  int ret;
583  fd_set readfds, writefds;
585 
586  if (termination_signal)
587  {
588  g_debug ("%s: Received %s signal.",
589  __FUNCTION__,
590  sys_siglist[get_termination_signal()]);
591 
593  {
595  }
596 
597  goto client_free;
598  }
599 
600  /* Setup for select. */
601 
604  FD_ZERO (&readfds);
605  FD_ZERO (&writefds);
606 
609  if (client_active)
610  {
611  /* See whether to read from the client. */
613  FD_SET (client_connection->socket, &readfds);
614  /* See whether to write to the client. */
616  FD_SET (client_connection->socket, &writefds);
617  }
618 
619  /* See whether we need to read from the scannner. */
627  && !openvas_scanner_full ())
628  openvas_scanner_fd_set (&readfds);
629 
630  /* See whether we need to write to the scanner. */
636  && to_server_buffer_space () > 0)
640  openvas_scanner_fd_set (&writefds);
641 
642  /* Select, then handle result. Due to GNUTLS internal buffering
643  * we test for pending records first and emulate a select call
644  * in that case. Note, that GNUTLS guarantees that writes are
645  * not buffered. Note also that GNUTLS versions < 3 did not
646  * exhibit a problem in OpenVAS due to a different buffering
647  * strategy. */
648  ret = 0;
649  if (client_connection->socket > 0
650  && client_connection->tls
651  && FD_ISSET (client_connection->socket, &readfds)
652  && gnutls_record_check_pending (client_connection->session))
653  {
654  FD_ZERO (&readfds);
655  FD_ZERO (&writefds);
656  ret++;
657  FD_SET (client_connection->socket, &readfds);
658  }
659  if (openvas_scanner_fd_isset (&readfds))
660  {
662  {
663  if (!ret)
664  {
665  FD_ZERO (&readfds);
666  FD_ZERO (&writefds);
667  }
668  ret++;
669  openvas_scanner_fd_set (&readfds);
670  }
671  else if (openvas_scanner_peek () == 0)
672  {
673  /* Scanner has gone down. Exit. */
674  rc = -1;
675  goto client_free;
676  }
677  }
678 
679  if (!ret)
680  {
681  /* Timeout periodically, so that process_omp_change runs
682  * periodically. */
683  struct timeval timeout;
684 
685  timeout.tv_usec = 0;
686  timeout.tv_sec = 1;
687  ret = select (nfds, &readfds, &writefds, NULL, &timeout);
688  }
689  if ((ret < 0 && errno == EINTR) || ret == 0)
690  {
691  if (process_omp_change () == -1)
692  {
693  rc = -1;
694  goto client_free;
695  }
696  if (!scan_handler && !ompd_nvt_cache_mode)
697  continue;
698  }
699  else if (ret < 0)
700  {
701  g_warning ("%s: child select failed: %s\n", __FUNCTION__,
702  strerror (errno));
703  rc = -1;
704  goto client_free;
705  }
706 
707  /* Read any data from the client. */
708  if (client_connection->socket > 0
709  && FD_ISSET (client_connection->socket, &readfds))
710  {
711  buffer_size_t initial_start = from_client_end;
712 
713  switch (read_from_client (client_connection))
714  {
715  case 0: /* Read everything. */
716  break;
717  case -1: /* Error. */
718  rc = -1;
719  goto client_free;
720  case -2: /* from_client buffer full. */
721  /* There may be more to read. */
722  break;
723  case -3: /* End of file. */
724  g_debug (" EOF reading from client.\n");
725  if (client_connection->socket > 0
726  && FD_ISSET (client_connection->socket, &writefds))
727  /* Write rest of to_client to client, so that the client gets
728  * any buffered output and the response to the error. */
729  write_to_client (client_connection);
730  rc = 0;
731  goto client_free;
732  default: /* Programming error. */
733  assert (0);
734  }
735 
736  /* This check prevents output in the "asynchronous network
737  * error" case. */
738  if (from_client_end > initial_start)
739  {
740  logf ("<= client %.*s\n",
741  from_client_end - initial_start,
742  from_client + initial_start);
743  if (g_strstr_len (from_client + initial_start,
744  from_client_end - initial_start,
745  "<password>"))
746  g_debug ("<= client Input may contain password, suppressed.\n");
747  else
748  g_debug ("<= client \"%.*s\"\n",
749  from_client_end - initial_start,
750  from_client + initial_start);
751  }
752 
753  ret = process_omp_client_input ();
754  if (ret == 0)
755  /* Processed all input. */
756  client_input_stalled = 0;
757  else if (ret == 3)
758  {
759  /* In the parent after a start_task fork. Free the scanner session
760  * without closing it, for usage by the child process. */
763  nfds = openvas_scanner_get_nfds (client_connection->socket);
764  client_input_stalled = 0;
765  /* Skip the rest of the loop because the scanner socket is
766  * a new socket. This is asking for select trouble, really. */
767  continue;
768  }
769  else if (ret == 2)
770  {
771  /* Now in a process forked to run a task, which has
772  * successfully started the task. Close the client
773  * connection, as the parent process has continued the
774  * session with the client. */
775  session_clean (client_connection);
776  client_active = 0;
777  client_input_stalled = 0;
778  scan_handler = 1;
779  }
780  else if (ret == 4)
781  {
782  /* Now in a process forked for some operation which has
783  * successfully completed. Close the client connection,
784  * and exit, as the parent process has continued the
785  * session with the client. */
786  session_clean (client_connection);
787  return 0;
788  }
789  else if (ret == -10)
790  {
791  /* Now in a process forked to run a task, which has
792  * failed in starting the task. */
793  session_clean (client_connection);
794  return -1;
795  }
796  else if (ret == -1 || ret == -4)
797  {
798  /* Error. Write rest of to_client to client, so that the
799  * client gets any buffered output and the response to the
800  * error. */
801  write_to_client (client_connection);
802  rc = -1;
803  goto client_free;
804  }
805  else if (ret == -2)
806  {
807  /* to_scanner buffer full. */
808  g_debug (" client input stalled 1\n");
809  client_input_stalled = 1;
810  /* Carry on to write to_scanner. */
811  }
812  else if (ret == -3)
813  {
814  /* to_client buffer full. */
815  g_debug (" client input stalled 2\n");
816  client_input_stalled = 2;
817  /* Carry on to write to_client. */
818  }
819  else
820  {
821  /* Programming error. */
822  assert (0);
823  client_input_stalled = 0;
824  }
825  }
826 
827  /* Read any data from the scanner. */
829  && (openvas_scanner_fd_isset (&readfds) || scan_handler))
830  {
831  switch (openvas_scanner_read ())
832  {
833  case 0: /* Read everything. */
834  break;
835  case -1: /* Error. */
836  /* This may be because the scanner closed the connection
837  * at the end of a command. */
840  rc = -1;
841  goto client_free;
842  case -2: /* from_scanner buffer full. */
843  /* There may be more to read. */
844  break;
845  case -3: /* End of file. */
847  if (client_active == 0)
848  /* The client has closed the connection, so exit. */
849  return 0;
850  /* Scanner went down, exit. */
851  rc = -1;
852  goto client_free;
853  default: /* Programming error. */
854  assert (0);
855  }
856  }
857 
858  /* Write any data to the scanner. */
860  && (openvas_scanner_fd_isset (&writefds) || scan_handler))
861  {
862  /* Write as much as possible to the scanner. */
863 
864  switch (openvas_scanner_write (ompd_nvt_cache_mode))
865  {
866  case 0: /* Wrote everything in to_scanner. */
867  break;
868  case -1: /* Error. */
871  rc = -1;
872  goto client_free;
873  case -2: /* Wrote as much as scanner was willing to accept. */
874  break;
875  case -3: /* Did an initialisation step. */
876  break;
877  default: /* Programming error. */
878  assert (0);
879  }
880  }
881 
882  /* Write any data to the client. */
883  if (client_connection->socket > 0
884  && FD_ISSET (client_connection->socket, &writefds))
885  {
886  /* Write as much as possible to the client. */
887 
888  switch (write_to_client (client_connection))
889  {
890  case 0: /* Wrote everything in to_client. */
891  break;
892  case -1: /* Error. */
893  rc = -1;
894  goto client_free;
895  case -2: /* Wrote as much as client was willing to accept. */
896  break;
897  default: /* Programming error. */
898  assert (0);
899  }
900  }
901 
902  if (client_input_stalled)
903  {
904  /* Try process the client input, in case writing to the scanner
905  * or client has freed some space in to_scanner or to_client. */
906 
907  ret = process_omp_client_input ();
908  if (ret == 0)
909  /* Processed all input. */
910  client_input_stalled = 0;
911  else if (ret == 3)
912  {
913  /* In the parent after a start_task fork. Free the scanner session
914  * without closing it, for usage by the child process. */
917  nfds = openvas_scanner_get_nfds (client_connection->socket);
918  /* Skip the rest of the loop because the scanner socket is
919  * a new socket. This is asking for select trouble, really. */
920  continue;
921  }
922  else if (ret == 2)
923  {
924  /* Now in a process forked to run a task, which has
925  * successfully started the task. Close the client
926  * connection, as the parent process has continued the
927  * session with the client. */
928  session_clean (client_connection);
929  scan_handler = 1;
930  client_active = 0;
931  }
932  else if (ret == 4)
933  {
934  /* Now in a process forked for some operation which has
935  * successfully completed. Close the client connection,
936  * and exit, as the parent process has continued the
937  * session with the client. */
938  session_clean (client_connection);
939  return 0;
940  }
941  else if (ret == -10)
942  {
943  /* Now in a process forked to run a task, which has
944  * failed in starting the task. */
945  session_clean (client_connection);
946  return -1;
947  }
948  else if (ret == -1)
949  {
950  /* Error. Write rest of to_client to client, so that the
951  * client gets any buffered output and the response to the
952  * error. */
953  write_to_client (client_connection);
954  rc = -1;
955  goto client_free;
956  }
957  else if (ret == -2)
958  {
959  /* to_scanner buffer full. */
960  g_debug (" client input still stalled (1)\n");
961  client_input_stalled = 1;
962  }
963  else if (ret == -3)
964  {
965  /* to_client buffer full. */
966  g_debug (" client input still stalled (2)\n");
967  client_input_stalled = 2;
968  }
969  else
970  {
971  /* Programming error. */
972  assert (0);
973  client_input_stalled = 0;
974  }
975  }
976 
978  {
979  /* Try process the scanner input, in case writing to the scanner
980  * has freed some space in to_scanner. */
981 
983  if (ret == 1)
984  {
985  /* Received scanner BYE. Write out the rest of to_scanner (the
986  * BYE ACK).
987  */
988  openvas_scanner_write (ompd_nvt_cache_mode);
990  if (client_active == 0)
991  return 0;
993  nfds = openvas_scanner_get_nfds (client_connection->socket);
994  }
995  else if (ret == 2)
996  {
997  /* Bad login to scanner. */
998  if (client_active == 0)
999  return 0;
1000  rc = -1;
1001  goto client_free;
1002  }
1003  else if (ret == 3)
1004  {
1005  /* Calls via serve_client() should continue. */
1006  if (ompd_nvt_cache_mode)
1007  return 1;
1009  }
1010  else if (ret == -1)
1011  {
1012  /* Error. */
1013  rc = -1;
1014  goto client_free;
1015  }
1016  else if (ret == -3)
1017  /* to_scanner buffer still full. */
1018  g_debug (" scanner input stalled\n");
1019  else
1020  {
1021  /* Programming error. */
1022  assert (ret == 0 || ret == 5);
1023  }
1024  }
1025 
1026  if (process_omp_change () == -1)
1027  {
1028  rc = -1;
1029  goto client_free;
1030  }
1031 
1032  } /* while (1) */
1033 
1034 client_free:
1035  if (client_active)
1036  openvas_connection_free (client_connection);
1037  return rc;
1038 }
void init_omp_process(int update_nvt_cache, const gchar *database, int(*write_to_client)(const char *, void *), void *write_to_client_data, gchar **disable)
Initialise OMP library data for a process.
Definition: omp.c:30846
int openvas_scanner_read()
Read as much from the server as the from_scanner buffer will.
Definition: scanner.c:233
void openvas_scanner_free()
Free the scanner allocated data. Doesn&#39;t close socket and terminate the session.
Definition: scanner.c:659
int process_omp_change()
Deal with any changes caused by other processes.
Definition: omp.c:31098
scanner_init_state_t scanner_init_state
The initialisation state of the scanner.
Definition: otp.c:411
#define logf(format, args...)
Dummy macro, enabled with LOG.
Definition: logf.h:81
int openvas_scanner_peek()
Check if there is any data to receive from connected Scanner socket.
Definition: scanner.c:715
buffer_size_t from_client_end
The end of the data in the from_client buffer.
Definition: ompd.c:89
gboolean ompd_send_to_client(const char *msg, void *write_to_client_data)
Send a response message to the client.
Definition: ompd.c:390
buffer_size_t from_buffer_size
Size of from_client data buffer, in bytes.
Definition: ompd.c:79
buffer_size_t to_client_start
The start of the data in the to_client buffer.
Definition: omp.c:4984
unsigned int to_server_buffer_space()
Get the number of characters free in the server output buffer.
void openvas_scanner_fd_set(fd_set *fd)
Add connected to Scanner&#39;s socket to an fd_set.
Definition: scanner.c:701
int openvas_scanner_connected()
Whether we have started a connection to the Scanner using openvas_scanner_connect().
Definition: scanner.c:764
int process_omp_client_input()
Process any XML available in from_client.
Definition: omp.c:30895
int openvas_scanner_full()
Check whether the buffer for data from Scanner is full.
Definition: scanner.c:310
void(* progress)()
Function to mark progress.
Definition: manage_sql.c:352
volatile int termination_signal
Flag for signal handlers.
Definition: openvasmd.c:256
int openvas_scanner_write(int nvt_cache_mode)
Write as much as possible from the to_scanner buffer to the scanner.
Definition: scanner.c:338
void set_scanner_init_state(scanner_init_state_t state)
Set the scanner initialisation state, scanner_init_state.
Definition: otp.c:432
int openvas_scanner_connect()
Create a new connection to the scanner and set it as current scanner.
Definition: scanner.c:619
int get_termination_signal()
Gets the last termination signal or 0.
Definition: manage.c:9582
int openvas_scanner_get_nfds(int socket)
Get the nfds value to use for a select() call.
Definition: scanner.c:732
char from_client[FROM_BUFFER_SIZE]
Buffer of input from the client.
Definition: ompd.c:74
int openvas_scanner_init(int cache_mode)
Initializes the already setup connection with the Scanner.
Definition: scanner.c:778
int openvas_scanner_session_peek()
Check if there is any data to receive from connected Scanner session.
Definition: scanner.c:747
credentials_t current_credentials
Current credentials during any OMP command.
Definition: manage.c:717
#define g_info(...)
Defines g_info for glib versions older than 2.40.
Definition: manage.h:55
void free_tasks()
Dummy function.
Definition: manage_sql.c:31878
buffer_size_t to_client_end
The end of the data in the to_client buffer.
Definition: omp.c:4988
int manage_scanner_set_default()
Set the default scanner as the scanner to connect to.
Definition: manage_sql.c:17440
int process_otp_scanner_input(void(*progress)())
Process any lines available in from_scanner.
Definition: otp.c:781
unsigned int buffer_size_t
Definition: types.h:31
int openvas_scanner_fd_isset(fd_set *fd)
Check if connected to Scanner is set in an fd_set.
Definition: scanner.c:688
int openvas_scanner_close()
Finish the connection to the Scanner and free internal buffers.
Definition: scanner.c:551

Variable Documentation

◆ from_buffer_size

buffer_size_t from_buffer_size = FROM_BUFFER_SIZE

Size of from_client data buffer, in bytes.

Todo:
As with the OMP version, this should most likely be passed to and from the client in a data structure like an otp_parser_t.

Definition at line 79 of file ompd.c.

◆ from_client

char from_client[FROM_BUFFER_SIZE]

Buffer of input from the client.

Todo:
Most likely the client should get these from init_omp_process inside an omp_parser_t and should pass the omp_parser_t to process_omp_client_input. process_omp_client_input can pass then pass them on to the other Manager "libraries".

Definition at line 74 of file ompd.c.

◆ from_client_end

buffer_size_t from_client_end = 0

The end of the data in the from_client buffer.

Definition at line 89 of file ompd.c.

Referenced by init_ompd_process().

◆ from_client_start

buffer_size_t from_client_start = 0

The start of the data in the from_client buffer.

Definition at line 84 of file ompd.c.

Referenced by init_ompd_process().