Fixed alignment issue

This commit is contained in:
adamdunkels 2009-11-09 08:22:40 +00:00
parent 01153b468e
commit 60a3fc0cae
1 changed files with 14 additions and 12 deletions

View File

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: netflood.c,v 1.4 2009/11/08 19:40:17 adamdunkels Exp $
* $Id: netflood.c,v 1.5 2009/11/09 08:22:40 adamdunkels Exp $
*/
/**
@ -76,42 +76,44 @@ static void
recv_from_ipolite(struct ipolite_conn *ipolite, const rimeaddr_t *from)
{
struct netflood_conn *c = (struct netflood_conn *)ipolite;
struct netflood_hdr *hdr = packetbuf_dataptr();
struct netflood_hdr hdr;
uint8_t hops;
struct queuebuf *queuebuf;
hops = hdr->hops;
memcpy(&hdr, packetbuf_dataptr(), sizeof(struct netflood_hdr));
hops = hdr.hops;
/* Remember packet if we need to forward it. */
queuebuf = queuebuf_new_from_packetbuf();
packetbuf_hdrreduce(sizeof(struct netflood_hdr));
if(c->u->recv != NULL) {
if(!(rimeaddr_cmp(&hdr->originator, &c->last_originator) &&
hdr->originator_seqno <= c->last_originator_seqno)) {
if(!(rimeaddr_cmp(&hdr.originator, &c->last_originator) &&
hdr.originator_seqno <= c->last_originator_seqno)) {
if(c->u->recv(c, from, &hdr->originator, hdr->originator_seqno,
if(c->u->recv(c, from, &hdr.originator, hdr.originator_seqno,
hops)) {
if(queuebuf != NULL) {
queuebuf_to_packetbuf(queuebuf);
queuebuf_free(queuebuf);
queuebuf = NULL;
hdr = packetbuf_dataptr();
memcpy(&hdr, packetbuf_dataptr(), sizeof(struct netflood_hdr));
/* Rebroadcast received packet. */
if(hops < HOPS_MAX) {
PRINTF("%d.%d: netflood rebroadcasting %d.%d/%d (%d.%d/%d) hops %d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
hdr->originator.u8[0], hdr->originator.u8[1],
hdr->originator_seqno,
hdr.originator.u8[0], hdr.originator.u8[1],
hdr.originator_seqno,
c->last_originator.u8[0], c->last_originator.u8[1],
c->last_originator_seqno,
hops);
hdr->hops++;
hdr.hops++;
memcpy(packetbuf_dataptr(), &hdr, sizeof(struct netflood_hdr));
send(c);
rimeaddr_copy(&c->last_originator, &hdr->originator);
c->last_originator_seqno = hdr->originator_seqno;
rimeaddr_copy(&c->last_originator, &hdr.originator);
c->last_originator_seqno = hdr.originator_seqno;
}
}
}