Flowgrind
Advanced TCP traffic generator
fg_rpc_client.c
Go to the documentation of this file.
1 
6 /*
7  * Copyright (C) 2013-2014 Alexander Zimmermann <alexander.zimmermann@netapp.com>
8  * Copyright (C) 2010-2014 Arnd Hannemann <arnd@arndnet.de>
9  * Copyright (C) 2010-2013 Christian Samsel <christian.samsel@rwth-aachen.de>
10  * Copyright (C) 2009 Tim Kosse <tim.kosse@gmx.de>
11  * Copyright (C) 2007-2008 Daniel Schaffrath <daniel.schaffrath@mac.com>
12  *
13  * This file is part of Flowgrind.
14  *
15  * Flowgrind is free software: you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation, either version 3 of the License, or
18  * (at your option) any later version.
19  *
20  * Flowgrind is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with Flowgrind. If not, see <http://www.gnu.org/licenses/>.
27  *
28  */
29 
30 #ifdef HAVE_CONFIG_H
31 #include "config.h"
32 #endif /* HAVE_CONFIG_H */
33 
34 #include <stdlib.h>
35 #include <stdbool.h>
36 #include <string.h>
37 
38 #include "fg_rpc_client.h"
39 
40 void parse_rpc_address(char **rpc_address, int *port, bool *is_ipv6)
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 }
void parse_rpc_address(char **rpc_address, int *port, bool *is_ipv6)
Parse RPC address for the xmlrpc control connection.
Definition: fg_rpc_client.c:40
static unsigned port
Definition: flowgrindd.c:95
RPC related functions used by the Flowgrind controller flowgrind-stop.