Merge pull request #812 from kkrentz/packetbuf-holds-broadcast
packetbuf_holds_broadcast()
This commit is contained in:
commit
9b90c378e8
@ -87,7 +87,7 @@ anti_replay_was_replayed(struct anti_replay_info *info)
|
|||||||
|
|
||||||
received_counter = anti_replay_get_counter();
|
received_counter = anti_replay_get_counter();
|
||||||
|
|
||||||
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
|
if(packetbuf_holds_broadcast()) {
|
||||||
/* broadcast */
|
/* broadcast */
|
||||||
if(received_counter <= info->last_broadcast_counter) {
|
if(received_counter <= info->last_broadcast_counter) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -522,7 +522,7 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr,
|
|||||||
/* If NETSTACK_CONF_BRIDGE_MODE is set, assume PACKETBUF_ADDR_SENDER is already set. */
|
/* If NETSTACK_CONF_BRIDGE_MODE is set, assume PACKETBUF_ADDR_SENDER is already set. */
|
||||||
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &linkaddr_node_addr);
|
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &linkaddr_node_addr);
|
||||||
#endif
|
#endif
|
||||||
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
|
if(packetbuf_holds_broadcast()) {
|
||||||
is_broadcast = 1;
|
is_broadcast = 1;
|
||||||
PRINTDEBUG("contikimac: send broadcast\n");
|
PRINTDEBUG("contikimac: send broadcast\n");
|
||||||
|
|
||||||
@ -876,8 +876,7 @@ input_packet(void)
|
|||||||
packetbuf_totlen() > 0 &&
|
packetbuf_totlen() > 0 &&
|
||||||
(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
|
(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
|
||||||
&linkaddr_node_addr) ||
|
&linkaddr_node_addr) ||
|
||||||
linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
|
packetbuf_holds_broadcast())) {
|
||||||
&linkaddr_null))) {
|
|
||||||
/* This is a regular packet that is destined to us or to the
|
/* This is a regular packet that is destined to us or to the
|
||||||
broadcast address. */
|
broadcast address. */
|
||||||
|
|
||||||
|
@ -433,7 +433,7 @@ send_packet(void)
|
|||||||
/* If NETSTACK_CONF_BRIDGE_MODE is set, assume PACKETBUF_ADDR_SENDER is already set. */
|
/* If NETSTACK_CONF_BRIDGE_MODE is set, assume PACKETBUF_ADDR_SENDER is already set. */
|
||||||
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &linkaddr_node_addr);
|
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &linkaddr_node_addr);
|
||||||
#endif
|
#endif
|
||||||
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
|
if(packetbuf_holds_broadcast()) {
|
||||||
is_broadcast = 1;
|
is_broadcast = 1;
|
||||||
PRINTDEBUG("cxmac: send broadcast\n");
|
PRINTDEBUG("cxmac: send broadcast\n");
|
||||||
} else {
|
} else {
|
||||||
|
@ -104,7 +104,7 @@ create_frame(int type, int do_create)
|
|||||||
/* Build the FCF. */
|
/* Build the FCF. */
|
||||||
params.fcf.frame_type = packetbuf_attr(PACKETBUF_ATTR_FRAME_TYPE);
|
params.fcf.frame_type = packetbuf_attr(PACKETBUF_ATTR_FRAME_TYPE);
|
||||||
params.fcf.frame_pending = packetbuf_attr(PACKETBUF_ATTR_PENDING);
|
params.fcf.frame_pending = packetbuf_attr(PACKETBUF_ATTR_PENDING);
|
||||||
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
|
if(packetbuf_holds_broadcast()) {
|
||||||
params.fcf.ack_required = 0;
|
params.fcf.ack_required = 0;
|
||||||
} else {
|
} else {
|
||||||
params.fcf.ack_required = packetbuf_attr(PACKETBUF_ATTR_MAC_ACK);
|
params.fcf.ack_required = packetbuf_attr(PACKETBUF_ATTR_MAC_ACK);
|
||||||
@ -159,11 +159,7 @@ create_frame(int type, int do_create)
|
|||||||
}
|
}
|
||||||
params.dest_pid = mac_dst_pan_id;
|
params.dest_pid = mac_dst_pan_id;
|
||||||
|
|
||||||
/*
|
if(packetbuf_holds_broadcast()) {
|
||||||
* If the output address is NULL in the Rime buf, then it is broadcast
|
|
||||||
* on the 802.15.4 network.
|
|
||||||
*/
|
|
||||||
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
|
|
||||||
/* Broadcast requires short address mode. */
|
/* Broadcast requires short address mode. */
|
||||||
params.fcf.dest_addr_mode = FRAME802154_SHORTADDRMODE;
|
params.fcf.dest_addr_mode = FRAME802154_SHORTADDRMODE;
|
||||||
params.dest_addr[0] = 0xFF;
|
params.dest_addr[0] = 0xFF;
|
||||||
|
@ -132,8 +132,7 @@ send_one_packet(mac_callback_t sent, void *ptr)
|
|||||||
|
|
||||||
NETSTACK_RADIO.prepare(packetbuf_hdrptr(), packetbuf_totlen());
|
NETSTACK_RADIO.prepare(packetbuf_hdrptr(), packetbuf_totlen());
|
||||||
|
|
||||||
is_broadcast = linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
|
is_broadcast = packetbuf_holds_broadcast();
|
||||||
&linkaddr_null);
|
|
||||||
|
|
||||||
if(NETSTACK_RADIO.receiving_packet() ||
|
if(NETSTACK_RADIO.receiving_packet() ||
|
||||||
(!is_broadcast && NETSTACK_RADIO.pending_packet())) {
|
(!is_broadcast && NETSTACK_RADIO.pending_packet())) {
|
||||||
@ -282,8 +281,7 @@ packet_input(void)
|
|||||||
#if NULLRDC_ADDRESS_FILTER
|
#if NULLRDC_ADDRESS_FILTER
|
||||||
} else if(!linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
|
} else if(!linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
|
||||||
&linkaddr_node_addr) &&
|
&linkaddr_node_addr) &&
|
||||||
!linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
|
!packetbuf_holds_broadcast()) {
|
||||||
&linkaddr_null)) {
|
|
||||||
PRINTF("nullrdc: not for us\n");
|
PRINTF("nullrdc: not for us\n");
|
||||||
#endif /* NULLRDC_ADDRESS_FILTER */
|
#endif /* NULLRDC_ADDRESS_FILTER */
|
||||||
} else {
|
} else {
|
||||||
|
@ -123,11 +123,7 @@ send_packet(mac_callback_t sent, void *ptr)
|
|||||||
params.fcf.src_addr_mode = FRAME802154_LONGADDRMODE;
|
params.fcf.src_addr_mode = FRAME802154_LONGADDRMODE;
|
||||||
params.dest_pid = mac_dst_pan_id;
|
params.dest_pid = mac_dst_pan_id;
|
||||||
|
|
||||||
/*
|
if(packetbuf_holds_broadcast()) {
|
||||||
* If the output address is NULL in the Rime buf, then it is broadcast
|
|
||||||
* on the 802.15.4 network.
|
|
||||||
*/
|
|
||||||
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
|
|
||||||
/* Broadcast requires short address mode. */
|
/* Broadcast requires short address mode. */
|
||||||
params.fcf.dest_addr_mode = FRAME802154_SHORTADDRMODE;
|
params.fcf.dest_addr_mode = FRAME802154_SHORTADDRMODE;
|
||||||
params.dest_addr[0] = 0xFF;
|
params.dest_addr[0] = 0xFF;
|
||||||
|
@ -320,4 +320,11 @@ packetbuf_addr(uint8_t type)
|
|||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#endif /* PACKETBUF_CONF_ATTRS_INLINE */
|
#endif /* PACKETBUF_CONF_ATTRS_INLINE */
|
||||||
|
int
|
||||||
|
packetbuf_holds_broadcast(void)
|
||||||
|
{
|
||||||
|
return linkaddr_cmp(&packetbuf_addrs[PACKETBUF_ADDR_RECEIVER - PACKETBUF_ADDR_FIRST].addr, &linkaddr_null);
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
@ -453,6 +453,12 @@ int packetbuf_set_addr(uint8_t type, const linkaddr_t *addr);
|
|||||||
const linkaddr_t *packetbuf_addr(uint8_t type);
|
const linkaddr_t *packetbuf_addr(uint8_t type);
|
||||||
#endif /* PACKETBUF_CONF_ATTRS_INLINE */
|
#endif /* PACKETBUF_CONF_ATTRS_INLINE */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Checks whether the current packet is a broadcast.
|
||||||
|
* \retval 0 iff current packet is not a broadcast
|
||||||
|
*/
|
||||||
|
int packetbuf_holds_broadcast(void);
|
||||||
|
|
||||||
void packetbuf_attr_clear(void);
|
void packetbuf_attr_clear(void);
|
||||||
|
|
||||||
void packetbuf_attr_copyto(struct packetbuf_attr *attrs,
|
void packetbuf_attr_copyto(struct packetbuf_attr *attrs,
|
||||||
|
@ -426,11 +426,7 @@ sicslowmac_dataRequest(void)
|
|||||||
params.fcf.srcAddrMode = LONGADDRMODE;
|
params.fcf.srcAddrMode = LONGADDRMODE;
|
||||||
params.dest_pid = ieee15_4ManagerAddress.get_dst_panid();
|
params.dest_pid = ieee15_4ManagerAddress.get_dst_panid();
|
||||||
|
|
||||||
/*
|
if(packetbuf_holds_broadcast()) {
|
||||||
* If the output address is NULL in the Rime buf, then it is broadcast
|
|
||||||
* on the 802.15.4 network.
|
|
||||||
*/
|
|
||||||
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null) ) {
|
|
||||||
/* Broadcast requires short address mode. */
|
/* Broadcast requires short address mode. */
|
||||||
params.fcf.destAddrMode = SHORTADDRMODE;
|
params.fcf.destAddrMode = SHORTADDRMODE;
|
||||||
params.dest_pid = BROADCASTPANDID;
|
params.dest_pid = BROADCASTPANDID;
|
||||||
|
@ -481,11 +481,8 @@ void mac_LowpanToEthernet(void)
|
|||||||
//Setup generic ethernet stuff
|
//Setup generic ethernet stuff
|
||||||
ETHBUF(uip_buf)->type = uip_htons(UIP_ETHTYPE_IPV6);
|
ETHBUF(uip_buf)->type = uip_htons(UIP_ETHTYPE_IPV6);
|
||||||
|
|
||||||
//Check for broadcast message
|
|
||||||
|
|
||||||
#if RF230BB
|
#if RF230BB
|
||||||
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
|
if(packetbuf_holds_broadcast()) {
|
||||||
// if(linkaddr_cmp((const linkaddr_t *)destAddr, &linkaddr_null)) {
|
|
||||||
#else
|
#else
|
||||||
if( ( parsed_frame->fcf->destAddrMode == SHORTADDRMODE) &&
|
if( ( parsed_frame->fcf->destAddrMode == SHORTADDRMODE) &&
|
||||||
( parsed_frame->dest_addr->addr16 == 0xffff) ) {
|
( parsed_frame->dest_addr->addr16 == 0xffff) ) {
|
||||||
@ -977,7 +974,7 @@ mac_log_802_15_4_tx(const uint8_t* buffer, size_t total_len) {
|
|||||||
ETHBUF(raw_buf)->type = uip_htons(0x809A); //UIP_ETHTYPE_802154 0x809A
|
ETHBUF(raw_buf)->type = uip_htons(0x809A); //UIP_ETHTYPE_802154 0x809A
|
||||||
|
|
||||||
/* Check for broadcast message */
|
/* Check for broadcast message */
|
||||||
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
|
if(packetbuf_holds_broadcast()) {
|
||||||
ETHBUF(raw_buf)->dest.addr[0] = 0x33;
|
ETHBUF(raw_buf)->dest.addr[0] = 0x33;
|
||||||
ETHBUF(raw_buf)->dest.addr[1] = 0x33;
|
ETHBUF(raw_buf)->dest.addr[1] = 0x33;
|
||||||
ETHBUF(raw_buf)->dest.addr[2] = 0x00;
|
ETHBUF(raw_buf)->dest.addr[2] = 0x00;
|
||||||
@ -1018,7 +1015,7 @@ mac_log_802_15_4_rx(const uint8_t* buf, size_t len) {
|
|||||||
ETHBUF(raw_buf)->type = uip_htons(0x809A); //UIP_ETHTYPE_802154 0x809A
|
ETHBUF(raw_buf)->type = uip_htons(0x809A); //UIP_ETHTYPE_802154 0x809A
|
||||||
|
|
||||||
/* Check for broadcast message */
|
/* Check for broadcast message */
|
||||||
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
|
if(packetbuf_holds_broadcast()) {
|
||||||
ETHBUF(raw_buf)->dest.addr[0] = 0x33;
|
ETHBUF(raw_buf)->dest.addr[0] = 0x33;
|
||||||
ETHBUF(raw_buf)->dest.addr[1] = 0x33;
|
ETHBUF(raw_buf)->dest.addr[1] = 0x33;
|
||||||
ETHBUF(raw_buf)->dest.addr[2] = 0x00;
|
ETHBUF(raw_buf)->dest.addr[2] = 0x00;
|
||||||
|
@ -312,7 +312,7 @@ void mac_LowpanToEthernet(void)
|
|||||||
ETHBUF(uip_buf)->type = uip_htons(UIP_ETHTYPE_IPV6);
|
ETHBUF(uip_buf)->type = uip_htons(UIP_ETHTYPE_IPV6);
|
||||||
|
|
||||||
//Check for broadcast message
|
//Check for broadcast message
|
||||||
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
|
if(packetbuf_holds_broadcast()) {
|
||||||
/* if( ( parsed_frame->fcf->destAddrMode == SHORTADDRMODE) && */
|
/* if( ( parsed_frame->fcf->destAddrMode == SHORTADDRMODE) && */
|
||||||
/* ( parsed_frame->dest_addr->addr16 == 0xffff) ) { */
|
/* ( parsed_frame->dest_addr->addr16 == 0xffff) ) { */
|
||||||
ETHBUF(uip_buf)->dest.addr[0] = 0x33;
|
ETHBUF(uip_buf)->dest.addr[0] = 0x33;
|
||||||
|
@ -339,7 +339,7 @@ void mac_LowpanToEthernet(void)
|
|||||||
ETHBUF(uip_buf)->type = htons(UIP_ETHTYPE_IPV6);
|
ETHBUF(uip_buf)->type = htons(UIP_ETHTYPE_IPV6);
|
||||||
|
|
||||||
//Check for broadcast message
|
//Check for broadcast message
|
||||||
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
|
if(packetbuf_holds_broadcast()) {
|
||||||
/* if( ( parsed_frame->fcf->destAddrMode == SHORTADDRMODE) && */
|
/* if( ( parsed_frame->fcf->destAddrMode == SHORTADDRMODE) && */
|
||||||
/* ( parsed_frame->dest_addr->addr16 == 0xffff) ) { */
|
/* ( parsed_frame->dest_addr->addr16 == 0xffff) ) { */
|
||||||
ETHBUF(uip_buf)->dest.addr[0] = 0x33;
|
ETHBUF(uip_buf)->dest.addr[0] = 0x33;
|
||||||
|
Loading…
Reference in New Issue
Block a user