Dont forward the ping packet

This commit is contained in:
Erik Ekman 2006-06-05 23:56:32 +00:00
parent 36b134361b
commit e24f396039
2 changed files with 12 additions and 8 deletions

17
dns.c
View file

@ -185,7 +185,7 @@ dns_ping(int dns_fd)
printf("No reply on chunk, resending\n");
dns_send_chunk(dns_fd);
} else {
dns_write(dns_fd, dns_fd, "", 0);
dns_write(dns_fd, chunkid++, "", 0);
}
}
@ -258,19 +258,22 @@ dns_write(int fd, int id, char *buf, int len)
avail = MIN(avail, len); // do not use more bytes than is available;
final = (avail == len); // is this the last block?
bzero(data, sizeof(data));
d = data;
// First byte is 0 for middle packet and 1 for last packet
*d = '0' + final;
d++;
for (i = 0; i < avail; i++) {
if (i > 0 && i % 31 == 0) {
*d = '.';
d++;
if (len > 0) {
for (i = 0; i < avail; i++) {
if (i > 0 && i % 31 == 0) {
*d = '.';
d++;
}
put_hex(d, buf[i]);
d += 2;
}
put_hex(d, buf[i]);
d += 2;
}
if (*d != '.') {
*d++ = '.';

3
dnsd.c
View file

@ -290,8 +290,9 @@ dnsd_read(int fd, char *buf, int buflen)
packetlen++;
}
dnsd_respond(fd, id, from);
if (lastblock && packetlen == 0) {
if (lastblock && packetlen < 2) {
// Skipping ping packet
packetlen = 0;
return 0;
}
if (lastblock) {