From 10daa7f84190dccb6efc2947b0ebf7167ffa0436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCller?= Date: Fri, 31 Jul 2020 16:14:41 +0200 Subject: [PATCH] Add ActiveConnection StateChanged signal subscription --- ActiveConnection.go | 59 +++++++++++++++++++++ enums.go | 109 +++++++++++++++++++++++++++++++++++++++ nm80211apflags_string.go | 14 +++-- nm80211apsec_string.go | 31 +++++++---- nm80211mode_string.go | 16 ++++-- nmconnectivity_string.go | 17 ++++-- nmdevicestate_string.go | 41 +++++++++++---- nmdevicetype_string.go | 47 +++++++++++++++-- nmstate_string.go | 31 ++++++----- 9 files changed, 315 insertions(+), 50 deletions(-) diff --git a/ActiveConnection.go b/ActiveConnection.go index c03d6eb..3f6e3dc 100644 --- a/ActiveConnection.go +++ b/ActiveConnection.go @@ -1,6 +1,7 @@ package gonetworkmanager import ( + "fmt" "github.com/godbus/dbus/v5" ) @@ -24,6 +25,10 @@ const ( ActiveConnectionPropertyDhcp6Config = ActiveConnectionInterface + ".Dhcp6Config" // readable o ActiveConnectionPropertyVpn = ActiveConnectionInterface + ".Vpn" // readable b ActiveConnectionPropertyMaster = ActiveConnectionInterface + ".Master" // readable o + + /* Signals */ + ActiveConnectionSignalStateChanged = "StateChanged" // u state, u reason + ) type ActiveConnection interface { @@ -76,6 +81,8 @@ type ActiveConnection interface { // GetMaster gets the master device of the connection. GetPropertyMaster() (Device, error) + + SubscribeState(receiver chan StateChange, exit chan struct{}) (err error) } func NewActiveConnection(objectPath dbus.ObjectPath) (ActiveConnection, error) { @@ -211,3 +218,55 @@ func (a *activeConnection) GetPropertyMaster() (Device, error) { } return DeviceFactory(path) } + +type StateChange struct { + State NmActiveConnectionState + Reason NmActiveConnectionStateReason +} + +func (a *activeConnection) SubscribeState(receiver chan StateChange, exit chan struct{}) (err error) { + + channel := make(chan *dbus.Signal, 1) + + a.conn.Signal(channel) + + err = a.conn.AddMatchSignal( + dbus.WithMatchInterface(ActiveConnectionInterface), + dbus.WithMatchMember(ActiveConnectionSignalStateChanged), + dbus.WithMatchObjectPath(a.GetPath()), + ) + if err != nil { + return err + } + + go func() { + for { + select { + case signal, ok := <-channel: + + if !ok { + err = fmt.Errorf("connection closed for %s", ActiveConnectionSignalStateChanged) + return + } + + if signal.Path != a.GetPath() || signal.Name != ActiveConnectionInterface+"."+ActiveConnectionSignalStateChanged { + continue + } + + stateChange := StateChange{ + State: NmActiveConnectionState(signal.Body[0].(uint32)), + Reason: NmActiveConnectionStateReason(signal.Body[1].(uint32)), + } + + receiver <- stateChange + + case <-exit: + a.conn.RemoveSignal(channel) + close(channel) + return + } + } + }() + + return +} diff --git a/enums.go b/enums.go index cf12b36..2aebf44 100644 --- a/enums.go +++ b/enums.go @@ -169,3 +169,112 @@ const ( Nm80211ModeInfra Nm80211Mode = 2 Nm80211ModeAp Nm80211Mode = 3 ) + +//go:generate stringer -type=NmActiveConnectionState +type NmVpnConnectionState uint32 + +const ( + NmVpnConnectionUnknown = 0 //The state of the VPN connection is unknown. + NmVpnConnectionPrepare = 1 //The VPN connection is preparing to connect. + NmVpnConnectionNeedAuth = 2 //The VPN connection needs authorization credentials. + NmVpnConnectionConnect = 3 //The VPN connection is being established. + NmVpnConnectionIpConfigGet = 4 //The VPN connection is getting an IP address. + NmVpnConnectionActivated = 5 //The VPN connection is active. + NmVpnConnectionFailed = 6 //The VPN connection failed. + NmVpnConnectionDisconnected = 7 //The VPN connection is disconnected. +) + +//go:generate stringer -type=NmDeviceStateReason +type NmDeviceStateReason uint32 + +const ( + NmDeviceStateReasonNone = 0 // No reason given + NmDeviceStateReasonUnknown = 1 // Unknown error + NmDeviceStateReasonNowManaged = 2 // Device is now managed + NmDeviceStateReasonNowUnmanaged = 3 // Device is now unmanaged + NmDeviceStateReasonConfigFailed = 4 // The device could not be readied for configuration + NmDeviceStateReasonIpConfigUnavailable = 5 // IP configuration could not be reserved (no available address, timeout, etc) + NmDeviceStateReasonIpConfigExpired = 6 // The IP config is no longer valid + NmDeviceStateReasonNoSecrets = 7 // Secrets were required, but not provided + NmDeviceStateReasonSupplicantDisconnect = 8 // 802.1x supplicant disconnected + NmDeviceStateReasonSupplicantConfigFailed = 9 // 802.1x supplicant configuration failed + NmDeviceStateReasonSupplicantFailed = 10 // 802.1x supplicant failed + NmDeviceStateReasonSupplicantTimeout = 11 // 802.1x supplicant took too long to authenticate + NmDeviceStateReasonPppStartFailed = 12 // PPP service failed to start + NmDeviceStateReasonPppDisconnect = 13 // PPP service disconnected + NmDeviceStateReasonPppFailed = 14 // PPP failed + NmDeviceStateReasonDhcpStartFailed = 15 // DHCP client failed to start + NmDeviceStateReasonDhcpError = 16 // DHCP client error + NmDeviceStateReasonDhcpFailed = 17 // DHCP client failed + NmDeviceStateReasonSharedStartFailed = 18 // Shared connection service failed to start + NmDeviceStateReasonSharedFailed = 19 // Shared connection service failed + NmDeviceStateReasonAutoipStartFailed = 20 // AutoIP service failed to start + NmDeviceStateReasonAutoipError = 21 // AutoIP service error + NmDeviceStateReasonAutoipFailed = 22 // AutoIP service failed + NmDeviceStateReasonModemBusy = 23 // The line is busy + NmDeviceStateReasonModemNoDialTone = 24 // No dial tone + NmDeviceStateReasonModemNoCarrier = 25 // No carrier could be established + NmDeviceStateReasonModemDialTimeout = 26 // The dialing request timed out + NmDeviceStateReasonModemDialFailed = 27 // The dialing attempt failed + NmDeviceStateReasonModemInitFailed = 28 // Modem initialization failed + NmDeviceStateReasonGsmApnFailed = 29 // Failed to select the specified APN + NmDeviceStateReasonGsmRegistrationNotSearching = 30 // Not searching for networks + NmDeviceStateReasonGsmRegistrationDenied = 31 // Network registration denied + NmDeviceStateReasonGsmRegistrationTimeout = 32 // Network registration timed out + NmDeviceStateReasonGsmRegistrationFailed = 33 // Failed to register with the requested network + NmDeviceStateReasonGsmPinCheckFailed = 34 // PIN check failed + NmDeviceStateReasonFirmwareMissing = 35 // Necessary firmware for the device may be missing + NmDeviceStateReasonRemoved = 36 // The device was removed + NmDeviceStateReasonSleeping = 37 // NetworkManager went to sleep + NmDeviceStateReasonConnectionRemoved = 38 // The device's active connection disappeared + NmDeviceStateReasonUserRequested = 39 // Device disconnected by user or client + NmDeviceStateReasonCarrier = 40 // Carrier/link changed + NmDeviceStateReasonConnectionAssumed = 41 // The device's existing connection was assumed + NmDeviceStateReasonSupplicantAvailable = 42 // The supplicant is now available + NmDeviceStateReasonModemNotFound = 43 // The modem could not be found + NmDeviceStateReasonBtFailed = 44 // The Bluetooth connection failed or timed out + NmDeviceStateReasonGsmSimNotInserted = 45 // GSM Modem's SIM Card not inserted + NmDeviceStateReasonGsmSimPinRequired = 46 // GSM Modem's SIM Pin required + NmDeviceStateReasonGsmSimPukRequired = 47 // GSM Modem's SIM Puk required + NmDeviceStateReasonGsmSimWrong = 48 // GSM Modem's SIM wrong + NmDeviceStateReasonInfinibandMode = 49 // InfiniBand device does not support connected mode + NmDeviceStateReasonDependencyFailed = 50 // A dependency of the connection failed + NmDeviceStateReasonBr2684Failed = 51 // Problem with the RFC 2684 Ethernet over ADSL bridge + NmDeviceStateReasonModemManagerUnavailable = 52 // ModemManager not running + NmDeviceStateReasonSsidNotFound = 53 // The Wi-Fi network could not be found + NmDeviceStateReasonSecondaryConnectionFailed = 54 // A secondary connection of the base connection failed + NmDeviceStateReasonDcbFcoeFailed = 55 // DCB or FCoE setup failed + NmDeviceStateReasonTeamdControlFailed = 56 // teamd control failed + NmDeviceStateReasonModemFailed = 57 // Modem failed or no longer available + NmDeviceStateReasonModemAvailable = 58 // Modem now ready and available + NmDeviceStateReasonSimPinIncorrect = 59 // SIM PIN was incorrect + NmDeviceStateReasonNewActivation = 60 // New connection activation was enqueued + NmDeviceStateReasonParentChanged = 61 // the device's parent changed + NmDeviceStateReasonParentManagedChanged = 62 // the device parent's management changed + NmDeviceStateReasonOvsdbFailed = 63 // problem communicating with Open vSwitch database + NmDeviceStateReasonIpAddressDuplicate = 64 // a duplicate IP address was detected + NmDeviceStateReasonIpMethodUnsupported = 65 // The selected IP method is not supported + NmDeviceStateReasonSriovConfigurationFailed = 66 // configuration of SR-IOV parameters failed + NmDeviceStateReasonPeerNotFound = 67 // The Wi-Fi P2P peer could not be found +) + +//go:generate stringer -type=NmActiveConnectionStateReason +type NmActiveConnectionStateReason uint32 + +const ( + NmActiveConnectionStateReasonUnknown = 0 // The reason for the active connection state change is unknown. + NmActiveConnectionStateReasonNone = 1 // No reason was given for the active connection state change. + NmActiveConnectionStateReasonUserDisconnected = 2 // The active connection changed state because the user disconnected it. + NmActiveConnectionStateReasonDeviceDisconnected = 3 // The active connection changed state because the device it was using was disconnected. + NmActiveConnectionStateReasonServiceStopped = 4 // The service providing the VPN connection was stopped. + NmActiveConnectionStateReasonIpConfigInvalid = 5 // The IP config of the active connection was invalid. + NmActiveConnectionStateReasonConnectTimeout = 6 // The connection attempt to the VPN service timed out. + NmActiveConnectionStateReasonServiceStartTimeout = 7 // A timeout occurred while starting the service providing the VPN connection. + NmActiveConnectionStateReasonServiceStartFailed = 8 // Starting the service providing the VPN connection failed. + NmActiveConnectionStateReasonNoSecrets = 9 // Necessary secrets for the connection were not provided. + NmActiveConnectionStateReasonLoginFailed = 10 // Authentication to the server failed. + NmActiveConnectionStateReasonConnectionRemoved = 11 // The connection was deleted from settings. + NmActiveConnectionStateReasonDependencyFailed = 12 // Master connection of this connection failed to activate. + NmActiveConnectionStateReasonDeviceRealizeFailed = 13 // Could not create the software device link. + NmActiveConnectionStateReasonDeviceRemoved = 14 // The device this connection depended on disappeared. +) diff --git a/nm80211apflags_string.go b/nm80211apflags_string.go index 9b04c55..8213550 100644 --- a/nm80211apflags_string.go +++ b/nm80211apflags_string.go @@ -1,8 +1,16 @@ -// Code generated by "stringer -type=Nm80211APFlags"; DO NOT EDIT +// Code generated by "stringer -type=Nm80211APFlags"; DO NOT EDIT. package gonetworkmanager -import "fmt" +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[Nm80211APFlagsNone-0] + _ = x[Nm80211APFlagsPrivacy-1] +} const _Nm80211APFlags_name = "Nm80211APFlagsNoneNm80211APFlagsPrivacy" @@ -10,7 +18,7 @@ var _Nm80211APFlags_index = [...]uint8{0, 18, 39} func (i Nm80211APFlags) String() string { if i >= Nm80211APFlags(len(_Nm80211APFlags_index)-1) { - return fmt.Sprintf("Nm80211APFlags(%d)", i) + return "Nm80211APFlags(" + strconv.FormatInt(int64(i), 10) + ")" } return _Nm80211APFlags_name[_Nm80211APFlags_index[i]:_Nm80211APFlags_index[i+1]] } diff --git a/nm80211apsec_string.go b/nm80211apsec_string.go index 99d7ed0..8461909 100644 --- a/nm80211apsec_string.go +++ b/nm80211apsec_string.go @@ -1,8 +1,25 @@ -// Code generated by "stringer -type=Nm80211APSec"; DO NOT EDIT +// Code generated by "stringer -type=Nm80211APSec"; DO NOT EDIT. package gonetworkmanager -import "fmt" +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[Nm80211APSecNone-0] + _ = x[Nm80211APSecPairWEP40-1] + _ = x[Nm80211APSecPairWEP104-2] + _ = x[Nm80211APSecPairTKIP-4] + _ = x[Nm80211APSecPairCCMP-8] + _ = x[Nm80211APSecGroupWEP40-16] + _ = x[Nm80211APSecGroupWEP104-32] + _ = x[Nm80211APSecGroupTKIP-64] + _ = x[Nm80211APSecGroupCCMP-128] + _ = x[Nm80211APSecKeyMgmtPSK-256] + _ = x[Nm80211APSecKeyMgmt8021X-512] +} const ( _Nm80211APSec_name_0 = "Nm80211APSecNoneNm80211APSecPairWEP40Nm80211APSecPairWEP104" @@ -18,14 +35,6 @@ const ( var ( _Nm80211APSec_index_0 = [...]uint8{0, 16, 37, 59} - _Nm80211APSec_index_1 = [...]uint8{0, 20} - _Nm80211APSec_index_2 = [...]uint8{0, 20} - _Nm80211APSec_index_3 = [...]uint8{0, 22} - _Nm80211APSec_index_4 = [...]uint8{0, 23} - _Nm80211APSec_index_5 = [...]uint8{0, 21} - _Nm80211APSec_index_6 = [...]uint8{0, 21} - _Nm80211APSec_index_7 = [...]uint8{0, 22} - _Nm80211APSec_index_8 = [...]uint8{0, 24} ) func (i Nm80211APSec) String() string { @@ -49,6 +58,6 @@ func (i Nm80211APSec) String() string { case i == 512: return _Nm80211APSec_name_8 default: - return fmt.Sprintf("Nm80211APSec(%d)", i) + return "Nm80211APSec(" + strconv.FormatInt(int64(i), 10) + ")" } } diff --git a/nm80211mode_string.go b/nm80211mode_string.go index 96d38a1..477062f 100644 --- a/nm80211mode_string.go +++ b/nm80211mode_string.go @@ -1,8 +1,18 @@ -// Code generated by "stringer -type=Nm80211Mode"; DO NOT EDIT +// Code generated by "stringer -type=Nm80211Mode"; DO NOT EDIT. package gonetworkmanager -import "fmt" +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[Nm80211ModeUnknown-0] + _ = x[Nm80211ModeAdhoc-1] + _ = x[Nm80211ModeInfra-2] + _ = x[Nm80211ModeAp-3] +} const _Nm80211Mode_name = "Nm80211ModeUnknownNm80211ModeAdhocNm80211ModeInfraNm80211ModeAp" @@ -10,7 +20,7 @@ var _Nm80211Mode_index = [...]uint8{0, 18, 34, 50, 63} func (i Nm80211Mode) String() string { if i >= Nm80211Mode(len(_Nm80211Mode_index)-1) { - return fmt.Sprintf("Nm80211Mode(%d)", i) + return "Nm80211Mode(" + strconv.FormatInt(int64(i), 10) + ")" } return _Nm80211Mode_name[_Nm80211Mode_index[i]:_Nm80211Mode_index[i+1]] } diff --git a/nmconnectivity_string.go b/nmconnectivity_string.go index c9bc0e1..cb8605b 100644 --- a/nmconnectivity_string.go +++ b/nmconnectivity_string.go @@ -1,8 +1,19 @@ -// Code generated by "stringer -type=NmConnectivity"; DO NOT EDIT +// Code generated by "stringer -type=NmConnectivity"; DO NOT EDIT. package gonetworkmanager -import "fmt" +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[NmConnectivityUnknown-0] + _ = x[NmConnectivityNone-1] + _ = x[NmConnectivityPortal-2] + _ = x[NmConnectivityLimited-3] + _ = x[NmConnectivityFull-4] +} const _NmConnectivity_name = "NmConnectivityUnknownNmConnectivityNoneNmConnectivityPortalNmConnectivityLimitedNmConnectivityFull" @@ -10,7 +21,7 @@ var _NmConnectivity_index = [...]uint8{0, 21, 39, 59, 80, 98} func (i NmConnectivity) String() string { if i >= NmConnectivity(len(_NmConnectivity_index)-1) { - return fmt.Sprintf("NmConnectivity(%d)", i) + return "NmConnectivity(" + strconv.FormatInt(int64(i), 10) + ")" } return _NmConnectivity_name[_NmConnectivity_index[i]:_NmConnectivity_index[i+1]] } diff --git a/nmdevicestate_string.go b/nmdevicestate_string.go index c88842d..1243ea7 100644 --- a/nmdevicestate_string.go +++ b/nmdevicestate_string.go @@ -1,10 +1,29 @@ -// Code generated by "stringer -type=NmDeviceState"; DO NOT EDIT +// Code generated by "stringer -type=NmDeviceState"; DO NOT EDIT. package gonetworkmanager -import "fmt" +import "strconv" -const _NmDeviceState_name = "NmDeviceStateUnknownNmDeviceStateUnmanagedNmDeviceStateUnavailableNmDeviceStateDisconnectedNmDeviceStatePrepareNmDeviceStateConfigNmDeviceStateNeed_authNmDeviceStateIp_configNmDeviceStateIp_checkNmDeviceStateSecondariesNmDeviceStateActivatedNmDeviceStateDeactivatingNmDeviceStateFailed" +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[NmDeviceStateUnknown-0] + _ = x[NmDeviceStateUnmanaged-10] + _ = x[NmDeviceStateUnavailable-20] + _ = x[NmDeviceStateDisconnected-30] + _ = x[NmDeviceStatePrepare-40] + _ = x[NmDeviceStateConfig-50] + _ = x[NmDeviceStateNeedAuth-60] + _ = x[NmDeviceStateIpConfig-70] + _ = x[NmDeviceStateIpCheck-80] + _ = x[NmDeviceStateSecondaries-90] + _ = x[NmDeviceStateActivated-100] + _ = x[NmDeviceStateDeactivating-110] + _ = x[NmDeviceStateFailed-120] +} + +const _NmDeviceState_name = "NmDeviceStateUnknownNmDeviceStateUnmanagedNmDeviceStateUnavailableNmDeviceStateDisconnectedNmDeviceStatePrepareNmDeviceStateConfigNmDeviceStateNeedAuthNmDeviceStateIpConfigNmDeviceStateIpCheckNmDeviceStateSecondariesNmDeviceStateActivatedNmDeviceStateDeactivatingNmDeviceStateFailed" var _NmDeviceState_map = map[NmDeviceState]string{ 0: _NmDeviceState_name[0:20], @@ -13,18 +32,18 @@ var _NmDeviceState_map = map[NmDeviceState]string{ 30: _NmDeviceState_name[66:91], 40: _NmDeviceState_name[91:111], 50: _NmDeviceState_name[111:130], - 60: _NmDeviceState_name[130:152], - 70: _NmDeviceState_name[152:174], - 80: _NmDeviceState_name[174:195], - 90: _NmDeviceState_name[195:219], - 100: _NmDeviceState_name[219:241], - 110: _NmDeviceState_name[241:266], - 120: _NmDeviceState_name[266:285], + 60: _NmDeviceState_name[130:151], + 70: _NmDeviceState_name[151:172], + 80: _NmDeviceState_name[172:192], + 90: _NmDeviceState_name[192:216], + 100: _NmDeviceState_name[216:238], + 110: _NmDeviceState_name[238:263], + 120: _NmDeviceState_name[263:282], } func (i NmDeviceState) String() string { if str, ok := _NmDeviceState_map[i]; ok { return str } - return fmt.Sprintf("NmDeviceState(%d)", i) + return "NmDeviceState(" + strconv.FormatInt(int64(i), 10) + ")" } diff --git a/nmdevicetype_string.go b/nmdevicetype_string.go index af9645f..d5003b5 100644 --- a/nmdevicetype_string.go +++ b/nmdevicetype_string.go @@ -1,16 +1,53 @@ -// Code generated by "stringer -type=NmDeviceType"; DO NOT EDIT +// Code generated by "stringer -type=NmDeviceType"; DO NOT EDIT. package gonetworkmanager -import "fmt" +import "strconv" -const _NmDeviceType_name = "NmDeviceTypeUnknownNmDeviceTypeEthernetNmDeviceTypeWifiNmDeviceTypeUnused1NmDeviceTypeUnused2NmDeviceTypeBtNmDeviceTypeOlpcMeshNmDeviceTypeWimaxNmDeviceTypeModemNmDeviceTypeInfinibandNmDeviceTypeBondNmDeviceTypeVlanNmDeviceTypeAdslNmDeviceTypeBridgeNmDeviceTypeGenericNmDeviceTypeTeam" +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[NmDeviceTypeUnknown-0] + _ = x[NmDeviceTypeGeneric-14] + _ = x[NmDeviceTypeEthernet-1] + _ = x[NmDeviceTypeWifi-2] + _ = x[NmDeviceTypeUnused1-3] + _ = x[NmDeviceTypeUnused2-4] + _ = x[NmDeviceTypeBt-5] + _ = x[NmDeviceTypeOlpcMesh-6] + _ = x[NmDeviceTypeWimax-7] + _ = x[NmDeviceTypeModem-8] + _ = x[NmDeviceTypeInfiniband-9] + _ = x[NmDeviceTypeBond-10] + _ = x[NmDeviceTypeVlan-11] + _ = x[NmDeviceTypeAdsl-12] + _ = x[NmDeviceTypeBridge-13] + _ = x[NmDeviceTypeTeam-15] + _ = x[NmDeviceTypeTun-16] + _ = x[NmDeviceTypeIpTunnel-17] + _ = x[NmDeviceTypeMacvlan-18] + _ = x[NmDeviceTypeVxlan-19] + _ = x[NmDeviceTypeVeth-20] + _ = x[NmDeviceTypeMacsec-21] + _ = x[NmDeviceTypeDummy-22] + _ = x[NmDeviceTypePpp-23] + _ = x[NmDeviceTypeOvsInterface-24] + _ = x[NmDeviceTypeOvsPort-25] + _ = x[NmDeviceTypeOvsBridge-26] + _ = x[NmDeviceTypeWpan-27] + _ = x[NmDeviceType6lowpan-28] + _ = x[NmDeviceTypeWireguard-29] + _ = x[NmDeviceTypeWifiP2p-30] +} -var _NmDeviceType_index = [...]uint16{0, 19, 39, 55, 74, 93, 107, 127, 144, 161, 183, 199, 215, 231, 249, 268, 284} +const _NmDeviceType_name = "NmDeviceTypeUnknownNmDeviceTypeEthernetNmDeviceTypeWifiNmDeviceTypeUnused1NmDeviceTypeUnused2NmDeviceTypeBtNmDeviceTypeOlpcMeshNmDeviceTypeWimaxNmDeviceTypeModemNmDeviceTypeInfinibandNmDeviceTypeBondNmDeviceTypeVlanNmDeviceTypeAdslNmDeviceTypeBridgeNmDeviceTypeGenericNmDeviceTypeTeamNmDeviceTypeTunNmDeviceTypeIpTunnelNmDeviceTypeMacvlanNmDeviceTypeVxlanNmDeviceTypeVethNmDeviceTypeMacsecNmDeviceTypeDummyNmDeviceTypePppNmDeviceTypeOvsInterfaceNmDeviceTypeOvsPortNmDeviceTypeOvsBridgeNmDeviceTypeWpanNmDeviceType6lowpanNmDeviceTypeWireguardNmDeviceTypeWifiP2p" + +var _NmDeviceType_index = [...]uint16{0, 19, 39, 55, 74, 93, 107, 127, 144, 161, 183, 199, 215, 231, 249, 268, 284, 299, 319, 338, 355, 371, 389, 406, 421, 445, 464, 485, 501, 520, 541, 560} func (i NmDeviceType) String() string { if i >= NmDeviceType(len(_NmDeviceType_index)-1) { - return fmt.Sprintf("NmDeviceType(%d)", i) + return "NmDeviceType(" + strconv.FormatInt(int64(i), 10) + ")" } return _NmDeviceType_name[_NmDeviceType_index[i]:_NmDeviceType_index[i+1]] } diff --git a/nmstate_string.go b/nmstate_string.go index 42c467a..30dcaf4 100644 --- a/nmstate_string.go +++ b/nmstate_string.go @@ -1,8 +1,22 @@ -// Code generated by "stringer -type=NmState"; DO NOT EDIT +// Code generated by "stringer -type=NmState"; DO NOT EDIT. package gonetworkmanager -import "fmt" +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[NmStateUnknown-0] + _ = x[NmStateAsleep-10] + _ = x[NmStateDisconnected-20] + _ = x[NmStateDisconnecting-30] + _ = x[NmStateConnecting-40] + _ = x[NmStateConnectedLocal-50] + _ = x[NmStateConnectedSite-60] + _ = x[NmStateConnectedGlobal-70] +} const ( _NmState_name_0 = "NmStateUnknown" @@ -15,17 +29,6 @@ const ( _NmState_name_7 = "NmStateConnectedGlobal" ) -var ( - _NmState_index_0 = [...]uint8{0, 14} - _NmState_index_1 = [...]uint8{0, 13} - _NmState_index_2 = [...]uint8{0, 19} - _NmState_index_3 = [...]uint8{0, 20} - _NmState_index_4 = [...]uint8{0, 17} - _NmState_index_5 = [...]uint8{0, 21} - _NmState_index_6 = [...]uint8{0, 20} - _NmState_index_7 = [...]uint8{0, 22} -) - func (i NmState) String() string { switch { case i == 0: @@ -45,6 +48,6 @@ func (i NmState) String() string { case i == 70: return _NmState_name_7 default: - return fmt.Sprintf("NmState(%d)", i) + return "NmState(" + strconv.FormatInt(int64(i), 10) + ")" } }