Skip to content

Commit

Permalink
Fix networktocode#6: 'Improved Detection logic'
Browse files Browse the repository at this point in the history
  • Loading branch information
Yakuza-UA committed May 10, 2020
1 parent 59c822b commit 730b2cc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
27 changes: 14 additions & 13 deletions templates/cisco_ios_show_ip_cef.textfsm
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,27 @@ Start
^\d.*?flags\s+\[?(?:[^\]\n]+?,\s+){5}${FLAGS} -> Continue
# Stop processing Flags (6+)
^\d.*?flags.*?$$
# Extract Type / Nexthop / Interface
# Available Type (IOS >v15.x):
# 1st attempt to extract details via source info
# Supported Type (IOS >v15.x):
# - attached
# - receive
# - drop
# - no route
# - nexthop
# - multicast
^\s+Adj\s+source:\s+IP\s+adj\s+out\s+of\s+${INTERFACE},\s+addr\s+${NEXTHOP}\s*
^\s+Special\s+source:\s+${TYPE}$$
^\s+Interface\s+source:\s+${INTERFACE}
^\s+DefNet\s+source
# 2nd attempt to extract details
^\s+recursive\s+via\s+${NEXTHOP}
^\s+${TYPE}(?<=receive)\s+for\s+${INTERFACE}
^\s+${TYPE}(?<=attached)\s+to\s+${INTERFACE}
^\s+${TYPE}(?<=drop)$$
^\s+${TYPE}(?<=no route)$$
^\s+${TYPE}(?<=receive)$$
^\s+${TYPE}(?<=multicast)$$
^\s+${TYPE}(?<=nexthop)\s+${NEXTHOP}\s+${INTERFACE}
^\s+recursive\s+via\s+${NEXTHOP}
^\s+${TYPE}(?<=receive)\s+for\s+${INTERFACE}
^\s+${TYPE}(?<=attached)\s+to\s+${INTERFACE}
#
# --- Parse CEF table from Cisco IOS 12.x ISR G1
#
Expand All @@ -67,10 +72,10 @@ Start
^.*?epoch.*?$$
# Extract extra Flag, such as recursive
^.*?dependenc(?:y|ies),\s+${FLAGS} -> Continue
^\s+via\s+${NEXTHOP},\s+\d+\s+dependenc
^\s+via\s+${INTERFACE},\s+\d+\s+dependenc
^\s+via\s+${NEXTHOP},\s+${INTERFACE},\s+\d+\s+dependenc
^.*?dependenc(?:y|ies)
^\s+via\s+${NEXTHOP},\s+\d+\s+depend
^\s+via\s+${INTERFACE},\s+\d+\s+depend
^\s+via\s+${NEXTHOP},\s+${INTERFACE},\s+\d+\s+depend
^.*?depend
# Extract Nexthop and Interface
^\s+next\s+hop\s+${NEXTHOP}\s*$$
^\s+next\s+hop\s+${NEXTHOP},\s+${INTERFACE}
Expand All @@ -86,10 +91,6 @@ Start
# Ignore JUNK
#
^\s+Q[Oo]S
^\s+Special\s+source
^\s+Interface\s+source
^\s+Adj\s+source
^\s+DefNet\s+source
^\s+Covered\s+dependent
^\s+need\s+deagg
^\s+notify\s+cover
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ parsed_sample:
flags:
- "attached"
type: "attached"
nexthop: ""
nexthop: "10.191.64.2"
interface: "GigabitEthernet0/0"
- prefix: "172.17.40.0/24"
flags:
Expand Down
4 changes: 2 additions & 2 deletions tests/cisco_ios/show_ip_cef/show_ip_cef_detail_c2900_v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ parsed_sample:
flags:
- "attached"
type: "attached"
nexthop: ""
nexthop: "10.180.140.153"
interface: "GigabitEthernet0/1"
- prefix: "10.180.150.0/26"
flags:
Expand Down Expand Up @@ -73,7 +73,7 @@ parsed_sample:
flags:
- "attached"
type: "attached"
nexthop: ""
nexthop: "10.180.150.33"
interface: "Port-channel1.1822"
- prefix: "10.180.150.38/32"
flags:
Expand Down
2 changes: 1 addition & 1 deletion tests/cisco_ios/show_ip_cef/show_ip_cef_detail_c3750.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ parsed_sample:
flags:
- "attached"
type: "attached"
nexthop: ""
nexthop: "10.158.0.195"
interface: "Vlan1801"
- prefix: "224.0.0.0/4"
flags: []
Expand Down
4 changes: 2 additions & 2 deletions tests/cisco_ios/show_ip_cef/show_ip_cef_detail_c3850_v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ parsed_sample:
flags:
- "attached"
type: "attached"
nexthop: ""
nexthop: "10.255.1.1"
interface: "Port-channel1.1"
- prefix: "10.255.1.11/32"
flags:
Expand Down Expand Up @@ -73,7 +73,7 @@ parsed_sample:
flags:
- "attached"
type: "attached"
nexthop: ""
nexthop: "10.180.163.133"
interface: "Vlan1831"
- prefix: "127.0.0.0/8"
flags: []
Expand Down

0 comments on commit 730b2cc

Please sign in to comment.