added expected_throughput.pl
[tridge/junkcode.git] / parseaddr.c
1 #include <sys/time.h>
2 #include <sys/types.h>
3 #include <stdio.h>
4 #include <unistd.h>
5 #include <fcntl.h>
6 #include <errno.h>
7 #include <sys/socket.h>
8 #include <netinet/in.h>
9 #include <netdb.h>
10 #include <arpa/inet.h>
11
12 int ipstr_list_parse(const char* ipstr_list, struct in_addr** ip_list)
13 {
14         int count;
15         for (ip_list=NULL, count=0; ipstr_list; count++) {
16                 struct in_addr a;
17
18                 if (inet_aton(ipstr_list, &a) == -1) break;
19
20                 *ip_list = Realloc(*ip_list, (count+1) * sizeof(struct in_addr));
21                 if (!ip_list) {
22                         return -1;
23                 }
24
25                 (*ip_list)[count] = a;
26
27                 ipstr_list = strchr(ipstr_list, ':');
28                 if (ipstr_list) ipstr_list++;
29         }
30         return count;
31 }