tdb/toos: allow transactions with TDB_MUTEX_LOCKING
[obnox/samba/samba-obnox.git] / python / pyglue.c
index 735f03a1e16339cb4da3129d8fe1319963cea0ba..3fc6e38691f1e8a2df68de5f19a200e3fd52393b 100644 (file)
 
 void init_glue(void);
 
-#ifndef Py_RETURN_NONE
-#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
-#endif
-
 static PyObject *py_generate_random_str(PyObject *self, PyObject *args)
 {
        int len;
@@ -164,18 +160,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;