+static bool
+load_extension(struct fw3_ipt_handle *h, const char *name)
+{
+ char path[256];
+ void *lib, **tmp;
+ const char *pfx = (h->family == FW3_FAMILY_V6) ? "libip6t" : "libipt";
+
+ snprintf(path, sizeof(path), "/usr/lib/iptables/libxt_%s.so", name);
+ if (!(lib = dlopen(path, RTLD_NOW)))
+ {
+ snprintf(path, sizeof(path), "/usr/lib/iptables/%s_%s.so", pfx, name);
+ lib = dlopen(path, RTLD_NOW);
+ }
+
+ if (!lib)
+ return false;
+
+ tmp = realloc(h->libv, sizeof(lib) * (h->libc + 1));
+
+ if (!tmp)
+ return false;
+
+ h->libv = tmp;
+ h->libv[h->libc++] = lib;
+
+ return true;
+}
+