dispatch_test.c revision ca41b452ede6feaa9d8739ec3cae19389a7b0d03
/*
* Copyright (C) 1998, 1999, 2000 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <isc/assertions.h>
#include <dns/dispatch.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/rdataclass.h>
#include <dns/rdatatype.h>
#include "printmsg.h"
typedef struct {
int count;
unsigned char render_buffer[1024];
} clictx_t;
unsigned int client_count = 0;
static inline void CHECKRESULT(isc_result_t, char *);
void hex_dump(isc_buffer_t *);
void
hex_dump(isc_buffer_t *b)
{
unsigned int len;
isc_region_t r;
isc_buffer_remaining(b, &r);
printf("Buffer %p: used region base %p, length %d",
if (len % 16 == 0)
printf("\n");
}
printf("\n");
}
static inline void
{
if (result != DNS_R_SUCCESS) {
exit(1);
}
}
void
{
(void)task;
printf("Send done (SUCCESS)\n");
return;
}
printf("--- removing response (FAILURE)\n");
}
void
{
unsigned char namebuf[255];
#ifdef ISC_PLATFORM_HAVESALEN
#endif
&target);
printf("--- adding response\n");
client_count++;
}
void
{
unsigned int cnt;
(void)task;
printf("App: Got response (id %d). Result: %s\n",
printf("--- ERROR, shutting down response slot\n");
printf("--- shutting down dispatcher\n");
printf("--- removing response\n");
INSIST(client_count > 0);
client_count--;
cnt = client_count;
if (cnt == 0)
return;
}
printf("--- shutting down dispatcher\n");
printf("--- removing response\n");
INSIST(client_count > 0);
client_count--;
cnt = client_count;
if (cnt == 0)
}
void
{
unsigned int cnt;
printf("App: Got request. Result: %s\n",
printf("Got error, terminating CLIENT %p resp %p\n",
INSIST(client_count > 0);
client_count--;
cnt = client_count;
if (cnt == 0)
return;
}
sleep (1);
case 4:
printf("--- starting DNS lookup\n");
break;
case 2:
printf("--- removing request\n");
printf("--- adding request\n");
== DNS_R_SUCCESS);
break;
default:
break;
}
}
int
{
unsigned int i;
(void)argc;
(void)argv;
/*
* EVERYTHING needs a memory context.
*/
/*
* The task manager is independent (other than memory context)
*/
/*
* Open up a random socket. Who cares where.
*/
isc_sockettype_udp, &s0) ==
/*
* Create a dispatch context
*/
== ISC_R_SUCCESS);
for (i = 0 ; i < 2 ; i++) {
&clients[i],
== ISC_R_SUCCESS);
client_count++;
}
isc_app_run();
return (0);
}