Fixed alignment issue
This commit is contained in:
parent
01153b468e
commit
60a3fc0cae
1 changed files with 14 additions and 12 deletions
|
@ -33,7 +33,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* 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)
|
recv_from_ipolite(struct ipolite_conn *ipolite, const rimeaddr_t *from)
|
||||||
{
|
{
|
||||||
struct netflood_conn *c = (struct netflood_conn *)ipolite;
|
struct netflood_conn *c = (struct netflood_conn *)ipolite;
|
||||||
struct netflood_hdr *hdr = packetbuf_dataptr();
|
struct netflood_hdr hdr;
|
||||||
uint8_t hops;
|
uint8_t hops;
|
||||||
struct queuebuf *queuebuf;
|
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. */
|
/* Remember packet if we need to forward it. */
|
||||||
queuebuf = queuebuf_new_from_packetbuf();
|
queuebuf = queuebuf_new_from_packetbuf();
|
||||||
|
|
||||||
packetbuf_hdrreduce(sizeof(struct netflood_hdr));
|
packetbuf_hdrreduce(sizeof(struct netflood_hdr));
|
||||||
if(c->u->recv != NULL) {
|
if(c->u->recv != NULL) {
|
||||||
if(!(rimeaddr_cmp(&hdr->originator, &c->last_originator) &&
|
if(!(rimeaddr_cmp(&hdr.originator, &c->last_originator) &&
|
||||||
hdr->originator_seqno <= c->last_originator_seqno)) {
|
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)) {
|
hops)) {
|
||||||
|
|
||||||
if(queuebuf != NULL) {
|
if(queuebuf != NULL) {
|
||||||
queuebuf_to_packetbuf(queuebuf);
|
queuebuf_to_packetbuf(queuebuf);
|
||||||
queuebuf_free(queuebuf);
|
queuebuf_free(queuebuf);
|
||||||
queuebuf = NULL;
|
queuebuf = NULL;
|
||||||
hdr = packetbuf_dataptr();
|
memcpy(&hdr, packetbuf_dataptr(), sizeof(struct netflood_hdr));
|
||||||
|
|
||||||
/* Rebroadcast received packet. */
|
/* Rebroadcast received packet. */
|
||||||
if(hops < HOPS_MAX) {
|
if(hops < HOPS_MAX) {
|
||||||
PRINTF("%d.%d: netflood rebroadcasting %d.%d/%d (%d.%d/%d) hops %d\n",
|
PRINTF("%d.%d: netflood rebroadcasting %d.%d/%d (%d.%d/%d) hops %d\n",
|
||||||
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
|
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
|
||||||
hdr->originator.u8[0], hdr->originator.u8[1],
|
hdr.originator.u8[0], hdr.originator.u8[1],
|
||||||
hdr->originator_seqno,
|
hdr.originator_seqno,
|
||||||
c->last_originator.u8[0], c->last_originator.u8[1],
|
c->last_originator.u8[0], c->last_originator.u8[1],
|
||||||
c->last_originator_seqno,
|
c->last_originator_seqno,
|
||||||
hops);
|
hops);
|
||||||
hdr->hops++;
|
hdr.hops++;
|
||||||
|
memcpy(packetbuf_dataptr(), &hdr, sizeof(struct netflood_hdr));
|
||||||
send(c);
|
send(c);
|
||||||
rimeaddr_copy(&c->last_originator, &hdr->originator);
|
rimeaddr_copy(&c->last_originator, &hdr.originator);
|
||||||
c->last_originator_seqno = hdr->originator_seqno;
|
c->last_originator_seqno = hdr.originator_seqno;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue