Exemple #1
0
/********************************************************************************************************
 * @fn      ZMacSecurityGetReq
 *
 * @brief   Read a MAC Security PIB attribute.
 *
 * @param   attr - PIB attribute to get
 * @param   value - pointer to the buffer to store the attribute
 *
 * @return  status
 ********************************************************************************************************/
uint8 ZMacSecurityGetReq( uint8 attr, uint8 *value )
{
  return (ZMacStatus_t) MAC_MlmeGetSecurityReq( attr, value );
}
Exemple #2
0
/********************************************************************************************************
 * @fn      ZMacSecurityGetReq
 *
 * @brief   Read a MAC Security PIB attribute.
 *
 * @param   attr - PIB attribute to get
 * @param   value - pointer to the buffer to store the attribute
 *
 * @return  status
 ********************************************************************************************************/
uint8 ZMacSecurityGetReq( uint8 attr, uint8 *value )
{
  uint8         keyIndex, entry, status;
  uint8        *ptr;

  ptr = (uint8 *) value;
  switch (attr)
  {
    case ZMacKeyIdLookupEntry:
      keyIndex = *ptr++; /* key_index */
      entry    = *ptr++; /* key_id_lookup_index */
      
      /* Transform byte array to propriety PIB struct */
      ((macSecurityPibKeyIdLookupEntry_t *)value)->key_id_lookup_index = entry;
      ((macSecurityPibKeyIdLookupEntry_t *)value)->key_index = keyIndex;
      break;
      
    case ZMacKeyDeviceEntry:
      keyIndex = *ptr++; /* key_index */
      entry    = *ptr++; /* key_device_index */
      
      /* Transform byte array to propriety PIB struct */
      ((macSecurityPibKeyDeviceEntry_t *)value)->key_device_index = entry;
      ((macSecurityPibKeyDeviceEntry_t *)value)->key_index = keyIndex;
      break;
      
    case ZMacKeyUsageEntry:
      keyIndex = *ptr++; /* key_index */
      entry    = *ptr++; /* key_key_usage_index */
      
      /* Transform byte array to propriety PIB struct */
      ((macSecurityPibKeyUsageEntry_t *)value)->key_key_usage_index = entry;
      ((macSecurityPibKeyUsageEntry_t *)value)->key_index = keyIndex;
      break;
      
    case ZMacKeyEntry:
      keyIndex = *ptr++; /* key_index */
      
      /* Transform byte array to propriety PIB struct */
      ((macSecurityPibKeyEntry_t *)value)->key_index = keyIndex;
      break;
      
    case ZMacDeviceEntry:
      entry = *ptr++; /* device_index */
      
      /* Transform byte array to propriety PIB struct */
      ((macSecurityPibDeviceEntry_t *)value)->device_index = entry;
      break;

    case ZMacSecurityLevelEntry:
      entry = *ptr++; /* security_level_index */
      
      /* Transform byte array to propriety PIB struct */
      ((macSecurityPibSecurityLevelEntry_t *)value)->security_level_index = entry;
      break;
  }

  status = (ZMacStatus_t) MAC_MlmeGetSecurityReq( attr, value );
  
  ptr = (uint8 *) value;
  switch (attr)
  {
    case ZMacKeyIdLookupEntry:
      *ptr++ = keyIndex; /* key_index */
      *ptr++ = entry;    /* key_id_lookup_index */
      
      /* Transform propriety PIB struct to byte array */
      osal_memcpy(ptr, &((macSecurityPibKeyIdLookupEntry_t *)value)->macKeyIdLookupEntry, sizeof(keyIdLookupDescriptor_t));
      break;
      
    case ZMacKeyDeviceEntry:
      *ptr++ = keyIndex; /* key_index */
      *ptr++ = entry;    /* key_device_index */
      
      /* Transform propriety PIB struct to byte array */
      osal_memcpy(ptr, &((macSecurityPibKeyDeviceEntry_t *)value)->macKeyDeviceEntry, sizeof(keyDeviceDescriptor_t));
      break;
      
    case ZMacKeyUsageEntry:
      *ptr++ = keyIndex; /* key_index */
      *ptr++ = entry;    /* key_key_usage_index */
      
      /* Transform propriety PIB struct to byte array */
      osal_memcpy(ptr, &((macSecurityPibKeyUsageEntry_t *)value)->macKeyUsageEntry, sizeof(keyUsageDescriptor_t));
      break;
      
    case ZMacKeyEntry:
      *ptr++ = keyIndex; /* key_index */
      
      /* Transform propriety PIB struct to byte array */
      osal_memcpy(ptr, &((macSecurityPibKeyEntry_t *)value)->keyEntry, MAC_KEY_MAX_LEN);
      break;
      
    case ZMacDeviceEntry:
      *ptr++ = entry; /* device_index */
      
      /* Transform propriety PIB struct to byte array */
      osal_memcpy(ptr, &((macSecurityPibDeviceEntry_t *)value)->macDeviceEntry, sizeof(deviceDescriptor_t));
      break;

    case ZMacSecurityLevelEntry:
      *ptr++ = entry; /* security_level_index */
      
      /* Transform propriety PIB struct to byte array */
      osal_memcpy(ptr, &((macSecurityPibSecurityLevelEntry_t *)value)->macSecurityLevelEntry, sizeof(securityLevelDescriptor_t));
      break;
  }
  
  return status;
}