#include <time.h>
#include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
#include "ib/ibwrapper.h"
struct ibwtest_ctx {
return -1;
}
}
- DEBUG(10, ("sent %d connect request...\n", tcx->naddrs));
+ DEBUG(DEBUG_DEBUG, ("sent %d connect request...\n", tcx->naddrs));
return 0;
}
void *key;
uint32_t len;
- DEBUG(10, ("ibwtest_send_id\n"));
+ DEBUG(DEBUG_DEBUG, ("ibwtest_send_id\n"));
len = sizeof(uint32_t)+strlen(tcx->id)+2;
if (ibw_alloc_send_buf(conn, (void **)&buf, &key, len)) {
- DEBUG(0, ("send_id: ibw_alloc_send_buf failed\n"));
+ DEBUG(DEBUG_ERR, ("send_id: ibw_alloc_send_buf failed\n"));
return -1;
}
strcpy(buf+sizeof(uint32_t)+1, tcx->id);
if (ibw_send(conn, buf, key, len)) {
- DEBUG(0, ("send_id: ibw_send error\n"));
+ DEBUG(DEBUG_ERR, ("send_id: ibw_send error\n"));
return -1;
}
tcx->nsent++;
strcpy(p, msg);
if (ibw_send(conn, buf, key, len)) {
- DEBUG(0, ("send_test_msg: ibw_send error\n"));
+ DEBUG(DEBUG_ERR, ("send_test_msg: ibw_send error\n"));
return -1;
}
tcx->nsent++;
len = sizeof(uint32_t) + 1 + size + 1;
if (ibw_alloc_send_buf(conn, (void **)&buf, &key, len)) {
- DEBUG(0, ("varsize/ibw_alloc_send_buf failed\n"));
+ DEBUG(DEBUG_ERR, ("varsize/ibw_alloc_send_buf failed\n"));
return -1;
}
*((uint32_t *)buf) = len;
sum = ibwtest_fill_random(buf + sizeof(uint32_t) + 1, size);
buf[sizeof(uint32_t) + 1 + size] = sum;
if (ibw_send(conn, buf, key, len)) {
- DEBUG(0, ("varsize/ibw_send failed\n"));
+ DEBUG(DEBUG_ERR, ("varsize/ibw_send failed\n"));
return -1;
}
tcx->nsent++;
switch(ctx->state) {
case IBWS_INIT:
- DEBUG(10, ("test IBWS_INIT\n"));
+ DEBUG(DEBUG_DEBUG, ("test IBWS_INIT\n"));
break;
case IBWS_READY:
- DEBUG(10, ("test IBWS_READY\n"));
+ DEBUG(DEBUG_DEBUG, ("test IBWS_READY\n"));
break;
case IBWS_CONNECT_REQUEST:
- DEBUG(10, ("test IBWS_CONNECT_REQUEST\n"));
+ DEBUG(DEBUG_DEBUG, ("test IBWS_CONNECT_REQUEST\n"));
tconn = talloc_zero(conn, struct ibwtest_conn);
if (ibw_accept(ctx, conn, tconn)) {
- DEBUG(0, ("error accepting the connect request\n"));
+ DEBUG(DEBUG_ERR, ("error accepting the connect request\n"));
}
break;
case IBWS_STOPPED:
- DEBUG(10, ("test IBWS_STOPPED\n"));
+ DEBUG(DEBUG_DEBUG, ("test IBWS_STOPPED\n"));
tcx->kill_me = 1; /* main loop can exit */
break;
case IBWS_ERROR:
- DEBUG(10, ("test IBWS_ERROR\n"));
+ DEBUG(DEBUG_DEBUG, ("test IBWS_ERROR\n"));
ibw_stop(tcx->ibwctx);
break;
default:
tconn = talloc_get_type(conn->conn_userdata, struct ibwtest_conn);
switch(conn->state) {
case IBWC_INIT:
- DEBUG(10, ("test IBWC_INIT\n"));
+ DEBUG(DEBUG_DEBUG, ("test IBWC_INIT\n"));
break;
case IBWC_CONNECTED:
if (gettimeofday(&tcx->start_time, NULL)) {
- DEBUG(0, ("gettimeofday error %d", errno));
+ DEBUG(DEBUG_ERR, ("gettimeofday error %d", errno));
return -1;
}
ibwtest_send_id(conn);
break;
case IBWC_DISCONNECTED:
- DEBUG(10, ("test IBWC_DISCONNECTED\n"));
+ DEBUG(DEBUG_DEBUG, ("test IBWC_DISCONNECTED\n"));
talloc_free(conn);
break;
case IBWC_ERROR:
- DEBUG(10, ("test IBWC_ERROR %s\n", ibw_getLastError()));
+ DEBUG(DEBUG_DEBUG, ("test IBWC_ERROR %s\n", ibw_getLastError()));
break;
default:
assert(0);
tconn->id = talloc_strdup(tconn, ((char *)buf)+sizeof(uint32_t)+1);
}
if (op==TESTOP_SEND_ID || op==TESTOP_SEND_TEXT) {
- DEBUG(11, ("[%d]msg from %s: \"%s\"(%d)\n", op,
+ DEBUG(DEBUG_DEBUG, ("[%d]msg from %s: \"%s\"(%d)\n", op,
tconn->id ? tconn->id : "NULL", ((char *)buf)+sizeof(uint32_t)+1, n));
}
unsigned char sum;
sum = ibwtest_get_sum((unsigned char *)buf + sizeof(uint32_t) + 1,
n - sizeof(uint32_t) - 2);
- DEBUG(11, ("[%d]msg varsize %u/sum %u from %s\n",
+ DEBUG(DEBUG_DEBUG, ("[%d]msg varsize %u/sum %u from %s\n",
op,
n - sizeof(uint32_t) - 2,
(uint32_t)sum,
tconn->id ? tconn->id : "NULL"));
if (sum!=((unsigned char *)buf)[n-1]) {
- DEBUG(0, ("ERROR: checksum mismatch %u!=%u\n",
+ DEBUG(DEBUG_ERR, ("ERROR: checksum mismatch %u!=%u\n",
(uint32_t)sum, (uint32_t)((unsigned char *)buf)[n-1]));
ibw_stop(tcx->ibwctx);
goto error;
void ibwtest_sigint_handler(int sig)
{
- DEBUG(0, ("got SIGINT\n"));
+ DEBUG(DEBUG_ERR, ("got SIGINT\n"));
if (testctx) {
if (testctx->ibwctx->state==IBWS_READY ||
testctx->ibwctx->state==IBWS_CONNECT_REQUEST ||
testctx->ibwctx->state==IBWS_ERROR)
{
if (testctx->stopping) {
- DEBUG(10, ("forcing exit...\n"));
+ DEBUG(DEBUG_DEBUG, ("forcing exit...\n"));
testctx->kill_me = 1;
} else {
/* mostly expected case */
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));
+ DEBUG(DEBUG_ERR, ("invalid nework address '%s'\n", address));
return -1;
}
memcpy(addr, he->h_addr, he->h_length);
char *tmp;
tmp = talloc_strdup(tcx, optarg);
+ if (tmp == NULL) return -1;
/* hack to reuse the above ibw_initattr parser */
if (ibwtest_parse_attrs(tcx, tmp, &attrs, &tcx->naddrs, op))
return -1;
}
if (ibw_bind(tcx->ibwctx, &tcx->addrs[0])) {
- DEBUG(0, ("ERROR: ibw_bind failed\n"));
+ DEBUG(DEBUG_ERR, ("ERROR: ibw_bind failed\n"));
return -1;
}
if (ibw_listen(tcx->ibwctx, 1)) {
- DEBUG(0, ("ERROR: ibw_listen failed\n"));
+ DEBUG(DEBUG_ERR, ("ERROR: ibw_listen failed\n"));
return -1;
}
{
int rc, op;
int result = 1;
- struct event_context *ev = NULL;
+ struct tevent_context *ev = NULL;
struct ibwtest_ctx *tcx = NULL;
float usec;
break;
case 'o':
tcx->opts = talloc_strdup(tcx, optarg);
+ if (tcx->opts) goto cleanup;
if (ibwtest_parse_attrs(tcx, tcx->opts, &tcx->attrs,
&tcx->nattrs, op))
goto cleanup;
if (!tcx->is_server && tcx->nsent!=0 && !tcx->error) {
if (gettimeofday(&tcx->end_time, NULL)) {
- DEBUG(0, ("gettimeofday error %d\n", errno));
+ DEBUG(DEBUG_ERR, ("gettimeofday error %d\n", errno));
goto cleanup;
}
usec = (tcx->end_time.tv_sec - tcx->start_time.tv_sec) * 1000000 +
talloc_free(tcx);
if (ev)
talloc_free(ev);
- DEBUG(0, ("exited with code %d\n", result));
+ DEBUG(DEBUG_ERR, ("exited with code %d\n", result));
return result;
}