Add DHCP6 config
This commit is contained in:
parent
3a91ad9f21
commit
2cd4d064d3
2 changed files with 60 additions and 12 deletions
|
@ -67,7 +67,7 @@ type ActiveConnection interface {
|
|||
GetIP6Config() IP6Config
|
||||
|
||||
// GetDHCP6Config gets the DHCP4Config of the connection.
|
||||
//GetDHCP6Config() DHCP6Config
|
||||
GetDHCP6Config() DHCP6Config
|
||||
|
||||
// GetVPN gets the VPN flag of the connection.
|
||||
GetVPN() bool
|
||||
|
@ -185,18 +185,18 @@ func (a *activeConnection) GetIP6Config() IP6Config {
|
|||
return r
|
||||
}
|
||||
|
||||
//func (a *activeConnection) GetDHCP6Config() DHCP6Config {
|
||||
// path := a.getObjectProperty(ActiveConnectionPropertyDhcp6Config)
|
||||
// if path == "/" {
|
||||
// return nil
|
||||
// }
|
||||
func (a *activeConnection) GetDHCP6Config() DHCP6Config {
|
||||
path := a.getObjectProperty(ActiveConnectionPropertyDhcp6Config)
|
||||
if path == "/" {
|
||||
return nil
|
||||
}
|
||||
|
||||
// r, err := NewDHCP6Config(path)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// return r
|
||||
//}
|
||||
r, err := NewDHCP6Config(path)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (a *activeConnection) GetVPN() bool {
|
||||
ret := a.getProperty(ActiveConnectionPropertyVpn)
|
||||
|
|
48
DHCP6Config.go
Normal file
48
DHCP6Config.go
Normal file
|
@ -0,0 +1,48 @@
|
|||
package gonetworkmanager
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/godbus/dbus"
|
||||
)
|
||||
|
||||
const (
|
||||
DHCP6ConfigInterface = NetworkManagerInterface + ".DHCP6Config"
|
||||
|
||||
DHCP6ConfigPropertyOptions = DHCP6ConfigInterface + ".Options"
|
||||
)
|
||||
|
||||
type DHCP6Options map[string]interface{}
|
||||
|
||||
type DHCP6Config interface {
|
||||
// GetOptions gets options map of configuration returned by the IPv4 DHCP server.
|
||||
GetOptions() DHCP6Options
|
||||
|
||||
MarshalJSON() ([]byte, error)
|
||||
}
|
||||
|
||||
func NewDHCP6Config(objectPath dbus.ObjectPath) (DHCP6Config, error) {
|
||||
var c dhcp6Config
|
||||
return &c, c.init(NetworkManagerInterface, objectPath)
|
||||
}
|
||||
|
||||
type dhcp6Config struct {
|
||||
dbusBase
|
||||
}
|
||||
|
||||
func (c *dhcp6Config) GetOptions() DHCP6Options {
|
||||
options := c.getMapStringVariantProperty(DHCP6ConfigPropertyOptions)
|
||||
rv := make(DHCP6Options)
|
||||
|
||||
for k, v := range options {
|
||||
rv[k] = v.Value()
|
||||
}
|
||||
|
||||
return rv
|
||||
}
|
||||
|
||||
func (c *dhcp6Config) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(map[string]interface{}{
|
||||
"Options": c.GetOptions(),
|
||||
})
|
||||
}
|
Reference in a new issue