github.com/Cloud-Foundations/Dominator@v0.3.4/lib/net/util/api.go (about) 1 package util 2 3 import ( 4 "net" 5 ) 6 7 const ( 8 RouteFlagUp = 1 << iota 9 RouteFlagGateway 10 RouteFlagHost 11 ) 12 13 type DefaultRouteInfo struct { 14 Address net.IP 15 Interface string 16 Mask net.IPMask 17 } 18 19 type RouteEntry struct { 20 BaseAddr net.IP 21 BroadcastAddr net.IP 22 Flags uint32 23 GatewayAddr net.IP 24 InterfaceName string 25 Mask net.IPMask 26 } 27 28 type RouteTable struct { 29 DefaultRoute *DefaultRouteInfo 30 RouteEntries []*RouteEntry 31 } 32 33 type ResolverConfiguration struct { 34 Domain string 35 Nameservers []net.IP 36 SearchDomains []string 37 } 38 39 // CompareIPs returns true if the left IP is less than the right IP, else false. 40 func CompareIPs(left, right net.IP) bool { 41 return compareIPs(left, right) 42 } 43 44 func CopyIP(ip net.IP) net.IP { 45 return copyIP(ip) 46 } 47 48 func DecrementIP(ip net.IP) { 49 decrementIP(ip) 50 } 51 func GetDefaultRoute() (*DefaultRouteInfo, error) { 52 return getDefaultRoute() 53 } 54 55 func GetMyIP() (net.IP, error) { 56 return getMyIP() 57 } 58 59 func GetResolverConfiguration() (*ResolverConfiguration, error) { 60 return getResolverConfiguration() 61 } 62 63 func GetRouteTable() (*RouteTable, error) { 64 return getRouteTable() 65 } 66 67 func IncrementIP(ip net.IP) { 68 incrementIP(ip) 69 } 70 71 func InvertIP(input net.IP) { 72 invertIP(input) 73 } 74 75 func ShrinkIP(netIP net.IP) net.IP { 76 return shrinkIP(netIP) 77 }