package netdevice //NetDevice describes all the options a layer3 network device must have type NetDevice interface { //Ping should return a bool if there was a response, a string containing the output, or an error if the command failed Ping(string) (bool, string, error) //ARP is used to gather a full ARP table, if a command fails it should return an error ARP() error //FindARP returns an error not found if the arp entry is not in the ARP table FindARP(string) (ARP, error) //InterfaceConfigs is used to gather full interface configurations InterfaceConfigs() error //FindInterface is used to search for a interface by name, if it is not found an error is returned FindInterface(string) (IfConfig, error) //Routes is used to pull the device routing table, if the command fails an error is returned Routes() error //FindRoute is used to search for a route by ip, if the route is not found or only matches default it will return not found FindRoute(string) (Route, error) //Device returns the device number assigned to the netdevice Number() int //Name returns the core name Name() string //Platform returns the platform model and type Platform() (string, string) //Status returns the core status string ProductionStatus() string //Is Active returns the current status, if it is unable to gather the information required to determine its status, an error is returned. DeviceActive() (bool, error) //Is HA will return true if the device is configured for fail over or there is a core failover device assigned IsHA() bool //Failover returns the device number and name of the failover device FailoverDevice() int //MACAddresses is used to gather mac address table, this may call arp depending on the device support MACAddresses() error //FindMAC returns the MAC data associated with the MAC Address given FindMAC(string) (MAC, error) //VLAN is used to gather vlan information VLans() error //FindVlanNumber returns the VLAN that matches the number given FindVlanNumber(int) (Vlan, error) //FindVlanName reutrns the vlan that matches the name given FindVlanName(string) (Vlan, error) } type ( //ARP contains the basic ARP information returned by all devices ARP struct { IPAddress string `json:"ip_address"` TTL int `json:"timeout"` MAC string `json:"timeoute"` Vlan string `json:"vlan"` IfName string `json:"interface_name"` CoreDevice int `json:"device_number"` CoreName string `json:"device_name"` Netdevice int `json:"netdevice"` } //Route contains the basic route information returned by all devices Route struct { NextHop string `json:"nexthop"` Network string `json:"network"` IfName string `json:"interface_name"` VlanName string `json:"vlan_name"` VlanNum string `json:"vlan"` Type string `json:"type"` LastResort bool `json:"last_resort"` CoreDevice int `json:"device_number"` CoreName string `json:"device_name"` Netdevice int `json:"netdevice"` } //IfConfig contains the basic route information returned by all network interfaces IfConfig struct { IntName string `json:"interface_name"` IPAddress string `json:"ip_address"` VlanName string `json:"vlan_name"` VlanNum int `json:"vlan_num"` Sec int `json:"security_level"` Name string `json:"interface_name"` Type string `json:"type"` MAC string `json:"mac_address"` MTU int `json:"mtu"` AdminUp bool `json:"admin_up"` Link bool `json:"link"` Hardware string `json:"hardware"` Netdevice int `json:"netdevice"` } //NAT contains the basic nat information NAT struct { Type string `json:"type"` Host *HostNat `json:"host_nat,omitempty"` Network *NetworkNat `json:"network_nat,omitempty"` SrcNet string `json:"source_network"` DstNet string `json:"destination_network"` Connected bool `json:"connected"` DNS bool `json:"dns"` CoreDevice int `json:"core_device"` CoreName string `json:"core_device_name"` Netdevice string `json:"netdevice"` } //HostNat describes a 1 to 1 nat configuration HostNat struct { PrivateIP string `json:"private_ip"` PublicIP string `json:"public_ip"` } //NetworkNat describes a network nat configuration NetworkNat struct { PrivateNet string `json:"private_network"` PrivateMask string `json:"private_netmask"` PublicNet string `json:"public_network"` } //Vlan contains vlan information Vlan struct { Name string `json:"vlan_name"` Number int `json:"vlan_number"` Netdevice string `json:"netdevice"` } // MAC contains mac address information MAC struct { MAC string `json:"mac_address"` VlanName string `json:"vlan_name"` VlanNum int `json:"vlan_num"` Netdevice string `json:"netdevice"` } )