⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 enable_gmacs.c

📁 hifn ipsec固件下载工具
💻 C
📖 第 1 页 / 共 4 页
字号:
         if (((configParams_p[i].state == SET) ||              (configParams_p[i].state == UNSET_DEFAULT)) &&             (configParams_p[i].parameter == parameter))         {            *value_pp = &configParams_p[i].value;            status = HFTC_STATUS_OK;            break;         }      }   } while (HFTC_FALSE);   return status;} /* End findParameterValue *//*----------------------------------------------------------------------------* * compareMACAddress *----------------------------------------------------------------------------* * @ingroup startup * @brief Compare two mac addresses * * @param macA_p           RO: MAC addresses to compare (array) * @param macB_p           RO: MAC addresses to compare (array) * * @par Externals: * * @return *    0 if equal *    1 if macA is greater than macB *   -1 if macB is greater than macA * * @par Errors: *    None. * * @par Locks: *    None. * * @par Assumptions: *    Assumes MAC address is an array of 6 values. * *----------------------------------------------------------------------------*/staticint compareMACAddress(HFTC_MAC_t             *macA_p,                      HFTC_MAC_t             *macB_p){   uint32_t     i;   int          results = 0;   for (i = 0; i < 6; i++ )   {      if ((*macA_p)[i] > (*macB_p)[i])      {         results = 1;         break;      }      if ((*macB_p)[i] > (*macA_p)[i])      {         results = -1;         break;      }   }   return results;} /* End compareMACAddress *//*----------------------------------------------------------------------------* * appendMACAddress *----------------------------------------------------------------------------* * @ingroup startup * @brief Appends a MAC address into a MAC address table * * Appends a MAC address into a MAC address table.  A MAC address of all * zeros is considered an invalid value and is not entered.  Thus, a value * of zeros won't take up one of the 16 slots. * * @param mac_p            RO: MAC addresses to add into table * @param macTable_p       RW: Table in which to add address * * @par Externals: * * @return *    HFTC_STATUS_OK            Either value was succussfully added or it *                              was already found in the table. * * @par Errors: *    HFTC_NO_MORE_RESOURCE     More unique MAC addresses were found *                              than exist in the MAC filtering table. * * @par Locks: *    None. * * @par Assumptions: *    None. * *----------------------------------------------------------------------------*/staticHFTC_Status_t appendMACAddress(HFTC_MAC_t             *mac_p,                               HFTC_APIKEMACTable_t   *macTable_p){   HFTC_Status_t        status  = HFTC_STATUS_OK;   uint32_t             i;   HFTC_Boolean_t       found   = HFTC_FALSE;   HFTC_MAC_t           zeros   = {0, 0, 0, 0, 0, 0};   for (i = 0; i < macTable_p->valid_count; i++ )   {      if (compareMACAddress((HFTC_MAC_t *) macTable_p->values[i], mac_p) == 0)      {         found = HFTC_TRUE;         break;      }   }   /* If the value to append is all 0s, don't bother appending it. */   if (compareMACAddress(mac_p, &zeros) == 0)   {      found = HFTC_TRUE;   }   /* Append the MAC address if it wasn't already found. */   if (found == HFTC_FALSE)   {      if (macTable_p->valid_count < NUM_SYN_MAC_ADDRESS_PAIRS)      {         memcpy(&(macTable_p->values[macTable_p->valid_count]),                mac_p,                sizeof(HFTC_MAC_t));         ++macTable_p->valid_count;      }      else /* No more room left. */      {         printf("More than %d unique MAC addresses were found.\n",                NUM_SYN_MAC_ADDRESS_PAIRS);         status = HFTC_NO_MORE_RESOURCE;      }   }   return status;} /* End appendMACAddress *//*----------------------------------------------------------------------------* * writeMACAddress *----------------------------------------------------------------------------* * @ingroup startup * @brief Write the MAC addresses into the specified NET filter slot. * * @param mac_p            RO: MAC addresses to write (array) * @param gmac             RO: GMAC Register set * @param slot             RO: slot 0-NUM_SYN_MAC_ADDRESS_PAIRS * * @par Externals: * * @return *    HFTC_STATUS_OK            Parsing ok, MAC addresses found. * * @par Errors: *    HFTC_NOT_FOUND            Parsing problem, no MAC addresses. * * @par Locks: *    None. * * @par Assumptions: *    None. * *----------------------------------------------------------------------------*/staticHFTC_Status_t writeMACAddress(HFTC_MAC_t             mac,                              HFTC_GMACReg_t         gmac,                              uint32_t               slot){   HFTC_Status_t              status            = HFTC_STATUS_OK;   HFTC_Unit_t                unit              = 0;   HFTC_Reqid_t               reqid             = 0; /* Arbitrary */   HFTC_Cbp_t                 cbp               = NULL;   uint32_t                   retries           = 0;   uint32_t                   macValue;   HFTC_GMACIndex_t           index_lo;   HFTC_GMACIndex_t           index_hi;   do   {      /*         Set up the index based on the slot      */      if (slot > NUM_SYN_MAC_ADDRESS_PAIRS)      {         status = HFTC_NOT_FOUND;         break;      }      else      {         index_lo = gmac_filter_table[slot].lo;         index_hi = gmac_filter_table[slot].hi;      }      /*         The values being written into the MAC address filters are         from the IKE MAC addresses in the configparams file.         The order of the bytes are reversed and the high bit of the         low address is set (it is the enable bit).  Thus a MAC address of         11:22:33:44:55:66 will be written as 0x80006655 0x44332211      */      macValue = 0x80000000 | ((uint32_t) mac[5] << 8) | (uint32_t) mac[4];      do      {         status = HFTC_WriteGMACRegister(unit, cbp, reqid,                                         gmac,                                         index_lo,                                         &macValue);         RESEND_TIMEOUTS(status, retries);      } while (status == HFTC_RESEND);      if (status != HFTC_STATUS_OK)      {         printf("Write of MAC address (lo) failed.  status = %s (%d)\n",                HFTC_Status_t_text(status), status);         break;      }      macValue = ((uint32_t) mac[3] << 24) | ((uint32_t) mac[2] << 16) |                 ((uint32_t) mac[1] << 8)  |  (uint32_t) mac[0];      retries = 0;      do      {         status = HFTC_WriteGMACRegister(unit, cbp, reqid,                                         gmac,                                         index_hi,                                         &macValue);         RESEND_TIMEOUTS(status, retries);      } while (status == HFTC_RESEND);      if (status != HFTC_STATUS_OK)      {         printf("Write of MAC address (hi) failed.  status = %s (%d)\n",                HFTC_Status_t_text(status), status);         break;      }      if (DL_DEBUG && (status == HFTC_STATUS_OK))      {         printf("Wrote MAC addr: "                "%02x:%02x:%02x:%02x:%02x:%02x to GMAC %s (%d)\n",               mac[0], mac[1], mac[2], mac[3], mac[4], mac[5],               HFTC_GMACReg_t_text(gmac), gmac);      }   } while (HFTC_FALSE);   return status;} /* End writeMACAddress *//*----------------------------------------------------------------------------* * readMACFilterValue *----------------------------------------------------------------------------* * @ingroup startup * @brief Read the MAC addresses from the specified NET filter slot. * * This routine is currently just used for debug.  It prints the values * read. * * @param gmac             RO: GMAC Register set * @param slot             RO: slot 0-NUM_SYN_MAC_ADDRESS_PAIRS * * @par Externals: * * @return *    None. * * @par Errors: *    None. * * @par Locks: *    None. * * @par Assumptions: *    Assumes slot is valid. * *----------------------------------------------------------------------------*/staticvoid readMACFilterValue(HFTC_GMACReg_t         gmac,                        uint32_t               slot){   HFTC_Status_t              status            = HFTC_STATUS_OK;   HFTC_Unit_t                unit              = 0;   HFTC_Reqid_t               reqid             = 0; /* Arbitrary */   HFTC_Cbp_t                 cbp               = NULL;   uint32_t                   retries           = 0;   uint32_t                   value_lo;   uint32_t                   value_hi;   HFTC_GMACIndex_t           index_lo;   HFTC_GMACIndex_t           index_hi;   do   {      index_lo = gmac_filter_table[slot].lo;      index_hi = gmac_filter_table[slot].hi;      /*         The values being read from the MAC address filters are just left         in the order that they are written on the chip.  This does NOT         match the MAC address in the IKE table.  See the writeMACAddress         routine to interpret the results.      */      do      {         status = HFTC_ReadGMACRegister(unit, cbp, reqid,                                        gmac,                                        index_lo,                                        &value_lo);         RESEND_TIMEOUTS(status, retries);      } while (status == HFTC_RESEND);      if (status != HFTC_STATUS_OK)      {         printf("Write of MAC address (lo) failed.  status = %s (%d)\n",                HFTC_Status_t_text(status), status);         break;      }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -