Lines Matching refs:tcp

969 	struct xfrd_tcp* tcp = tp->tcp_w;  in xfrd_tcp_setup_write_packet()  local
982 xfrd_setup_packet(tcp->packet, TYPE_AXFR, CLASS_IN, zone->apex, in xfrd_tcp_setup_write_packet()
990 xfrd_setup_packet(tcp->packet, TYPE_IXFR, CLASS_IN, zone->apex, in xfrd_tcp_setup_write_packet()
993 NSCOUNT_SET(tcp->packet, 1); in xfrd_tcp_setup_write_packet()
994 xfrd_write_soa_buffer(tcp->packet, zone->apex, &zone->soa_disk); in xfrd_tcp_setup_write_packet()
998 tcp->packet, &zone->latest_xfr->tsig, zone->master); in xfrd_tcp_setup_write_packet()
1000 buffer_flip(tcp->packet); in xfrd_tcp_setup_write_packet()
1002 tcp->msglen = buffer_limit(tcp->packet); in xfrd_tcp_setup_write_packet()
1003 tcp->total_bytes = 0; in xfrd_tcp_setup_write_packet()
1007 tcp_conn_ready_for_reading(struct xfrd_tcp* tcp) in tcp_conn_ready_for_reading() argument
1009 tcp->total_bytes = 0; in tcp_conn_ready_for_reading()
1010 tcp->msglen = 0; in tcp_conn_ready_for_reading()
1011 buffer_clear(tcp->packet); in tcp_conn_ready_for_reading()
1016 conn_write_ssl(struct xfrd_tcp* tcp, SSL* ssl) in conn_write_ssl() argument
1021 if(tcp->total_bytes < sizeof(tcp->msglen)) { in conn_write_ssl()
1022 uint16_t sendlen = htons(tcp->msglen); in conn_write_ssl()
1024 request_length = sizeof(tcp->msglen) - tcp->total_bytes; in conn_write_ssl()
1026 sent = SSL_write(ssl, (const char*)&sendlen + tcp->total_bytes, in conn_write_ssl()
1044 tcp->total_bytes += sent; in conn_write_ssl()
1045 if(sent > (ssize_t)sizeof(tcp->msglen)) in conn_write_ssl()
1046 buffer_skip(tcp->packet, sent-sizeof(tcp->msglen)); in conn_write_ssl()
1047 if(tcp->total_bytes < sizeof(tcp->msglen)) { in conn_write_ssl()
1051 assert(tcp->total_bytes >= sizeof(tcp->msglen)); in conn_write_ssl()
1054 assert(tcp->total_bytes < tcp->msglen + sizeof(tcp->msglen)); in conn_write_ssl()
1056 request_length = buffer_remaining(tcp->packet); in conn_write_ssl()
1058 sent = SSL_write(ssl, buffer_current(tcp->packet), request_length); in conn_write_ssl()
1074 buffer_skip(tcp->packet, sent); in conn_write_ssl()
1075 tcp->total_bytes += sent; in conn_write_ssl()
1077 if(tcp->total_bytes < tcp->msglen + sizeof(tcp->msglen)) { in conn_write_ssl()
1082 assert(tcp->total_bytes == tcp->msglen + sizeof(tcp->msglen)); in conn_write_ssl()
1087 int conn_write(struct xfrd_tcp* tcp) in conn_write() argument
1091 if(tcp->total_bytes < sizeof(tcp->msglen)) { in conn_write()
1092 uint16_t sendlen = htons(tcp->msglen); in conn_write()
1095 iov[0].iov_base = (uint8_t*)&sendlen + tcp->total_bytes; in conn_write()
1096 iov[0].iov_len = sizeof(sendlen) - tcp->total_bytes; in conn_write()
1097 iov[1].iov_base = buffer_begin(tcp->packet); in conn_write()
1098 iov[1].iov_len = buffer_limit(tcp->packet); in conn_write()
1099 sent = writev(tcp->fd, iov, 2); in conn_write()
1101 sent = write(tcp->fd, in conn_write()
1102 (const char*)&sendlen + tcp->total_bytes, in conn_write()
1103 sizeof(tcp->msglen) - tcp->total_bytes); in conn_write()
1115 tcp->total_bytes += sent; in conn_write()
1116 if(sent > (ssize_t)sizeof(tcp->msglen)) in conn_write()
1117 buffer_skip(tcp->packet, sent-sizeof(tcp->msglen)); in conn_write()
1118 if(tcp->total_bytes < sizeof(tcp->msglen)) { in conn_write()
1123 if(tcp->total_bytes == tcp->msglen + sizeof(tcp->msglen)) { in conn_write()
1128 assert(tcp->total_bytes >= sizeof(tcp->msglen)); in conn_write()
1131 assert(tcp->total_bytes < tcp->msglen + sizeof(tcp->msglen)); in conn_write()
1133 sent = write(tcp->fd, in conn_write()
1134 buffer_current(tcp->packet), in conn_write()
1135 buffer_remaining(tcp->packet)); in conn_write()
1145 buffer_skip(tcp->packet, sent); in conn_write()
1146 tcp->total_bytes += sent; in conn_write()
1148 if(tcp->total_bytes < tcp->msglen + sizeof(tcp->msglen)) { in conn_write()
1153 assert(tcp->total_bytes == tcp->msglen + sizeof(tcp->msglen)); in conn_write()
1161 struct xfrd_tcp* tcp = tp->tcp_w; in xfrd_tcp_write() local
1170 if(getsockopt(tcp->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0){ in xfrd_tcp_write()
1186 ret = conn_write_ssl(tcp, tp->ssl); in xfrd_tcp_write()
1208 ret = conn_write(tcp); in xfrd_tcp_write()
1214 if(tcp->total_bytes != 0 && !tp->connection_established) in xfrd_tcp_write()
1232 ret = conn_write_ssl(tcp, tp->ssl); in xfrd_tcp_write()
1235 ret = conn_write(tcp); in xfrd_tcp_write()
1255 conn_read_ssl(struct xfrd_tcp* tcp, SSL* ssl) in conn_read_ssl() argument
1259 if(tcp->total_bytes < sizeof(tcp->msglen)) { in conn_read_ssl()
1262 (char*) &tcp->msglen + tcp->total_bytes, in conn_read_ssl()
1263 sizeof(tcp->msglen) - tcp->total_bytes); in conn_read_ssl()
1293 tcp->total_bytes += received; in conn_read_ssl()
1294 if(tcp->total_bytes < sizeof(tcp->msglen)) { in conn_read_ssl()
1299 assert(tcp->total_bytes == sizeof(tcp->msglen)); in conn_read_ssl()
1300 tcp->msglen = ntohs(tcp->msglen); in conn_read_ssl()
1302 if(tcp->msglen == 0) { in conn_read_ssl()
1303 buffer_set_limit(tcp->packet, tcp->msglen); in conn_read_ssl()
1306 if(tcp->msglen > buffer_capacity(tcp->packet)) { in conn_read_ssl()
1310 buffer_set_limit(tcp->packet, tcp->msglen); in conn_read_ssl()
1313 assert(buffer_remaining(tcp->packet) > 0); in conn_read_ssl()
1316 received = SSL_read(ssl, buffer_current(tcp->packet), in conn_read_ssl()
1317 buffer_remaining(tcp->packet)); in conn_read_ssl()
1346 tcp->total_bytes += received; in conn_read_ssl()
1347 buffer_skip(tcp->packet, received); in conn_read_ssl()
1349 if(buffer_remaining(tcp->packet) > 0) { in conn_read_ssl()
1355 assert(buffer_position(tcp->packet) == tcp->msglen); in conn_read_ssl()
1361 conn_read(struct xfrd_tcp* tcp) in conn_read() argument
1365 if(tcp->total_bytes < sizeof(tcp->msglen)) { in conn_read()
1366 received = read(tcp->fd, in conn_read()
1367 (char*) &tcp->msglen + tcp->total_bytes, in conn_read()
1368 sizeof(tcp->msglen) - tcp->total_bytes); in conn_read()
1384 tcp->total_bytes += received; in conn_read()
1385 if(tcp->total_bytes < sizeof(tcp->msglen)) { in conn_read()
1390 assert(tcp->total_bytes == sizeof(tcp->msglen)); in conn_read()
1391 tcp->msglen = ntohs(tcp->msglen); in conn_read()
1393 if(tcp->msglen == 0) { in conn_read()
1394 buffer_set_limit(tcp->packet, tcp->msglen); in conn_read()
1397 if(tcp->msglen > buffer_capacity(tcp->packet)) { in conn_read()
1401 buffer_set_limit(tcp->packet, tcp->msglen); in conn_read()
1404 assert(buffer_remaining(tcp->packet) > 0); in conn_read()
1406 received = read(tcp->fd, buffer_current(tcp->packet), in conn_read()
1407 buffer_remaining(tcp->packet)); in conn_read()
1424 tcp->total_bytes += received; in conn_read()
1425 buffer_skip(tcp->packet, received); in conn_read()
1427 if(buffer_remaining(tcp->packet) > 0) { in conn_read()
1433 assert(buffer_position(tcp->packet) == tcp->msglen); in conn_read()
1441 struct xfrd_tcp* tcp = tp->tcp_r; in xfrd_tcp_read() local
1447 ret = conn_read_ssl(tcp, tp->ssl); in xfrd_tcp_read()
1469 ret = conn_read(tcp); in xfrd_tcp_read()
1481 buffer_flip(tcp->packet); in xfrd_tcp_read()
1483 if(tcp->msglen < QHEADERSZ) { in xfrd_tcp_read()
1487 tcp_conn_ready_for_reading(tcp); in xfrd_tcp_read()
1490 zone = xfrd_tcp_pipeline_lookup_id(tp, ID(tcp->packet)); in xfrd_tcp_read()
1496 tcp_conn_ready_for_reading(tcp); in xfrd_tcp_read()
1502 pkt_result = xfrd_handle_received_xfr_packet(zone, tcp->packet); in xfrd_tcp_read()
1504 tcp_conn_ready_for_reading(tcp); in xfrd_tcp_read()