/*
* ucimap-example - sample code for the ucimap library
- * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ * Copyright (C) 2008-2009 Felix Fietkau <nbd@openwrt.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
#include <stdlib.h>
#include <unistd.h>
#include <ucimap.h>
+#include "list.h"
struct list_head ifs;
}
static int
-network_format_ip(void *sction, struct uci_optmap *om, union ucimap_data *data, char **str)
+network_format_ip(void *section, struct uci_optmap *om, union ucimap_data *data, char **str)
{
static char buf[16];
unsigned char *ip = (unsigned char *) data->data[0];
list_for_each(p, &ifs) {
const unsigned char *ipaddr;
+ int n_aliases = 0;
net = list_entry(p, struct uci_network, list);
ipaddr = net->ipaddr;
printf("\n");
}
list_for_each_entry(alias, &net->alias, list) {
+ n_aliases++;
for (i = 0; i < net->aliases->n_items; i++) {
if (alias == net->aliases->item[i].ptr)
goto next_alias;
if (set && !strcmp(net->name, "lan")) {
ucimap_free_item(&net->map, &net->ipaddr);
ucimap_set_changed(&net->map, &net->ipaddr);
+ ucimap_resize_list(&net->map, &net->aliases, n_aliases);
+ net->aliases->n_items = 0;
+ list_for_each_entry(alias, &net->alias, list) {
+ net->aliases->item[net->aliases->n_items++].ptr = alias;
+ }
+ ucimap_set_changed(&net->map, &net->aliases);
ucimap_store_section(&network_map, pkg, &net->map);
uci_save(ctx, pkg);
}