Hard-题目55:65. Valid Number

本文深入探讨了LeetCode中一道颇具挑战性的题目,即判断输入字符串是否为合法数字。通过详细分析题目要求和给出的示例,文章揭示了一个巧妙的正则表达式解决方案,帮助读者理解如何在复杂情况下精确匹配特定模式。

题目原文:
Validate if a given string is numeric.

Some examples:
“0” => true
” 0.1 ” => true
“abc” => false
“1 a” => false
“2e10” => true
题目大意:
判断输入是否是合法数字。
题目分析:
这是leetcode里面最坑的一道题,奇葩用例非常多,也有很多不可思议的解。discuss中某位大神终于写出了一个合法约束题意的正则式。
源码:(language:java)

public class Solution {
    public boolean isNumber(String s) {
        return s.matches("^\\s*[\\+\\-]?((\\.[0-9]+)|([0-9]+(\\.[0-9]*)?))(e[\\+\\-]?[0-9]+)?\\s*$");
    }
}

成绩:
51ms,5.65%,4ms,25.87%

typedef enum{ /** reserved */ PRV_CPSS_DXCH_NET_DSA_TAG_RESERVED_0_E = 0, /** reserved */ PRV_CPSS_DXCH_NET_DSA_TAG_RESERVED_1_E = 1, /** Control BPDU packet. */ PRV_CPSS_DXCH_NET_DSA_TAG_BPDU_E = 2, /** @brief Source & Destination MAC * trapped packet. */ PRV_CPSS_DXCH_NET_DSA_TAG_MAC_ADDR_TRAP_E = 3, /** @brief MAC SA is found in FDB * but changed it's location */ PRV_CPSS_DXCH_NET_DSA_TAG_MAC_SA_MOVED_E = 4, /** ARP CPU code */ PRV_CPSS_DXCH_NET_DSA_TAG_ARP_CPU_CODE_E = 5, /** @brief Intervention IGMP * can also be trapped according to VLAN) */ PRV_CPSS_DXCH_NET_DSA_TAG_IGMP_PACKET_E = 6, /** MAC SA is DA */ PRV_CPSS_DXCH_NET_DSA_TAG_MAC_SA_IS_DA_E = 7, /** @brief Unknown MAC SA Command * MIRRORING CODES: */ PRV_CPSS_DXCH_NET_DSA_TAG_UNK_SRC_MAC_ADDR_E = 8, /** Source IP (SIP) is Destination IP (DIP) */ PRV_CPSS_DXCH_NET_DSA_TAG_SIP_IS_DIP_E = 9, /** @brief Packet Mirrored to * CPU because port lock * MISC CODES: */ PRV_CPSS_DXCH_NET_DSA_TAG_MIRROR_LOCK_TO_CPU_E = 10, /** TCP/UDP Source port is destination port */ PRV_CPSS_DXCH_NET_DSA_TAG_TCP_UDP_SPORT_IS_DPORT_E = 11, /** TCP flags has FIN but no ACK */ PRV_CPSS_DXCH_NET_DSA_TAG_TCP_FIN_WITHOUT_ACK_E = 12, /** @brief Packet with MAC * DA in the IEEE Reserved Multicast range trapped or * mirrored to the host CPU. */ PRV_CPSS_DXCH_NET_DSA_TAG_IEEE_RSRVD_MULTICAST_ADDR_E = 13, /** IPv6 ICMP packet. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV6_ICMP_E = 14, /** TCP has no full header */ PRV_CPSS_DXCH_NET_DSA_TAG_DSA_TCP_WITHOUT_FULL_HEADER_E = 15, /** @brief IPv4/ Pv6 * Link Local MC DIP packet trapped or mirrored to the host CPU. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_IPV6_LINK_LOCAL_MC_DIP_TRP_MRR_E = 16, /** @brief IPv4 RIPv1 * packet mirrored to the host CPU. */ PRV_CPSS_DXCH_NET_DSA_TAG_MIRROR_IPV4_RIPV1_TO_CPU_E = 17, /** @brief IPv6 neighbor * solicitation packet trapped or mirrored to the host CPU. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV6_NEIGHBOR_SOLICITATION_E = 18, /** @brief IPv4 Broadcast packet assigned to a VLAN with * IPv4 Broadcast Command set to Trap or Mirror. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_BROADCAST_PACKET_E = 19, /** @brief Non IPv4 Broadcast packet assigned to a VLAN * with non IPv4 Broadcast Command set to Trap * or Mirror. */ PRV_CPSS_DXCH_NET_DSA_TAG_NON_IPV4_BROADCAST_PACKET_E = 20, /** @brief A Multicast packet with a MAC DA in the CISCO * AUI range trapped or mirrored to the host CPU. */ PRV_CPSS_DXCH_NET_DSA_TAG_CISCO_MCAST_MAC_RANGE_E = 21, /** @brief Unregistered Multicast packet assigned * to a VLAN with Unregistered Multicast Command set to Trap or Mirror. */ PRV_CPSS_DXCH_NET_DSA_TAG_BRG_UNREGD_MCAST_E = 22, /** @brief IPv4 Unregistered Multicast packet assigned * to a VLAN with IPv4 Unregistered Multicast * Command set to Trap or Mirror. */ PRV_CPSS_DXCH_NET_DSA_TAG_BRG_IPV4_UNREG_MCAST_E = 23, /** @brief IPv6 Unregistered Multicast packet assigned * to a VLAN with IPv6 Unregistered Multicast * Command set to Trap or Mirror. */ PRV_CPSS_DXCH_NET_DSA_TAG_BRG_IPV6_UNREG_MCAST_E = 24, /** @brief unknown unicast that where trapped/mirrored * to cpu due to vlan command */ PRV_CPSS_DXCH_NET_DSA_TAG_UNKNOWN_UNICAST_EXT_E = 25, /** CPU Code=1 for Ieee Reserved Multicast Addrs. */ PRV_CPSS_DXCH_NET_DSA_TAG_IEEE_RSRVD_MULTICAST_ADDR_1_E = 26, /** CPU Code=2 for Ieee Reserved Multicast Addrs. */ PRV_CPSS_DXCH_NET_DSA_TAG_IEEE_RSRVD_MULTICAST_ADDR_2_E = 27, /** CPU Code=3 for Ieee Reserved Multicast Addrs. */ PRV_CPSS_DXCH_NET_DSA_TAG_IEEE_RSRVD_MULTICAST_ADDR_3_E = 28, /** Ipv4/Ipv6 link local multicast CPU Code index=1 */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_IPV6_LINK_LOCAL_MC_DIP_TRP_MRR_1_E = 29, /** Ipv4/Ipv6 link local multicast CPU Code index=2 */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_IPV6_LINK_LOCAL_MC_DIP_TRP_MRR_2_E = 30, /** Ipv4/Ipv6 link local multicast CPU Code index=3 */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_IPV6_LINK_LOCAL_MC_DIP_TRP_MRR_3_E = 31, /** @brief The UDP BC packet matches one of entries * in UDP relay table and its CPU code index is 0 */ PRV_CPSS_DXCH_NET_DSA_TAG_UDP_BC_MIRROR_TRAP0_E = 32, /** @brief The UDP BC packet matches one of entries * in UDP relay table and its CPU code index is 1 */ PRV_CPSS_DXCH_NET_DSA_TAG_UDP_BC_MIRROR_TRAP1_E = 33, /** @brief The UDP BC packet matches one of entries * in UDP relay table and its CPU code index is 2 */ PRV_CPSS_DXCH_NET_DSA_TAG_UDP_BC_MIRROR_TRAP2_E = 34, /** @brief The UDP BC packet matches one of entries * in UDP relay table and its CPU code index is 3 */ PRV_CPSS_DXCH_NET_DSA_TAG_UDP_BC_MIRROR_TRAP3_E = 35, /** @brief In Secure Automatic learning,an uknown source MAC * is trapped to CPU. */ PRV_CPSS_DXCH_NET_DSA_TAG_SEC_AUTO_LEARN_UNK_SRC_TRAP_E = 36, /** @brief The drop code for a packet that * was dropped by the RxDMA and forwarded to the ingress pipe.(RXDMA) */ PRV_CPSS_DXCH_NET_DSA_TAG_RXDMA_DROP_E = 37, /** VLAN Not Valid Drop (a security breach) */ PRV_CPSS_DXCH_NET_DSA_TAG_VLAN_NOT_VALID_E = 38, /** Port Not Member in VLAN Drop (a security breach) */ PRV_CPSS_DXCH_NET_DSA_TAG_PORT_NOT_VLAN_MEM_E = 39, /** VLAN Range Drop (a security breach) */ PRV_CPSS_DXCH_NET_DSA_TAG_VLAN_RANGE_E = 40, /** Moved Static Address Drop (a security breach) */ PRV_CPSS_DXCH_NET_DSA_TAG_STATIC_ADDR_MOVED_E = 41, /** Mac Spoof Protection Event */ PRV_CPSS_DXCH_NET_DSA_TAG_MAC_SPOOF_E = 42, /** ARP SA mismatch Drop */ PRV_CPSS_DXCH_NET_DSA_TAG_ARP_SA_MISMATCH_E = 43, /** SYN with Data Drop */ PRV_CPSS_DXCH_NET_DSA_TAG_SYN_WITH_DATA_E = 44, /** TCP over Multicast or Broadcast Drop */ PRV_CPSS_DXCH_NET_DSA_TAG_TCP_OVER_MC_BC_E = 45, /** Fragmented ICMP Drop */ PRV_CPSS_DXCH_NET_DSA_TAG_FRAGMENT_ICMP_E = 46, /** TCP Flags Zero Drop */ PRV_CPSS_DXCH_NET_DSA_TAG_TCP_FLAGS_ZERO_E = 47, /** TCP Flags FIN, URG and PSH are all set Drop */ PRV_CPSS_DXCH_NET_DSA_TAG_TCP_FLAGS_FIN_URG_PSH_E = 48, /** TCP Flags SYN and FIN are set Drop */ PRV_CPSS_DXCH_NET_DSA_TAG_TCP_FLAGS_SYN_FIN_E = 49, /** TCP Flags SYN and RST are set Drop */ PRV_CPSS_DXCH_NET_DSA_TAG_TCP_FLAGS_SYN_RST_E = 50, /** TCP/UDP Source or Destination Port is Zero Drop */ PRV_CPSS_DXCH_NET_DSA_TAG_TCP_UDP_SRC_DEST_ZERO_E = 51, /** Bridge Access Matrix Drop */ PRV_CPSS_DXCH_NET_DSA_TAG_BRIDGE_ACCESS_MATRIX_E = 52, /** Acceptable Frame Type Drop */ PRV_CPSS_DXCH_NET_DSA_TAG_ACCEPT_FRAME_TYPE_E = 53, /** VLAN MRU Drop */ PRV_CPSS_DXCH_NET_DSA_TAG_VLAN_MRU_E = 54, /** Rate Limiting Drop */ PRV_CPSS_DXCH_NET_DSA_TAG_RATE_LIMITING_E = 55, /** Local Port Drop */ PRV_CPSS_DXCH_NET_DSA_TAG_LOCAL_PORT_E = 56, /** IP Multicast In Iana Range Drop */ PRV_CPSS_DXCH_NET_DSA_TAG_IP_MC_E = 57, /** IP Multicast Not In Iana Range Drop */ PRV_CPSS_DXCH_NET_DSA_TAG_NON_IP_MC_E = 58, /** DSA Tag source device equals Local device Drop */ PRV_CPSS_DXCH_NET_DSA_TAG_DSA_TAG_LOCAL_DEV_E = 59, /** Invalid SA Drop (a security breach) */ PRV_CPSS_DXCH_NET_DSA_TAG_INVALID_SA_E = 60, /** @brief Indicates that no * engine has assigned a target ePort to the current packet, * and thus the packet is dropped.(EQ) */ PRV_CPSS_DXCH_NET_DSA_TAG_TARGET_NULL_PORT_E = 62, /** @brief Used when the packet is trapped or dropped due to an MTU check based on the target ePort in the E2PHY.(EQ) * Or when the packet is dropped due to a protection switching filter.(EQ) * Or when a packet is filtered by the ingress forwarding restrictions feature. (EQ) */ PRV_CPSS_DXCH_NET_DSA_TAG_TARGET_EPORT_MTU_EXCEEDED_OR_RX_PROTECTION_SWITCHING_OR_INGRESS_FORWARDING_RESTRICTIONS_E = 63, /** @brief packet forwarded to the host CPU by the * router ("IP to me") */ PRV_CPSS_DXCH_NET_DSA_TAG_ROUTED_PACKET_FORWARD_E = 64, /** @brief Packet forwarded to the host CPU by one of * the following engines in the device: * 1. Redirected by the PCL engine to the CPU * port number. * 2. MAC DA is associated with the CPU port * number. * 3. Private VLAN edge target set to CPU port * number. */ PRV_CPSS_DXCH_NET_DSA_TAG_BRIDGED_PACKET_FRW_E = 65, /** @brief Ingress mirrored packets to the analyzer port, * when the ingress analyzer port number is set * to the CPU port number. */ PRV_CPSS_DXCH_NET_DSA_TAG_INGRESS_MIRRORED_TO_ANALYZER_E = 66, /** @brief Egress mirrored packets to the analyzer port, * when the egress analyzer port number is set * to the CPU port number. */ PRV_CPSS_DXCH_NET_DSA_TAG_EGRESS_MIRRORED_TO_ANALYZER_E = 67, /** @brief A packet sent to the local host CPU as a mail * from the neighboring CPU. */ PRV_CPSS_DXCH_NET_DSA_TAG_MAIL_FROM_NEIGHBOR_CPU_E = 68, /** @brief A packet sent to the local host CPU, from one * of the other host CPUs in the system. */ PRV_CPSS_DXCH_NET_DSA_TAG_CPU_TO_CPU_E = 69, /** @brief Packet mirrored to the host CPU by the egress * STC mechanism. */ PRV_CPSS_DXCH_NET_DSA_TAG_EGRESS_SAMPLED_E = 70, /** @brief Packet mirrored to the host CPU by the ingress * STC mechanism. */ PRV_CPSS_DXCH_NET_DSA_TAG_INGRESS_SAMPLED_E = 71, /** @brief Packet trapped/mirrored to the host CPU by the * Policy Engine due to the following: * User-defined bytes in the key could not be * parsed due to packet header length or its * format. */ PRV_CPSS_DXCH_NET_DSA_TAG_INVALID_PCL_KEY_TRAP_E = 74, /** @brief Tunnel-terminated packet is trapped to the CPU * due to an IPV4 tunnel header error. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_TT_HEADER_ERROR_E = 75, /** @brief Tunnel-terminated packet is trapped to the CPU * due to the IPV4 tunnel header, which is * fragmented or has options. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_TT_OPTION_FRAG_ERROR_E = 76, /** @brief Tunnel-terminated packet is trapped to the CPU * due to an unsupported GRE tunnel header format. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_TT_UNSUP_GRE_ERROR_E = 77, /** @brief Used in Hop-By-Hop mirroring mode, * when a packet is duplicated to a target analyzer, and the * global Ingress Analyzer Index or Egress Analyzer Index disabled. * In this case the packet is hard dropped with this drop code. */ PRV_CPSS_DXCH_NET_DSA_TAG_BAD_ANALYZER_INDEX_DROP_ERROR_E = 78, /** @brief Tunnel-terminated MPLS packet is trapped to the CPU * due to an illegal MPLS header or MPLS command in action entry. */ PRV_CPSS_DXCH_NET_DSA_TAG_TT_MPLS_HEADER_CHECK_E = 79, /** @brief Tunnel-terminated MPLS packet is trapped to the CPU * due to an assigned TTL of ZERO. */ PRV_CPSS_DXCH_NET_DSA_TAG_TT_MPLS_TTL_EXCEED_E = 80, /** @brief Oversize drop - * used only for drop command. (TTI) */ PRV_CPSS_DXCH_NET_DSA_TAG_UNTAGGED_OVERSIZE_DROP_CODE_E = 81, /** @brief Used by the TTI engine * to indicate an error with the GRE tunnel header on tunneltermination.(TTI) */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV6_TT_UNSUP_GRE_ERROR_E = 82, /** An OAM-PDU packet is trappedto the CPU */ PRV_CPSS_DXCH_NET_DSA_TAG_OAM_PDU_TRAP_E = 83, /** CCFC packet dropped. */ PRV_CPSS_DXCH_NET_DSA_TAG_CCFC_PKT_DROP_E = 86, /** @brief PTP packet received by TTI, and the header is too short, * i.e., it does not contain some of the necessary fields for PTP parsing. */ PRV_CPSS_DXCH_NET_DSA_TAG_PTP_HEADER_ERROR_E = 87, /** @brief Used for bad IEEE 802.3x Flow * Control packets.(TTI) * PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_UDP_E * PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_UC_BAD_DIP_SIP_E * PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_MC_BAD_SIP_DIP_E * PRV_CPSS_DXCH_NET_DSA_TAG_IPV6_UC_BAD_DIP_SIP_E * PRV_CPSS_DXCH_NET_DSA_TAG_IPV6_MC_BAD_SIP_DIP_E */ PRV_CPSS_DXCH_NET_DSA_TAG_BAD_FC_PKT_DROP_E = 88, /** @brief IPv4 packet, triggered for routing Trapped/Mirrored * to the CPU due to TTL exceeded. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_UC_TTL_EXCEEDED_E = 133, /** @brief IPv4/6 packet, triggered for routing Trapped/Mirrored * to the CPU due packet's length longer than Route entry <MTU Index>. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_6_MTU_EXCEEDED_E = 134, /** @brief IPv6 packet, triggered for routing Trapped/Mirrored * to the CPU due to Hop Limit exceeded. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV6_UC_HOP_LIMIT_EXCEEDED_E = 135, /** @brief IPv4/6 packet, triggered for routing, is Trapped/Mirrored * due to an illegal IPv4/6 destination or source address. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_6_ILLEGAL_ADDR_ERROR_E = 136, /** @brief IPv4 packet, triggered for routing Trapped/Mirrored * to the CPU due to IPv4 header Error */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_UC_HEADER_ERROR_E = 137, /** @brief IPv4/6 packet, triggered for routing, is Trapped/Mirrored * due to a mismatch between the destination IP address * and the destination MAC address. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_6_DIP_DA_MISMATCH_E = 138, /** @brief IPv6 packet, triggered for routing Trapped/Mirrored * to the CPU due to IPv6 header Error. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV6_UC_HEADER_ERROR_E = 139, /** @brief IPv4/6 Unicast packet, triggered for routing, * is Trapped/Mirrored due to a mismatch between * the source IP address and its configured ARP MAC address. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_6_UC_SIP_SA_MISMATCH_E = 140, /** @brief IPv4 packet, triggered for routing Trapped/Mirrored * to the CPU due to IPv4 header Options. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_UC_OPTIONS_E = 141, /** @brief IPv6 packet, triggered for routing, Trapped/Mirrored * due to one of the following non hopbyhop header * extension options: Routing, Fragmentation, * Encapsulating Security Payload, Authentication, Destination. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV6_NON_HBH_OPTION_E = 142, /** @brief IPv6 packet, triggered for routing Trapped/Mirrored * to the CPU due to IPv6 header HopByHop Options. * PRV_CPSS_DXCH_NET_DSA_TAG_IPv4_6_SIP_FILTERING_E - Indicates that the * source IP address was filtered by the SIP filtering mechanism.(Router) * PRV_CPSS_DXCH_NET_DSA_TAG_IPv4_6_SIP_IS_ZERO_E - Indicates that the * source IP address is 0. (Router) */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV6_UC_OPTIONS_E = 143, PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_6_SIP_FILTERING_E = 144, PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_6_SIP_IS_ZERO_E = 145, /** @brief Indicates that the * packet was dropped/mirrored/trapped. (Router) */ PRV_CPSS_DXCH_NET_DSA_TAG_ACCESS_MATRIX_E = 146, /** @brief Indicates an invalid field in the FCoE header Or FCoE DIP was not * found. (Router) */ PRV_CPSS_DXCH_NET_DSA_TAG_FCOE_DIP_LOOKUP_NOT_FOUND_OR_FCOE_EXCEPTION_E = 147, /** @brief Indicates that the * FCoE SIP was not found. (Router) */ PRV_CPSS_DXCH_NET_DSA_TAG_FCOE_SIP_NOT_FOUND_E = 148, /** @brief IPv6 packet, triggered for routing, Trapped/Mirrored * to CPU due to IPv6 Scope checking. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV6_SCOPE_E = 159, /** @brief IPv4 Unicast packet, triggered for routing, Trapped/Mirrored * to CPU from Route entry with <CPUCodeIndex> = 0. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_UC_ROUTE0_E = 160, /** @brief IPv4 Unicast packet, triggered for routing, Trapped/Mirrored * to CPU from Route entry with <CPUCodeIndex> = 1. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_UC_ROUTE1_E = 161, /** @brief IPv4 Unicast packet, triggered for routing, Trapped/Mirrored * to CPU from Route entry with <CPUCodeIndex> = 2. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_UC_ROUTE2_E = 162, /** @brief IPv4 Unicast packet, triggered for routing, Trapped/Mirrored * to CPU from Route entry with <CPUCodeIndex> = 3. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_UC_ROUTE3_E = 163, /** @brief IPv4 Multicast packet, triggered for routing, Trapped/Mirrored * to CPU from Route entry with <CPUCodeIndex> = 0. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_MC_ROUTE0_E = 164, /** @brief IPv4 Multicast packet, triggered for routing, Trapped/Mirrored * to CPU from Route entry with <CPUCodeIndex> = 1 */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_MC_ROUTE1_E = 165, /** @brief IPv4 Multicast packet, triggered for routing, Trapped/Mirrored * to CPU from Route entry with <CPUCodeIndex> = 2. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_MC_ROUTE2_E = 166, /** @brief IPv4 Multicast packet, triggered for routing, Trapped/Mirrored * to CPU from Route entry with <CPUCodeIndex> = 3. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_MC_ROUTE3_E = 167, /** @brief IPv6 Unicast packet, triggered for routing, Trapped/Mirrored * to CPU from Route entry with <CPUCodeIndex> = 0. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV6_UC_ROUTE0_E = 168, /** @brief IPv6 Unicast packet, triggered for routing, Trapped/Mirrored * to CPU from Route entry with <CPUCodeIndex> = 1. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV6_UC_ROUTE1_E = 169, /** @brief IPv6 Unicast packet, triggered for routing, Trapped/Mirrored * to CPU from Route entry with <CPUCodeIndex> = 2. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV6_UC_ROUTE2_E = 170, /** @brief IPv6 Unicast packet, triggered for routing, Trapped/Mirrored * to CPU from Route entry with <CPUCodeIndex> = 3. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV6_UC_ROUTE3_E = 171, /** @brief IPv6 Multicast packet, triggered for routing, Trapped/Mirrored * to CPU from Route entry with <CPUCodeIndex> = 0. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV6_MC_ROUTE0_E = 172, /** @brief IPv6 Multicast packet, triggered for routing, Trapped/Mirrored * to CPU from Route entry with <CPUCodeIndex> = 1. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV6_MC_ROUTE1_E = 173, /** @brief IPv6 Multicast packet, triggered for routing, Trapped/Mirrored * to CPU from Route entry with <CPUCodeIndex> = 2. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV6_MC_ROUTE2_E = 174, /** @brief IPv6 Multicast packet, triggered for routing, Trapped/Mirrored * to CPU from Route Entry with <CPUCodeIndex> = 3. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV6_MC_ROUTE3_E = 175, /** @brief IPv4/6 Unicast packet, triggered for routing, is Trapped/Mirrored * due to Unicast RPF Check failure. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_6_UC_RPF_FAIL_E = 176, /** @brief IPv4/6 Multicast packet, triggered for routing, Trapped/Mirrored * to CPU Due to Route entry Multicast RPF Fail command. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_6_MC_ROUTE_RPF_FAIL_E = 177, /** @brief IPv4/6 Multicast packet, triggered for routing, Trapped/Mirrored * to CPU Due to MLL entry Multicast RPF Fail command. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_6_MC_MLL_RPF_FAIL_E = 178, /** @brief ARP Broadcast packet, whose destination IP address is the host * address of the router, as indicated in the * Route entry <Trap/Mirror ARP BC to CPU>. */ PRV_CPSS_DXCH_NET_DSA_TAG_ARP_BC_TO_ME_E = 179, /** @brief IPv4 Unicast packet, triggered for routing, Mirrored * to CPU due to ICMP redirect. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_UC_ICMP_REDIRECT_E = 180, /** @brief IPv6 Unicast packet, triggered for routing, Mirrored * to CPU due to ICMP redirect. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV6_UC_ICMP_REDIRECT_E = 181, /** @brief Indication that * the packet was trapped/mirrored to the CPU due to the bidirectional * tree RPF check failure.(Router) */ PRV_CPSS_DXCH_NET_DSA_TAG_IP_MC_ROUTE_BIDIR_RPF_FAIL_E = 182, /** @brief While PHA firmware version is being upgraded, * packets which go through PPA are routed to specific * thread which sets packet to be dropped */ PRV_CPSS_DXCH_NET_DSA_TAG_PHA_FW_DROP_E = 183, /** @brief Used when a packet is dropped * by the Ingress Policer engine due to an ECC error.(IPLR) */ PRV_CPSS_DXCH_NET_DSA_TAG_ECC_DROP_CODE_E = 185, /** @brief Used when a non-conforming * packet is dropped by the Ingress Policer engine.(PLR) */ PRV_CPSS_DXCH_NET_DSA_TAG_MET_RED_DROP_CODE_E = 186, /** @brief The packet is an ARP reply, and forwarded by the FDB * entry with <destination port> = CPU port 63, and <application specific CPU code> = 1. */ PRV_CPSS_DXCH_NET_DSA_TAG_ARP_REPLY_TO_ME_E = 188, /** @brief The packet is sent with a FROM_CPU DSA tag with * the <mirror2CPU> bit set and this mirrored to the local CPU. * PRV_CPSS_DXCH_NET_DSA_TAG_CPU_TO_ALL_CPUS_E - The packet is sent witha FROM_CPU DSA Tag with * the <mirror2CPU> bit set and thus mirrored to a * local CPU. */ PRV_CPSS_DXCH_NET_DSA_TAG_CPU_TO_ALL_CPUS_E = 189, /** @brief The packet is Trapped, Mirrored, forwarded to the * CPU port 63, or forwarded to the Virtual Router port 63, * and the packet is a TCP SYN packet. */ PRV_CPSS_DXCH_NET_DSA_TAG_TCP_SYN_TO_CPU_E = 190, /** @brief The packet is * sent to virtual router port */ PRV_CPSS_DXCH_NET_DSA_TAG_PACKET_TO_VIRTUAL_ROUTER_PORT_E = 191, /** @brief User-Defined CPU codes. The user may use this * range for any application specific purpose. */ PRV_CPSS_DXCH_NET_DSA_TAG_FIRST_USER_DEFINED_E = 192, /** @brief User-Defined CPU codes. The user may use this * range for any application specific purpose. */ PRV_CPSS_DXCH_NET_DSA_TAG_LAST_USER_DEFINED_E = 255, /** DSA TAG CPU codes 200-205 will be overlapping with * user defined CPU codes */ /** @brief Packet is dropped in Router engine as the * IPV4 multicast DIP is not found in LPM table and * default rule is not configured. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_MC_DIP_NOT_FOUND_E = 200, /** @brief Packet is dropped in Router engine as the * IPV4 unicast DIP is not found in LPM table and * default rule is not configured. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_UC_DIP_NOT_FOUND_E = 201, /** @brief Packet is dropped in Router engine as the * IPV6 multicast DIP is not found in LPM table and * default rule is not configured. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV6_MC_DIP_NOT_FOUND_E = 202, /** @brief Packet is dropped in Router engine as the * IPV6 unicast DIP is not found in LPM table and * default rule is not configured. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV6_UC_DIP_NOT_FOUND_E = 203, /** @brief Packet is dropped in Router engine as the * IPV4 unicast SIP is not found in LPM table and * default rule is not configured. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV4_UC_SIP_NOT_FOUND_E = 204, /** @brief Packet is dropped in Router engine as the * IPV6 unicast SIP is not found in LPM table and * default rule is not configured. */ PRV_CPSS_DXCH_NET_DSA_TAG_IPV6_UC_SIP_NOT_FOUND_E = 205, /** one more than the last */ PRV_CPSS_DXCH_NET_DSA_TAG_MAX_E = PRV_CPSS_DXCH_NET_DSA_TAG_LAST_USER_DEFINED_E + 1 } PRV_CPSS_DXCH_NET_DSA_TAG_CPU_CODE_ENT;帮我把以上枚举转化为字符串数组,枚举值为下标,下标对应的字符串为枚举对应的注释例如str[0]="reserved"
11-05
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值