dispatch_tcp_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"
unsigned char render_buffer[1024];
void start_response(void);
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 (%p, %d): 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
{
}
/*
* Create a dispatch context
*/
== ISC_R_SUCCESS);
&resp)
== ISC_R_SUCCESS);
}
void
{
(void)task;
printf("Send done (SUCCESS)\n");
return;
}
printf("--- removing response (FAILURE)\n");
}
void
start_response(void)
{
unsigned char namebuf[255];
#define QUESTION "flame.org."
#ifdef ISC_PLATFORM_HAVESALEN
#endif
&target);
printf("--- adding response\n");
}
void
{
(void)task;
printf("App: Got response (id %d). Result: %s\n",
printf("--- removing response\n");
}
void
{
static int cnt = 0;
printf("App: Got request. Result: %s\n",
printf("Got error, terminating application\n");
return;
}
sleep (1);
printf("App: Ready.\n");
cnt++;
switch (cnt) {
case 6:
printf("--- removing request\n");
break;
case 3:
printf("--- removing request\n");
printf("--- adding request\n");
== DNS_R_SUCCESS);
break;
default:
break;
}
}
int
{
(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_tcp, &s0) ==
== ISC_R_SUCCESS);
isc_app_run();
return (0);
}