return;
}
- DEBUG(10,("Received krb5 TCP packet of length %lu from %s\n",
+ DEBUG(10,("Received DNS TCP packet of length %lu from %s\n",
(long) call->in.length,
tsocket_address_string(dns_conn->conn->remote_address, call)));
/* skip length header */
- call->in.data += 4;
- call->in.length -= 4;
+ call->in.data += 2;
+ call->in.length -= 2;
/* Call dns */
status = dns_process(dns_conn->dns_socket->dns, call, &call->in, &call->out);
}
/* First add the length of the out buffer */
- RSIVAL(call->out_hdr, 0, call->out.length);
+ RSSVAL(call->out_hdr, 0, call->out.length);
call->out_iov[0].iov_base = (char *) call->out_hdr;
- call->out_iov[0].iov_len = 4;
+ call->out_iov[0].iov_len = 2;
call->out_iov[1].iov_base = (char *) call->out.data;
call->out_iov[1].iov_len = call->out.length;
tevent_req_set_callback(subreq, dns_tcp_call_writev_done, call);
/*
- * The krb5 tcp pdu's has the length as 4 byte (initial_read_size),
- * packet_full_request_u32 provides the pdu length then.
+ * The dns tcp pdu's has the length as 2 byte (initial_read_size),
+ * packet_full_request_u16 provides the pdu length then.
*/
subreq = tstream_read_pdu_blob_send(dns_conn,
dns_conn->conn->event.ctx,
dns_conn->tstream,
- 4, /* initial_read_size */
- packet_full_request_u32,
+ 2, /* initial_read_size */
+ packet_full_request_u16,
dns_conn);
if (subreq == NULL) {
dns_tcp_terminate_connection(dns_conn, "dns_tcp_call_loop: "
conn->private_data = dns_conn;
/*
- * The krb5 tcp pdu's has the length as 4 byte (initial_read_size),
- * packet_full_request_u32 provides the pdu length then.
+ * The dns tcp pdu's has the length as 2 byte (initial_read_size),
+ * packet_full_request_u16 provides the pdu length then.
*/
subreq = tstream_read_pdu_blob_send(dns_conn,
dns_conn->conn->event.ctx,
dns_conn->tstream,
- 4, /* initial_read_size */
- packet_full_request_u32,
+ 2, /* initial_read_size */
+ packet_full_request_u16,
dns_conn);
if (subreq == NULL) {
dns_tcp_terminate_connection(dns_conn, "dns_tcp_accept: "
if s is not None:
s.close()
+ def dns_transaction_tcp(self, packet, host=os.getenv('DC_SERVER_IP')):
+ "send a DNS query and read the reply"
+ s = None
+ try:
+ send_packet = ndr.ndr_pack(packet)
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
+ s.connect((host, 53))
+ tcp_packet = struct.pack('!H', len(send_packet))
+ tcp_packet += send_packet
+ s.send(tcp_packet, 0)
+ recv_packet = s.recv(0xffff + 2, 0)
+ return ndr.ndr_unpack(dns.name_packet, recv_packet[2:])
+ finally:
+ if s is not None:
+ s.close()
+
def test_one_a_query(self):
"create a query packet containing one query record"
p = self.make_name_packet(dns.DNS_OPCODE_QUERY)
self.assertEquals(response.answers[0].rdata,
os.getenv('DC_SERVER_IP'))
+ def test_one_a_query_tcp(self):
+ "create a query packet containing one query record via TCP"
+ p = self.make_name_packet(dns.DNS_OPCODE_QUERY)
+ questions = []
+
+ name = "%s.%s" % (os.getenv('DC_SERVER'), self.get_dns_domain())
+ q = self.make_name_question(name, dns.DNS_QTYPE_A, dns.DNS_QCLASS_IN)
+ print "asking for ", q.name
+ questions.append(q)
+
+ self.finish_name_packet(p, questions)
+ response = self.dns_transaction_tcp(p)
+ self.assert_dns_rcode_equals(response, dns.DNS_RCODE_OK)
+ self.assert_dns_opcode_equals(response, dns.DNS_OPCODE_QUERY)
+ self.assertEquals(response.ancount, 1)
+ self.assertEquals(response.answers[0].rdata,
+ os.getenv('DC_SERVER_IP'))
+
def test_two_queries(self):
"create a query packet containing two query records"
p = self.make_name_packet(dns.DNS_OPCODE_QUERY)