summaryrefslogtreecommitdiffstats
path: root/src/sysinfolibsysfs.cpp
blob: feacd30aa1df79394be7b36503b45c9fbb52fe04 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * sysinfolibsysfs.cpp
 *
 *  Created on: Mar 23, 2011
 *      Author: niklas
 */

#include "sysinfolibsysfs.h"

SysInfoLibsysfs::SysInfoLibsysfs() {
	// TODO Auto-generated constructor stub

}

SysInfoLibsysfs::~SysInfoLibsysfs() {
	// TODO Auto-generated destructor stub
}

void SysInfoLibsysfs::getInfoAboutNetworkInterface()
{
	struct sysfs_class_device *class_device = sysfs_open_class_device("net","eth0");
	struct dlist *attrlist = sysfs_get_classdev_attributes(class_device);
	struct sysfs_device *device = sysfs_get_classdev_device(class_device);
	//struct sysfs_driver *driver = sysfs_get_classdev_driver(class_device);
	if(device == NULL) {
		qDebug() << "device is NULL!";
	}
	else {
		qDebug() << "--- print eth0 device path:";
		qDebug() << QString(device->path);
	}

	sysfs_close_class_device(class_device);
}

void SysInfoLibsysfs::getInfoAboutClassNet()
{
	struct sysfs_class *sysfsclass = sysfs_open_class("net");
	struct dlist *devices = sysfs_get_class_devices(sysfsclass);
	struct sysfs_device *dev = NULL;
	dlist_for_each_data(devices,dev, struct sysfs_device) {
		if(dev == NULL) {
			qDebug() << "device is NULL!";
		}
		else {
			qDebug() << "--- print device:";
			qDebug() << QString(dev->name);
		}
	}

	sysfs_close_class(sysfsclass);
}