Commit afc36c5f authored by Juliusz Chroboczek's avatar Juliusz Chroboczek Committed by Juliusz Chroboczek

Move address computation into struct buffered.

parent 9fb50fd6
...@@ -24,6 +24,8 @@ THE SOFTWARE. ...@@ -24,6 +24,8 @@ THE SOFTWARE.
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <assert.h> #include <assert.h>
#ifdef __linux #ifdef __linux
......
...@@ -25,6 +25,8 @@ THE SOFTWARE. ...@@ -25,6 +25,8 @@ THE SOFTWARE.
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <assert.h> #include <assert.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/time.h> #include <sys/time.h>
#include "babeld.h" #include "babeld.h"
......
...@@ -302,6 +302,12 @@ interface_up(struct interface *ifp, int up) ...@@ -302,6 +302,12 @@ interface_up(struct interface *ifp, int up)
goto fail; goto fail;
} }
memset(&ifp->buf.sin6, 0, sizeof(ifp->buf.sin6));
ifp->buf.sin6.sin6_family = AF_INET6;
memcpy(&ifp->buf.sin6.sin6_addr, protocol_group, 16);
ifp->buf.sin6.sin6_port = htons(protocol_port);
ifp->buf.sin6.sin6_scope_id = ifp->ifindex;
mtu = kernel_interface_mtu(ifp->name, ifp->ifindex); mtu = kernel_interface_mtu(ifp->name, ifp->ifindex);
if(mtu < 0) { if(mtu < 0) {
fprintf(stderr, "Warning: couldn't get MTU of interface %s (%d).\n", fprintf(stderr, "Warning: couldn't get MTU of interface %s (%d).\n",
......
...@@ -80,6 +80,7 @@ struct interface_conf { ...@@ -80,6 +80,7 @@ struct interface_conf {
#define IF_CHANNEL_NONINTERFERING -2 #define IF_CHANNEL_NONINTERFERING -2
struct buffered { struct buffered {
struct sockaddr_in6 sin6;
char *buf; char *buf;
int len; int len;
int size; int size;
......
...@@ -943,7 +943,6 @@ void ...@@ -943,7 +943,6 @@ void
flushbuf(struct interface *ifp) flushbuf(struct interface *ifp)
{ {
int rc; int rc;
struct sockaddr_in6 sin6;
assert(ifp->buf.len <= ifp->buf.size); assert(ifp->buf.len <= ifp->buf.size);
...@@ -953,17 +952,13 @@ flushbuf(struct interface *ifp) ...@@ -953,17 +952,13 @@ flushbuf(struct interface *ifp)
debugf(" (flushing %d buffered bytes on %s)\n", debugf(" (flushing %d buffered bytes on %s)\n",
ifp->buf.len, ifp->name); ifp->buf.len, ifp->name);
if(check_bucket(ifp)) { if(check_bucket(ifp)) {
memset(&sin6, 0, sizeof(sin6));
sin6.sin6_family = AF_INET6;
memcpy(&sin6.sin6_addr, protocol_group, 16);
sin6.sin6_port = htons(protocol_port);
sin6.sin6_scope_id = ifp->ifindex;
DO_HTONS(packet_header + 2, ifp->buf.len); DO_HTONS(packet_header + 2, ifp->buf.len);
fill_rtt_message(ifp); fill_rtt_message(ifp);
rc = babel_send(protocol_socket, rc = babel_send(protocol_socket,
packet_header, sizeof(packet_header), packet_header, sizeof(packet_header),
ifp->buf.buf, ifp->buf.len, ifp->buf.buf, ifp->buf.len,
(struct sockaddr*)&sin6, sizeof(sin6)); (struct sockaddr*)&ifp->buf.sin6,
sizeof(ifp->buf.sin6));
if(rc < 0) if(rc < 0)
perror("send"); perror("send");
} else { } else {
......
...@@ -24,6 +24,8 @@ THE SOFTWARE. ...@@ -24,6 +24,8 @@ THE SOFTWARE.
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <time.h> #include <time.h>
#include <assert.h> #include <assert.h>
......
...@@ -24,6 +24,8 @@ THE SOFTWARE. ...@@ -24,6 +24,8 @@ THE SOFTWARE.
#include <time.h> #include <time.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include "babeld.h" #include "babeld.h"
#include "util.h" #include "util.h"
......
...@@ -24,6 +24,8 @@ THE SOFTWARE. ...@@ -24,6 +24,8 @@ THE SOFTWARE.
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <assert.h> #include <assert.h>
#include "babeld.h" #include "babeld.h"
......
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