Fix: 修正H3C ARP表解析器适配真实输出格式
- 修正标题行匹配: Type: (带冒号) - 跳过IP address标题行 - 适配真实ARP表格式: IP MAC VLAN Interface Aging Type - 正确解析MAC到IP映射
This commit is contained in:
@@ -199,13 +199,14 @@ func (p *H3CParser) parseARPTable(output string) map[string]string {
|
|||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
// 跳过空行和标题行
|
// 跳过空行和标题行
|
||||||
if strings.TrimSpace(line) == "" ||
|
if strings.TrimSpace(line) == "" ||
|
||||||
strings.Contains(line, "Type") ||
|
strings.Contains(line, "Type:") ||
|
||||||
strings.Contains(line, "------") {
|
strings.Contains(line, "------") ||
|
||||||
|
strings.Contains(line, "IP address") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// ARP表格式: IP Address MAC Address Interface/Vlan
|
// ARP表格式: IP address MAC address VLAN/VSI name Interface Aging Type
|
||||||
// 例: 172.16.12.1 a4bb-6de2-62cd GE1/0/1
|
// 例: 172.16.8.10 743a-2047-38e0 8 GE1/0/47 1163 D
|
||||||
fields := strings.Fields(line)
|
fields := strings.Fields(line)
|
||||||
if len(fields) >= 2 {
|
if len(fields) >= 2 {
|
||||||
ip := fields[0]
|
ip := fields[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user