Flowgrind
Advanced TCP traffic generator
fg_rpc_server.h File Reference

RPCServer related functions and structs used by the Flowgrind daemon. More...

#include "config.h"
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <netdb.h>
#include <netinet/tcp.h>
#include <xmlrpc-c/base.h>
#include <xmlrpc-c/server.h>
#include <xmlrpc-c/server_abyss.h>
#include <xmlrpc-c/util.h>

Go to the source code of this file.

Data Structures

struct  fg_rpc_server
 Information about the daemons XMLrpc server. More...
 

Functions

void init_rpc_server (struct fg_rpc_server *server, char *rpc_bind_addr, unsigned port)
 Initializes the xmlrpc server. More...
 
void run_rpc_server (struct fg_rpc_server *server)
 Enters the xmlrpc server mainloop. More...
 

Detailed Description

RPCServer related functions and structs used by the Flowgrind daemon.

Definition in file fg_rpc_server.h.

Function Documentation

void init_rpc_server ( struct fg_rpc_server server,
char *  rpc_bind_addr,
unsigned  port 
)

Initializes the xmlrpc server.

This function initializes the xmlrpc environment, registers exported methods and binds to the control port.

Definition at line 835 of file fg_rpc_server.c.

836 {
837  xmlrpc_registry * registryP;
838  xmlrpc_env *env = &(server->env);
839  memset(&(server->parms), 0, sizeof(server->parms));
840 
841  xmlrpc_env_init(env);
842  registryP = xmlrpc_registry_new(env);
843 
844  xmlrpc_registry_add_method(env, registryP, NULL, "add_flow_destination", &add_flow_destination, NULL);
845  xmlrpc_registry_add_method(env, registryP, NULL, "add_flow_source", &add_flow_source, NULL);
846  xmlrpc_registry_add_method(env, registryP, NULL, "start_flows", &start_flows, NULL);
847  xmlrpc_registry_add_method(env, registryP, NULL, "get_reports", &method_get_reports, NULL);
848  xmlrpc_registry_add_method(env, registryP, NULL, "stop_flow", &method_stop_flow, NULL);
849  xmlrpc_registry_add_method(env, registryP, NULL, "get_version", &method_get_version, NULL);
850  xmlrpc_registry_add_method(env, registryP, NULL, "get_status", &method_get_status, NULL);
851  xmlrpc_registry_add_method(env, registryP, NULL, "get_uuid", &method_get_uuid, NULL);
852 
853  /* In the modern form of the Abyss API, we supply parameters in memory
854  like a normal API. We select the modern form by setting
855  config_file_name to NULL:
856  */
857  server->parms.config_file_name = NULL;
858  server->parms.registryP = registryP;
859  server->parms.socket_bound = 1;
860  server->parms.log_file_name = NULL; /*"/tmp/xmlrpc_log";*/
861 
862  /* Increase HTTP keep-alive duration. Using defaults the amount of
863  * sockets in TIME_WAIT state would become too high.
864  */
865  server->parms.keepalive_timeout = 60;
866  server->parms.keepalive_max_conn = 1000;
867 
868  /* Disable introspection */
869  server->parms.dont_advertise = 1;
870 
871  logging(LOG_NOTICE, "running XML-RPC server on port %u", port);
872  printf("Running XML-RPC server...\n");
873 
874  server->parms.socket_handle = bind_rpc_server(rpc_bind_addr, port);
875 }
static xmlrpc_value * method_get_reports(xmlrpc_env *const env, xmlrpc_value *const param_array, void *const user_data)
To get the reports from the daemon.
static char * rpc_bind_addr
Definition: flowgrindd.c:98
static xmlrpc_value * method_stop_flow(xmlrpc_env *const env, xmlrpc_value *const param_array, void *const user_data)
static int bind_rpc_server(char *bind_addr, unsigned port)
void logging(int priority, const char *fmt,...)
Definition: fg_log.c:69
static unsigned port
Definition: flowgrindd.c:95
xmlrpc_server_abyss_parms parms
Parameters of the XMLrpc server.
Definition: fg_rpc_server.h:54
static xmlrpc_value * add_flow_source(xmlrpc_env *const env, xmlrpc_value *const param_array, void *const user_data)
Prepare data connection for source endpoint.
Definition: fg_rpc_server.c:62
static xmlrpc_value * method_get_status(xmlrpc_env *const env, xmlrpc_value *const param_array, void *const user_data)
static xmlrpc_value * method_get_uuid(xmlrpc_env *const env, xmlrpc_value *const param_array, void *const user_data)
To get the daemons UUID.
static xmlrpc_value * start_flows(xmlrpc_env *const env, xmlrpc_value *const param_array, void *const user_data)
static xmlrpc_value * method_get_version(xmlrpc_env *const env, xmlrpc_value *const param_array, void *const user_data)
static xmlrpc_value * add_flow_destination(xmlrpc_env *const env, xmlrpc_value *const param_array, void *const user_data)
Prepare data connection for destination endpoint.
xmlrpc_env env
Environment used by the Abyss server.
Definition: fg_rpc_server.h:52
void run_rpc_server ( struct fg_rpc_server server)

Enters the xmlrpc server mainloop.

Definition at line 878 of file fg_rpc_server.c.

879 {
880  xmlrpc_env *env = &(server->env);
881  xmlrpc_server_abyss(env, &(server->parms), XMLRPC_APSIZE(socket_handle));
882 
883  if (env->fault_occurred)
884  logging(LOG_ALERT, "XML-RPC Fault: %s (%d)", env->fault_string,
885  env->fault_code);
886  /* xmlrpc_server_abyss() never returns */
887 }
void logging(int priority, const char *fmt,...)
Definition: fg_log.c:69
xmlrpc_server_abyss_parms parms
Parameters of the XMLrpc server.
Definition: fg_rpc_server.h:54
xmlrpc_env env
Environment used by the Abyss server.
Definition: fg_rpc_server.h:52