blob: d338aebb9e9ddfb1195cffa374778b819d83067e [file] [log] [blame]
diff --git csrc/libexec/ccndc.c csrc/libexec/ccndc.c
index ecde5f0..9b91c65 100644
--- csrc/libexec/ccndc.c
+++ csrc/libexec/ccndc.c
@@ -649,6 +649,19 @@ ccndc_srv(struct ccndc_data *self,
if (res < 0) {
ccndc_warn(__LINE__, "Cannot register prefix [%s]\n", ccn_charbuf_as_string(uri));
}
+
+ ccn_charbuf_destroy (&uri);
+ uri = ccn_charbuf_create();
+ ccn_charbuf_append_string(uri, "ccnx:/autoconf-route");
+ if (domain_size != 0) {
+ ccn_uri_append_percentescaped(uri, domain, domain_size);
+ }
+ prefix->name_prefix = uri;
+
+ res = ccndc_do_prefix_action(self, "prefixreg", prefix);
+ if (res < 0) {
+ ccndc_warn(__LINE__, "Cannot register prefix [%s]\n", ccn_charbuf_as_string(uri));
+ }
Cleanup:
free(uri);
diff --git csrc/util/ccnd-autoconfig.sh csrc/util/ccnd-autoconfig.sh
new file mode 100755
index 0000000..2bef939
--- /dev/null
+++ csrc/util/ccnd-autoconfig.sh
@@ -0,0 +1,55 @@
+# Source file: util/ccnd-autoconfig.sh
+#
+# Script that tries to (automatically) discover of a local ccnd gateway
+#
+# Part of the CCNx distribution.
+#
+# Copyright (C) 2012 Palo Alto Research Center, Inc.
+#
+# This work is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License version 2 as published by the
+# Free Software Foundation.
+# This work is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.
+
+# This script should be installed in the same place as ccnd, ccndc, ccndsmoketest, ...
+# adjust the path to get consistency.
+D=`dirname "$0"`
+export PATH="$D:$PATH"
+
+ccndstatus | grep 224.0.23.170:59695 > /dev/null
+MCAST_EXISTED=$?
+
+# Removing any previously created (either by this script or ccndc srv command) default route
+for i in `ccndstatus | grep "ccnx:/autoconf-route face" | awk '{print $3}'`; do
+ ccndc del / face $i
+ ccndc del /autoconf-route face $i
+done
+
+# Set temporary multicast face
+ccndc -t 10 add "/local/ndn" udp 224.0.23.170 59695
+
+# Get info from local hub, if available
+info=`ccncat -s 2 /local/ndn/udp`
+if [ "x$info" = "x" ]; then
+ echo "Local hub is not availble, trying to use DNS to get local configuration"
+ # Try to use DNS search list to get default route information
+ ccndc srv
+
+ if [ ! $MCAST_EXISTED ]; then
+ # destroying multicast face
+ ccndstatus | grep 224.0.23.170:59695 | awk '{print $2}' | xargs ccndc destroy face
+ fi
+ exit 1
+fi
+
+echo Setting default route to a local hub: "$info"
+echo "$info" | xargs ccndc add / udp
+echo "$info" | xargs ccndc add /autoconf-route udp
+
+if [ ! $MCAST_EXISTED ]; then
+ # destroying multicast face
+ ccndstatus | grep 224.0.23.170:59695 | awk '{print $2}' | xargs ccndc destroy face
+fi
+
diff --git csrc/util/ccnd-publish-local-info.sh csrc/util/ccnd-publish-local-info.sh
new file mode 100755
index 0000000..b433f69
--- /dev/null
+++ csrc/util/ccnd-publish-local-info.sh
@@ -0,0 +1,34 @@
+# Source file: util/ccnd-autoconfig.sh
+#
+# Script to publish information about local ccnd gateway in local repo (should be run only on ccnd gateway nodes)
+#
+# Part of the CCNx distribution.
+#
+# Copyright (C) 2012 Palo Alto Research Center, Inc.
+#
+# This work is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License version 2 as published by the
+# Free Software Foundation.
+# This work is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.
+
+# This script should be installed in the same place as ccnd, ccndc, ccndsmoketest, ...
+# adjust the path to get consistency.
+D=`dirname "$0"`
+export PATH="$D:$PATH"
+
+#
+
+udp_face_info=$1
+local_prefix=$2
+
+if [ "x$udp_face_info" = "x" -o "x$local_prefix" = "x" ]; then
+ echo "Usage: "
+ echo " " $0 " <udp_face_info> <routable_prefix>"
+ exit 1
+fi
+
+echo $udp_face_info | ccnseqwriter -c 1 -r -x 5 "/local/ndn/udp"
+echo $local_prefix | ccnseqwriter -c 1 -r -x 5 "/local/ndn/prefix"
+
diff --git csrc/util/dir.mk csrc/util/dir.mk
index f29038f..94bc7b6 100644
--- csrc/util/dir.mk
+++ csrc/util/dir.mk
@@ -14,8 +14,10 @@
SCRIPTSRC = shebang \
ccndstart.sh ccndstop.sh ccndstatus.sh ccndlogging.sh ccnget.sh ccnput.sh \
- ccntestloop-trampoline
-PROGRAMS = ccndstart ccndstop ccndstatus ccntestloop ccndlogging ccnget ccnput
+ ccntestloop-trampoline \
+ ccnd-autoconfig.sh ccnd-publish-local-info.sh
+
+PROGRAMS = ccndstart ccndstop ccndstatus ccntestloop ccndlogging ccnget ccnput ccnd-autoconfig ccnd-publish-local-info
INSTALLED_PROGRAMS = $(PROGRAMS)
default all: $(SCRIPTSRC) $(PROGRAMS)