35static void trace_connection_input_input (
trace_type_t *,
unsigned,
char *);
37static void trace_connection_output_input (
trace_type_t *,
unsigned,
char *);
38static void trace_connection_output_stop (
trace_type_t *);
41static isc_result_t omapi_connection_reader_trace (
omapi_object_t *,
48 trace_connection_input =
51 trace_connection_input_input,
52 trace_connection_input_stop,
MDL);
53 trace_connection_output =
56 trace_connection_output_input,
57 trace_connection_output_stop,
MDL);
60static void trace_connection_input_input (
trace_type_t *ttype,
61 unsigned length,
char *buf)
63 unsigned left, taken, cc = 0;
65 int32_t connect_index;
69 memcpy (&connect_index, buf,
sizeof connect_index);
70 connect_index = ntohl (connect_index);
74 if (lp -> index == ntohl (connect_index)) {
75 omapi_connection_reference (&c, lp,
MDL);
76 omapi_connection_dereference (&lp,
MDL);
83 log_error (
"trace connection input: no connection index %ld",
84 (
long int)connect_index);
88 s = buf +
sizeof connect_index;
89 left = length -
sizeof connect_index;
97 isc_result_totext (status));
103 "input is not being consumed.");
112 omapi_connection_dereference (&c,
MDL);
115static void trace_connection_input_stop (
trace_type_t *ttype) { }
117static void trace_connection_output_input (
trace_type_t *ttype,
118 unsigned length,
char *buf)
124static void trace_connection_output_stop (
trace_type_t *ttype) { }
134 return omapi_connection_reader_trace (h, 0, (
char *)0, (
unsigned *)0);
137static isc_result_t omapi_connection_reader_trace (
omapi_object_t *h,
140 unsigned *stuff_taken)
148 unsigned bytes_to_read;
156 c -> in_bytes > c -> bytes_needed)
179 while (bytes_to_read) {
188 if (read_len > stuff_len)
189 read_len = stuff_len;
191 *stuff_taken += read_len;
193 stuff_buf, read_len);
194 stuff_len -= read_len;
195 stuff_buf += read_len;
196 read_status = read_len;
203 read_status = read (c -> socket,
207 if (read_status < 0) {
208 if (errno == EWOULDBLOCK)
210 else if (errno == EIO)
211 return ISC_R_IOERROR;
212 else if (errno == EINVAL)
214 else if (errno == ECONNRESET) {
216 return ISC_R_SHUTTINGDOWN;
218 return ISC_R_UNEXPECTED;
223 if (read_status == 0) {
225 return ISC_R_SHUTTINGDOWN;
230 int32_t connect_index;
232 connect_index = htonl (c -> index);
234 iov [0].
buf = (
char *)&connect_index;
235 iov [0].
len =
sizeof connect_index;
237 iov [1].
len = read_status;
240 (trace_connection_input, 2, iov,
MDL));
244 isc_result_totext (status));
248 buffer -> tail += read_status;
249 c -> in_bytes += read_status;
252 if (read_status < read_len)
254 bytes_to_read -= read_status;
257 if (c -> bytes_needed <= c -> in_bytes) {
266 const unsigned char *bufp,
271 int bytes_copied = 0;
285 return ISC_R_NOTCONNECTED;
288 for (
buffer = c -> outbufs;
298 while (bytes_copied < len) {
313 if (copy_len > (len - bytes_copied))
314 copy_len = len - bytes_copied;
317 if (!c -> out_context)
320 (sig_flags, c -> out_key, &c -> out_context,
321 &bufp [bytes_copied], copy_len,
328 &bufp [bytes_copied], copy_len);
329 buffer -> tail += copy_len;
330 c -> out_bytes += copy_len;
331 bytes_copied += copy_len;
345 if ((c->outer != NULL) &&
348 isc_socket_fdwatchpoke(io->
fd,
349 ISC_SOCKFDWATCH_WRITE);
363 unsigned bytes_remaining;
364 unsigned bytes_this_copy;
376 if (size > c -> in_bytes)
379 bytes_remaining = size;
382 while (bytes_remaining) {
384 return ISC_R_UNEXPECTED;
389 first_byte =
buffer -> head + 1;
391 if (first_byte >
buffer -> tail) {
392 bytes_this_copy = (
sizeof buffer -> buf -
396 buffer -> tail - first_byte;
398 if (bytes_this_copy > bytes_remaining)
399 bytes_this_copy = bytes_remaining;
402 if (!c -> in_context)
409 &
buffer -> buf [first_byte],
416 memcpy (bufp, &
buffer -> buf [first_byte],
418 bufp += bytes_this_copy;
420 bytes_remaining -= bytes_this_copy;
421 buffer -> head = first_byte + bytes_this_copy - 1;
422 c -> in_bytes -= bytes_this_copy;
431 while (c -> inbufs &&
433 if (c -> inbufs -> next) {
435 c -> inbufs -> next,
MDL);
450 unsigned bytes_this_write;
466 while (c -> out_bytes) {
468 return ISC_R_UNEXPECTED;
473 first_byte =
buffer -> head + 1;
475 if (first_byte >
buffer -> tail) {
476 bytes_this_write = (
sizeof buffer -> buf -
480 buffer -> tail - first_byte;
482 bytes_written = write (c -> socket,
483 &
buffer -> buf [first_byte],
489 if (bytes_written < 0) {
490 if (errno == EWOULDBLOCK || errno == EAGAIN)
491 return ISC_R_INPROGRESS;
492 else if (errno == EPIPE)
495 else if (errno == EFBIG || errno == EDQUOT)
497 else if (errno == EFBIG)
499 return ISC_R_NORESOURCES;
500 else if (errno == ENOSPC)
501 return ISC_R_NOSPACE;
502 else if (errno == EIO)
503 return ISC_R_IOERROR;
504 else if (errno == EINVAL)
506 else if (errno == ECONNRESET)
507 return ISC_R_SHUTTINGDOWN;
509 return ISC_R_UNEXPECTED;
511 if (bytes_written == 0)
512 return ISC_R_INPROGRESS;
518 int32_t connect_index;
520 connect_index = htonl (c -> index);
522 iov [0].
buf = (
char *)&connect_index;
523 iov [0].
len =
sizeof connect_index;
525 iov [1].
len = bytes_written;
528 (trace_connection_input, 2, iov,
534 isc_result_totext (status));
539 buffer -> head = first_byte + bytes_written - 1;
540 c -> out_bytes -= bytes_written;
545 if (bytes_written != bytes_this_write)
546 return ISC_R_INPROGRESS;
555 while (c -> outbufs &&
557 if (c -> outbufs -> next) {
559 c -> outbufs -> next,
MDL);
574 return ISC_R_SHUTTINGDOWN;
591 *result = ntohl (inbuf);
600 inbuf = htonl (
value);
617 *result = ntohs (inbuf);
626 inbuf = htons (
value);
642 switch (data -> type) {
681 unsigned len = strlen (name);
696 len = strlen (
string);
705 (c, (
const unsigned char *)
string, len);
isc_result_t omapi_buffer_dereference(omapi_buffer_t **, const char *, int)
isc_result_t omapi_buffer_new(omapi_buffer_t **, const char *, int)
isc_result_t omapi_buffer_reference(omapi_buffer_t **, omapi_buffer_t *, const char *, int)
isc_result_t omapi_connection_put_string(omapi_object_t *c, const char *string)
isc_result_t omapi_connection_reader(omapi_object_t *h)
isc_result_t omapi_connection_write_typed_data(omapi_object_t *c, omapi_typed_data_t *data)
isc_result_t omapi_connection_writer(omapi_object_t *h)
isc_result_t omapi_connection_put_named_uint32(omapi_object_t *c, const char *name, u_int32_t value)
isc_result_t omapi_connection_put_uint16(omapi_object_t *c, u_int32_t value)
isc_result_t omapi_connection_get_uint16(omapi_object_t *c, u_int16_t *result)
isc_result_t omapi_connection_copyin(omapi_object_t *h, const unsigned char *bufp, unsigned len)
isc_result_t omapi_connection_copyout(unsigned char *buf, omapi_object_t *h, unsigned size)
isc_result_t omapi_connection_put_name(omapi_object_t *c, const char *name)
isc_result_t omapi_connection_put_handle(omapi_object_t *c, omapi_object_t *h)
isc_result_t omapi_connection_put_uint32(omapi_object_t *c, u_int32_t value)
isc_result_t omapi_connection_get_uint32(omapi_object_t *c, u_int32_t *result)
struct _omapi_buffer omapi_buffer_t
#define BYTES_IN_BUFFER(x)
#define BUFFER_BYTES_FREE(x)
#define omapi_array_foreach_begin(array, stype, var)
omapi_object_type_t * omapi_type_io_object
isc_result_t omapi_object_handle(omapi_handle_t *, omapi_object_t *)
struct __omapi_object omapi_object_t
isc_result_t omapi_disconnect(omapi_object_t *, int)
isc_result_t omapi_signal(omapi_object_t *, const char *,...)
#define omapi_array_foreach_end(array, stype, var)
unsigned int omapi_handle_t
omapi_object_type_t * omapi_type_connection
int log_error(const char *,...) __attribute__((__format__(__printf__
struct __omapi_connection_object omapi_connection_object_t
omapi_type_protocol_listener omapi_type_listener omapi_type_waiter omapi_type_message isc_result_t omapi_connection_sign_data(int mode, dst_key_t *key, void **context, const unsigned char *data, const unsigned len, omapi_typed_data_t **result)
void omapi_buffer_trace_setup(void)
struct __omapi_io_object omapi_io_object_t
@ omapi_connection_disconnecting
@ omapi_connection_closed
#define DHCP_R_INVALIDARG
omapi_connection_state_t state
struct omapi_typed_data_t::@005330231110240362320041053235346164005276246221::@131374275124060200224243254021133345104025056044 buffer
struct trace_iov trace_iov_t
trace_type_t * trace_type_register(const char *, void *, void(*)(trace_type_t *, unsigned, char *), void(*)(trace_type_t *), const char *, int)
struct trace_type trace_type_t
isc_result_t trace_write_packet_iov(trace_type_t *, int, trace_iov_t *, const char *, int)