Exemple #1
0
/*
 * Callback function usr_mlme_get_conf
 *
 * @param status            Result of requested PIB attribute get operation.
 * @param PIBAttribute      Retrieved PIB attribute.
 * @param PIBAttributeIndex Index of the PIB attribute to be read.
 * @param PIBAttributeValue Pointer to data containing retrieved PIB attribute,
 *
 * @return void
 */
void usr_mlme_get_conf(uint8_t status,
		uint8_t PIBAttribute,
#if (defined MAC_SECURITY_ZIP) || (defined MAC_SECURITY_2006)		
		uint8_t PIBAttributeIndex,
#endif		
		void *PIBAttributeValue)
{
#if (defined MAC_SECURITY_ZIP) || (defined MAC_SECURITY_2006)
	 mac_key_table_t *key_table = (mac_key_table_t *)PIBAttributeValue;
#endif
	if ((status == MAC_SUCCESS) && (PIBAttribute == phyCurrentPage)) {
        #ifdef HIGH_DATA_RATE_SUPPORT
		current_channel_page = 17;
        #else
		current_channel_page = *(uint8_t *)PIBAttributeValue;
        #endif
		wpan_mlme_get_req(phyChannelsSupported 
#if (defined MAC_SECURITY_ZIP) || (defined MAC_SECURITY_2006)		
		,0
#endif		
		);
	} else if ((status == MAC_SUCCESS) &&
			(PIBAttribute == phyChannelsSupported)) {
		uint8_t index;

		channels_supported = convert_byte_array_to_32_bit(PIBAttributeValue);

		for (index = 0; index < 32; index++) {
			if (channels_supported & (1 << index)) {
				current_channel = index + CHANNEL_OFFSET;
				break;
			}
		}
				/*
		 * Set the short address of this node.
		 * Use: bool wpan_mlme_set_req(uint8_t PIBAttribute,
		 *                             void *PIBAttributeValue);
		 *
		 * This request leads to a set confirm message ->
		 *usr_mlme_set_conf
		 */
				
/* MAC Short Address will be set after setting the Security PIB's */	
#if (defined MAC_SECURITY_ZIP) || (defined MAC_SECURITY_2006)
		/* Set security PIB attributes now. */
		wpan_mlme_set_req(macDefaultKeySource,
						NO_PIB_INDEX,
						&default_key_source);
#else			
		uint8_t short_addr[2];

		short_addr[0] = (uint8_t)COORD_SHORT_ADDR;  /* low byte */
		short_addr[1] = (uint8_t)(COORD_SHORT_ADDR >> 8); /* high byte */

		wpan_mlme_set_req(macShortAddress, short_addr);
#endif /* (defined MAC_SECURITY_ZIP) || (defined MAC_SECURITY_2006) */

	}
Exemple #2
0
/*
 * @brief Callback function usr_mlme_comm_status_ind
 *
 * @param SrcAddrSpec      Pointer to source address specification
 * @param DstAddrSpec      Pointer to destination address specification
 * @param status           Result for related response operation
 */
void usr_mlme_comm_status_ind(wpan_addr_spec_t *SrcAddrSpec,
		wpan_addr_spec_t *DstAddrSpec,
		uint8_t status)
{
	if (status == MAC_SUCCESS) {
#if (defined MAC_SECURITY_ZIP) || (defined MAC_SECURITY_2006)	
		 recent_assoc_dev_no++;
        wpan_mlme_set_req(macDeviceTableEntries,
                          NO_PIB_INDEX,
                          &no_of_assoc_devices);
		 wpan_mlme_get_req(macKeyTable, recent_assoc_dev_no);
#endif		 
		/*
		 * Now the association of the device has been successful and its
		 * information, like address, could  be stored.
		 * But for the sake of simple handling it has been done
		 * during assignment of the short address within the function
		 * assign_new_short_addr()
		 */

		/* Start timer to initiate indirect data transmission. */
		sw_timer_start(APP_TIMER_INDIRECT_DATA,
				((uint32_t)APP_INDIRECT_DATA_DURATION_MS * 1000),
				SW_TIMEOUT_RELATIVE,
				(FUNC_PTR)indirect_data_cb,
				NULL);
 
	} else {
	}

	/* Keep compiler happy. */
	SrcAddrSpec = SrcAddrSpec;
	DstAddrSpec = DstAddrSpec;
}
Exemple #3
0
/*
 * @brief Callback function usr_mlme_set_conf will be used after starting the
 * network
 *
 * @param status        Result of requested PIB attribute set operation
 * @param PIBAttribute  Updated PIB attribute
 *
 */
static void usr_mlme_set_conf_run_time(uint8_t status, uint8_t PIBAttribute,
		uint8_t PIBAttributeIndex)
{
	if (status != MAC_SUCCESS) {
		/* something went wrong at mlme set request; restart */
		wpan_mlme_reset_req(true);
	} else {
		switch (PIBAttribute) {
		case macShortAddress:
		{
			/* set the mac association permission */
			uint8_t association_permit = true;

			wpan_mlme_set_req(macAssociationPermit, NO_PIB_INDEX,
					&association_permit);
		}
		break;

		case macAssociationPermit:
		{
			/* Set the MAC Rx on when Idle */
			bool rx_on_when_idle = true;

			wpan_mlme_set_req(macRxOnWhenIdle, NO_PIB_INDEX,
					&rx_on_when_idle);
		}
		break;

		case macRxOnWhenIdle:
		{
			/* Set the beacon payload length. */
			uint8_t beacon_payload_len = BEACON_PAYLOAD_LEN;
			wpan_mlme_set_req(macBeaconPayloadLength, NO_PIB_INDEX,
					&beacon_payload_len);
		}
		break;

		case macBeaconPayloadLength:
		{
			/*
			 * Once the length of the beacon payload has been
			 * defined,
			 * set the actual beacon payload.
			 */
			wpan_mlme_set_req(macBeaconPayload, NO_PIB_INDEX,
					&beacon_payload);
		}
		break;

		case macBeaconPayload:
		{
			if (COORD_STARTING == coord_state) {
				/*
				 * Initiate an active scan over all channels to
				 * determine
				 * which channel to use.
				 * Use: bool wpan_mlme_scan_req(uint8_t
				 * ScanType,
				 *                              uint32_t
				 * ScanChannels,
				 *                              uint8_t
				 * ScanDuration,
				 *                              uint8_t
				 * ChannelPage);
				 *
				 * This request leads to a scan confirm message
				 *->
				 * usr_mlme_scan_conf
				 * Scan for about 50 ms on each channel ->
				 * ScanDuration
				 *= 1
				 * Scan for about 1/2 second on each channel ->
				 * ScanDuration = 5
				 * Scan for about 1 second on each channel ->
				 * ScanDuration = 6
				 */
				wpan_mlme_scan_req(MLME_SCAN_TYPE_ACTIVE,
						SCAN_CHANNEL(current_channel),
						SCAN_DURATION_COORDINATOR,
						current_channel_page);
			}
		}
		break;

		case macDefaultKeySource:
		{
			/* set the maximum no.of mac security level table
			 * entries */
			uint8_t mac_sec_level_table_entries
				= DEFAULT_MAC_SEC_LVL_TABLE_ENTRIES;

			wpan_mlme_set_req(macSecurityLevelTableEntries,
					NO_PIB_INDEX,
					&mac_sec_level_table_entries);
		}
		break;

		case macSecurityLevelTableEntries:
		{
			/* set the mac security level table for the MAC Data
			 * Security */
			uint8_t mac_sec_level_table[4] = {FRAME_TYPE_DATA,  /*
					                                     *
					                                     *FrameType:
					                                     *
					                                     *Data
					                                     **/
							  CMD_FRAME_ID_NA,  /*
					                                     *
					                                     *CommandFrameIdentifier:
					                                     *
					                                     *N/A
					                                     **/

				                          /* ZIP_SEC_MIN,
				                           *          //
				                           * SecurityMinimum: 5
				                           **/
							  0X05,
							  DEV_OVERRIDE_SEC_MIN /*
					                                        *
					                                        *DeviceOverrideSecurityMinimum:
					                                        *
					                                        *True
					                                        **/
			};

			wpan_mlme_set_req(macSecurityLevelTable,
					INDEX_0,  /* Index: 0 */
					&mac_sec_level_table);
		}
		break;

		case macSecurityLevelTable:
		{
			/* set the maximum no.of key table entries */
			uint8_t mac_key_table_entries
				= DEFAULT_MAC_KEY_TABLE_ENTRIES;

			wpan_mlme_set_req(macKeyTableEntries,
					NO_PIB_INDEX,
					&mac_key_table_entries);
		}
		break;

		case macKeyTableEntries:
		{
			/* MAC Beacon Frame type default mac key table values */
			uint8_t mac_key_table[43] = {
				default_key_source[0],                 /*
					                                *
					                                *LookupData[0]
					                                **/
				default_key_source[1],                 /*
					                                *
					                                *LookupData[1]
					                                **/
				default_key_source[2],                 /*
					                                *
					                                *LookupData[2]
					                                **/
				default_key_source[3],                 /*
					                                *
					                                *LookupData[3]
					                                **/
				default_key_source[4],                 /*
					                                *
					                                *LookupData[4]
					                                **/
				default_key_source[5],                 /*
					                                *
					                                *LookupData[5]
					                                **/
				default_key_source[6],                 /*
					                                *
					                                *LookupData[6]
					                                **/
				default_key_source[7],                 /*
					                                *
					                                *LookupData[7]
					                                **/
				KEY_INDEX_0,                           /*
					                                *
					                                *LookupData[8]
					                                **/
				LOOKUP_DATA_SIZE_1,                 /*
					                             *
					                             *LookupDataSize:
					                             * 0x01 :
					                             * Size 9
					                             * octets */
				MAC_ZIP_MAX_KEY_ID_LOOKUP_LIST_ENTRIES,                 /*
					                                                 *
					                                                 *KeyIdLookupListEntries
					                                                 *
					                                                 *=
					                                                 *
					                                                 *1
					                                                 **/
				/* KeyDeviceList[1] */
				DEV_DESC_HANDLE_IDX_0,                           /*
					                                          *
					                                          *DeviceDescriptorHandle
					                                          **/
				true,                              /*
					                            *
					                            *UniqueDevice
					                            **/
				false,                              /*
					                             *
					                             *Blacklisted
					                             **/
				DEV_DESC_HANDLE_IDX_0,                           /*
					                                          *
					                                          *DeviceDescriptorHandle
					                                          **/
				true,                              /*
					                            *
					                            *UniqueDevice
					                            **/
				false,                              /*
					                             *
					                             *Blacklisted
					                             **/
				DEV_DESC_HANDLE_IDX_0,                           /*
					                                          *
					                                          *DeviceDescriptorHandle
					                                          **/
				true,                              /*
					                            *
					                            *UniqueDevice
					                            **/
				false,                              /*
					                             *
					                             *Blacklisted
					                             **/
				DEV_DESC_HANDLE_IDX_0,                           /*
					                                          *
					                                          *DeviceDescriptorHandle
					                                          **/
				true,                              /*
					                            *
					                            *UniqueDevice
					                            **/
				false,                              /*
					                             *
					                             *Blacklisted
					                             **/
				MAC_ZIP_MAX_KEY_DEV_LIST_ENTRIES,                 /*
					                                           *
					                                           *KeyDeviceListEntries
					                                           **/
				/*  KeyUsageList */
				FRAME_TYPE_BEACON,                    /*
					                               *
					                               *FrameType
					                               * -
					                               * Beacon
					                               * frames
					                               **/
				CMD_FRAME_ID_NA,                    /*
					                             *
					                             *CommandFrameIdentifier
					                             * not used
					                             * in ZIP */
				MAC_ZIP_MAX_KEY_USAGE_LIST_ENTRIES,                 /*
					                                             *
					                                             *KeyUsageListEntries
					                                             **/
				/* Key */
				default_key[3][0],
				default_key[3][1],
				default_key[3][2],
				default_key[3][3],
				default_key[3][4],
				default_key[3][5],
				default_key[3][6],
				default_key[3][7],
				default_key[3][8],
				default_key[3][9],
				default_key[3][10],
				default_key[3][11],
				default_key[3][12],
				default_key[3][13],
				default_key[3][14],
				default_key[3][15],
			};
			wpan_mlme_set_req(macKeyTable,
					INDEX_3,    /* Index: 3 */
					&mac_key_table);
		}
		break;

		case macKeyTable:

			/*
			 * Setting of PIB attributes will continue once a device
			 * has associated successful.
			 */
			break;

		case macDeviceTableEntries:
		{
			/* MAC Device Table entries for the recently associated
			 * device */
			static uint8_t Temp = 0;
			uint8_t mac_dev_table[17];

			/* Temp is used to not update the already device table
			 * again */
			for (uint16_t i = Temp; i < no_of_assoc_devices; i++) {
				mac_dev_table[0]
					= (uint8_t)(DEFAULT_PAN_ID &
						0x00FF);
				mac_dev_table[1]
					= (uint8_t)(DEFAULT_PAN_ID >>
						8);
				mac_dev_table[2]
					= (uint8_t)device_list[i].short_addr;
				mac_dev_table[3]
					= (uint8_t)(device_list[i].short_addr
						>> 8);
				mac_dev_table[4]
					= (uint8_t)device_list[i].ieee_addr;
				mac_dev_table[5]
					= (uint8_t)(device_list[i].ieee_addr
						>> 8);
				mac_dev_table[6]
					= (uint8_t)(device_list[i].ieee_addr
						>> 16);
				mac_dev_table[7]
					= (uint8_t)(device_list[i].ieee_addr
						>> 24);
				mac_dev_table[8]
					= (uint8_t)(device_list[i].ieee_addr
						>> 32);
				mac_dev_table[9]
					= (uint8_t)(device_list[i].ieee_addr
						>> 40);
				mac_dev_table[10]
					= (uint8_t)(device_list[i].ieee_addr
						>> 48);
				mac_dev_table[11]
					= (uint8_t)(device_list[i].ieee_addr
						>> 56);
				mac_dev_table[12] = 0;      /* Initial Frame
					                     * counter value */
				mac_dev_table[13] = 0;
				mac_dev_table[14] = 0;
				mac_dev_table[15] = 0;
				mac_dev_table[16] = 0;      /* Exempt */

				wpan_mlme_set_req(macDeviceTable,
						i, /* Index */
						&mac_dev_table);
			}
			Temp++;
		}
		break;

		case macDeviceTable:
		{
			/* Use DSN start value as in ZIP test spec. */
			uint8_t new_dsn = 0x0;

			wpan_mlme_set_req(macDSN,
					NO_PIB_INDEX,
					&new_dsn);
		}
		break;

		case macDSN:
		{
			/* Use DSN start value as in ZIP test spec. */
			uint32_t frame_counter = 1;

			wpan_mlme_set_req(macFrameCounter,
					NO_PIB_INDEX,
					&frame_counter);
		}
		break;

		case macFrameCounter:
			break;

		default:
			/* undesired PIB attribute set request; restart */
			wpan_mlme_reset_req(true);
			break;
		}
	}

	/* Keep compiler happy. */
	PIBAttributeIndex = PIBAttributeIndex;
}
Exemple #4
0
/** @brief Initialize the security PIB and set the security parameters
 *
 *  @param PIBAttribute MAC PIB Attribute type
 *  @param PIBAttributeIndex MAC PIB Attribute Index
 *
 */
static void init_secuity_pib(uint8_t PIBAttribute, uint8_t PIBAttributeIndex)
{
	switch (PIBAttribute) {
	case macDefaultKeySource:
	{
		/* Set the no.of security level table  entries */
		uint8_t mac_sec_level_table_entries
			= DEFAULT_MAC_SEC_LVL_TABLE_ENTRIES;

		wpan_mlme_set_req(macSecurityLevelTableEntries,
				NO_PIB_INDEX,
				&mac_sec_level_table_entries);
	}
	break;

	case macSecurityLevelTableEntries:
	{
		/* set type of frames will be encrypted and decrypted */
		uint8_t mac_sec_level_table[4] = {  FRAME_TYPE_BEACON, /*
				                                        *
				                                        *FrameType:
				                                        * Beacon
				                                        **/
						    CMD_FRAME_ID_NA,  /*
				                                       *
				                                       *CommandFrameIdentifier:
				                                       * N/A */
						    SECURITY_05_LEVEL,
						    DEV_OVERRIDE_SEC_MIN /*
				                                          *
				                                          *DeviceOverrideSecurityMinimum:
				                                          * True
				                                          **/
		};

		wpan_mlme_set_req(macSecurityLevelTable,
				INDEX_1,    /* Index: 1 */
				&mac_sec_level_table);
	}
	break;

	case macSecurityLevelTable:
	{
		if (INDEX_1 == PIBAttributeIndex) {
			/* set type of frames will be encrypted and decrypted */
			uint8_t mac_sec_level_table[4] =
			{       FRAME_TYPE_DATA,              /* FrameType:
					                       * Beacon */
				CMD_FRAME_ID_NA,              /*
					                       *
					                       *CommandFrameIdentifier:
					                       * N/A */
				SECURITY_05_LEVEL,
				DEV_OVERRIDE_SEC_MIN          /*
					                       *
					                       *DeviceOverrideSecurityMinimum:
					                       * True */
			};
			wpan_mlme_set_req(macSecurityLevelTable,
					INDEX_0, /* Index: 0 */
					&mac_sec_level_table);
		} else if (INDEX_0 == PIBAttributeIndex) {
			/* set the maximum no.of mac key table entries */
			uint8_t mac_key_table_entries
				= DEFAULT_MAC_KEY_TABLE_ENTRIES;

			wpan_mlme_set_req(macKeyTableEntries,
					NO_PIB_INDEX,
					&mac_key_table_entries);
		}
	}
	break;

	case macKeyTableEntries:
	{
		/* set the maximum no.of device table entries */
		uint16_t coord_key_index = DEFAULT_MAC_DEV_TABLE_ENTRIES;
		wpan_mlme_set_req(macDeviceTableEntries,
				NO_PIB_INDEX,
				&coord_key_index);
	}
	break;

	case macDeviceTableEntries:
	{
		/* set the default mac key table values */
		uint8_t mac_key_table[43] = {
			default_key_source[0], /* LookupData[0] */
			default_key_source[1], /* LookupData[1] */
			default_key_source[2], /* LookupData[2] */
			default_key_source[3], /* LookupData[3] */
			default_key_source[4], /* LookupData[4] */
			default_key_source[5], /* LookupData[5] */
			default_key_source[6], /* LookupData[6] */
			default_key_source[7], /* LookupData[7] */
			KEY_INDEX_0,       /* LookupData[8] */
			LOOKUP_DATA_SIZE_1, /* LookupDataSize: 0x01 : Size 9
				             * octets */
			MAC_ZIP_MAX_KEY_ID_LOOKUP_LIST_ENTRIES, /*
				                                 *
				                                 *KeyIdLookupListEntries
				                                 * = 1 */
			/* KeyDeviceList[1] */
			DEV_DESC_HANDLE_IDX_0,       /* DeviceDescriptorHandle
				                      **/
			true,          /* UniqueDevice */
			false,          /* Blacklisted */
			DEV_DESC_HANDLE_IDX_0,       /* DeviceDescriptorHandle
				                      **/
			true,          /* UniqueDevice */
			false,          /* Blacklisted */
			DEV_DESC_HANDLE_IDX_0,       /* DeviceDescriptorHandle
				                      **/
			true,          /* UniqueDevice */
			false,          /* Blacklisted */
			DEV_DESC_HANDLE_IDX_0,                   /*
				                                  *
				                                  *DeviceDescriptorHandle
				                                  **/
			true,          /* UniqueDevice */
			false,          /* Blacklisted */
			MAC_ZIP_MAX_KEY_DEV_LIST_ENTRIES, /*
				                           *
				                           *KeyDeviceListEntries
				                           **/
			/*  KeyUsageList */
			FRAME_TYPE_BEACON, /* FrameType - Beacon frames */
			CMD_FRAME_ID_NA, /* CommandFrameIdentifier not used in
				          * ZIP */
			MAC_ZIP_MAX_KEY_USAGE_LIST_ENTRIES, /*
				                             *
				                             *KeyUsageListEntries
				                             **/
			/* Key */
			default_key[3][0],
			default_key[3][1],
			default_key[3][2],
			default_key[3][3],
			default_key[3][4],
			default_key[3][5],
			default_key[3][6],
			default_key[3][7],
			default_key[3][8],
			default_key[3][9],
			default_key[3][10],
			default_key[3][11],
			default_key[3][12],
			default_key[3][13],
			default_key[3][14],
			default_key[3][15],
		};
		wpan_mlme_set_req(macKeyTable,
				INDEX_3, /* Index: 3 */
				&mac_key_table);
	}
	break;

	case macKeyTable:
	{
		/* set the default mac key table values */
		switch (PIBAttributeIndex) {
		case INDEX_3:
		{
			uint8_t mac_key_table1[43] = {
				/* KeyIdLookupList[1].LookupData :
				 * macDefaultKeySource || g_Sec_KeyIndex_1 */
				default_key_source[0],                         /*
						                                *
						                                *LookupData[0]
						                                **/
				default_key_source[1],                         /*
						                                *
						                                *LookupData[1]
						                                **/
				default_key_source[2],                         /*
						                                *
						                                *LookupData[2]
						                                **/
				default_key_source[3],                         /*
						                                *
						                                *LookupData[3]
						                                **/
				default_key_source[4],                         /*
						                                *
						                                *LookupData[4]
						                                **/
				default_key_source[5],                         /*
						                                *
						                                *LookupData[5]
						                                **/
				default_key_source[6],                         /*
						                                *
						                                *LookupData[6]
						                                **/
				default_key_source[7],                         /*
						                                *
						                                *LookupData[7]
						                                **/
				KEY_INDEX_1,                                   /*
						                                *
						                                *LookupData[8]
						                                **/
				LOOKUP_DATA_SIZE_1,                         /*
						                             *
						                             *LookupDataSize:
						                             *
						                             *0x01
						                             * :
						                             *
						                             *Size
						                             * 9
						                             *
						                             *octets
						                             **/
				MAC_ZIP_MAX_KEY_ID_LOOKUP_LIST_ENTRIES,                         /*
						                                                 *
						                                                 *KeyIdLookupListEntries
						                                                 *
						                                                 *=
						                                                 *
						                                                 *1
						                                                 **/
				/* KeyDeviceList[1] */
				EMPTY_DEV_HANDLE,                                   /*
						                                     *
						                                     *DeviceDescriptorHandle
						                                     **/
				false,                                      /*
						                             *
						                             *UniqueDevice
						                             **/
				false,                                      /*
						                             *
						                             *Blacklisted
						                             **/
				EMPTY_DEV_HANDLE,                                   /*
						                                     *
						                                     *DeviceDescriptorHandle
						                                     **/
				false,                                      /*
						                             *
						                             *UniqueDevice
						                             **/
				false,                                      /*
						                             *
						                             *Blacklisted
						                             **/
				EMPTY_DEV_HANDLE,                                   /*
						                                     *
						                                     *DeviceDescriptorHandle
						                                     **/
				false,                                      /*
						                             *
						                             *UniqueDevice
						                             **/
				false,                                      /*
						                             *
						                             *Blacklisted
						                             **/
				EMPTY_DEV_HANDLE,                                   /*
						                                     *
						                                     *DeviceDescriptorHandle
						                                     **/
				false,                                      /*
						                             *
						                             *UniqueDevice
						                             **/
				false,                                      /*
						                             *
						                             *Blacklisted
						                             **/
				MAC_ZIP_MAX_KEY_DEV_LIST_ENTRIES,                         /*
						                                           *
						                                           *KeyDeviceListEntries
						                                           **/
				/*  KeyUsageList */
				FRAME_TYPE_DATA,                            /*
						                             *
						                             *FrameType
						                             * -
						                             *
						                             *Data
						                             *
						                             *frames
						                             **/
				CMD_FRAME_ID_NA,                            /*
						                             *
						                             *CommandFrameIdentifier
						                             *
						                             *not
						                             *
						                             *used
						                             *
						                             *in
						                             *
						                             *ZIP
						                             **/
				MAC_ZIP_MAX_KEY_USAGE_LIST_ENTRIES,                         /*
						                                             *
						                                             *KeyUsageListEntries
						                                             **/
				/* Key */
				default_key[0][0],
				default_key[0][1],
				default_key[0][2],
				default_key[0][3],
				default_key[0][4],
				default_key[0][5],
				default_key[0][6],
				default_key[0][7],
				default_key[0][8],
				default_key[0][9],
				default_key[0][10],
				default_key[0][11],
				default_key[0][12],
				default_key[0][13],
				default_key[0][14],
				default_key[0][15],
			};
			wpan_mlme_set_req(macKeyTable,
					INDEX_0,            /* Index: 0 */
					&mac_key_table1);
		}
		break;

		case INDEX_0:
		{
			uint8_t mac_key_table2[43] = {
				/* KeyIdLookupList[1].LookupData :
				 * macDefaultKeySource || g_Sec_KeyIndex_1 */
				default_key_source[0],                         /*
						                                *
						                                *LookupData[0]
						                                **/
				default_key_source[1],                         /*
						                                *
						                                *LookupData[1]
						                                **/
				default_key_source[2],                         /*
						                                *
						                                *LookupData[2]
						                                **/
				default_key_source[3],                         /*
						                                *
						                                *LookupData[3]
						                                **/
				default_key_source[4],                         /*
						                                *
						                                *LookupData[4]
						                                **/
				default_key_source[5],                         /*
						                                *
						                                *LookupData[5]
						                                **/
				default_key_source[6],                         /*
						                                *
						                                *LookupData[6]
						                                **/
				default_key_source[7],                         /*
						                                *
						                                *LookupData[7]
						                                **/
				KEY_INDEX_2,                                   /*
						                                *
						                                *LookupData[8]
						                                **/
				LOOKUP_DATA_SIZE_1,                         /*
						                             *
						                             *LookupDataSize:
						                             *
						                             *0x01
						                             * :
						                             *
						                             *Size
						                             * 9
						                             *
						                             *octets
						                             **/
				MAC_ZIP_MAX_KEY_ID_LOOKUP_LIST_ENTRIES,                         /*
						                                                 *
						                                                 *KeyIdLookupListEntries
						                                                 *
						                                                 *=
						                                                 *
						                                                 *1
						                                                 **/
				/* KeyDeviceList[1] */
				EMPTY_DEV_HANDLE,                         /*
						                           *
						                           *DeviceDescriptorHandle
						                           **/
				false,                                      /*
						                             *
						                             *UniqueDevice
						                             **/
				false,                                      /*
						                             *
						                             *Blacklisted
						                             **/
				EMPTY_DEV_HANDLE,                         /*
						                           *
						                           *DeviceDescriptorHandle
						                           **/
				false,                                      /*
						                             *
						                             *UniqueDevice
						                             **/
				false,                                      /*
						                             *
						                             *Blacklisted
						                             **/
				EMPTY_DEV_HANDLE,                         /*
						                           *
						                           *DeviceDescriptorHandle
						                           **/
				false,                                      /*
						                             *
						                             *UniqueDevice
						                             **/
				false,                                      /*
						                             *
						                             *Blacklisted
						                             **/
				EMPTY_DEV_HANDLE,                                   /*
						                                     *
						                                     *DeviceDescriptorHandle
						                                     **/
				false,                                      /*
						                             *
						                             *UniqueDevice
						                             **/
				false,                                      /*
						                             *
						                             *Blacklisted
						                             **/
				MAC_ZIP_MAX_KEY_DEV_LIST_ENTRIES,                         /*
						                                           *
						                                           *KeyDeviceListEntries
						                                           **/
				/*  KeyUsageList */
				FRAME_TYPE_DATA,                            /*
						                             *
						                             *FrameType
						                             * -
						                             *
						                             *Data
						                             *
						                             *frames
						                             **/
				CMD_FRAME_ID_NA,                            /*
						                             *
						                             *CommandFrameIdentifier
						                             *
						                             *not
						                             *
						                             *used
						                             *
						                             *in
						                             *
						                             *ZIP
						                             **/
				MAC_ZIP_MAX_KEY_USAGE_LIST_ENTRIES,                         /*
						                                             *
						                                             *KeyUsageListEntries
						                                             **/
				/* Key */
				default_key[1][0],
				default_key[1][1],
				default_key[1][2],
				default_key[1][3],
				default_key[1][4],
				default_key[1][5],
				default_key[1][6],
				default_key[1][7],
				default_key[1][8],
				default_key[1][9],
				default_key[1][10],
				default_key[1][11],
				default_key[1][12],
				default_key[1][13],
				default_key[1][14],
				default_key[1][15],
			};

			wpan_mlme_set_req(macKeyTable,
					INDEX_1,            /* Index: 1 */
					&mac_key_table2);
		}
		break;

		case INDEX_1:
		{
			uint8_t mac_key_table3[43] = {
				/* KeyIdLookupList[1].LookupData :
				 * macDefaultKeySource || g_Sec_KeyIndex_1 */
				default_key_source[0],                 /*
						                        *
						                        *LookupData[0]
						                        **/
				default_key_source[1],                 /*
						                        *
						                        *LookupData[1]
						                        **/
				default_key_source[2],                 /*
						                        *
						                        *LookupData[2]
						                        **/
				default_key_source[3],                 /*
						                        *
						                        *LookupData[3]
						                        **/
				default_key_source[4],                 /*
						                        *
						                        *LookupData[4]
						                        **/
				default_key_source[5],                 /*
						                        *
						                        *LookupData[5]
						                        **/
				default_key_source[6],                 /*
						                        *
						                        *LookupData[6]
						                        **/
				default_key_source[7],                 /*
						                        *
						                        *LookupData[7]
						                        **/
				KEY_INDEX_3,                           /*
						                        *
						                        *LookupData[8]
						                        **/
				LOOKUP_DATA_SIZE_1,                 /*
						                     *
						                     *LookupDataSize:
						                     * 0x01 :
						                     * Size 9
						                     * octets */
				MAC_ZIP_MAX_KEY_ID_LOOKUP_LIST_ENTRIES,                 /*
						                                         *
						                                         *KeyIdLookupListEntries
						                                         *
						                                         *=
						                                         *
						                                         *1
						                                         **/
				/* KeyDeviceList[1] */
				EMPTY_DEV_HANDLE,                 /*
						                   *
						                   *DeviceDescriptorHandle
						                   **/
				false,                              /*
						                     *
						                     *UniqueDevice
						                     **/
				false,                              /*
						                     *
						                     *Blacklisted
						                     **/
				EMPTY_DEV_HANDLE,                 /*
						                   *
						                   *DeviceDescriptorHandle
						                   **/
				false,                              /*
						                     *
						                     *UniqueDevice
						                     **/
				false,                              /*
						                     *
						                     *Blacklisted
						                     **/
				EMPTY_DEV_HANDLE,                 /*
						                   *
						                   *DeviceDescriptorHandle
						                   **/
				false,                              /*
						                     *
						                     *UniqueDevice
						                     **/
				false,                              /*
						                     *
						                     *Blacklisted
						                     **/
				EMPTY_DEV_HANDLE,                           /*
						                             *
						                             *DeviceDescriptorHandle
						                             **/
				false,                              /*
						                     *
						                     *UniqueDevice
						                     **/
				false,                              /*
						                     *
						                     *Blacklisted
						                     **/
				MAC_ZIP_MAX_KEY_DEV_LIST_ENTRIES,                 /*
						                                   *
						                                   *KeyDeviceListEntries
						                                   **/
				/*  KeyUsageList */
				FRAME_TYPE_DATA,                    /* FrameType
						                     * - Data
						                     * frames */
				CMD_FRAME_ID_NA,                    /*
						                     *
						                     *CommandFrameIdentifier
						                     * not used
						                     * in ZIP */
				MAC_ZIP_MAX_KEY_USAGE_LIST_ENTRIES,                 /*
						                                     *
						                                     *KeyUsageListEntries
						                                     **/
				/* Key */
				default_key[2][0],
				default_key[2][1],
				default_key[2][2],
				default_key[2][3],
				default_key[2][4],
				default_key[2][5],
				default_key[2][6],
				default_key[2][7],
				default_key[2][8],
				default_key[2][9],
				default_key[2][10],
				default_key[2][11],
				default_key[2][12],
				default_key[2][13],
				default_key[2][14],
				default_key[2][15],
			};
			wpan_mlme_set_req(macKeyTable,
					INDEX_2,                            /*
					                                     *
					                                     *Index:
					                                     * 2
					                                     **/
					&mac_key_table3);
		}
		break;

		case INDEX_2:
		{
			/** set the coordinator IEEE Address and default PAN ID
			 *  into the MAC Device table
			 */

			uint8_t coord_dev_index = 3;
			uint8_t mac_dev_table[17];

			mac_dev_table[0] = (uint8_t)DEFAULT_PAN_ID;
			mac_dev_table[1] = (uint8_t)(DEFAULT_PAN_ID >> 8);
			mac_dev_table[2] = (uint8_t)COORD_SHORT_ADDR;
			mac_dev_table[3] = (uint8_t)(COORD_SHORT_ADDR >> 8);
			mac_dev_table[4] = COORD_IEEE_ADDRESS[7];
			mac_dev_table[5] = COORD_IEEE_ADDRESS[6];
			mac_dev_table[6] = COORD_IEEE_ADDRESS[5];
			mac_dev_table[7] = COORD_IEEE_ADDRESS[4];
			mac_dev_table[8] = COORD_IEEE_ADDRESS[3];
			mac_dev_table[9] = COORD_IEEE_ADDRESS[2];
			mac_dev_table[10] = COORD_IEEE_ADDRESS[1];
			mac_dev_table[11] = COORD_IEEE_ADDRESS[0];
			mac_dev_table[12] = 0;                  /* Frame counter
					                         **/
			mac_dev_table[13] = 0;
			mac_dev_table[14] = 0;
			mac_dev_table[15] = 0;
			mac_dev_table[16] = 0;                  /* Exempt */

			wpan_mlme_set_req(macDeviceTable,
					coord_dev_index,                                            /*
					                                                             *
					                                                             *Index
					                                                             **/
					&mac_dev_table);
		}
		break;

		default:
			break;
		}
	}
	break;

	case macDeviceTable:
	{
		/* Set the PAN Coordinator Extended Address */
		uint8_t pan_coord_add[8];
		pan_coord_add[0] = COORD_IEEE_ADDRESS[7];
		pan_coord_add[1] = COORD_IEEE_ADDRESS[6];
		pan_coord_add[2] = COORD_IEEE_ADDRESS[5];
		pan_coord_add[3] = COORD_IEEE_ADDRESS[4];
		pan_coord_add[4] = COORD_IEEE_ADDRESS[3];
		pan_coord_add[5] = COORD_IEEE_ADDRESS[2];
		pan_coord_add[6] = COORD_IEEE_ADDRESS[1];
		pan_coord_add[7] = COORD_IEEE_ADDRESS[0];

		wpan_mlme_set_req(macPANCoordExtendedAddress,
				NO_PIB_INDEX,                                                    /*
			                                                                          *
			                                                                          *Index
			                                                                          **/
				pan_coord_add);
	}
	break;

	case macPANCoordExtendedAddress:
	{
		/* Set the PAN Coordinator IEEE Address */
		uint8_t pan_coord_add[8];
		pan_coord_add[0] = COORD_IEEE_ADDRESS[7];
		pan_coord_add[1] = COORD_IEEE_ADDRESS[6];
		pan_coord_add[2] = COORD_IEEE_ADDRESS[5];
		pan_coord_add[3] = COORD_IEEE_ADDRESS[4];
		pan_coord_add[4] = COORD_IEEE_ADDRESS[3];
		pan_coord_add[5] = COORD_IEEE_ADDRESS[2];
		pan_coord_add[6] = COORD_IEEE_ADDRESS[1];
		pan_coord_add[7] = COORD_IEEE_ADDRESS[0];

		wpan_mlme_set_req(macIeeeAddress,
				NO_PIB_INDEX, /* Index */
				pan_coord_add);
	}
	break;

	case macIeeeAddress:
	{
		/* Set the PAN Coordinator Short Address */
		uint16_t short_add = COORD_SHORT_ADDR;
		wpan_mlme_set_req(macPANCoordShortAddress,
				NO_PIB_INDEX,                                                    /*
			                                                                          *
			                                                                          *Index
			                                                                          **/
				&short_add);
	}
	break;

	case macPANCoordShortAddress:
	{
		/* Set the PAN Coordinator Short Address */
		uint8_t short_addr[2];

		short_addr[0] = (uint8_t)COORD_SHORT_ADDR;          /* low byte
			                                            **/
		short_addr[1] = (uint8_t)(COORD_SHORT_ADDR >> 8);         /*
			                                                   *
			                                                   *high
			                                                   *
			                                                   *byte
			                                                   **/

		wpan_mlme_set_req(macShortAddress,
				NO_PIB_INDEX,
				short_addr);
		mlme_set_conf_run_time = true;
	}
	break;

	default:
		break;
	}
}
Exemple #5
0
/** @brief Initialize the security PIB and set the security parameters
 *  
 *  @param PIBAttribute MAC PIB Attribute type
 *  @param PIBAttributeIndex MAC PIB Attribute Index
 *  
 */
static void init_secuity_pib(uint8_t PIBAttribute, uint8_t PIBAttributeIndex)
{
	switch (PIBAttribute)
	{		
		case macDefaultKeySource:		
		{
			/* Set the no.of security level table  entries */
            uint8_t mac_sec_level_table_entries = DEFAULT_MAC_SEC_LVL_TABLE_ENTRIES;

            wpan_mlme_set_req(macSecurityLevelTableEntries,
                                NO_PIB_INDEX,
                                &mac_sec_level_table_entries);
							
        }
		break;
		
		case macSecurityLevelTableEntries:
		{
			/* set type of frames will be encrypted and decrypted */
            uint8_t mac_sec_level_table[4] = {	FRAME_TYPE_BEACON,    // FrameType: Beacon
                                                CMD_FRAME_ID_NA,      // CommandFrameIdentifier: N/A
												SECURITY_05_LEVEL,
                                                DEV_OVERRIDE_SEC_MIN  // DeviceOverrideSecurityMinimum: True
                                                };
												
											

            wpan_mlme_set_req(macSecurityLevelTable,
                                INDEX_1,    // Index: 1
                                &mac_sec_level_table);									
         }
		 break;
		 
		 case macSecurityLevelTable:
         {
			if(INDEX_1 == PIBAttributeIndex)
			{
				/* set type of frames will be encrypted and decrypted */
				uint8_t mac_sec_level_table[4] =
				{	FRAME_TYPE_DATA,      // FrameType: Beacon
					CMD_FRAME_ID_NA,      // CommandFrameIdentifier: N/A
					SECURITY_05_LEVEL,
					DEV_OVERRIDE_SEC_MIN  // DeviceOverrideSecurityMinimum: True
				};
				wpan_mlme_set_req(macSecurityLevelTable,
				INDEX_0,    // Index: 0
				&mac_sec_level_table);
			}
			else if(INDEX_0 == PIBAttributeIndex)
			{
				/* set the maximum no.of mac key table entries */
				uint8_t mac_key_table_entries = DEFAULT_MAC_KEY_TABLE_ENTRIES;

				wpan_mlme_set_req(macKeyTableEntries,
								NO_PIB_INDEX,
								&mac_key_table_entries);				
			}
         }
		break;
		
		case macKeyTableEntries:
		{
		  /* set the maximum no.of device table entries */
		  uint16_t coord_key_index = DEFAULT_MAC_DEV_TABLE_ENTRIES;
		  wpan_mlme_set_req(macDeviceTableEntries,
                          NO_PIB_INDEX,
                          &coord_key_index);	
		}        
		break;						  						  
		
		case macDeviceTableEntries:
        {
			/* set the default mac key table values */
            uint8_t mac_key_table[43] =
            {
	            default_key_source[0], // LookupData[0]
	            default_key_source[1], // LookupData[1]
	            default_key_source[2], // LookupData[2]
	            default_key_source[3], // LookupData[3]
	            default_key_source[4], // LookupData[4]
	            default_key_source[5], // LookupData[5]
	            default_key_source[6], // LookupData[6]
	            default_key_source[7], // LookupData[7]
	            KEY_INDEX_0,           // LookupData[8]
	            LOOKUP_DATA_SIZE_1, // LookupDataSize: 0x01 : Size 9 octets
	            MAC_ZIP_MAX_KEY_ID_LOOKUP_LIST_ENTRIES, // KeyIdLookupListEntries = 1
	            // KeyDeviceList[1]
	            DEV_DESC_HANDLE_IDX_0,           // DeviceDescriptorHandle
	            true,              // UniqueDevice
	            false,              // Blacklisted
	            DEV_DESC_HANDLE_IDX_0,           // DeviceDescriptorHandle
	            true,              // UniqueDevice
	            false,              // Blacklisted
	            DEV_DESC_HANDLE_IDX_0,           // DeviceDescriptorHandle
	            true,              // UniqueDevice
	            false,              // Blacklisted
				DEV_DESC_HANDLE_IDX_0,           // DeviceDescriptorHandle
	            true,              // UniqueDevice
	            false,              // Blacklisted
	            MAC_ZIP_MAX_KEY_DEV_LIST_ENTRIES, // KeyDeviceListEntries
	            //  KeyUsageList
	            FRAME_TYPE_BEACON,    // FrameType - Beacon frames
	            CMD_FRAME_ID_NA,    // CommandFrameIdentifier not used in ZIP
	            MAC_ZIP_MAX_KEY_USAGE_LIST_ENTRIES, // KeyUsageListEntries
	            // Key
	            default_key[3][0],
	            default_key[3][1],
	            default_key[3][2],
	            default_key[3][3],
	            default_key[3][4],
	            default_key[3][5],
	            default_key[3][6],
	            default_key[3][7],
	            default_key[3][8],
	            default_key[3][9],
	            default_key[3][10],
	            default_key[3][11],
	            default_key[3][12],
	            default_key[3][13],
	            default_key[3][14],
	            default_key[3][15],
            };
            wpan_mlme_set_req(macKeyTable,
            INDEX_3,    // Index: 3
            &mac_key_table);
        }
		break;
		
		case macKeyTable:
		{
			/* set the default mac key table values */
					switch(PIBAttributeIndex)
					{
					case INDEX_3:
					{			
						uint8_t mac_key_table1[43] = { 
							// KeyIdLookupList[1].LookupData : macDefaultKeySource || g_Sec_KeyIndex_1
							default_key_source[0], // LookupData[0]
							default_key_source[1], // LookupData[1]
							default_key_source[2], // LookupData[2]
							default_key_source[3], // LookupData[3]
							default_key_source[4], // LookupData[4]
							default_key_source[5], // LookupData[5]
							default_key_source[6], // LookupData[6]
							default_key_source[7], // LookupData[7]
							KEY_INDEX_1,           // LookupData[8]
							LOOKUP_DATA_SIZE_1, // LookupDataSize: 0x01 : Size 9 octets
							MAC_ZIP_MAX_KEY_ID_LOOKUP_LIST_ENTRIES, // KeyIdLookupListEntries = 1
							// KeyDeviceList[1]
							EMPTY_DEV_HANDLE,           // DeviceDescriptorHandle
							false,              // UniqueDevice
							false,              // Blacklisted
							EMPTY_DEV_HANDLE,           // DeviceDescriptorHandle
							false,              // UniqueDevice
							false,              // Blacklisted
							EMPTY_DEV_HANDLE,           // DeviceDescriptorHandle
							false,              // UniqueDevice
							false,              // Blacklisted
							EMPTY_DEV_HANDLE,           // DeviceDescriptorHandle
							false,              // UniqueDevice
							false,              // Blacklisted
							MAC_ZIP_MAX_KEY_DEV_LIST_ENTRIES, // KeyDeviceListEntries
							//  KeyUsageList
							FRAME_TYPE_DATA,    // FrameType - Data frames
							CMD_FRAME_ID_NA,    // CommandFrameIdentifier not used in ZIP
							MAC_ZIP_MAX_KEY_USAGE_LIST_ENTRIES, // KeyUsageListEntries
							// Key
							default_key[0][0],
							default_key[0][1],
							default_key[0][2],
							default_key[0][3],
							default_key[0][4],
							default_key[0][5],
							default_key[0][6],
							default_key[0][7],
							default_key[0][8],
							default_key[0][9],
							default_key[0][10],
							default_key[0][11],
							default_key[0][12],
							default_key[0][13],
							default_key[0][14],
							default_key[0][15],
						};
						wpan_mlme_set_req(macKeyTable,
						INDEX_0,    // Index: 0
						&mac_key_table1);
					}
					break;	
			
				 case INDEX_0:
				 {
						uint8_t mac_key_table2[43] = {
							// KeyIdLookupList[1].LookupData : macDefaultKeySource || g_Sec_KeyIndex_1
							default_key_source[0], // LookupData[0]
							default_key_source[1], // LookupData[1]
							default_key_source[2], // LookupData[2]
							default_key_source[3], // LookupData[3]
							default_key_source[4], // LookupData[4]
							default_key_source[5], // LookupData[5]
							default_key_source[6], // LookupData[6]
							default_key_source[7], // LookupData[7]
							KEY_INDEX_2,           // LookupData[8]
							LOOKUP_DATA_SIZE_1, // LookupDataSize: 0x01 : Size 9 octets
							MAC_ZIP_MAX_KEY_ID_LOOKUP_LIST_ENTRIES, // KeyIdLookupListEntries = 1
							// KeyDeviceList[1]
							EMPTY_DEV_HANDLE, // DeviceDescriptorHandle
							false,              // UniqueDevice
							false,              // Blacklisted
							EMPTY_DEV_HANDLE, // DeviceDescriptorHandle
							false,              // UniqueDevice
							false,              // Blacklisted
							EMPTY_DEV_HANDLE, // DeviceDescriptorHandle
							false,              // UniqueDevice
							false,              // Blacklisted
							EMPTY_DEV_HANDLE,           // DeviceDescriptorHandle
							false,              // UniqueDevice
							false,              // Blacklisted
							MAC_ZIP_MAX_KEY_DEV_LIST_ENTRIES, // KeyDeviceListEntries
							//  KeyUsageList
							FRAME_TYPE_DATA,    // FrameType - Data frames
							CMD_FRAME_ID_NA,    // CommandFrameIdentifier not used in ZIP
							MAC_ZIP_MAX_KEY_USAGE_LIST_ENTRIES, // KeyUsageListEntries
							// Key
							default_key[1][0],
							default_key[1][1],
							default_key[1][2],
							default_key[1][3],
							default_key[1][4],
							default_key[1][5],
							default_key[1][6],
							default_key[1][7],
							default_key[1][8],
							default_key[1][9],
							default_key[1][10],
							default_key[1][11],
							default_key[1][12],
							default_key[1][13],
							default_key[1][14],
							default_key[1][15],
						};
				
						wpan_mlme_set_req(macKeyTable,
						INDEX_1,    // Index: 1
						&mac_key_table2);
					  }
					  break;
			
					case INDEX_1:
					{  
					  uint8_t mac_key_table3[43] = {
						// KeyIdLookupList[1].LookupData : macDefaultKeySource || g_Sec_KeyIndex_1
						default_key_source[0], // LookupData[0]
						default_key_source[1], // LookupData[1]
						default_key_source[2], // LookupData[2]
						default_key_source[3], // LookupData[3]
						default_key_source[4], // LookupData[4]
						default_key_source[5], // LookupData[5]
						default_key_source[6], // LookupData[6]
						default_key_source[7], // LookupData[7]
						KEY_INDEX_3,           // LookupData[8]
						LOOKUP_DATA_SIZE_1, // LookupDataSize: 0x01 : Size 9 octets
						MAC_ZIP_MAX_KEY_ID_LOOKUP_LIST_ENTRIES, // KeyIdLookupListEntries = 1
						// KeyDeviceList[1]
						EMPTY_DEV_HANDLE, // DeviceDescriptorHandle
						false,              // UniqueDevice
						false,              // Blacklisted
						EMPTY_DEV_HANDLE, // DeviceDescriptorHandle
						false,              // UniqueDevice
						false,              // Blacklisted
						EMPTY_DEV_HANDLE, // DeviceDescriptorHandle
						false,              // UniqueDevice
						false,              // Blacklisted
						EMPTY_DEV_HANDLE,           // DeviceDescriptorHandle
						false,              // UniqueDevice
						false,              // Blacklisted
						MAC_ZIP_MAX_KEY_DEV_LIST_ENTRIES, // KeyDeviceListEntries
						//  KeyUsageList
						FRAME_TYPE_DATA,    // FrameType - Data frames
						CMD_FRAME_ID_NA,    // CommandFrameIdentifier not used in ZIP
						MAC_ZIP_MAX_KEY_USAGE_LIST_ENTRIES, // KeyUsageListEntries
						// Key
						default_key[2][0],
						default_key[2][1],
						default_key[2][2],
						default_key[2][3],
						default_key[2][4],
						default_key[2][5],
						default_key[2][6],
						default_key[2][7],
						default_key[2][8],
						default_key[2][9],
						default_key[2][10],
						default_key[2][11],
						default_key[2][12],
						default_key[2][13],
						default_key[2][14],
						default_key[2][15],
					};		
				wpan_mlme_set_req(macKeyTable,
								INDEX_2,    // Index: 2
								&mac_key_table3);
				}
				break;
				
				case INDEX_2:
				{
					/** set the coordinator IEEE Address and default PAN ID
					 *  into the MAC Device table
					 */
					
					uint8_t coord_dev_index = 3;
					uint8_t mac_dev_table[17];
			
					mac_dev_table[0] = (uint8_t)DEFAULT_PAN_ID;
					mac_dev_table[1] = (uint8_t)(DEFAULT_PAN_ID >> 8);
					mac_dev_table[2] = (uint8_t)COORD_SHORT_ADDR;
					mac_dev_table[3] = (uint8_t)(COORD_SHORT_ADDR >> 8);
					mac_dev_table[4] = COORD_IEEE_ADDRESS[7];
					mac_dev_table[5] = COORD_IEEE_ADDRESS[6];
					mac_dev_table[6] = COORD_IEEE_ADDRESS[5];
					mac_dev_table[7] = COORD_IEEE_ADDRESS[4];
					mac_dev_table[8] = COORD_IEEE_ADDRESS[3];
					mac_dev_table[9] = COORD_IEEE_ADDRESS[2];
					mac_dev_table[10] = COORD_IEEE_ADDRESS[1];
					mac_dev_table[11] = COORD_IEEE_ADDRESS[0];
					mac_dev_table[12] = 0;  // Frame counter
					mac_dev_table[13] = 0;
					mac_dev_table[14] = 0;
					mac_dev_table[15] = 0;
					mac_dev_table[16] = 0;  // Exempt
			
					wpan_mlme_set_req(macDeviceTable,
										coord_dev_index,    // Index
										&mac_dev_table);
				}
				break;
		
				default:
				break;
			  }
		}
		break;
		
		case macDeviceTable:
		{
			/* Set the PAN Coordinator Extended Address */
			uint8_t pan_coord_add[8];
			pan_coord_add[0] = COORD_IEEE_ADDRESS[7];
			pan_coord_add[1] = COORD_IEEE_ADDRESS[6];
			pan_coord_add[2] = COORD_IEEE_ADDRESS[5];
			pan_coord_add[3] = COORD_IEEE_ADDRESS[4];
			pan_coord_add[4] = COORD_IEEE_ADDRESS[3];
			pan_coord_add[5] = COORD_IEEE_ADDRESS[2];
			pan_coord_add[6] = COORD_IEEE_ADDRESS[1];
			pan_coord_add[7] = COORD_IEEE_ADDRESS[0];
			
			wpan_mlme_set_req(macPANCoordExtendedAddress,
										NO_PIB_INDEX,    // Index
										pan_coord_add);
		}
		break;
		
		case macPANCoordExtendedAddress:
		{
			/* Set the PAN Coordinator IEEE Address */
			uint8_t pan_coord_add[8];
			pan_coord_add[0] = COORD_IEEE_ADDRESS[7];
			pan_coord_add[1] = COORD_IEEE_ADDRESS[6];
			pan_coord_add[2] = COORD_IEEE_ADDRESS[5];
			pan_coord_add[3] = COORD_IEEE_ADDRESS[4];
			pan_coord_add[4] = COORD_IEEE_ADDRESS[3];
			pan_coord_add[5] = COORD_IEEE_ADDRESS[2];
			pan_coord_add[6] = COORD_IEEE_ADDRESS[1];
			pan_coord_add[7] = COORD_IEEE_ADDRESS[0];
			
			wpan_mlme_set_req(macIeeeAddress,
			NO_PIB_INDEX,    // Index
			pan_coord_add);
		}		
		break;
		
		case macIeeeAddress:
		{
			/* Set the PAN Coordinator Short Address */
			uint16_t short_add = COORD_SHORT_ADDR;
			wpan_mlme_set_req(macPANCoordShortAddress,
										NO_PIB_INDEX,    // Index
										&short_add);
		}
		break;
		
		case macPANCoordShortAddress:		
		{
			/* Set the PAN Coordinator Short Address */
			uint8_t short_addr[2];

			short_addr[0] = (uint8_t)COORD_SHORT_ADDR;  /* low byte */
			short_addr[1] = (uint8_t)(COORD_SHORT_ADDR >> 8); /* high byte */

			wpan_mlme_set_req(macShortAddress, 
								NO_PIB_INDEX, 
								short_addr);
			mlme_set_conf_run_time = true;
		}
		break;
		
		default:
		break;
	 }

}
/*
 * @brief Callback function usr_mlme_set_conf
 *
 * @param status        Result of requested PIB attribute set operation
 * @param PIBAttribute  Updated PIB attribute
 */
static void usr_mlme_set_conf_run_time(uint8_t status, uint8_t PIBAttribute,
		uint8_t PIBAttributeIndex)
{
	if (status != MAC_SUCCESS) {
		/* something went wrong; restart */
		wpan_mlme_reset_req(true);
	} else {
		switch (PIBAttribute) {
		case macPANId:
		{
			/*
			 * Set the Coordinator Short Address of the scanned
			 * network.
			 * This is required in order to perform a proper sync
			 * before association.
			 */
			wpan_mlme_set_req(macCoordShortAddress,
					NO_PIB_INDEX,
					&coord_addr_spec.Addr);
		}
		break;

		case macCoordShortAddress:
		{
#ifdef BEACON_SUPPORT
			wpan_mlme_sync_req(current_channel,
					current_channel_page,
					1);
#endif /* BEACON_SUPPORT */
		}
		break;

		case macDefaultKeySource:
		{
			uint8_t mac_sec_level_table_entries
				= DEFAULT_MAC_SEC_LVL_TABLE_ENTRIES;

			wpan_mlme_set_req(macSecurityLevelTableEntries,
					NO_PIB_INDEX,
					&mac_sec_level_table_entries);
		}
		break;

		case macSecurityLevelTableEntries:
		{
			uint8_t mac_sec_level_table[4] = {FRAME_TYPE_DATA,  /*
					                                     *
					                                     *FrameType:
					                                     *
					                                     *Data
					                                     **/
							  CMD_FRAME_ID_NA,  /*
					                                     *
					                                     *CommandFrameIdentifier:
					                                     *
					                                     *N/A
					                                     **/

				                          /* ZIP_SEC_MIN,
				                           *          //
				                           * SecurityMinimum: 5
				                           **/
							  0X05,
							  DEV_OVERRIDE_SEC_MIN /*
					                                        *
					                                        *DeviceOverrideSecurityMinimum:
					                                        *
					                                        *True
					                                        **/
			};

			wpan_mlme_set_req(macSecurityLevelTable,
					INDEX_0,  /* Index: 0 */
					&mac_sec_level_table);
		}
		break;

		case macSecurityLevelTable:
		{
			uint8_t mac_key_table_entries
				= DEFAULT_MAC_KEY_TABLE_ENTRIES;

			wpan_mlme_set_req(macKeyTableEntries,
					NO_PIB_INDEX,
					&mac_key_table_entries);
		}
		break;

		case macKeyTableEntries:
		{
			uint8_t mac_key_table[43] = {
				default_key_source[0],                 /*
					                                *
					                                *LookupData[0]
					                                **/
				default_key_source[1],                 /*
					                                *
					                                *LookupData[1]
					                                **/
				default_key_source[2],                 /*
					                                *
					                                *LookupData[2]
					                                **/
				default_key_source[3],                 /*
					                                *
					                                *LookupData[3]
					                                **/
				default_key_source[4],                 /*
					                                *
					                                *LookupData[4]
					                                **/
				default_key_source[5],                 /*
					                                *
					                                *LookupData[5]
					                                **/
				default_key_source[6],                 /*
					                                *
					                                *LookupData[6]
					                                **/
				default_key_source[7],                 /*
					                                *
					                                *LookupData[7]
					                                **/
				KEY_INDEX_0,                           /*
					                                *
					                                *LookupData[8]
					                                **/
				LOOKUP_DATA_SIZE_1,                 /*
					                             *
					                             *LookupDataSize:
					                             * 0x01 :
					                             * Size 9
					                             * octets */
				MAC_ZIP_MAX_KEY_ID_LOOKUP_LIST_ENTRIES,                 /*
					                                                 *
					                                                 *KeyIdLookupListEntries
					                                                 *
					                                                 *=
					                                                 *
					                                                 *1
					                                                 **/
				/* KeyDeviceList[1] */
				DEV_DESC_HANDLE_IDX_0,                           /*
					                                          *
					                                          *DeviceDescriptorHandle
					                                          **/
				true,                              /*
					                            *
					                            *UniqueDevice
					                            **/
				false,                              /*
					                             *
					                             *Blacklisted
					                             **/
				DEV_DESC_HANDLE_IDX_0,                           /*
					                                          *
					                                          *DeviceDescriptorHandle
					                                          **/
				true,                              /*
					                            *
					                            *UniqueDevice
					                            **/
				false,                              /*
					                             *
					                             *Blacklisted
					                             **/
				DEV_DESC_HANDLE_IDX_0,                           /*
					                                          *
					                                          *DeviceDescriptorHandle
					                                          **/
				true,                              /*
					                            *
					                            *UniqueDevice
					                            **/
				false,                              /*
					                             *
					                             *Blacklisted
					                             **/
				DEV_DESC_HANDLE_IDX_0,                           /*
					                                          *
					                                          *DeviceDescriptorHandle
					                                          **/
				true,                              /*
					                            *
					                            *UniqueDevice
					                            **/
				false,                              /*
					                             *
					                             *Blacklisted
					                             **/
				MAC_ZIP_MAX_KEY_DEV_LIST_ENTRIES,                 /*
					                                           *
					                                           *KeyDeviceListEntries
					                                           **/
				/*  KeyUsageList */
				FRAME_TYPE_BEACON,                    /*
					                               *
					                               *FrameType
					                               * -
					                               * Beacon
					                               * frames
					                               **/
				CMD_FRAME_ID_NA,                    /*
					                             *
					                             *CommandFrameIdentifier
					                             * not used
					                             * in ZIP */
				MAC_ZIP_MAX_KEY_USAGE_LIST_ENTRIES,                 /*
					                                             *
					                                             *KeyUsageListEntries
					                                             **/
				/* Key */
				default_key[3][0],
				default_key[3][1],
				default_key[3][2],
				default_key[3][3],
				default_key[3][4],
				default_key[3][5],
				default_key[3][6],
				default_key[3][7],
				default_key[3][8],
				default_key[3][9],
				default_key[3][10],
				default_key[3][11],
				default_key[3][12],
				default_key[3][13],
				default_key[3][14],
				default_key[3][15],
			};
			wpan_mlme_set_req(macKeyTable,
					INDEX_3,    /* Index: 3 */
					&mac_key_table);
		}
		break;

		case macKeyTable:
		{
			/*
			 * Sync with beacon frames from our coordinator.
			 * Use: bool wpan_mlme_sync_req(uint8_t LogicalChannel,
			 *                              uint8_t ChannelPage,
			 *                              bool TrackBeacon);
			 *
			 * This does not lead to an immediate reaction.
			 *
			 * In case we receive beacon frames from our coordinator
			 * including
			 * a beacon payload, this is indicated in the callback
			 * function
			 * usr_mlme_beacon_notify_ind().
			 *
			 * In case the device cannot find its coordinator or
			 * later
			 * looses
			 * synchronization with its parent, this is indicated in
			 * the
			 * callback function usr_mlme_sync_loss_ind().
			 */
			if (PIBAttributeIndex == INDEX_3 && app_state ==
					APP_IDLE) {
				wpan_mlme_get_req(phyCurrentPage, NO_PIB_INDEX);
			}
		}
		break;

		case macDeviceTableEntries:
		{
			uint8_t mac_dev_table[17] = {
				/* DeviceDescriptor */
				/* PANId */
				(uint8_t)DEFAULT_PAN_ID,
				(uint8_t)(DEFAULT_PAN_ID >> 8),
				/* Device ShortAddress */
				(uint8_t)COORD_SHORT_ADDR,
				(uint8_t)(COORD_SHORT_ADDR >> 8),
				/* Device ExtAddress */
				COORD_IEEE_ADDRESS[7],
				COORD_IEEE_ADDRESS[6],
				COORD_IEEE_ADDRESS[5],
				COORD_IEEE_ADDRESS[4],
				COORD_IEEE_ADDRESS[3],
				COORD_IEEE_ADDRESS[2],
				COORD_IEEE_ADDRESS[1],
				COORD_IEEE_ADDRESS[0],
				/* FrameCounter */
				0, 0, 0, 0,
				/* Exempt */
				0
			};

			wpan_mlme_set_req(macDeviceTable,
					INDEX_0, /* Index: 0 */
					&mac_dev_table);
		}
		break;

		case macDeviceTable:
		{
			/* Use DSN start value as in ZIP test spec. */
			uint8_t new_dsn = 0x0;

			wpan_mlme_set_req(macDSN,
					NO_PIB_INDEX,
					&new_dsn);
		}
		break;

		case macDSN:
		{
			/* Use DSN start value as in ZIP test spec. */
			uint32_t frame_counter = 1;

			wpan_mlme_set_req(macFrameCounter,
					NO_PIB_INDEX,
					&frame_counter);
		}
		break;

		case macFrameCounter:
		{
			wpan_mlme_get_req(macKeyTable, deviceShortAddress - 1);
		}
		break;

		default:
			/* undesired PIB attribute; restart */
			wpan_mlme_reset_req(true);
			break;
		}
	}

	/* Keep compiler happy. */
	PIBAttributeIndex = PIBAttributeIndex;
}