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

📄 enable_gmacs.c

📁 hifn ipsec固件下载工具
💻 C
📖 第 1 页 / 共 4 页
字号:
      retries = 0;      do      {         status = HFTC_ReadGMACRegister(unit, cbp, reqid,                                        gmac,                                        index_hi,                                        &value_hi);         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;      }      printf("\tMAC Filter %02d lo:hi = %08x:%08x\n",             slot, value_lo, value_hi);   } while (HFTC_FALSE);   return;} /* End readMACFilterValue *//*----------------------------------------------------------------------------* * gatherMACaddresses *----------------------------------------------------------------------------* * @ingroup startup * @brief Read config file and find the MAC values in it. * * Reads the config file and saves MAC addresses for filtering * on NET0 and NET1 ports. * * @param filename         RO: File to read with esc parameters * @param port0_p          WO: Pointer to table for Port 0 MAC values * @param port1_p          WO: Pointer to table for Port 1 MAC values * * @par Externals: *    None. * * @return *    HFTC_STATUS_OK            Parsing ok, MAC addresses read into table. * * @par Errors: *    HFTC_NO_MORE_RESOURCE     More than 16 unique MAC addresses were found *                              for a particular port. *    HFTC_NOT_FOUND            Neither V4 nor V6 MAC addresses were found. *    HFTC_INVALID_LENGTH       Table size mismatch * *    Errors returned from HFTC_ReadConfigFile. * * @par Locks: *    None. * * @par Assumptions: *    Assumes the MAC addresses are valid, or if they are not valid that it *    doesn't matter to the GMAC. * *----------------------------------------------------------------------------*/staticHFTC_Status_t gatherMACaddresses(char                 *configparamsFile,                                 HFTC_APIKEMACTable_t *port0_p,                                 HFTC_APIKEMACTable_t *port1_p){   HFTC_Status_t                status            = HFTC_STATUS_OK;   HFTC_Status_t                v4found           = HFTC_STATUS_OK;   HFTC_Status_t                v6found           = HFTC_STATUS_OK;   HFTC_ConfigParameters_t     *configParams_p   = NULL;   HFTC_ConfigParameterValue_t *parameterValue_p = NULL;   HFTC_APIKEMACTable_t        *v4macTable_p      = NULL;   HFTC_APIKEMACTable_t        *v6macTable_p      = NULL;   HFTC_APIKEPortMapTable_t    *v4macMap_p        = NULL;   HFTC_APIKEPortMapTable_t    *v6macMap_p        = NULL;   uint32_t                     i;   do   {      /*         Read the config params file to look for MAC addresses.      */      status = HFTC_ReadConfigFile(configparamsFile,                                   &configParams_p);      if (status != HFTC_STATUS_OK)      {         printf("Problem with config file %s - status = %s (%d).\n",                configparamsFile, HFTC_Status_t_text(status), status);         break;      }      /*         Find the IKE MAC addresses from data in the configparams         file.  If a MAC address table is found then it would be an error to         not have a port mapping table.  First get V4 values, then get V6         values.      */      /* V4 values */      v4found  = findParameterValue(configParams_p,                                    HFTC_AP_IKE_MAC_ADDR_TABLE,                                    &parameterValue_p);      if (v4found == HFTC_STATUS_OK)      {         v4macTable_p = &(parameterValue_p->macAddrArray);      }      status  = findParameterValue(configParams_p,                                   HFTC_AP_IKE_PORT_MAPPING_TABLE,                                    &parameterValue_p);      if (status == HFTC_STATUS_OK)      {         v4macMap_p = &(parameterValue_p->portMappingArray);      }      else      {         if (v4found == HFTC_STATUS_OK)         {            printf("Found IPV4 MAC addresses yet no mapping values.\n");            break;         }         v4found = status;      }      /* V6 values */      v6found = findParameterValue(configParams_p,                                   HFTC_AP_IKE_MAC_ADDR_IPV6_TABLE,                                   &parameterValue_p);      if (v6found == HFTC_STATUS_OK)      {         v6macTable_p = &(parameterValue_p->macAddrArray);      }      status  = findParameterValue(configParams_p,                                   HFTC_AP_IKE_PORT_MAPPING_IPV6_TABLE,                                   &parameterValue_p);      if (status == HFTC_STATUS_OK)      {         v6macMap_p = &(parameterValue_p->portMappingArray);      }      else      {         if (v6found == HFTC_STATUS_OK)         {            printf("Found IPV6 MAC addresses, yet no mapping values.\n");            break;         }         v6found = status;      }      /* Check that something (V4 or V6) was found. */      if ((v4found != HFTC_STATUS_OK) && (v6found != HFTC_STATUS_OK))      {         printf("Problem finding MAC addresses in %s.\n",                configparamsFile);         printf("Found neither V4 MAC addresses status = %s (%d)\n"                "nor V6 MAC addresses status = %s (%d)\n",                HFTC_Status_t_text(v4found), v4found,                HFTC_Status_t_text(v6found), v6found);         status = v4found;         break;      }      /* Check that size of tables match */      if ((v4found == HFTC_TRUE) &&          (v4macMap_p->valid_count != v4macTable_p->valid_count))      {         printf("Table size mismatch of V4 MAC table vs. map.\n");         printf("table size %d != map size %d\n",                v4macTable_p->valid_count, v4macMap_p->valid_count);         status = HFTC_INVALID_LENGTH;         break;      }      if ((v6found == HFTC_TRUE) &&          (v6macMap_p->valid_count != v6macTable_p->valid_count))      {         printf("Table size mismatch of V6 MAC table vs. map.\n");         printf("table size %d != map size %d\n",                v6macTable_p->valid_count, v6macMap_p->valid_count);         status = HFTC_INVALID_LENGTH;         break;      }      /*         Append mac addresses into the passed tables.      */      port0_p->valid_count = 0;      port1_p->valid_count = 0;      /* First do any V4 MAC addresses that were found. */      status = HFTC_STATUS_OK;      if (v4found == HFTC_STATUS_OK)      {         for (i = 0; i < v4macTable_p->valid_count; i++)         {            if (DL_DEBUG)            {               printf("Found V4 MAC value %d: "                      "%02x:%02x:%02x:%02x:%02x:%02x\n", i,                     v4macTable_p->values[i][0], v4macTable_p->values[i][1],                     v4macTable_p->values[i][2], v4macTable_p->values[i][3],                     v4macTable_p->values[i][4], v4macTable_p->values[i][5]);            }            if ((v4macMap_p->ports[i] == HFTC_PORT_0) ||                (v4macMap_p->ports[i] == HFTC_PORT_ALL))            {               status = appendMACAddress(&(v4macTable_p->values[i]), port0_p);            }            if (status != HFTC_STATUS_OK)            {               /* Printf occurs in appendMACAddress. */               break;            }            if ((v4macMap_p->ports[i] == HFTC_PORT_1) ||                (v4macMap_p->ports[i] == HFTC_PORT_ALL))            {               status = appendMACAddress(&(v4macTable_p->values[i]), port1_p);            }            if (status != HFTC_STATUS_OK)            {               /* Printf occurs in appendMACAddress. */               break;            }         }      }      /* Then do any V6 MAC addresses that were found. */      status = HFTC_STATUS_OK;      if (v6found == HFTC_STATUS_OK)      {         for (i = 0; i < v6macTable_p->valid_count; i++)         {            if (DL_DEBUG)            {               printf("Found V6 MAC value %d: "                      "%02x:%02x:%02x:%02x:%02x:%02x\n", i,                     v6macTable_p->values[i][0], v6macTable_p->values[i][1],                     v6macTable_p->values[i][2], v6macTable_p->values[i][3],                     v6macTable_p->values[i][4], v6macTable_p->values[i][5]);            }            if ((v6macMap_p->ports[i] == HFTC_PORT_0) ||                (v6macMap_p->ports[i] == HFTC_PORT_ALL))            {               status = appendMACAddress(&(v6macTable_p->values[i]), port0_p);            }            if (status != HFTC_STATUS_OK)            {               /* Printf occurs in appendMACAddress. */               break;            }            if ((v6macMap_p->ports[i] == HFTC_PORT_1) ||                (v6macMap_p->ports[i] == HFTC_PORT_ALL))            {               status = appendMACAddress(&(v6macTable_p->values[i]), port1_p);            }            if (status != HFTC_STATUS_OK)            {               /* Printf occurs in appendMACAddress. */               break;            }         }      }   } while (HFTC_FALSE);   return status;} /* End gatherMACaddresses *//*----------------------------------------------------------------------------* * setupMACFiltering *----------------------------------------------------------------------------* * @ingroup startup * @brief Read config file and write all the MAC addresses for the ports. * * Reads the config file and writes out all the MAC addresses for filtering * on NET0 and NET1 ports. * * @param filename         RO: File to read with esc parameters * @param isX300           RO: Boolean set to true if this is an x300. * * @par Externals: *    None. * * @return *    HFTC_STATUS_OK            Parsing ok, MAC addresses set. * * @par Errors: *    HFTC_NO_MORE_RESOURCE     More than 16 unique MAC addresses were found *                              for a particular port. *    HFTC_INVALID_OPERATION    Port 1 was specified and this is an X300 * *    Errors returned from HFTC_ReadConfigFile. * * @par Locks: *    None. * * @par Assumptions: *    Assumes the MAC addresses are valid, or if they are not valid that it *    doesn't matter to the GMAC. * *----------------------------------------------------------------------------*/staticHFTC_Status_t setupMACFiltering(char                 *configparamsFile,                                HFTC_Boolean_t        isX300){   HFTC_Status_t status                           = HFTC_STATUS_OK;   HFTC_APIKEMACTable_t         port0Table;   HFTC_APIKEMACTable_t         port1Table;   uint32_t                     i;   do   {      /*         Read the configparams file and gather the MAC addresses for each port.      */      status = gatherMACaddresses(configparamsFile, &port0Table, &port1Table);      if (status != HFTC_STATUS_OK)      {         /* Messages are printed out in gatherMACaddresses */         break;      }      /*         NOTE: The code below assumes that all MAC values that are present         are valid, or if they are not that it doesn't matter to the GMAC.

⌨️ 快捷键说明

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