(cli *SeesawCLI, args []string)
| 37 | ) |
| 38 | |
| 39 | func showBGPNeighbors(cli *SeesawCLI, args []string) error { |
| 40 | neighbors, err := cli.seesaw.BGPNeighbors() |
| 41 | if err != nil { |
| 42 | return fmt.Errorf("Failed to get BGP neighbors: %v", err) |
| 43 | } |
| 44 | |
| 45 | if len(args) == 0 { |
| 46 | printHdr("BGP Neighbors") |
| 47 | for i, n := range neighbors { |
| 48 | fmt.Printf("[%3d] %s (%v, %v)\n", i+1, n.IP, n.BGPState, n.Uptime) |
| 49 | } |
| 50 | } else if len(args) == 1 { |
| 51 | ip := net.ParseIP(args[0]) |
| 52 | if ip == nil { |
| 53 | return fmt.Errorf("%q is not a valid IP address", args[0]) |
| 54 | } |
| 55 | var n *quagga.Neighbor |
| 56 | for i := range neighbors { |
| 57 | if neighbors[i].IP.Equal(ip) { |
| 58 | n = neighbors[i] |
| 59 | break |
| 60 | } |
| 61 | } |
| 62 | if n == nil { |
| 63 | return fmt.Errorf("No such neighbor") |
| 64 | } |
| 65 | printHdr("BGP Neighbor") |
| 66 | printVal("IP Address:", n.IP) |
| 67 | printVal("Router ID:", n.RouterID) |
| 68 | printVal("ASN:", n.ASN) |
| 69 | printVal("Description:", n.Description) |
| 70 | printVal("BGP State:", n.BGPState) |
| 71 | printVal("Duration:", n.Uptime) |
| 72 | } else { |
| 73 | return fmt.Errorf("Too many arguments") |
| 74 | } |
| 75 | return nil |
| 76 | } |
| 77 | |
| 78 | func showVLANs(cli *SeesawCLI, args []string) error { |
| 79 | if len(args) > 1 { |
nothing calls this directly
no test coverage detected