Renamed packet_sending to packet_empty

This commit is contained in:
Erik Ekman 2007-12-01 22:19:54 +00:00
parent fc632e6311
commit 9e60b36430
4 changed files with 15 additions and 17 deletions

View File

@ -160,10 +160,10 @@ read_dns(int fd, char *buf, int buflen)
rv = dns_decode(buf, buflen, &q, QR_ANSWER, data, r); rv = dns_decode(buf, buflen, &q, QR_ANSWER, data, r);
if (packet_sending(&packet) && chunkid == q.id) { if (packet_empty(&packet) == 0 && chunkid == q.id) {
/* Got ACK on sent packet */ /* Got ACK on sent packet */
packet_advance(&packet); packet_advance(&packet);
if (packet_sending(&packet)) { if (!packet_empty(&packet)) {
/* More to send */ /* More to send */
send_chunk(fd); send_chunk(fd);
} }
@ -213,7 +213,7 @@ tunnel_dns(int tun_fd, int dns_fd)
return -1; return -1;
write_tun(tun_fd, out, outlen); write_tun(tun_fd, out, outlen);
if (!packet_sending(&packet)) if (packet_empty(&packet))
send_ping(dns_fd); send_ping(dns_fd);
return read; return read;
@ -234,7 +234,7 @@ tunnel(int tun_fd, int dns_fd)
tv.tv_usec = 0; tv.tv_usec = 0;
FD_ZERO(&fds); FD_ZERO(&fds);
if (!packet_sending(&packet)) if (packet_empty(&packet))
FD_SET(tun_fd, &fds); FD_SET(tun_fd, &fds);
FD_SET(dns_fd, &fds); FD_SET(dns_fd, &fds);
@ -314,11 +314,8 @@ send_ping(int fd)
{ {
char data[3]; char data[3];
if (packet_sending(&packet)) { /* clear any packet not sent */
packet.sentlen = 0; packet_init(&packet);
packet.offset = 0;
packet.len = 0;
}
data[0] = userid; data[0] = userid;
data[1] = (rand_seed >> 8) & 0xff; data[1] = (rand_seed >> 8) & 0xff;

View File

@ -82,10 +82,8 @@ tunnel_tun(int tun_fd, int dns_fd)
compress2((uint8_t*)out, &outlen, (uint8_t*)in, read, 9); compress2((uint8_t*)out, &outlen, (uint8_t*)in, read, 9);
/* if another packet is queued, throw away this one. TODO build queue */ /* if another packet is queued, throw away this one. TODO build queue */
if (users[userid].outpacket.len == 0) { if (packet_empty(&(users[userid].outpacket)) == 0) {
memcpy(users[userid].outpacket.data, out, outlen); return packet_fill(&(users[userid].outpacket), out, outlen);
users[userid].outpacket.len = outlen;
return outlen;
} else { } else {
return 0; return 0;
} }

View File

@ -23,7 +23,7 @@
* Is some part of this packet sent? * Is some part of this packet sent?
*/ */
int int
packet_sending(struct packet *packet) packet_empty(struct packet *packet)
{ {
return (packet->len != 0); return (packet->len != 0);
} }

View File

@ -28,10 +28,13 @@ struct packet
}; };
void packet_init(struct packet *); void packet_init(struct packet *);
int packet_sending(struct packet *);
int packet_empty(struct packet *);
void packet_advance(struct packet *); void packet_advance(struct packet *);
int packet_len_to_send(struct packet *);
int packet_fill(struct packet *, char *, unsigned long);
void packet_send_len(struct packet *, int); void packet_send_len(struct packet *, int);
int packet_len_to_send(struct packet *);
int packet_fill(struct packet *, char *, unsigned long);
#endif #endif