From 3098fca44439e16de9ba922e1683a31d94e4c833 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 18 Jan 2010 17:24:05 -0800 Subject: [PATCH] (SIGAR-199) add arp_list Python binding --- bindings/python/_sigar.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/bindings/python/_sigar.c b/bindings/python/_sigar.c index 3af2b32c..0ba7df54 100644 --- a/bindings/python/_sigar.c +++ b/bindings/python/_sigar.c @@ -192,6 +192,29 @@ static PyObject *pysigar_net_interface_list(PyObject *self, PyObject *args) return RETVAL; } +static PyObject *pysigar_arp_list(PyObject *self, PyObject *args) +{ + int status; + sigar_t *sigar = PySIGAR; + sigar_arp_list_t arplist; + PyObject *RETVAL; + + status = sigar_arp_list_get(sigar, &arplist); + if (status != SIGAR_OK) { + PySigar_Croak(); + return NULL; + } + + RETVAL = pysigar_new_list((char *)&arplist.data[0], + arplist.number, + sizeof(*arplist.data), + &pysigar_PySigarArpType); + + sigar_arp_list_destroy(sigar, &arplist); + + return RETVAL; +} + static PyObject *pysigar_format_size(PyObject *self, PyObject *args) { char buffer[56]; @@ -209,6 +232,7 @@ static PyMethodDef pysigar_methods[] = { { "close", pysigar_close, METH_NOARGS, NULL }, { "net_interface_list", pysigar_net_interface_list, METH_NOARGS, NULL }, { "file_system_list", pysigar_file_system_list, METH_NOARGS, NULL }, + { "arp_list", pysigar_arp_list, METH_NOARGS, NULL }, PY_SIGAR_METHODS {NULL} };