summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2013-08-30 14:59:01 +0200
committerKarolin Seeger <kseeger@samba.org>2013-09-02 09:48:25 +0200
commit10c17840245d5604ef1e0c52b0f45fa43c9ad713 (patch)
tree45f614bbf33b0035f37b9f99abdbe3d2634c7202 /python
parentac1a309256d55e794d388080a15df3b5a72e2469 (diff)
downloadsamba-10c17840245d5604ef1e0c52b0f45fa43c9ad713.tar.gz
python/pyglue: filter out loopback and linklocal addresses unless all_interfaces is given
Bug: https://bugzilla.samba.org/show_bug.cgi?id=10030 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Bjoern Jacke <bj@sernet.de> (cherry picked from commit 0e6aca40413fb3cfd4300f282204a69743be4a65)
Diffstat (limited to 'python')
-rw-r--r--python/pyglue.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/python/pyglue.c b/python/pyglue.c
index 735f03a1e16..02fb005071a 100644
--- a/python/pyglue.c
+++ b/python/pyglue.c
@@ -164,18 +164,59 @@ static PyObject *py_interface_ips(PyObject *self, PyObject *args)
/* first count how many are not loopback addresses */
for (ifcount = i = 0; i<count; i++) {
const char *ip = iface_list_n_ip(ifaces, i);
- if (!(!all_interfaces && iface_list_same_net(ip, "127.0.0.1", "255.0.0.0"))) {
+
+ if (all_interfaces) {
ifcount++;
+ continue;
+ }
+
+ if (iface_list_same_net(ip, "127.0.0.1", "255.0.0.0")) {
+ continue;
+ }
+
+ if (iface_list_same_net(ip, "169.254.0.0", "255.255.0.0")) {
+ continue;
}
+
+ if (iface_list_same_net(ip, "::1", "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")) {
+ continue;
+ }
+
+ if (iface_list_same_net(ip, "fe80::", "ffff:ffff:ffff:ffff::")) {
+ continue;
+ }
+
+ ifcount++;
}
pylist = PyList_New(ifcount);
for (ifcount = i = 0; i<count; i++) {
const char *ip = iface_list_n_ip(ifaces, i);
- if (!(!all_interfaces && iface_list_same_net(ip, "127.0.0.1", "255.0.0.0"))) {
+
+ if (all_interfaces) {
PyList_SetItem(pylist, ifcount, PyString_FromString(ip));
ifcount++;
+ continue;
+ }
+
+ if (iface_list_same_net(ip, "127.0.0.1", "255.0.0.0")) {
+ continue;
+ }
+
+ if (iface_list_same_net(ip, "169.254.0.0", "255.255.0.0")) {
+ continue;
}
+
+ if (iface_list_same_net(ip, "::1", "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")) {
+ continue;
+ }
+
+ if (iface_list_same_net(ip, "fe80::", "ffff:ffff:ffff:ffff::")) {
+ continue;
+ }
+
+ PyList_SetItem(pylist, ifcount, PyString_FromString(ip));
+ ifcount++;
}
talloc_free(tmp_ctx);
return pylist;