Commit 7f4bba93 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek Committed by Juliusz Chroboczek

Make flusbuf take a struct buffered.

parent 7bac9a7c
......@@ -583,7 +583,7 @@ main(int argc, char **argv)
send_wildcard_retraction(ifp);
send_self_update(ifp);
flushupdates(ifp);
flushbuf(ifp);
flushbuf(&ifp->buf);
}
debugf("Entering main loop.\n");
......@@ -781,7 +781,7 @@ main(int argc, char **argv)
if(ifp->buf.timeout.tv_sec != 0) {
if(timeval_compare(&now, &ifp->buf.timeout) >= 0) {
flushupdates(ifp);
flushbuf(ifp);
flushbuf(&ifp->buf);
}
}
}
......@@ -806,7 +806,7 @@ main(int argc, char **argv)
/* Make sure that we expire quickly from our neighbours'
association caches. */
send_hello_noupdate(ifp, 10);
flushbuf(ifp);
flushbuf(&ifp->buf);
usleep(roughly(1000));
gettime(&now);
}
......@@ -816,7 +816,7 @@ main(int argc, char **argv)
/* Make sure they got it. */
send_wildcard_retraction(ifp);
send_hello_noupdate(ifp, 1);
flushbuf(ifp);
flushbuf(&ifp->buf);
usleep(roughly(10000));
gettime(&now);
interface_up(ifp, 0);
......
......@@ -915,33 +915,32 @@ fill_rtt_message(struct buffered *buf)
}
void
flushbuf(struct interface *ifp)
flushbuf(struct buffered *buf)
{
int rc;
assert(ifp->buf.len <= ifp->buf.size);
assert(buf->len <= buf->size);
if(ifp->buf.len > 0) {
debugf(" (flushing %d buffered bytes on %s)\n",
ifp->buf.len, ifp->name);
DO_HTONS(packet_header + 2, ifp->buf.len);
fill_rtt_message(&ifp->buf);
if(buf->len > 0) {
debugf(" (flushing %d buffered bytes)\n", buf->len);
DO_HTONS(packet_header + 2, buf->len);
fill_rtt_message(buf);
rc = babel_send(protocol_socket,
packet_header, sizeof(packet_header),
ifp->buf.buf, ifp->buf.len,
(struct sockaddr*)&ifp->buf.sin6,
sizeof(ifp->buf.sin6));
buf->buf, buf->len,
(struct sockaddr*)&buf->sin6,
sizeof(buf->sin6));
if(rc < 0)
perror("send");
}
VALGRIND_MAKE_MEM_UNDEFINED(ifp->buf.buf, ifp->buf.size);
ifp->buf.len = 0;
ifp->buf.hello = -1;
ifp->buf.have_id = 0;
ifp->buf.have_nh = 0;
ifp->buf.have_prefix = 0;
ifp->buf.timeout.tv_sec = 0;
ifp->buf.timeout.tv_usec = 0;
VALGRIND_MAKE_MEM_UNDEFINED(buf->buf, buf->size);
buf->len = 0;
buf->hello = -1;
buf->have_id = 0;
buf->have_nh = 0;
buf->have_prefix = 0;
buf->timeout.tv_sec = 0;
buf->timeout.tv_usec = 0;
}
static void
......@@ -982,14 +981,14 @@ static void
ensure_space(struct interface *ifp, int space)
{
if(ifp->buf.size - ifp->buf.len < space)
flushbuf(ifp);
flushbuf(&ifp->buf);
}
static void
start_message(struct interface *ifp, int type, int len)
{
if(ifp->buf.size - ifp->buf.len < len + 2)
flushbuf(ifp);
flushbuf(&ifp->buf);
ifp->buf.buf[ifp->buf.len++] = type;
ifp->buf.buf[ifp->buf.len++] = len;
}
......@@ -1111,7 +1110,7 @@ send_hello_noupdate(struct interface *ifp, unsigned interval)
link quality estimation. */
if(ifp->buf.hello >= 0) {
flushupdates(ifp);
flushbuf(ifp);
flushbuf(&ifp->buf);
}
ifp->hello_seqno = seqno_plus(ifp->hello_seqno, 1);
......@@ -1162,7 +1161,7 @@ flush_unicast(int dofree)
goto done;
/* Preserve ordering of messages */
flushbuf(unicast_neighbour->ifp);
flushbuf(&unicast_neighbour->ifp->buf);
memset(&sin6, 0, sizeof(sin6));
sin6.sin6_family = AF_INET6;
......
......@@ -57,7 +57,7 @@ extern struct timeval unicast_flush_timeout;
void parse_packet(const unsigned char *from, struct interface *ifp,
const unsigned char *packet, int packetlen);
void flushbuf(struct interface *ifp);
void flushbuf(struct buffered *buf);
void flushupdates(struct interface *ifp);
void send_ack(struct neighbour *neigh, unsigned short nonce,
unsigned short interval);
......
......@@ -29,10 +29,10 @@ THE SOFTWARE.
#include "babeld.h"
#include "util.h"
#include "interface.h"
#include "neighbour.h"
#include "resend.h"
#include "message.h"
#include "interface.h"
#include "configuration.h"
struct timeval resend_time = {0, 0};
......
......@@ -30,13 +30,13 @@ THE SOFTWARE.
#include "babeld.h"
#include "kernel.h"
#include "interface.h"
#include "neighbour.h"
#include "message.h"
#include "route.h"
#include "xroute.h"
#include "util.h"
#include "configuration.h"
#include "interface.h"
#include "local.h"
static struct xroute *xroutes;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment