Wifx / gonetworkmanager

Go D-Bus bindings for NetworkManager
Other
96 stars 42 forks source link

Define some contants necessary to access types/settings maps etc #22

Open ijc opened 3 years ago

ijc commented 3 years ago

The C library has a bunch of #defines for keys used in various maps. e.g. from nm-setting-wireless.h:

#define NM_SETTING_WIRELESS_SETTING_NAME "802-11-wireless"

...

#define NM_SETTING_WIRELESS_SSID                      "ssid"
#define NM_SETTING_WIRELESS_MODE                      "mode"
#define NM_SETTING_WIRELESS_BAND                      "band"
#define NM_SETTING_WIRELESS_CHANNEL                   "channel"
#define NM_SETTING_WIRELESS_BSSID                     "bssid"

Could these bindings define a similar set of Go consts to reduce the possibility of typos? Or would specific getter methods be more appropriate?

There are also various defines and enums etc for values, such as:

#define NM_SETTING_WIRELESS_MODE_ADHOC "adhoc"

....

typedef enum {                                                            /*< flags >*/
    NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE                 = 0, /*< skip >*/
    NM_SETTING_WIRELESS_WAKE_ON_WLAN_ANY                  = 0x2,
    NM_SETTING_WIRELESS_WAKE_ON_WLAN_DISCONNECT           = 0x4,
    NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC                = 0x8,
...
} NMSettingWirelessWakeOnWLan;

There are lots of nm-setting-*.h though and it would be a lot to maintain all of them, but perhaps ad-hoc/as needed coverage could be acceptable?

everactivemilligan commented 3 years ago

Something like this might ease the burden:

https://github.com/elliotchance/c2go

We have used it in the past to "import" some headers w/ defines.