| | 67 | |
|---|
| | 68 | # Split an STP root bridge in to bridge priority and bridge address |
|---|
| | 69 | |
|---|
| | 70 | def parse_stp_root_bridge_address(stp_root) |
|---|
| | 71 | |
|---|
| | 72 | root_fields = stp_root.upcase.match(/(.{4})(.{12})/) |
|---|
| | 73 | |
|---|
| | 74 | return root_fields |
|---|
| | 75 | |
|---|
| | 76 | end |
|---|
| | 77 | |
|---|
| | 78 | |
|---|
| | 79 | # Return true if the specified STP root bridge address is valid, or false |
|---|
| | 80 | # otherwise |
|---|
| | 81 | |
|---|
| | 82 | def validate_stp_root_bridge_address(stp_root) |
|---|
| | 83 | |
|---|
| | 84 | root_fields = parse_stp_root_bridge_address(stp_root) |
|---|
| | 85 | |
|---|
| | 86 | if root_fields[1].match(/[0-9A-F]{4}/) and root_fields[2].match(/[0-9A-F]{12}/) |
|---|
| | 87 | return :true |
|---|
| | 88 | else |
|---|
| | 89 | return :false |
|---|
| | 90 | end |
|---|
| | 91 | |
|---|
| | 92 | end |
|---|
| | 93 | |
|---|