diff options
author | Radek Vykydal <rvykydal@redhat.com> | 2010-05-11 11:04:06 +0200 |
---|---|---|
committer | Radek Vykydal <rvykydal@redhat.com> | 2010-05-24 16:47:51 +0200 |
commit | 2f4eeebd17b33406aaa79a0e4c5f989db9a4a455 (patch) | |
tree | df5042fa2d30821b1aa8214c21cc057687807bab /isys | |
parent | 4a78447cae4474f8c04e5169aaa59e44452a318c (diff) | |
download | anaconda-2f4eeebd17b33406aaa79a0e4c5f989db9a4a455.tar.gz anaconda-2f4eeebd17b33406aaa79a0e4c5f989db9a4a455.tar.xz anaconda-2f4eeebd17b33406aaa79a0e4c5f989db9a4a455.zip |
Make ssid and wepkey in boot params and stage 1 kickstart work (#473803)
Diffstat (limited to 'isys')
-rw-r--r-- | isys/iface.c | 33 | ||||
-rw-r--r-- | isys/iface.h | 5 | ||||
-rw-r--r-- | isys/isys.c | 16 | ||||
-rwxr-xr-x | isys/isys.py | 22 |
4 files changed, 56 insertions, 20 deletions
diff --git a/isys/iface.c b/isys/iface.c index 58972869d..036910448 100644 --- a/isys/iface.c +++ b/isys/iface.c @@ -49,6 +49,7 @@ #include <nm-device.h> #include <nm-ip4-config.h> #include <nm-setting-ip4-config.h> +#include <nm-device-wifi.h> #include "isys.h" #include "iface.h" @@ -541,3 +542,35 @@ ifacemtu_error1: return ret; } + +/* + * Checks if interface is wireless + */ +int is_wireless_device(char *ifname){ + NMClient *client = NULL; + NMDevice *candidate = NULL; + const GPtrArray *devices; + const char *iface; + int i; + + client = nm_client_new(); + if (!client) { + return 0; + } + + devices = nm_client_get_devices(client); + for (i = 0; devices && (i < devices->len); i++) { + candidate = g_ptr_array_index(devices, i); + if (NM_IS_DEVICE_WIFI (candidate)) { + iface = nm_device_get_iface(candidate); + if (!strcmp(ifname, iface)) { + g_object_unref(client); + return 1; + } + } + + } + g_object_unref(client); + return 0; +} + diff --git a/isys/iface.h b/isys/iface.h index 820d10b36..d7ecc561d 100644 --- a/isys/iface.h +++ b/isys/iface.h @@ -163,4 +163,9 @@ int iface_start_NetworkManager(void); */ int iface_set_interface_mtu(char *ifname, int mtu); +/* + * Checks if interface is wireless + */ +int is_wireless_device(char *ifname); + #endif /* ISYSIFACE_H */ diff --git a/isys/isys.c b/isys/isys.c index ca3fb0d06..6aeb72f78 100644 --- a/isys/isys.c +++ b/isys/isys.c @@ -113,6 +113,7 @@ static PyObject * doIsCapsLockEnabled(PyObject * s, PyObject * args); static PyObject * doGetLinkStatus(PyObject * s, PyObject * args); static PyObject * doGetAnacondaVersion(PyObject * s, PyObject * args); static PyObject * doInitLog(PyObject * s); +static PyObject * doIsWirelessDevice(PyObject * s, PyObject * args); static PyMethodDef isysModuleMethods[] = { { "ejectcdrom", (PyCFunction) doEjectCdrom, METH_VARARGS, NULL }, @@ -145,6 +146,7 @@ static PyMethodDef isysModuleMethods[] = { { "getLinkStatus", (PyCFunction) doGetLinkStatus, METH_VARARGS, NULL }, { "getAnacondaVersion", (PyCFunction) doGetAnacondaVersion, METH_VARARGS, NULL }, { "initLog", (PyCFunction) doInitLog, METH_VARARGS, NULL }, + { "isWirelessDevice", (PyCFunction) doIsWirelessDevice, METH_VARARGS, NULL }, { NULL, NULL, 0, NULL } } ; @@ -699,4 +701,18 @@ static PyObject * doInitLog(PyObject * s) { return Py_None; } +static PyObject * doIsWirelessDevice(PyObject * s, PyObject * args) { + char *dev = NULL; + + if (!PyArg_ParseTuple(args, "s", &dev)) { + return NULL; + } + + if (is_wireless_device(dev) == 1) { + return PyBool_FromLong(1); + } + + return PyBool_FromLong(0); +} + /* vim:set shiftwidth=4 softtabstop=4: */ diff --git a/isys/isys.py b/isys/isys.py index cddb916bd..e037112b2 100755 --- a/isys/isys.py +++ b/isys/isys.py @@ -436,26 +436,8 @@ def getNetDevDesc(dev): return desc # Determine if a network device is a wireless device. -def isWireless(dev): - if dev == '' or dev is None: - return False - - device_props_iface = getDeviceProperties(dev=dev) - if device_props_iface is None: - return None - - device_type = int(device_props_iface.Get(NM_MANAGER_IFACE, "DeviceType")) - - # from include/NetworkManager.h in the NM source code - # 0 == NM_DEVICE_TYPE_UNKNOWN - # 1 == NM_DEVICE_TYPE_ETHERNET - # 2 == NM_DEVICE_TYPE_WIFI - # 3 == NM_DEVICE_TYPE_GSM - # 4 == NM_DEVICE_TYPE_CDMA - if device_type == 2: - return True - else: - return False +def isWirelessDevice(dev): + return _isys.isWirelessDevice(dev) # Get the IP address for a network device. def getIPAddress(dev): |