summaryrefslogtreecommitdiffstats
path: root/python-ethtool/etherinfo_struct.h
blob: 8f9e2e56f9b760fa49e0b1c26dca179dee76386b (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
 * @file   etherinfo_struct.h
 * @author David Sommerseth <dsommers@wsdsommers.usersys.redhat.com>
 * @date   Fri Sep  4 19:06:06 2009
 *
 * @brief  Contains the internal ethtool.etherinfo data structure
 *
 */

#ifndef _ETHERINFO_STRUCT_H
#define _ETHERINFO_STRUCT_H


struct etherinfo {
	char *device;
	int index;
	char *hwaddress;
	char *ipv4_address;
	int ipv4_netmask;
	char *ipv4_broadcast;
	struct ipv6address *ipv6_addresses;
};

struct ipv6address {
	char *address;
	int netmask;
	int scope;
	struct ipv6address *next;
};

/*
 *  NETLINK connection handle and related information to be shared
 *  among all the instantiated etherinfo objects.
 */
struct _nlconnection {
	struct nl_handle *nlrt_handle;
};

/**
 * Contains the internal data structure of the
 * ethtool.etherinfo object.
 *
 */
struct etherinfo_obj_data {
	struct _nlconnection *nlc;	/**< Contains NETLINK connection info */
	struct etherinfo *ethinfo;      /**< Contains info about our current interface */
};

typedef struct {
	PyObject_HEAD
	struct etherinfo_obj_data *data;
} etherinfo_py;


typedef struct {
	PyObject_HEAD
	struct ipv6address *addrdata;
} etherinfo_ipv6_py;

/**
 * NULL safe PyString_FromString() wrapper.  If input string is NULL, None will be returned
 *
 * @param str Input C string (char *)
 *
 * @return Returns a PyObject with either the input string wrapped up, or a Python None value.
 */
#define RETURN_STRING(str) (str ? PyString_FromString(str) : Py_None)

#endif