diff --git a/IP4Config.go b/IP4Config.go index b932b4b..5e096e1 100644 --- a/IP4Config.go +++ b/IP4Config.go @@ -25,12 +25,19 @@ const ( IP4ConfigPropertyWinsServerData = IP4ConfigInterface + ".WinsServerData" // readable as ) +// Deprecated: use IP4AddressData instead type IP4Address struct { Address string Prefix uint8 Gateway string } +type IP4AddressData struct { + Address string + Prefix uint8 +} + +// Deprecated: use IP4RouteData instead type IP4Route struct { Route string Prefix uint8 @@ -38,25 +45,58 @@ type IP4Route struct { Metric uint8 } +type IP4RouteData struct { + Destination string + Prefix uint8 + NextHop string + Metric uint8 + AdditionalAttributes []string +} + +type IP4NameserverData struct { + Address string +} + type IP4Config interface { - // GetAddresses gets an array of tuples of IPv4 address/prefix/gateway. All 3 - // elements of each tuple are in network byte order. Essentially: [(addr, - // prefix, gateway), (addr, prefix, gateway), ...] + // Array of arrays of IPv4 address/prefix/gateway. All 3 elements of each array are in network byte order. Essentially: [(addr, prefix, gateway), (addr, prefix, gateway), ...] + // Deprecated: use AddressData and Gateway GetAddresses() []IP4Address - // GetRoutes gets tuples of IPv4 route/prefix/next-hop/metric. All 4 elements - // of each tuple are in network byte order. 'route' and 'next hop' are IPv4 - // addresses, while prefix and metric are simple unsigned integers. - // Essentially: [(route, prefix, next-hop, metric), (route, prefix, next-hop, - // metric), ...] + // Array of IP address data objects. All addresses will include "address" (an IP address string), and "prefix" (a uint). Some addresses may include additional attributes. + GetAddressData() []IP4AddressData + + // The gateway in use. + GetGateway() string + + // Arrays of IPv4 route/prefix/next-hop/metric. All 4 elements of each tuple are in network byte order. 'route' and 'next hop' are IPv4 addresses, while prefix and metric are simple unsigned integers. Essentially: [(route, prefix, next-hop, metric), (route, prefix, next-hop, metric), ...] + // Deprecated: use RouteData GetRoutes() []IP4Route - // GetNameservers gets the nameservers in use. + // Array of IP route data objects. All routes will include "dest" (an IP address string) and "prefix" (a uint). Some routes may include "next-hop" (an IP address string), "metric" (a uint), and additional attributes. + GetRouteData() []IP4RouteData + + // The nameservers in use. + // Deprecated: use NameserverData GetNameservers() []string - // GetDomains gets a list of domains this address belongs to. + // The nameservers in use. Currently only the value "address" is recognized (with an IP address string). + GetNameserverData() []IP4NameserverData + + // A list of domains this address belongs to. GetDomains() []string + // A list of dns searches. + GetSearches() []string + + // A list of DNS options that modify the behavior of the DNS resolver. See resolv.conf(5) manual page for the list of supported options. + GetDnsOptions() []string + + // The relative priority of DNS servers. + GetDnsPriority() uint32 + + // The Windows Internet Name Service servers associated with the connection. + GetWinsServerData() []string + MarshalJSON() ([]byte, error) } @@ -69,6 +109,7 @@ type ip4Config struct { dbusBase } +// Deprecated: use GetAddressData func (c *ip4Config) GetAddresses() []IP4Address { addresses := c.getSliceSliceUint32Property(IP4ConfigPropertyAddresses) ret := make([]IP4Address, len(addresses)) @@ -84,6 +125,15 @@ func (c *ip4Config) GetAddresses() []IP4Address { return ret } +func (c *ip4Config) GetAddressData() []IP4AddressData { + return []IP4AddressData{} +} + +func (c *ip4Config) GetGateway() string { + return c.getStringProperty(IP4ConfigPropertyGateway) +} + +// Deprecated: use GetRouteData func (c *ip4Config) GetRoutes() []IP4Route { routes := c.getSliceSliceUint32Property(IP4ConfigPropertyRoutes) ret := make([]IP4Route, len(routes)) @@ -100,6 +150,11 @@ func (c *ip4Config) GetRoutes() []IP4Route { return ret } +func (c *ip4Config) GetRouteData() []IP4RouteData { + return []IP4RouteData{} +} + +// Deprecated: use GetNameserverData func (c *ip4Config) GetNameservers() []string { nameservers := c.getSliceUint32Property(IP4ConfigPropertyNameservers) ret := make([]string, len(nameservers)) @@ -111,10 +166,30 @@ func (c *ip4Config) GetNameservers() []string { return ret } +func (c *ip4Config) GetNameserverData() []IP4NameserverData { + return []IP4NameserverData{} +} + func (c *ip4Config) GetDomains() []string { return c.getSliceStringProperty(IP4ConfigPropertyDomains) } +func (c *ip4Config) GetSearches() []string { + return c.getSliceStringProperty(IP4ConfigPropertySearches) +} + +func (c *ip4Config) GetDnsOptions() []string { + return c.getSliceStringProperty(IP4ConfigPropertyDnsOptions) +} + +func (c *ip4Config) GetDnsPriority() uint32 { + return c.getUint32Property(IP4ConfigPropertyDnsPriority) +} + +func (c *ip4Config) GetWinsServerData() []string { + return c.getSliceStringProperty(IP4ConfigPropertyWinsServerData) +} + func (c *ip4Config) MarshalJSON() ([]byte, error) { return json.Marshal(map[string]interface{}{ "Addresses": c.GetAddresses(),