summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sommerseth <davids@redhat.com>2014-01-09 19:50:05 +0100
committerDavid Sommerseth <davids@redhat.com>2014-01-09 19:50:05 +0100
commit8156c8880b5148fe2ea19950b2229e1bb80b431c (patch)
tree1a4dac301e3f58fac281bdad8f2f2fde0d859e82
parenta5308a1856bbf5268b9f51c87ec3da032c371a6f (diff)
downloadpython-ethtool-8156c8880b5148fe2ea19950b2229e1bb80b431c.tar.gz
python-ethtool-8156c8880b5148fe2ea19950b2229e1bb80b431c.tar.xz
python-ethtool-8156c8880b5148fe2ea19950b2229e1bb80b431c.zip
cleanup: Rename etherinfo_py and ethtool_etherinfo_Type
Use PyEtherInfo and PyEtherInfoType the base names, to more easily see their relation, and more clearly indicate they are Python objects. Also remove an initialisation of PyEtherInfo/etherinfo_py not needed any more. Signed-off-by: David Sommerseth <davids@redhat.com>
-rw-r--r--python-ethtool/etherinfo.c16
-rw-r--r--python-ethtool/etherinfo.h8
-rw-r--r--python-ethtool/etherinfo_obj.c26
-rw-r--r--python-ethtool/etherinfo_obj.h10
-rw-r--r--python-ethtool/etherinfo_struct.h2
-rw-r--r--python-ethtool/ethtool.c10
-rw-r--r--python-ethtool/netlink.c8
7 files changed, 39 insertions, 41 deletions
diff --git a/python-ethtool/etherinfo.c b/python-ethtool/etherinfo.c
index 224cb26..bac0fe7 100644
--- a/python-ethtool/etherinfo.c
+++ b/python-ethtool/etherinfo.c
@@ -51,7 +51,7 @@
*/
static void callback_nl_link(struct nl_object *obj, void *arg)
{
- etherinfo_py *ethi = (etherinfo_py *) arg;
+ PyEtherInfo *ethi = (PyEtherInfo *) arg;
struct rtnl_link *link = (struct rtnl_link *) obj;
char hwaddr[130];
@@ -108,12 +108,12 @@ static void callback_nl_address(struct nl_object *obj, void *arg)
/**
* Sets the etherinfo.index member to the corresponding device set in etherinfo.device
*
- * @param self A pointer the current etherinfo_py Python object which contains the device name
+ * @param self A pointer the current PyEtherInfo Python object which contains the device name
* and the place where to save the corresponding index value.
*
* @return Returns 1 on success, otherwise 0.
*/
-static int _set_device_index(etherinfo_py *self)
+static int _set_device_index(PyEtherInfo *self)
{
struct nl_cache *link_cache;
struct rtnl_link *link;
@@ -153,13 +153,13 @@ static int _set_device_index(etherinfo_py *self)
*/
/**
- * Populate the etherinfo_py Python object with link information for the current device
+ * Populate the PyEtherInfo Python object with link information for the current device
*
- * @param self Pointer to the device object, a etherinfo_py Python object
+ * @param self Pointer to the device object, a PyEtherInfo Python object
*
* @return Returns 1 on success, otherwise 0
*/
-int get_etherinfo_link(etherinfo_py *self)
+int get_etherinfo_link(PyEtherInfo *self)
{
struct nl_cache *link_cache;
struct rtnl_link *link;
@@ -199,14 +199,14 @@ int get_etherinfo_link(etherinfo_py *self)
/**
* Query NETLINK for device IP address configuration
*
- * @param self A etherinfo_py Python object for the current device to retrieve IP address
+ * @param self A PyEtherInfo Python object for the current device to retrieve IP address
* configuration data from
* @param query What to query for. Must be NLQRY_ADDR4 for IPv4 addresses or NLQRY_ADDR6
* for IPv6 addresses.
*
* @return Returns a Python list containing PyNetlinkIPaddress objects on success, otherwise NULL
*/
-PyObject * get_etherinfo_address(etherinfo_py *self, nlQuery query)
+PyObject * get_etherinfo_address(PyEtherInfo *self, nlQuery query)
{
struct nl_cache *addr_cache;
struct rtnl_addr *addr;
diff --git a/python-ethtool/etherinfo.h b/python-ethtool/etherinfo.h
index 82b491f..d966819 100644
--- a/python-ethtool/etherinfo.h
+++ b/python-ethtool/etherinfo.h
@@ -19,11 +19,11 @@
typedef enum {NLQRY_ADDR4, NLQRY_ADDR6} nlQuery; /**< Supported query types in the etherinfo code */
-int get_etherinfo_link(etherinfo_py *data);
-PyObject * get_etherinfo_address(etherinfo_py *self, nlQuery query);
+int get_etherinfo_link(PyEtherInfo *data);
+PyObject * get_etherinfo_address(PyEtherInfo *self, nlQuery query);
-int open_netlink(etherinfo_py *);
+int open_netlink(PyEtherInfo *);
struct nl_sock * get_nlc();
-void close_netlink(etherinfo_py *);
+void close_netlink(PyEtherInfo *);
#endif
diff --git a/python-ethtool/etherinfo_obj.c b/python-ethtool/etherinfo_obj.c
index f2a43c1..f620157 100644
--- a/python-ethtool/etherinfo_obj.c
+++ b/python-ethtool/etherinfo_obj.c
@@ -34,9 +34,9 @@
/**
* ethtool.etherinfo deallocator - cleans up when a object is deleted
*
- * @param self etherinfo_py Python object to deallocate
+ * @param self PyEtherInfo Python object to deallocate
*/
-static void _ethtool_etherinfo_dealloc(etherinfo_py *self)
+static void _ethtool_etherinfo_dealloc(PyEtherInfo *self)
{
close_netlink(self);
Py_XDECREF(self->device); self->device = NULL;
@@ -79,12 +79,12 @@ static PyNetlinkIPaddress * get_last_ipv4_address(PyObject *addrlist)
/**
* ethtool.etherinfo function for retrieving data from a Python object.
*
- * @param self Pointer to the current etherinfo_py device object
+ * @param self Pointer to the current PyEtherInfo device object
* @param attr_o contains the object member request (which element to return)
*
* @return Returns a PyObject with the value requested on success, otherwise NULL
*/
-PyObject *_ethtool_etherinfo_getter(etherinfo_py *self, PyObject *attr_o)
+PyObject *_ethtool_etherinfo_getter(PyEtherInfo *self, PyObject *attr_o)
{
char *attr = PyString_AsString(attr_o);
PyNetlinkIPaddress *py_addr;
@@ -149,7 +149,7 @@ PyObject *_ethtool_etherinfo_getter(etherinfo_py *self, PyObject *attr_o)
*
* @return Returns always -1 (failure).
*/
-int _ethtool_etherinfo_setter(etherinfo_py *self, PyObject *attr_o, PyObject *val_o)
+int _ethtool_etherinfo_setter(PyEtherInfo *self, PyObject *attr_o, PyObject *val_o)
{
PyErr_SetString(PyExc_AttributeError, "etherinfo member values are read-only.");
return -1;
@@ -159,11 +159,11 @@ int _ethtool_etherinfo_setter(etherinfo_py *self, PyObject *attr_o, PyObject *va
/**
* Creates a human readable format of the information when object is being treated as a string
*
- * @param self Pointer to the current etherinfo_py device object
+ * @param self Pointer to the current PyEtherInfo device object
*
* @return Returns a PyObject with a string with all of the information
*/
-PyObject *_ethtool_etherinfo_str(etherinfo_py *self)
+PyObject *_ethtool_etherinfo_str(PyEtherInfo *self)
{
PyObject *ret = NULL;
PyObject *ipv4addrs = NULL, *ipv6addrs = NULL;
@@ -224,12 +224,12 @@ PyObject *_ethtool_etherinfo_str(etherinfo_py *self)
/**
* Returns a tuple list of configured IPv4 addresses
*
- * @param self Pointer to the current etherinfo_py device object to extract IPv4 info from
+ * @param self Pointer to the current PyEtherInfo device object to extract IPv4 info from
* @param notused
*
* @return Returns a Python tuple list of NetlinkIP4Address objects
*/
-static PyObject *_ethtool_etherinfo_get_ipv4_addresses(etherinfo_py *self, PyObject *notused) {
+static PyObject *_ethtool_etherinfo_get_ipv4_addresses(PyEtherInfo *self, PyObject *notused) {
if( !self ) {
PyErr_SetString(PyExc_AttributeError, "No data available");
return NULL;
@@ -242,12 +242,12 @@ static PyObject *_ethtool_etherinfo_get_ipv4_addresses(etherinfo_py *self, PyObj
/**
* Returns a tuple list of configured IPv6 addresses
*
- * @param self Pointer to the current etherinfo_py device object to extract IPv6 info from
+ * @param self Pointer to the current PyEtherInfo device object to extract IPv6 info from
* @param notused
*
* @return Returns a Python tuple list of NetlinkIP6Address objects
*/
-static PyObject *_ethtool_etherinfo_get_ipv6_addresses(etherinfo_py *self, PyObject *notused) {
+static PyObject *_ethtool_etherinfo_get_ipv6_addresses(PyEtherInfo *self, PyObject *notused) {
if( !self ) {
PyErr_SetString(PyExc_AttributeError, "No data available");
return NULL;
@@ -273,10 +273,10 @@ static PyMethodDef _ethtool_etherinfo_methods[] = {
* Definition of the functions a Python class/object requires.
*
*/
-PyTypeObject ethtool_etherinfoType = {
+PyTypeObject PyEtherInfo_Type = {
PyObject_HEAD_INIT(NULL)
.tp_name = "ethtool.etherinfo",
- .tp_basicsize = sizeof(etherinfo_py),
+ .tp_basicsize = sizeof(PyEtherInfo),
.tp_flags = Py_TPFLAGS_HAVE_CLASS,
.tp_dealloc = (destructor)_ethtool_etherinfo_dealloc,
.tp_str = (reprfunc)_ethtool_etherinfo_str,
diff --git a/python-ethtool/etherinfo_obj.h b/python-ethtool/etherinfo_obj.h
index ce77f79..6047f11 100644
--- a/python-ethtool/etherinfo_obj.h
+++ b/python-ethtool/etherinfo_obj.h
@@ -28,11 +28,11 @@
#include <Python.h>
#include "etherinfo_struct.h"
-void _ethtool_etherinfo_dealloc(etherinfo_py *);
+void _ethtool_etherinfo_dealloc(PyEtherInfo *);
PyObject *_ethtool_etherinfo_new(PyTypeObject *, PyObject *, PyObject *);
-int _ethtool_etherinfo_init(etherinfo_py *, PyObject *, PyObject *);
-PyObject *_ethtool_etherinfo_getter(etherinfo_py *, PyObject *);
-int _ethtool_etherinfo_setter(etherinfo_py *, PyObject *, PyObject *);
-PyObject *_ethtool_etherinfo_str(etherinfo_py *self);
+int _ethtool_etherinfo_init(PyEtherInfo *, PyObject *, PyObject *);
+PyObject *_ethtool_etherinfo_getter(PyEtherInfo *, PyObject *);
+int _ethtool_etherinfo_setter(PyEtherInfo *, PyObject *, PyObject *);
+PyObject *_ethtool_etherinfo_str(PyEtherInfo *self);
#endif
diff --git a/python-ethtool/etherinfo_struct.h b/python-ethtool/etherinfo_struct.h
index 542a2b2..bcad291 100644
--- a/python-ethtool/etherinfo_struct.h
+++ b/python-ethtool/etherinfo_struct.h
@@ -50,7 +50,7 @@ typedef struct {
int index; /**< NETLINK index reference */
PyObject *hwaddress; /**< string: HW address / MAC address of device */
unsigned short nlc_active; /**< Is this instance using NETLINK? */
-} etherinfo_py;
+} PyEtherInfo;
diff --git a/python-ethtool/ethtool.c b/python-ethtool/ethtool.c
index 146618f..65abb21 100644
--- a/python-ethtool/ethtool.c
+++ b/python-ethtool/ethtool.c
@@ -32,7 +32,7 @@
#include "etherinfo_obj.h"
#include "etherinfo.h"
-extern PyTypeObject ethtool_etherinfoType;
+extern PyTypeObject PyEtherInfo_Type;
#ifndef IFF_DYNAMIC
#define IFF_DYNAMIC 0x8000 /* dialup device with changing addresses*/
@@ -268,13 +268,13 @@ static PyObject *get_interfaces_info(PyObject *self __unused, PyObject *args) {
devlist = PyList_New(0);
for( i = 0; i < fetch_devs_len; i++ ) {
- etherinfo_py *dev = NULL;
+ PyEtherInfo *dev = NULL;
/* Store the device name and a reference to the NETLINK connection for
* objects to use when quering for device info
*/
- dev = PyObject_New(etherinfo_py, &ethtool_etherinfoType);
+ dev = PyObject_New(PyEtherInfo, &PyEtherInfo_Type);
if( !dev ) {
PyErr_SetString(PyExc_OSError, strerror(errno));
free(fetch_devs);
@@ -939,10 +939,8 @@ PyMODINIT_FUNC initethtool(void)
m = Py_InitModule3("ethtool", PyEthModuleMethods, "Python ethtool module");
// Prepare the ethtool.etherinfo class
- if (PyType_Ready(&ethtool_etherinfoType) < 0)
+ if (PyType_Ready(&PyEtherInfo_Type) < 0)
return;
- Py_INCREF(&ethtool_etherinfoType);
- PyModule_AddObject(m, "etherinfo", (PyObject *)&ethtool_etherinfoType);
// Prepare the ethtool IPv6 and IPv4 address types
if (PyType_Ready(&ethtool_netlink_ip_address_Type))
diff --git a/python-ethtool/netlink.c b/python-ethtool/netlink.c
index f24b312..9ba8338 100644
--- a/python-ethtool/netlink.c
+++ b/python-ethtool/netlink.c
@@ -33,11 +33,11 @@ static unsigned int nlconnection_users = 0; /* How many NETLINK users are activ
* for each etherinfo object being generated, and it will
* keep a separate file descriptor open for each object
*
- * @param ethi etherinfo_py structure (basically the "self" object)
+ * @param ethi PyEtherInfo structure (basically the "self" object)
*
* @return Returns 1 on success, otherwise 0.
*/
-int open_netlink(etherinfo_py *ethi)
+int open_netlink(PyEtherInfo *ethi)
{
if( !ethi ) {
return 0;
@@ -93,9 +93,9 @@ struct nl_sock * get_nlc()
* Closes the NETLINK connection. This should be called automatically whenever
* the corresponding etherinfo object is deleted.
*
- * @param ethi etherinfo_py structure (basically the "self" object)
+ * @param ethi PyEtherInfo structure (basically the "self" object)
*/
-void close_netlink(etherinfo_py *ethi)
+void close_netlink(PyEtherInfo *ethi)
{
if( !ethi || !nlconnection ) {
return;