blob: 27b5183a9795e8c09a987382fe4ab738f306f2e3 [file] [log] [blame]
diff --git csrc/util/ccnd-autoconfig.sh csrc/util/ccnd-autoconfig.sh
new file mode 100755
index 0000000..648e866
--- /dev/null
+++ csrc/util/ccnd-autoconfig.sh
@@ -0,0 +1,44 @@
+# 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"
+
+# Removing any previously existed default route
+for i in `ccndstatus | grep "ccnx:/ face" | awk '{print $3}'`; do ccndc destroy 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
+
+ # destroying multicast face
+ ccndstatus | grep 224.0.23.170:59695 | awk '{print $2}' | xargs ccndc destroy face
+ exit 1
+fi
+
+echo Setting default route to a local hub: "$info"
+echo "$info" | xargs ccndc add / udp
+
+# destroying multicast face
+ccndstatus | grep 224.0.23.170:59695 | awk '{print $2}' | xargs ccndc destroy face
+
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)