UciClient attribute needs to be public ...
This commit is contained in:
parent
5912ec7202
commit
a36ecb2f68
10
uci.go
10
uci.go
|
@ -147,3 +147,13 @@ func (u *UCI) GetWifiIfaces() map[int]*UCIWirelessInterface {
|
||||||
func (u *UCI) GetWifiDevices() []map[string]string {
|
func (u *UCI) GetWifiDevices() []map[string]string {
|
||||||
return u.Wireless.Devices
|
return u.Wireless.Devices
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetWifiDeviceByName returns a wifi device by his name "radio0" "radio1"
|
||||||
|
func (u *UCI) GetWifiDeviceByName(name string) map[string]string {
|
||||||
|
for _, device := range u.Wireless.Devices {
|
||||||
|
if device["Device"] == name {
|
||||||
|
return device
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -9,19 +9,19 @@ type UCIDHCPConf struct {
|
||||||
LeaseTime string
|
LeaseTime string
|
||||||
RangeLimit string
|
RangeLimit string
|
||||||
StartIP string
|
StartIP string
|
||||||
uciClient *UCI
|
UciClient *UCI
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewUCIDHCPConf builds a new UCIDHCPConf instance
|
// NewUCIDHCPConf builds a new UCIDHCPConf instance
|
||||||
func NewUCIDHCPConf(uci *UCI) *UCIDHCPConf {
|
func NewUCIDHCPConf(uci *UCI) *UCIDHCPConf {
|
||||||
return &UCIDHCPConf{
|
return &UCIDHCPConf{
|
||||||
uciClient: uci,
|
UciClient: uci,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create add a new entry for wifi interface in UCI Configuration
|
// Create add a new entry for wifi interface in UCI Configuration
|
||||||
func (dh *UCIDHCPConf) Create() *Action {
|
func (dh *UCIDHCPConf) Create() *Action {
|
||||||
uci := dh.uciClient
|
uci := dh.UciClient
|
||||||
conf := make(map[string]string)
|
conf := make(map[string]string)
|
||||||
|
|
||||||
conf["name"] = dh.Name
|
conf["name"] = dh.Name
|
||||||
|
@ -63,7 +63,7 @@ func (dh *UCIDHCPConf) Create() *Action {
|
||||||
|
|
||||||
// Save commit and relaod configuration (writes it to files !)
|
// Save commit and relaod configuration (writes it to files !)
|
||||||
func (dh *UCIDHCPConf) Save() *Action {
|
func (dh *UCIDHCPConf) Save() *Action {
|
||||||
uci := dh.uciClient
|
uci := dh.UciClient
|
||||||
commitRes := uci.Commit()
|
commitRes := uci.Commit()
|
||||||
if commitRes.ReturnCode != 0 {
|
if commitRes.ReturnCode != 0 {
|
||||||
return commitRes
|
return commitRes
|
||||||
|
@ -75,7 +75,7 @@ func (dh *UCIDHCPConf) Save() *Action {
|
||||||
|
|
||||||
// Delete remove wifi interface from UCI Configuration
|
// Delete remove wifi interface from UCI Configuration
|
||||||
func (dh *UCIDHCPConf) Delete() *Action {
|
func (dh *UCIDHCPConf) Delete() *Action {
|
||||||
uci := dh.uciClient
|
uci := dh.UciClient
|
||||||
toDelete := fmt.Sprintf("network.%s", dh.Name)
|
toDelete := fmt.Sprintf("network.%s", dh.Name)
|
||||||
del := uci.Delete(toDelete)
|
del := uci.Delete(toDelete)
|
||||||
if del.ReturnCode != 0 {
|
if del.ReturnCode != 0 {
|
||||||
|
@ -86,7 +86,7 @@ func (dh *UCIDHCPConf) Delete() *Action {
|
||||||
|
|
||||||
// Update add a new entry for wifi interface in UCI Configuration
|
// Update add a new entry for wifi interface in UCI Configuration
|
||||||
func (dh *UCIDHCPConf) Update() *Action {
|
func (dh *UCIDHCPConf) Update() *Action {
|
||||||
uci := dh.uciClient
|
uci := dh.UciClient
|
||||||
dh.Delete()
|
dh.Delete()
|
||||||
create := dh.Create()
|
create := dh.Create()
|
||||||
if create.ReturnCode != 0 {
|
if create.ReturnCode != 0 {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import "fmt"
|
||||||
|
|
||||||
// UCINetworkInterface describes uci network inteface (uci show network)
|
// UCINetworkInterface describes uci network inteface (uci show network)
|
||||||
type UCINetworkInterface struct {
|
type UCINetworkInterface struct {
|
||||||
uciClient *UCI
|
UciClient *UCI
|
||||||
Name string
|
Name string
|
||||||
Proto string
|
Proto string
|
||||||
IFName string
|
IFName string
|
||||||
|
@ -19,16 +19,16 @@ type UCINetworkInterface struct {
|
||||||
// NewUCINetworkInterface builds a new UCIWirelessConf instance
|
// NewUCINetworkInterface builds a new UCIWirelessConf instance
|
||||||
func NewUCINetworkInterface(uci *UCI) *UCINetworkInterface {
|
func NewUCINetworkInterface(uci *UCI) *UCINetworkInterface {
|
||||||
return &UCINetworkInterface{
|
return &UCINetworkInterface{
|
||||||
uciClient: uci,
|
UciClient: uci,
|
||||||
DHCP: &UCIDHCPConf{
|
DHCP: &UCIDHCPConf{
|
||||||
uciClient: uci,
|
UciClient: uci,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create add a new entry for wifi interface in UCI Configuration
|
// Create add a new entry for wifi interface in UCI Configuration
|
||||||
func (ni *UCINetworkInterface) Create() *Action {
|
func (ni *UCINetworkInterface) Create() *Action {
|
||||||
uci := ni.uciClient
|
uci := ni.UciClient
|
||||||
conf := make(map[string]string)
|
conf := make(map[string]string)
|
||||||
|
|
||||||
conf["proto"] = ni.Proto
|
conf["proto"] = ni.Proto
|
||||||
|
@ -68,12 +68,12 @@ func (ni *UCINetworkInterface) Create() *Action {
|
||||||
|
|
||||||
// Save commit and relaod configuration (writes it to files !)
|
// Save commit and relaod configuration (writes it to files !)
|
||||||
func (ni *UCINetworkInterface) Save() *Action {
|
func (ni *UCINetworkInterface) Save() *Action {
|
||||||
return ni.uciClient.Save()
|
return ni.UciClient.Save()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete remove wifi interface from UCI Configuration
|
// Delete remove wifi interface from UCI Configuration
|
||||||
func (ni *UCINetworkInterface) Delete() *Action {
|
func (ni *UCINetworkInterface) Delete() *Action {
|
||||||
uci := ni.uciClient
|
uci := ni.UciClient
|
||||||
|
|
||||||
if ni.DHCP.Name != "" {
|
if ni.DHCP.Name != "" {
|
||||||
toDelete := fmt.Sprintf("dhcp.%s", ni.Name)
|
toDelete := fmt.Sprintf("dhcp.%s", ni.Name)
|
||||||
|
@ -94,7 +94,7 @@ func (ni *UCINetworkInterface) Delete() *Action {
|
||||||
|
|
||||||
// Update add a new entry for wifi interface in UCI Configuration
|
// Update add a new entry for wifi interface in UCI Configuration
|
||||||
func (ni *UCINetworkInterface) Update() *Action {
|
func (ni *UCINetworkInterface) Update() *Action {
|
||||||
uci := ni.uciClient
|
uci := ni.UciClient
|
||||||
ni.Delete()
|
ni.Delete()
|
||||||
create := ni.Create()
|
create := ni.Create()
|
||||||
if create.ReturnCode != 0 {
|
if create.ReturnCode != 0 {
|
||||||
|
|
Loading…
Reference in New Issue