bool
fw3_parse_device(void *ptr, const char *val, bool is_list)
{
+ char *p;
struct fw3_device dev = { };
if (*val == '*')
while (isspace(*++val));
}
+ if ((p = strchr(val, '@')) != NULL)
+ {
+ *p++ = 0;
+ snprintf(dev.network, sizeof(dev.network), "%s", p);
+ }
+
if (*val)
snprintf(dev.name, sizeof(dev.name), "%s", val);
else
bool any;
bool invert;
char name[32];
- struct fw3_device *network;
+ char network[32];
};
struct fw3_address
if (dev->invert)
p += sprintf(p, "!");
- p += sprintf(p, "%s", dev->name);
+ if (*dev->network)
+ p += sprintf(p, "%s@%s", dev->name, dev->network);
+ else
+ p += sprintf(p, "%s", dev->name);
ptr.value = buf;
uci_add_list(ctx, &ptr);
struct fw3_zone *z = zone;
struct fw3_device *d = device;
- if (!d->network)
+ if (!*d->network)
return false;
switch (fork())
clearenv();
setenv("ACTION", add ? "add" : "remove", 1);
setenv("ZONE", z->name, 1);
- setenv("INTERFACE", d->network->name, 1);
+ setenv("INTERFACE", d->network, 1);
setenv("DEVICE", d->name, 1);
execl(FW3_HOTPLUG, FW3_HOTPLUG, "firewall", NULL);
continue;
}
- tmp->network = net;
+ snprintf(tmp->network, sizeof(tmp->network), "%s", net->name);
list_add_tail(&tmp->list, &zone->devices);
}
}
struct fw3_zone *z;
struct fw3_device *d;
- if (add)
+ list_for_each_entry(z, &state->zones, list)
{
- list_for_each_entry(z, &state->zones, list)
+ if (add != hasbit(z->flags[0], FW3_FLAG_HOTPLUG))
{
- if (!hasbit(z->flags[0], FW3_FLAG_HOTPLUG))
- {
- list_for_each_entry(d, &z->devices, list)
- fw3_hotplug(add, z, d);
+ list_for_each_entry(d, &z->devices, list)
+ fw3_hotplug(add, z, d);
+ if (add)
setbit(z->flags[0], FW3_FLAG_HOTPLUG);
- }
- }
- }
- else
- {
- list_for_each_entry(z, &state->zones, list)
- {
- if (hasbit(z->flags[0], FW3_FLAG_HOTPLUG))
- {
- list_for_each_entry(d, &z->devices, list)
- fw3_hotplug(add, z, d);
-
+ else
delbit(z->flags[0], FW3_FLAG_HOTPLUG);
- }
}
}
}