mirror of
https://github.com/yarrick/iodine.git
synced 2024-12-27 15:23:33 +02:00
Renamed packet_sending to packet_empty
This commit is contained in:
parent
fc632e6311
commit
9e60b36430
4 changed files with 15 additions and 17 deletions
15
src/iodine.c
15
src/iodine.c
|
@ -160,10 +160,10 @@ read_dns(int fd, char *buf, int buflen)
|
|||
|
||||
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 */
|
||||
packet_advance(&packet);
|
||||
if (packet_sending(&packet)) {
|
||||
if (!packet_empty(&packet)) {
|
||||
/* More to send */
|
||||
send_chunk(fd);
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ tunnel_dns(int tun_fd, int dns_fd)
|
|||
return -1;
|
||||
|
||||
write_tun(tun_fd, out, outlen);
|
||||
if (!packet_sending(&packet))
|
||||
if (packet_empty(&packet))
|
||||
send_ping(dns_fd);
|
||||
|
||||
return read;
|
||||
|
@ -234,7 +234,7 @@ tunnel(int tun_fd, int dns_fd)
|
|||
tv.tv_usec = 0;
|
||||
|
||||
FD_ZERO(&fds);
|
||||
if (!packet_sending(&packet))
|
||||
if (packet_empty(&packet))
|
||||
FD_SET(tun_fd, &fds);
|
||||
FD_SET(dns_fd, &fds);
|
||||
|
||||
|
@ -314,11 +314,8 @@ send_ping(int fd)
|
|||
{
|
||||
char data[3];
|
||||
|
||||
if (packet_sending(&packet)) {
|
||||
packet.sentlen = 0;
|
||||
packet.offset = 0;
|
||||
packet.len = 0;
|
||||
}
|
||||
/* clear any packet not sent */
|
||||
packet_init(&packet);
|
||||
|
||||
data[0] = userid;
|
||||
data[1] = (rand_seed >> 8) & 0xff;
|
||||
|
|
|
@ -82,10 +82,8 @@ tunnel_tun(int tun_fd, int dns_fd)
|
|||
compress2((uint8_t*)out, &outlen, (uint8_t*)in, read, 9);
|
||||
|
||||
/* if another packet is queued, throw away this one. TODO build queue */
|
||||
if (users[userid].outpacket.len == 0) {
|
||||
memcpy(users[userid].outpacket.data, out, outlen);
|
||||
users[userid].outpacket.len = outlen;
|
||||
return outlen;
|
||||
if (packet_empty(&(users[userid].outpacket)) == 0) {
|
||||
return packet_fill(&(users[userid].outpacket), out, outlen);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
* Is some part of this packet sent?
|
||||
*/
|
||||
int
|
||||
packet_sending(struct packet *packet)
|
||||
packet_empty(struct packet *packet)
|
||||
{
|
||||
return (packet->len != 0);
|
||||
}
|
||||
|
|
|
@ -28,10 +28,13 @@ struct packet
|
|||
};
|
||||
|
||||
void packet_init(struct packet *);
|
||||
int packet_sending(struct packet *);
|
||||
|
||||
int packet_empty(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);
|
||||
int packet_len_to_send(struct packet *);
|
||||
|
||||
int packet_fill(struct packet *, char *, unsigned long);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue