Flowgrind
Advanced TCP traffic generator
fg_rpc_client.h File Reference

RPC related functions used by the Flowgrind controller flowgrind-stop. More...

#include "config.h"
#include <stdbool.h>

Go to the source code of this file.

Functions

void parse_rpc_address (char **rpc_address, int *port, bool *is_ipv6)
 Parse RPC address for the xmlrpc control connection. More...
 

Detailed Description

RPC related functions used by the Flowgrind controller flowgrind-stop.

Definition in file fg_rpc_client.h.

Function Documentation

◆ parse_rpc_address()

void parse_rpc_address ( char **  rpc_address,
int *  port,
bool *  is_ipv6 
)

Parse RPC address for the xmlrpc control connection.

Parameters
[in,out]rpc_addressstring in format CONTROL[:PORT]. It will be truncated to CONTROL
[out]portport if the control address rpc_address contains a port
[out]is_ipv6true if control address rpc_address is a numerical

Definition at line 40 of file fg_rpc_client.c.

41 {
42  char* sepptr = NULL;
43 
44  /* 1st case: IPv6 with port, e.g. "[a:b::c]:5999" */
45  if ((sepptr = strchr(*rpc_address, ']'))) {
46  *is_ipv6 = true;
47  *sepptr = '\0';
48  if (*rpc_address[0] == '[')
49  (*rpc_address)++;
50  sepptr++;
51  if (sepptr != '\0' && *sepptr == ':')
52  sepptr++;
53  *port = atoi(sepptr);
54  } else if ((sepptr = strchr(*rpc_address, ':'))) {
55  /* 2nd case: IPv6 without port, e.g. "a:b::c" */
56  if (strchr(sepptr+1, ':')) {
57  *is_ipv6 = true;
58  } else {
59  /* 3rd case: IPv4 or name with port 1.2.3.4:5999 */
60  *sepptr = '\0';
61  sepptr++;
62  if ((*sepptr != '\0') && (*sepptr == ':'))
63  sepptr++;
64  *port = atoi(sepptr);
65  }
66  }
67 }
port
static unsigned port
Definition: flowgrindd.c:95