Merge pull request #812 from kkrentz/packetbuf-holds-broadcast

packetbuf_holds_broadcast()
This commit is contained in:
Nicolas Tsiftes 2014-11-28 19:15:19 +01:00
commit 9b90c378e8
12 changed files with 28 additions and 33 deletions

View File

@ -87,7 +87,7 @@ anti_replay_was_replayed(struct anti_replay_info *info)
received_counter = anti_replay_get_counter();
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
if(packetbuf_holds_broadcast()) {
/* broadcast */
if(received_counter <= info->last_broadcast_counter) {
return 1;

View File

@ -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. */
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &linkaddr_node_addr);
#endif
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
if(packetbuf_holds_broadcast()) {
is_broadcast = 1;
PRINTDEBUG("contikimac: send broadcast\n");
@ -876,8 +876,7 @@ input_packet(void)
packetbuf_totlen() > 0 &&
(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
&linkaddr_node_addr) ||
linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
&linkaddr_null))) {
packetbuf_holds_broadcast())) {
/* This is a regular packet that is destined to us or to the
broadcast address. */

View File

@ -433,7 +433,7 @@ send_packet(void)
/* If NETSTACK_CONF_BRIDGE_MODE is set, assume PACKETBUF_ADDR_SENDER is already set. */
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &linkaddr_node_addr);
#endif
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
if(packetbuf_holds_broadcast()) {
is_broadcast = 1;
PRINTDEBUG("cxmac: send broadcast\n");
} else {

View File

@ -104,7 +104,7 @@ create_frame(int type, int do_create)
/* Build the FCF. */
params.fcf.frame_type = packetbuf_attr(PACKETBUF_ATTR_FRAME_TYPE);
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;
} else {
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;
/*
* 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)) {
if(packetbuf_holds_broadcast()) {
/* Broadcast requires short address mode. */
params.fcf.dest_addr_mode = FRAME802154_SHORTADDRMODE;
params.dest_addr[0] = 0xFF;

View File

@ -132,8 +132,7 @@ send_one_packet(mac_callback_t sent, void *ptr)
NETSTACK_RADIO.prepare(packetbuf_hdrptr(), packetbuf_totlen());
is_broadcast = linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
&linkaddr_null);
is_broadcast = packetbuf_holds_broadcast();
if(NETSTACK_RADIO.receiving_packet() ||
(!is_broadcast && NETSTACK_RADIO.pending_packet())) {
@ -282,8 +281,7 @@ packet_input(void)
#if NULLRDC_ADDRESS_FILTER
} else if(!linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
&linkaddr_node_addr) &&
!linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
&linkaddr_null)) {
!packetbuf_holds_broadcast()) {
PRINTF("nullrdc: not for us\n");
#endif /* NULLRDC_ADDRESS_FILTER */
} else {

View File

@ -123,11 +123,7 @@ send_packet(mac_callback_t sent, void *ptr)
params.fcf.src_addr_mode = FRAME802154_LONGADDRMODE;
params.dest_pid = mac_dst_pan_id;
/*
* 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)) {
if(packetbuf_holds_broadcast()) {
/* Broadcast requires short address mode. */
params.fcf.dest_addr_mode = FRAME802154_SHORTADDRMODE;
params.dest_addr[0] = 0xFF;

View File

@ -320,4 +320,11 @@ packetbuf_addr(uint8_t type)
}
/*---------------------------------------------------------------------------*/
#endif /* PACKETBUF_CONF_ATTRS_INLINE */
int
packetbuf_holds_broadcast(void)
{
return linkaddr_cmp(&packetbuf_addrs[PACKETBUF_ADDR_RECEIVER - PACKETBUF_ADDR_FIRST].addr, &linkaddr_null);
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -453,6 +453,12 @@ int packetbuf_set_addr(uint8_t type, const linkaddr_t *addr);
const linkaddr_t *packetbuf_addr(uint8_t type);
#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_copyto(struct packetbuf_attr *attrs,

View File

@ -426,11 +426,7 @@ sicslowmac_dataRequest(void)
params.fcf.srcAddrMode = LONGADDRMODE;
params.dest_pid = ieee15_4ManagerAddress.get_dst_panid();
/*
* 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) ) {
if(packetbuf_holds_broadcast()) {
/* Broadcast requires short address mode. */
params.fcf.destAddrMode = SHORTADDRMODE;
params.dest_pid = BROADCASTPANDID;

View File

@ -481,11 +481,8 @@ void mac_LowpanToEthernet(void)
//Setup generic ethernet stuff
ETHBUF(uip_buf)->type = uip_htons(UIP_ETHTYPE_IPV6);
//Check for broadcast message
#if RF230BB
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
// if(linkaddr_cmp((const linkaddr_t *)destAddr, &linkaddr_null)) {
if(packetbuf_holds_broadcast()) {
#else
if( ( parsed_frame->fcf->destAddrMode == SHORTADDRMODE) &&
( 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
/* 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[1] = 0x33;
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
/* 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[1] = 0x33;
ETHBUF(raw_buf)->dest.addr[2] = 0x00;

View File

@ -312,7 +312,7 @@ void mac_LowpanToEthernet(void)
ETHBUF(uip_buf)->type = uip_htons(UIP_ETHTYPE_IPV6);
//Check for broadcast message
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
if(packetbuf_holds_broadcast()) {
/* if( ( parsed_frame->fcf->destAddrMode == SHORTADDRMODE) && */
/* ( parsed_frame->dest_addr->addr16 == 0xffff) ) { */
ETHBUF(uip_buf)->dest.addr[0] = 0x33;

View File

@ -339,7 +339,7 @@ void mac_LowpanToEthernet(void)
ETHBUF(uip_buf)->type = htons(UIP_ETHTYPE_IPV6);
//Check for broadcast message
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
if(packetbuf_holds_broadcast()) {
/* if( ( parsed_frame->fcf->destAddrMode == SHORTADDRMODE) && */
/* ( parsed_frame->dest_addr->addr16 == 0xffff) ) { */
ETHBUF(uip_buf)->dest.addr[0] = 0x33;