summaryrefslogtreecommitdiff
path: root/package/network
diff options
context:
space:
mode:
authorSteven Barth <cyrus@openwrt.org>2015-09-01 18:48:22 +0000
committerSteven Barth <cyrus@openwrt.org>2015-09-01 18:48:22 +0000
commit7e009c15988cc1ef19b5593cecd2f9187c9849a7 (patch)
tree5fa6a2e4de0a4569967d1ddde56e713894822007 /package/network
parent37160e21bbace045119b0733fe853e9cdb56ab02 (diff)
downloadmtk-20170518-7e009c15988cc1ef19b5593cecd2f9187c9849a7.zip
mtk-20170518-7e009c15988cc1ef19b5593cecd2f9187c9849a7.tar.gz
mtk-20170518-7e009c15988cc1ef19b5593cecd2f9187c9849a7.tar.bz2
map: add debug-code for mapcalc
Signed-off-by: Steven Barth <steven@midlink.org> SVN-Revision: 46763
Diffstat (limited to 'package/network')
-rw-r--r--package/network/ipv6/map/Makefile2
-rw-r--r--package/network/ipv6/map/src/mapcalc.c46
2 files changed, 29 insertions, 19 deletions
diff --git a/package/network/ipv6/map/Makefile b/package/network/ipv6/map/Makefile
index 3757ed6..a45e9bc 100644
--- a/package/network/ipv6/map/Makefile
+++ b/package/network/ipv6/map/Makefile
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=map
PKG_VERSION:=4
-PKG_RELEASE:=2
+PKG_RELEASE:=3
PKG_LICENSE:=GPL-2.0
include $(INCLUDE_DIR)/package.mk
diff --git a/package/network/ipv6/map/src/mapcalc.c b/package/network/ipv6/map/src/mapcalc.c
index cd72138..b9fab4d 100644
--- a/package/network/ipv6/map/src/mapcalc.c
+++ b/package/network/ipv6/map/src/mapcalc.c
@@ -157,6 +157,8 @@ enum {
OPT_PSID,
OPT_BR,
OPT_DMR,
+ OPT_PD,
+ OPT_PDLEN,
OPT_MAX
};
@@ -173,6 +175,8 @@ static char *const token[] = {
[OPT_PSID] = "psid",
[OPT_BR] = "br",
[OPT_DMR] = "dmr",
+ [OPT_PD] = "pd",
+ [OPT_PDLEN] = "pdlen",
[OPT_MAX] = NULL
};
@@ -239,10 +243,14 @@ int main(int argc, char *argv[])
// dummy
} else if (idx == OPT_IPV6PREFIX && inet_pton(AF_INET6, value, &ipv6prefix) == 1) {
// dummy
+ } else if (idx == OPT_PD && inet_pton(AF_INET6, value, &pd) == 1) {
+ // dummy
} else if (idx == OPT_OFFSET && (intval = strtoul(value, NULL, 0)) <= 16 && !errno) {
offset = intval;
} else if (idx == OPT_PSIDLEN && (intval = strtoul(value, NULL, 0)) <= 16 && !errno) {
psidlen = intval;
+ } else if (idx == OPT_PDLEN && (intval = strtoul(value, NULL, 0)) <= 128 && !errno) {
+ pdlen = intval;
} else if (idx == OPT_PSID && (intval = strtoul(value, NULL, 0)) <= 65535 && !errno) {
psid = intval;
} else if (idx == OPT_DMR) {
@@ -270,24 +278,26 @@ int main(int argc, char *argv[])
}
// Find PD
- struct blob_attr *c;
- unsigned rem;
- blobmsg_for_each_attr(c, dump, rem) {
- struct blob_attr *tb[IFACE_ATTR_MAX];
- blobmsg_parse(iface_attrs, IFACE_ATTR_MAX, tb, blobmsg_data(c), blobmsg_data_len(c));
-
- if (!tb[IFACE_ATTR_INTERFACE] || (strcmp(argv[1], "*") && strcmp(argv[1],
- blobmsg_get_string(tb[IFACE_ATTR_INTERFACE]))))
- continue;
-
- match_prefix(&pdlen, &pd, tb[IFACE_ATTR_PREFIX], &ipv6prefix, prefix6len);
-
- if (lw4o6)
- match_prefix(&pdlen, &pd, tb[IFACE_ATTR_ADDRESS], &ipv6prefix, prefix6len);
-
- if (pdlen >= 0) {
- iface = blobmsg_get_string(tb[IFACE_ATTR_INTERFACE]);
- break;
+ if (pdlen < 0) {
+ struct blob_attr *c;
+ unsigned rem;
+ blobmsg_for_each_attr(c, dump, rem) {
+ struct blob_attr *tb[IFACE_ATTR_MAX];
+ blobmsg_parse(iface_attrs, IFACE_ATTR_MAX, tb, blobmsg_data(c), blobmsg_data_len(c));
+
+ if (!tb[IFACE_ATTR_INTERFACE] || (strcmp(argv[1], "*") && strcmp(argv[1],
+ blobmsg_get_string(tb[IFACE_ATTR_INTERFACE]))))
+ continue;
+
+ match_prefix(&pdlen, &pd, tb[IFACE_ATTR_PREFIX], &ipv6prefix, prefix6len);
+
+ if (lw4o6)
+ match_prefix(&pdlen, &pd, tb[IFACE_ATTR_ADDRESS], &ipv6prefix, prefix6len);
+
+ if (pdlen >= 0) {
+ iface = blobmsg_get_string(tb[IFACE_ATTR_INTERFACE]);
+ break;
+ }
}
}