Skip to content

Commit

Permalink
Merge pull request #994 from networktocode/cisco-ios-show-mac-fix-type2
Browse files Browse the repository at this point in the history
Fix ios_mac-addr type2
  • Loading branch information
armartirosyan authored Sep 22, 2021
2 parents 1da900d + c8098cd commit a6e50ad
Show file tree
Hide file tree
Showing 14 changed files with 670 additions and 169 deletions.
31 changes: 25 additions & 6 deletions ntc_templates/templates/cisco_ios_show_mac-address-table.textfsm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Value DESTINATION_ADDRESS ([0-9a-fA-F]{4}\.[0-9a-fA-F]{4}\.[0-9a-fA-F]{4})
Value TYPE (\S+)
Value VLAN (\S+)
Value DESTINATION_PORT (\S+)
Value List DESTINATION_PORT (\S+?)

Start
^Destination\s+Address\s+Address\s+Type\s+VLAN\s+Destination\s+Port -> TYPE1
Expand All @@ -13,7 +13,7 @@ Start
^Time\s+source\s+is

TYPE1
^${DESTINATION_ADDRESS}\s+${TYPE}\s+${VLAN}\s+${DESTINATION_PORT} -> Record
^${DESTINATION_ADDRESS}\s+${TYPE}\s+${VLAN}\s+${DESTINATION_PORT}$$ -> Record
^-+\s+-+
^Displaying\s+entries
^Destination\s+Address\s+Address\s+Type\s+VLAN\s+Destination\s+Port
Expand All @@ -23,16 +23,35 @@ TYPE1

TYPE2
# Order of the group in brackets here matters
^\s*(?:\*\s+R|\*|R|\s)\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+${DESTINATION_PORT} -> Record
^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+) -> Continue.Record
^\s*(?:\*\s+R|\*|R|\s)\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s*$$ -> Continue
^\s*(?:\*\s+R|\*|R|\s)\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?!\S+?,)${DESTINATION_PORT}\s*$$ -> Continue
^\s*(?:\*\s+R|\*|R|\s)\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+${DESTINATION_PORT}, -> Continue
^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+)\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+\S+?,${DESTINATION_PORT}, -> Continue
^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+)\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+?,){2}${DESTINATION_PORT}, -> Continue
^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+)\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+?,){3}${DESTINATION_PORT}(?:,|$$) -> Continue
^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+)\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+?,){4}${DESTINATION_PORT}(?:,|$$) -> Continue
^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+)\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+?,){5}${DESTINATION_PORT}(?:,|$$) -> Continue
^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+)\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+?,){6}${DESTINATION_PORT}(?:,|$$) -> Continue
^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+)\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+?,){7}${DESTINATION_PORT}(?:,|$$) -> Continue
^\s{20}\s+${DESTINATION_PORT}, -> Continue
^\s{20}\s+(?:\S+?,)${DESTINATION_PORT}, -> Continue
^\s{20}\s+(?:\S+?,){2}${DESTINATION_PORT}, -> Continue
^\s{20}\s+(?:\S+?,){3}${DESTINATION_PORT}(?:,|$$) -> Continue
^\s{20}\s+(?:\S+?,){4}${DESTINATION_PORT}(?:,|$$) -> Continue
^\s{20}\s+(?:\S+?,){5}${DESTINATION_PORT}(?:,|$$) -> Continue
^\s{20}\s+(?:\S+?,){6}${DESTINATION_PORT}(?:,|$$) -> Continue
^\s{20}\s+(?:\S+?,){7}${DESTINATION_PORT}(?:,|$$) -> Continue
^-+\+-+
^Displaying\s+entries
^\s+vlan\s+mac address\s+type\s+learn\s+age\s+ports
^\s*$$
^\s*\S+
^Multicast\s+Entries -> End
^. -> Error

TYPE3
^\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+${DESTINATION_PORT} -> Record
^\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+${DESTINATION_PORT}$$ -> Record
^-+\+-+
^Displaying\s+entries
^\s+vlan\s+mac address\s+type\s+protocols\s+port
Expand All @@ -41,11 +60,11 @@ TYPE3
^. -> Error

TYPE4
^\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+${DESTINATION_PORT} -> Record
^\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+${DESTINATION_PORT}$$ -> Record
^-+\s+-+
^Displaying\s+entries
^Vlan\s+Mac Address\s+Type\s+Ports
^\s*$$
^Total\s+Mac\s+Addresses
^MultiCast\s+Entries -> End
^. -> Error
^. -> Error
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,45 @@ parsed_sample:
- destination_address: "0010.0de0.e289"
type: "Dynamic"
vlan: "1"
destination_port: "FastEthernet0/1"
destination_port:
- "FastEthernet0/1"
- destination_address: "0010.7b00.1540"
type: "Dynamic"
vlan: "2"
destination_port: "FastEthernet0/5"
destination_port:
- "FastEthernet0/5"
- destination_address: "0010.7b00.1545"
type: "Dynamic"
vlan: "2"
destination_port: "FastEthernet0/5"
destination_port:
- "FastEthernet0/5"
- destination_address: "0060.5cf4.0076"
type: "Dynamic"
vlan: "1"
destination_port: "FastEthernet0/1"
destination_port:
- "FastEthernet0/1"
- destination_address: "0060.5cf4.0077"
type: "Dynamic"
vlan: "1"
destination_port: "FastEthernet0/1"
destination_port:
- "FastEthernet0/1"
- destination_address: "0060.5cf4.1315"
type: "Dynamic"
vlan: "1"
destination_port: "FastEthernet0/1"
destination_port:
- "FastEthernet0/1"
- destination_address: "0060.70cb.f301"
type: "Dynamic"
vlan: "1"
destination_port: "FastEthernet0/1"
destination_port:
- "FastEthernet0/1"
- destination_address: "00e0.1e42.9978"
type: "Dynamic"
vlan: "1"
destination_port: "FastEthernet0/1"
destination_port:
- "FastEthernet0/1"
- destination_address: "00e0.1e9f.3900"
type: "Dynamic"
vlan: "1"
destination_port: "FastEthernet0/1"
destination_port:
- "FastEthernet0/1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
Legend: * - primary entry
age - seconds since last seen
n/a - not available

vlan mac address type learn age ports
------+----------------+--------+-----+----------+--------------------------
* 345 3333.0000.000d static Yes - Gi1/3,Gi1/6,Gi1/45,Gi1/46,Gi1/47
Gi1/48,Gi2/2,Gi2/45,Gi2/46
Gi3/1,Gi3/2,Gi3/46,Gi3/47
Gi3/48,Gi5/2,Gi8/1,Gi8/2
Gi8/3,Gi8/4,Gi8/5,Gi8/6
Gi8/7,Gi8/8,Gi8/9,Gi8/10
Gi8/15,Gi8/16,Gi8/17,Gi8/45
Gi9/1,Gi9/2,Gi9/3,Gi9/4
Gi9/5,Gi9/6,Gi9/7,Gi9/8
Gi9/9,Gi9/10,Gi9/15,Gi9/16
Gi9/26,Gi9/27,Gi9/28,Gi9/29
Gi9/45,Gi9/48,Router,Switch
Stby-Switch
* 344 3333.0000.000d static Yes - Gi1/3,Gi1/6,Gi1/45,Gi1/46
Gi1/48,Gi2/2,Gi2/45,Gi2/46
Gi3/1,Gi3/2,Gi3/46,Gi3/47
Gi3/48,Gi5/2,Gi8/1,Gi8/2
Gi8/3,Gi8/4,Gi8/5,Gi8/6
Gi8/7,Gi8/8,Gi8/9,Gi8/10
Gi8/15,Gi8/16,Gi8/17,Gi8/45
Gi9/1,Gi9/2,Gi9/3,Gi9/4
Gi9/5,Gi9/6,Gi9/7,Gi9/8
Gi9/9,Gi9/10,Gi9/15,Gi9/16
Gi9/26,Gi9/27,Gi9/28,Gi9/29
Gi9/45,Gi9/48,Router,Switch
Stby-Switch
* 300 b4b5.2fef.dd44 dynamic Yes 190 Gi9/16
* 800 00c0.ff1a.6aee dynamic Yes 10 Gi1/45
* 300 0015.5d0a.0502 dynamic Yes 0 Gi8/15
* 300 3333.0000.0016 static Yes - Switch
* 1102 00e1.6d87.f600 dynamic Yes 0 Gi9/1
* --- 0000.0000.0000 static No - Router
* 300 ecb1.d7aa.e791 dynamic Yes 0 Gi8/45
* 810 0023.ac8b.5000 static No - Router
* 300 0050.568f.4859 dynamic Yes 0 Gi8/8
* 800 0023.ac8b.5000 static No - Router
* 300 ecb1.d7aa.e790 dynamic Yes 5 Gi8/45
* 800 00c0.ff1a.372c dynamic Yes 15 Gi1/46
* 344 f092.1c04.f340 dynamic Yes 0 Gi8/6
* 300 0050.568f.7aa4 dynamic Yes 0 Gi8/8
* 344 3333.0000.0001 static Yes - Switch
* 345 3333.0000.0001 static Yes - Switch
* 410 0023.ac8b.5000 static No - Router
* 404 0023.ac8b.5000 static No - Router
* 800 0100.5e7f.4653 static Yes -
* 300 0050.568f.649a dynamic Yes 5 Gi8/8
* 1102 3333.0000.0016 static Yes - Switch
* 300 ecb1.d7aa.e799 dynamic Yes 0 Gi9/45
* 300 0050.568f.2416 dynamic Yes 5 Gi8/6
* 300 0050.568f.12fa dynamic Yes 0 Gi8/8
* 810 000d.ec3d.ef00 dynamic Yes 5 Gi3/2
* 444 f092.1c04.0510 dynamic Yes 0 Gi9/7
* 300 3333.0000.0001 static Yes - Switch
* 300 0050.568f.08c3 dynamic Yes 5 Gi8/6
* 1102 00e1.6d87.f700 dynamic Yes 0 Gi8/1
* 300 0050.568f.7fb7 dynamic Yes 0 Gi9/6
* 300 2c59.e537.d3bc dynamic Yes 0 Gi8/10
* 800 0100.5e7f.fffa static Yes -
Loading

0 comments on commit a6e50ad

Please sign in to comment.