summaryrefslogtreecommitdiff
path: root/source4/cluster/ctdb/ib/ibwrapper_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/cluster/ctdb/ib/ibwrapper_test.c')
-rw-r--r--source4/cluster/ctdb/ib/ibwrapper_test.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/source4/cluster/ctdb/ib/ibwrapper_test.c b/source4/cluster/ctdb/ib/ibwrapper_test.c
index 2942d26ed6..07c78e7709 100644
--- a/source4/cluster/ctdb/ib/ibwrapper_test.c
+++ b/source4/cluster/ctdb/ib/ibwrapper_test.c
@@ -289,7 +289,7 @@ int ibwtest_connstate_handler(struct ibw_ctx *ctx, struct ibw_conn *conn)
talloc_free(conn);
break;
case IBWC_ERROR:
- DEBUG(10, ("test IBWC_ERROR\n"));
+ DEBUG(10, ("test IBWC_ERROR %s\n", ibw_getLastError()));
break;
default:
assert(0);
@@ -335,7 +335,7 @@ int ibwtest_receive_handler(struct ibw_conn *conn, void *buf, int n)
ibw_stop(tcx->ibwctx);
goto error;
}
- } else {
+ } else if (op!=TESTOP_SEND_ID) {
char *buf2;
void *key2;
@@ -465,6 +465,19 @@ int ibwtest_parse_attrs(struct ibwtest_ctx *tcx, char *optext,
return 0;
}
+static int ibwtest_get_address(const char *address, struct in_addr *addr)
+{
+ if (inet_pton(AF_INET, address, addr) <= 0) {
+ struct hostent *he = gethostbyname(address);
+ if (he == NULL || he->h_length > sizeof(*addr)) {
+ DEBUG(0, ("invalid nework address '%s'\n", address));
+ return -1;
+ }
+ memcpy(addr, he->h_addr, he->h_length);
+ }
+ return 0;
+}
+
int ibwtest_getdests(struct ibwtest_ctx *tcx, char op)
{
int i;
@@ -482,7 +495,8 @@ int ibwtest_getdests(struct ibwtest_ctx *tcx, char op)
for(i=0; i<tcx->naddrs; i++) {
p = tcx->addrs + i;
p->sin_family = AF_INET;
- p->sin_addr.s_addr = inet_addr(attrs[i].name);
+ if (ibwtest_get_address(attrs[i].name, &p->sin_addr))
+ return -1;
p->sin_port = htons(atoi(attrs[i].value));
}
@@ -516,13 +530,14 @@ void ibwtest_usage(struct ibwtest_ctx *tcx, char *name)
printf("\t%s -i <id> -o {name:value} -d {addr:port} -t nsec -s\n", name);
printf("\t-i <id> is a free text, acting as a server id, max 23 chars [mandatory]\n");
printf("\t-o name1:value1,name2:value2,... is a list of (name, value) pairs\n");
- printf("\t-d addr1:port1,addr2:port2,... is a list of destination ip addresses\n");
+ printf("\t-a addr1:port1,addr2:port2,... is a list of destination ip addresses\n");
printf("\t-t nsec delta time between sends in nanosec [default %d]\n", tcx->nsec);
printf("\t\t send message periodically and endless when nsec is non-zero\n");
printf("\t-s server mode (you have to give exactly one -d address:port in this case)\n");
printf("\t-n number of messages to send [default %d]\n", tcx->nmsg);
printf("\t-l usec time to sleep in the main loop [default %d]\n", tcx->sleep_usec);
printf("\t-v max variable msg size in bytes [default %d], 0=don't send var. size\n", tcx->maxsize);
+ printf("\t-d LogLevel [default %d]\n", LogLevel);
printf("Press ctrl+C to stop the program.\n");
}
@@ -538,13 +553,14 @@ int main(int argc, char *argv[])
memset(tcx, 0, sizeof(struct ibwtest_ctx));
tcx->nsec = 0;
tcx->nmsg = 1000;
+ LogLevel = 0;
/* here is the only case we can't avoid using global... */
testctx = tcx;
signal(SIGINT, ibwtest_sigint_handler);
srand((unsigned)time(NULL));
- while ((op=getopt(argc, argv, "i:o:d:m:st:n:l:v:")) != -1) {
+ while ((op=getopt(argc, argv, "i:o:d:m:st:n:l:v:a:")) != -1) {
switch (op) {
case 'i':
tcx->id = talloc_strdup(tcx, optarg);
@@ -555,7 +571,7 @@ int main(int argc, char *argv[])
&tcx->nattrs, op))
goto cleanup;
break;
- case 'd':
+ case 'a':
if (ibwtest_getdests(tcx, op))
goto cleanup;
break;
@@ -574,6 +590,9 @@ int main(int argc, char *argv[])
case 'v':
tcx->maxsize = (unsigned int)atoi(optarg);
break;
+ case 'd':
+ LogLevel = atoi(optarg);
+ break;
default:
fprintf(stderr, "ERROR: unknown option -%c\n", (char)op);
ibwtest_usage(tcx, argv[0]);