亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? mac.c

?? ZIGBEE2006協議棧
?? C
?? 第 1 頁 / 共 4 頁
字號:
  phy_pib.currentTxFrm--;
  *phy_pib.currentTxFrm = LRWPAN_NWK_MAGICNUM_B0;
#endif

  phy_pib.currentTxFrm--;
  *phy_pib.currentTxFrm = mac_pib.macCapInfo;

  phy_pib.currentTxFrm--;
  *phy_pib.currentTxFrm = LRWPAN_MACCMD_ASSOC_REQ;

  phy_pib.currentTxFlen = LRWPAN_MACCMD_ASSOC_REQ_PAYLOAD_LEN;

}

#ifndef LRWPAN_COORDINATOR
//parse the association response
static void macParseAssocResponse(void){
  BYTE *ptr;
  SADDR saddr;

  //first, ensure that the payload length is correct
  //the +1 is because the offset takes into account the lenght byte at the start of the packet
  if ( (*(a_mac_rx_data.orgpkt->data)-a_mac_rx_data.pload_offset-PACKET_FOOTER_SIZE +1)
      != LRWPAN_MACCMD_ASSOC_RSP_PAYLOAD_LEN ) {
        DEBUG_STRING( DBG_INFO, "MAC: Failed to join, illegal assoc response\n");
        return; //wrong length
      }
  ptr = a_mac_rx_data.orgpkt->data + a_mac_rx_data.pload_offset;
  //check the status first which is last byte of the payload
  if (LRWPAN_GET_ASSOC_STATUS(*(ptr+LRWPAN_MACCMD_ASSOC_RSP_PAYLOAD_LEN-1)) != LRWPAN_ASSOC_STATUS_SUCCESS) {
    //failed to join
    DEBUG_STRING( DBG_INFO, "MAC: Failed to join, remote node rejected us.\n");
    return;
  }
  ptr++; //skip command byte

  //successful join, get my short SADDR
  saddr = (BYTE) *ptr;
  ptr++;
  saddr += (((UINT16) *ptr) << 8);
  macSetShortAddr(saddr);
  ptr++;

  //our PANID is our parent's panid.
  mac_pib.macPANID = a_mac_rx_data.SrcPANID;
  halSetRadioPANID(a_mac_rx_data.SrcPANID);

#ifndef IEEE_802_COMPLY
  //the short address of the parent are extra bytes in this payload
  mac_pib.macCoordShortAddress = (BYTE) *ptr;
  ptr++;
  mac_pib.macCoordShortAddress += (((UINT16) *ptr) << 8);
  ptr++;
  //get the depth of parent, our depth is 1+ that of our parent
  mac_pib.depth = *ptr + 1;
#else

#ifndef LRWPAN_FORCE_ASSOCIATION_TARGET
  //if we are not using forced association, then the beacon response
  //we got had the short address that we used for the association request,
  //so the short address of the beacon responder is our parent
  mac_pib.macCoordShortAddress = mac_pib.bcnSADDR;
  //beacon response also has the depth of our parent, so our depth is 1+ this
  mac_pib.depth = mac_pib.bcnDepth+1;
#endif


#endif

  //copy the SRC long address as my coordinator long address
  mac_pib.macCoordExtendedAddress.bytes[0] = a_mac_rx_data.SrcAddr.laddr.bytes[0];
  mac_pib.macCoordExtendedAddress.bytes[1] = a_mac_rx_data.SrcAddr.laddr.bytes[1];
  mac_pib.macCoordExtendedAddress.bytes[2] = a_mac_rx_data.SrcAddr.laddr.bytes[2];
  mac_pib.macCoordExtendedAddress.bytes[3] = a_mac_rx_data.SrcAddr.laddr.bytes[3];
  mac_pib.macCoordExtendedAddress.bytes[4] = a_mac_rx_data.SrcAddr.laddr.bytes[4];
  mac_pib.macCoordExtendedAddress.bytes[5] = a_mac_rx_data.SrcAddr.laddr.bytes[5];
  mac_pib.macCoordExtendedAddress.bytes[6] = a_mac_rx_data.SrcAddr.laddr.bytes[6];
  mac_pib.macCoordExtendedAddress.bytes[7] = a_mac_rx_data.SrcAddr.laddr.bytes[7];



  //indicate that the association was successful
  mac_pib.flags.bits.macIsAssociated = 1;
  mac_pib.flags.bits.ackPending = 0;  //only one outstanding association req, clear the ack bit
  DEBUG_STRING(DBG_INFO,"MAC:Received good association response!\n");

}
#endif


#ifndef  LRWPAN_COORDINATOR
//Parse the coordinator realignment (Orphan response)
static void macParseOrphanResponse(void){
  BYTE *ptr;
  UINT16 tmp;


  //first, ensure that the payload length is correct
  //the +1 is because the offset takes into account the lenght byte at the start of the packet
  if ( (*(a_mac_rx_data.orgpkt->data)-a_mac_rx_data.pload_offset-PACKET_FOOTER_SIZE +1)
      != LRWPAN_MACCMD_COORD_REALIGN_PAYLOAD_LEN ) {
        DEBUG_STRING( DBG_INFO, "MAC: illegal Coord Alignment packet\n");
        return; //wrong length
      }
  ptr = a_mac_rx_data.orgpkt->data + a_mac_rx_data.pload_offset;

  DEBUG_STRING(DBG_INFO, "Received Coord Realign (Orphan response)\n");
  mac_pib.flags.bits.GotOrphanResponse = 1;
  mac_pib.flags.bits.macIsAssociated = 1;  //we are associated with somebody!
   mac_pib.flags.bits.ackPending = 0;

  ptr++; //skip command byte

  //get the PANID
  tmp = (BYTE) *ptr;
  ptr++;
  tmp += (((UINT16) *ptr) << 8);
  ptr++;
  macSetPANID(tmp);

  //get the coordinator short address
  mac_pib.macCoordShortAddress = (BYTE) *ptr;
  ptr++;
  mac_pib.macCoordShortAddress += (((UINT16) *ptr) << 8);
  ptr++;

  tmp =(BYTE) *ptr; //get the channel
  ptr++;

  macSetChannel(tmp);  //set the channel

#ifndef LRWPAN_COORDINATOR

  //copy the SRC long address as my coordinator long address
  mac_pib.macCoordExtendedAddress.bytes[0] = a_mac_rx_data.SrcAddr.laddr.bytes[0];
  mac_pib.macCoordExtendedAddress.bytes[1] = a_mac_rx_data.SrcAddr.laddr.bytes[1];
  mac_pib.macCoordExtendedAddress.bytes[2] = a_mac_rx_data.SrcAddr.laddr.bytes[2];
  mac_pib.macCoordExtendedAddress.bytes[3] = a_mac_rx_data.SrcAddr.laddr.bytes[3];
  mac_pib.macCoordExtendedAddress.bytes[4] = a_mac_rx_data.SrcAddr.laddr.bytes[4];
  mac_pib.macCoordExtendedAddress.bytes[5] = a_mac_rx_data.SrcAddr.laddr.bytes[5];
  mac_pib.macCoordExtendedAddress.bytes[6] = a_mac_rx_data.SrcAddr.laddr.bytes[6];
  mac_pib.macCoordExtendedAddress.bytes[7] = a_mac_rx_data.SrcAddr.laddr.bytes[7];


#endif

#ifdef LRWPAN_RFD
  //get our short address
  tmp = (BYTE) *ptr;
  ptr++;
  tmp += (((UINT16) *ptr) << 8);
  ptr++;
  macSetShortAddr(tmp);
#else
  //this is a router
   //get our short ADDR

   tmp = (BYTE) *ptr;
   ptr++;
   tmp += (((UINT16) *ptr) << 8);
   ptr++;

   if (tmp != macGetShortAddr()) {
	   //our short address has changed!
	   //everything may have changed,
	   //clear neighbor table, and address map
	   ntInitAddressMap();
	   ntInitTable();
  }
  macSetShortAddr(tmp);
#endif

}

#endif



static void macFormatOrphanNotify(void){
phy_pib.currentTxFrm = &tmpTxBuff[LRWPAN_MAX_FRAME_SIZE-1];
  *phy_pib.currentTxFrm = LRWPAN_MACCMD_ORPHAN;
   phy_pib.currentTxFlen = 1;
}



#ifdef LRWPAN_FFD

static void macFormatCoordRealign(SADDR orphan_saddr){
  //format and send the realignment packet
  //first is the orphans short address
  phy_pib.currentTxFrm = &tmpTxBuff[LRWPAN_MAX_FRAME_SIZE-1];
  *phy_pib.currentTxFrm = (BYTE) (orphan_saddr >>8);

  --phy_pib.currentTxFrm;
  *phy_pib.currentTxFrm = (BYTE) (orphan_saddr);

  //logical channel
  --phy_pib.currentTxFrm;
  *phy_pib.currentTxFrm = phy_pib.phyCurrentChannel;

   //our short addresss
 --phy_pib.currentTxFrm;
  *phy_pib.currentTxFrm = (BYTE) (macGetShortAddr()>>8);

  --phy_pib.currentTxFrm;
  *phy_pib.currentTxFrm = (BYTE) (macGetShortAddr());

  //our PANID

--phy_pib.currentTxFrm;
  *phy_pib.currentTxFrm = (BYTE) (mac_pib.macPANID>>8);

  --phy_pib.currentTxFrm;
  *phy_pib.currentTxFrm = (BYTE) (mac_pib.macPANID);


  --phy_pib.currentTxFrm;
  *phy_pib.currentTxFrm = LRWPAN_MACCMD_COORD_REALIGN;


  phy_pib.currentTxFlen = LRWPAN_MACCMD_COORD_REALIGN_PAYLOAD_LEN;
}




static void macFormatAssociationResponse(void){
  NAYBORENTRY *ntptr;
  UINT16 new_saddr;
  BYTE tmp, capinfo;


  new_saddr = 0xFFFF;
  tmp = LRWPAN_ASSOC_STATUS_DENIED;  //default status

  //check reasons to reject first
  //check payload length
  if ( (*(a_mac_rx_data.orgpkt->data)-a_mac_rx_data.pload_offset-PACKET_FOOTER_SIZE+1 )
      != LRWPAN_MACCMD_ASSOC_REQ_PAYLOAD_LEN) {
        //invalid payload length
        DEBUG_STRING(DBG_INFO,"MAC:Invalid association request, rejecting node!\n");
        goto macFormatAssociationResponse_dopkt;
      }

#ifndef IEEE_802_COMPLY
  {
    BYTE *ptr;
    //Check Magic Number
    ptr = a_mac_rx_data.orgpkt->data + a_mac_rx_data.pload_offset;
    if (*(ptr+2) != LRWPAN_NWK_MAGICNUM_B0){
      goto macFormatAssociationResponse_dopkt;
    }
    if (*(ptr+3) != LRWPAN_NWK_MAGICNUM_B1){
      goto macFormatAssociationResponse_dopkt;
    }
    if (*(ptr+4) != LRWPAN_NWK_MAGICNUM_B2){
      goto macFormatAssociationResponse_dopkt;
    }
    if (*(ptr+5) != LRWPAN_NWK_MAGICNUM_B3){
      goto macFormatAssociationResponse_dopkt;
    }
  }
#endif

  //now, see if this node is in the table
  ntptr = ntFindByLADDR(&a_mac_rx_data.SrcAddr.laddr);
  if (ntptr) {
	   new_saddr = mac_addr_tbl[ntptr->map_index].saddr;
           tmp = LRWPAN_ASSOC_STATUS_SUCCESS;
           goto macFormatAssociationResponse_dopkt;
  }
  //node is not in table. Look at capability info byte and see if we
  //have room for this node type
  capinfo = *(a_mac_rx_data.orgpkt->data + a_mac_rx_data.pload_offset + 1);

  //node is not in table. Do final check with user
  if (!usrJoinVerifyCallback(&a_mac_rx_data.SrcAddr.laddr, capinfo)) {
    tmp = LRWPAN_ASSOC_STATUS_DENIED;
    goto macFormatAssociationResponse_dopkt;
  }


  if ( ((LRWPAN_GET_CAPINFO_DEVTYPE(capinfo)) && (mac_pib.ChildRouters == LRWPAN_MAX_ROUTERS_PER_PARENT))
      ||
        (!(LRWPAN_GET_CAPINFO_DEVTYPE(capinfo)) && (mac_pib.ChildRFDs == LRWPAN_MAX_NON_ROUTER_CHILDREN)))
    //no room left
  {
    //no room
    tmp = LRWPAN_ASSOC_STATUS_NOROOM;
    goto macFormatAssociationResponse_dopkt;

  }

  //not in table, Add this node
  new_saddr = ntAddNeighbor(&a_mac_rx_data.SrcAddr.laddr.bytes[0],capinfo);
  if (new_saddr == LRWPAN_BCAST_SADDR) {
	  //this is an error indication, adding neighbor failed
      tmp = LRWPAN_ASSOC_STATUS_NOROOM;
	  goto macFormatAssociationResponse_dopkt;
  }
  DEBUG_STRING(DBG_INFO,"MAC:Sending good association response!\n");
  tmp = LRWPAN_ASSOC_STATUS_SUCCESS;
  usrJoinNotifyCallback(&a_mac_rx_data.SrcAddr.laddr);

macFormatAssociationResponse_dopkt:

   if (tmp ==  LRWPAN_ASSOC_STATUS_SUCCESS) {
        DEBUG_STRING(DBG_INFO,"MAC:Sending good association response!\n");
   } else {
     DEBUG_STRING(DBG_INFO,"MAC:Rejecting assoc request: ");
     DEBUG_UINT8(DBG_INFO,tmp);
     DEBUG_STRING(DBG_INFO,"\n");
    }

  //format and send the packet
  //status byte
  phy_pib.currentTxFrm = &tmpTxBuff[LRWPAN_MAX_FRAME_SIZE-1];
  *phy_pib.currentTxFrm = tmp;

#ifndef IEEE_802_COMPLY
   //put our depth, short address so that the RFD will know both
  //the radius, short and long addresses even if Beacon request has not been done
   --phy_pib.currentTxFrm;
  *phy_pib.currentTxFrm = mac_pib.depth;

  --phy_pib.currentTxFrm;
  *phy_pib.currentTxFrm = (BYTE) (macGetShortAddr()>>8);

  --phy_pib.currentTxFrm;
  *phy_pib.currentTxFrm = (BYTE) (macGetShortAddr());
#endif
  //new short address for the RFD
  --phy_pib.currentTxFrm;
  *phy_pib.currentTxFrm = (BYTE) (new_saddr>>8);

  --phy_pib.currentTxFrm;
  *phy_pib.currentTxFrm = (BYTE) (new_saddr);

  //CMD

  --phy_pib.currentTxFrm;
  *phy_pib.currentTxFrm = LRWPAN_MACCMD_ASSOC_RSP;

  phy_pib.currentTxFlen = LRWPAN_MACCMD_ASSOC_RSP_PAYLOAD_LEN;

}

#endif


//check for DATA packets
//For RFD, just check if this packet came from parent
//For Routers, if this uses SHORT addressing, then check
//to see if this is associated with us

static BOOL macCheckDataRejection(void){

	BYTE AddrMode,i;

	
	//if not associated, reject
#ifndef LRWPAN_COORDINATOR
	if (!mac_pib.flags.bits.macIsAssociated) {
		DEBUG_STRING(DBG_INFO, "MAC: Rejecting data pkt as we are not associated\n");
		return(FALSE);
	}
#endif
    AddrMode = LRWPAN_GET_DST_ADDR(a_mac_rx_data.fcfmsb);

	if (AddrMode == LRWPAN_ADDRMODE_LADDR) {
		//this packet send directly to our long address. accept it.
		return(TRUE);
	}

	//check the parent
	AddrMode = LRWPAN_GET_SRC_ADDR(a_mac_rx_data.fcfmsb);
	if (AddrMode == LRWPAN_ADDRMODE_SADDR) {
		//check parent short address
		if (a_mac_rx_data.SrcAddr.saddr == mac_pib.macCoordShortAddress)
			return(TRUE);
	} else if (AddrMode == LRWPAN_ADDRMODE_LADDR){
		//check parent long address.
		for (i=0;i<8;i++) {
			if (a_mac_rx_data.SrcAddr.laddr.bytes[i] !=
				mac_pib.macCoordExtendedAddress.bytes[i])
				break;
		}
		if (i==8) return(TRUE); //have a match
	}
#ifdef LRWPAN_RFD
	DEBUG_STRING(DBG_INFO, "MAC: Rejecting data pkt from unassociated node\n");
	return(FALSE);
#else
	//ok, for FFDs, check the neighbor table
	if (AddrMode == LRWPAN_ADDRMODE_SADDR){
		if (ntFindBySADDR (a_mac_rx_data.SrcAddr.saddr) !=(NAYBORENTRY *) NULL)
			return(TRUE);
	}else if (AddrMode == LRWPAN_ADDRMODE_LADDR){
        if (ntFindByLADDR (&a_mac_rx_data.SrcAddr.laddr))
			return(TRUE);
	}
    DEBUG_STRING(DBG_INFO, "MAC: Rejecting data pkt from unassociated node\n");
	return(FALSE);
#endif
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩一区二区三区四区| 99re热这里只有精品免费视频 | 色综合久久99| 91在线一区二区三区| 国产成人av自拍| 国产一区二区三区黄视频| 精品一区二区免费| 精品一区二区精品| 国产91精品精华液一区二区三区 | 波多野结衣视频一区| 国产大陆a不卡| av激情综合网| 在线观看中文字幕不卡| 欧美精品丝袜久久久中文字幕| 欧美疯狂做受xxxx富婆| 日韩欧美国产一区二区三区| 久久久久久久国产精品影院| 国产精品水嫩水嫩| 日韩精品一二区| 激情深爱一区二区| 99re成人在线| 欧美一区二区在线免费播放| 久久久天堂av| 亚洲综合男人的天堂| 青青草成人在线观看| 国产一区不卡视频| 色菇凉天天综合网| 欧美mv和日韩mv的网站| 国产精品久久久久aaaa樱花| 午夜视频一区二区三区| 懂色av中文字幕一区二区三区| 色系网站成人免费| 精品人伦一区二区色婷婷| 国产精品久久久久永久免费观看| 亚洲成av人片在线| 国产福利一区在线| 欧美精品v日韩精品v韩国精品v| 久久综合色一综合色88| 亚洲精品免费电影| 国产一区二区日韩精品| 欧美在线一区二区| 中文字幕不卡在线观看| 麻豆精品精品国产自在97香蕉| 99re在线精品| 久久久久久久久97黄色工厂| 调教+趴+乳夹+国产+精品| 99久久伊人网影院| 国产亚洲视频系列| 免费成人av在线播放| 91福利视频在线| 综合欧美一区二区三区| 麻豆专区一区二区三区四区五区| 在线看国产一区| 亚洲视频网在线直播| 国产91丝袜在线观看| 精品日韩欧美一区二区| 午夜视频在线观看一区二区三区| aaa亚洲精品| 国产欧美日韩不卡免费| 精品一区二区三区蜜桃| 91精品国产91久久综合桃花| 亚洲综合偷拍欧美一区色| 99re这里只有精品首页| 国产精品视频第一区| 国产一区二区精品久久| 欧美xxxxxxxx| 极品瑜伽女神91| 91精品一区二区三区在线观看| 一区二区三区高清在线| 在线欧美一区二区| 亚洲午夜私人影院| 欧美性一区二区| 一级精品视频在线观看宜春院| av一本久道久久综合久久鬼色| 中文欧美字幕免费| 91视视频在线直接观看在线看网页在线看| 国产视频在线观看一区二区三区| 紧缚奴在线一区二区三区| 26uuu国产在线精品一区二区| 精品一区二区三区免费播放| 久久久久久久av麻豆果冻| 久久99国产精品麻豆| 国产欧美中文在线| 成人免费精品视频| 18成人在线观看| 91网站视频在线观看| 亚洲综合在线免费观看| 欧美日韩一区 二区 三区 久久精品| 亚洲国产精品久久不卡毛片| 91精品国产全国免费观看| 国产一区二三区| 日本一区二区成人在线| 91免费视频网| 免费成人美女在线观看.| 国产欧美日产一区| 91福利精品视频| 蜜臀a∨国产成人精品| 国产女人18水真多18精品一级做 | 亚洲精品国产一区二区精华液| 一本色道久久加勒比精品| 亚洲国产一二三| 亚洲精品在线电影| 99久久久无码国产精品| 日韩高清不卡一区| 欧美韩国日本不卡| 91精品1区2区| 国产一区二区三区免费播放| 亚洲视频一二三| 亚洲精品一区二区三区福利 | 91麻豆精品国产91久久久使用方法| 免费观看久久久4p| 亚洲欧美怡红院| 精品国产三级电影在线观看| 国产99精品视频| 日韩av午夜在线观看| 日本一区二区三区dvd视频在线| 欧美四级电影在线观看| 久久国产精品一区二区| 曰韩精品一区二区| 久久蜜桃一区二区| 9191国产精品| jlzzjlzz欧美大全| 九色综合狠狠综合久久| 亚洲电影激情视频网站| 中文字幕第一区第二区| 欧美成人女星排名| 欧美日韩久久久| av欧美精品.com| 紧缚捆绑精品一区二区| 日韩av在线免费观看不卡| 亚洲精品一二三| 中文字幕国产一区| 久久久久久日产精品| 日韩欧美国产综合| 911精品产国品一二三产区| 日本高清成人免费播放| av成人免费在线观看| 国产黑丝在线一区二区三区| 韩国一区二区三区| 麻豆精品久久精品色综合| 日韩福利电影在线观看| 亚洲综合小说图片| 亚洲天堂免费看| 亚洲精品成人少妇| 亚洲精品日韩综合观看成人91| 国产精品电影院| 中文字幕中文字幕在线一区| 欧美高清一级片在线观看| 欧美韩国日本一区| 中文字幕亚洲区| 亚洲人成人一区二区在线观看 | 午夜影院久久久| 亚洲午夜久久久久| 亚洲夂夂婷婷色拍ww47| 亚洲伦在线观看| 一区二区在线观看av| 日日夜夜精品视频免费| 日韩精品电影在线观看| 久久99久久99| 国产不卡在线一区| 成人av在线一区二区| 91网站在线播放| 欧美色偷偷大香| 日韩一级免费一区| 久久综合九色综合97婷婷| 中文字幕免费不卡在线| 亚洲视频你懂的| 天天操天天综合网| 久久99久久久欧美国产| 国产69精品久久久久777| 99re亚洲国产精品| 91精品国产高清一区二区三区蜜臀| 日韩女优电影在线观看| 国产精品美日韩| 一二三四区精品视频| 日本伊人午夜精品| 国产大陆a不卡| 欧美日韩视频专区在线播放| 日韩欧美精品在线视频| 一色桃子久久精品亚洲| 天堂久久久久va久久久久| 黑人巨大精品欧美一区| 色婷婷综合激情| 精品国产99国产精品| 一区二区三区在线视频播放| 美日韩一级片在线观看| 波多野结衣中文一区| 91 com成人网| 国产精品国产三级国产普通话99| 亚洲成人在线观看视频| 国产xxx精品视频大全| 欧美性高清videossexo| 国产欧美日产一区| 日产欧产美韩系列久久99| 成人av在线资源网| 久久免费精品国产久精品久久久久| 亚洲精品视频一区| 国产伦精品一区二区三区免费迷| 欧美在线高清视频| 国产精品久久久久久久第一福利 |