From 37480562401b30027e4e6db6e4898d0b0a1b0f63 Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Sat, 1 Dec 2007 22:10:48 +0000 Subject: [PATCH] Added packet_init --- src/packet.c | 11 +++++++++++ src/packet.h | 1 + src/user.c | 5 ++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/packet.c b/src/packet.c index 9b2c624..c288389 100644 --- a/src/packet.c +++ b/src/packet.c @@ -67,6 +67,17 @@ packet_fill(struct packet *packet, char *data, unsigned long datalen) return packet->len; } +/** + * Clear packet stuct, mark empty + */ +void +packet_init(struct packet *packet) +{ + packet->sentlen = 0; + packet->offset = 0; + packet->len = 0; +} + /** * Mark len number of bytes as being sent */ diff --git a/src/packet.h b/src/packet.h index 2df702c..9008659 100644 --- a/src/packet.h +++ b/src/packet.h @@ -27,6 +27,7 @@ struct packet char data[PKTSIZE]; /* The data */ }; +void packet_init(struct packet *); int packet_sending(struct packet *); void packet_advance(struct packet *); int packet_len_to_send(struct packet *); diff --git a/src/user.c b/src/user.c index 6cbddfb..2bfccca 100644 --- a/src/user.c +++ b/src/user.c @@ -46,9 +46,8 @@ init_users(in_addr_t my_ip) users[i].id = i; snprintf(newip, sizeof(newip), "0.0.0.%d", i + 1); users[i].tun_ip = my_ip + inet_addr(newip);; - users[i].inpacket.len = 0; - users[i].inpacket.offset = 0; - users[i].outpacket.len = 0; + packet_init(&(users[i].inpacket)); + packet_init(&(users[i].outpacket)); users[i].q.id = 0; } }