blob: 27b5183a9795e8c09a987382fe4ab738f306f2e3 [file] [log] [blame]
Alexander Afanasyeva556d7e2012-10-03 17:35:08 -07001diff --git csrc/util/ccnd-autoconfig.sh csrc/util/ccnd-autoconfig.sh
2new file mode 100755
Alexander Afanasyev72af1bf2012-10-04 12:14:10 -07003index 0000000..648e866
Alexander Afanasyeva556d7e2012-10-03 17:35:08 -07004--- /dev/null
5+++ csrc/util/ccnd-autoconfig.sh
Alexander Afanasyev72af1bf2012-10-04 12:14:10 -07006@@ -0,0 +1,44 @@
Alexander Afanasyeva556d7e2012-10-03 17:35:08 -07007+# Source file: util/ccnd-autoconfig.sh
8+#
9+# Script that tries to (automatically) discover of a local ccnd gateway
10+#
11+# Part of the CCNx distribution.
12+#
13+# Copyright (C) 2012 Palo Alto Research Center, Inc.
14+#
15+# This work is free software; you can redistribute it and/or modify it under
16+# the terms of the GNU General Public License version 2 as published by the
17+# Free Software Foundation.
18+# This work is distributed in the hope that it will be useful, but WITHOUT ANY
19+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20+# FOR A PARTICULAR PURPOSE.
21+
22+# This script should be installed in the same place as ccnd, ccndc, ccndsmoketest, ...
23+# adjust the path to get consistency.
24+D=`dirname "$0"`
25+export PATH="$D:$PATH"
26+
Alexander Afanasyev72af1bf2012-10-04 12:14:10 -070027+# Removing any previously existed default route
28+for i in `ccndstatus | grep "ccnx:/ face" | awk '{print $3}'`; do ccndc destroy face $i; done
29+
Alexander Afanasyeva556d7e2012-10-03 17:35:08 -070030+# Set temporary multicast face
31+ccndc -t 10 add "/local/ndn" udp 224.0.23.170 59695
32+
33+# Get info from local hub, if available
34+info=`ccncat -s 2 /local/ndn/udp`
35+if [ "x$info" = "x" ]; then
36+ echo "Local hub is not availble, trying to use DNS to get local configuration"
37+ # Try to use DNS search list to get default route information
38+ ccndc srv
Alexander Afanasyev72af1bf2012-10-04 12:14:10 -070039+
40+ # destroying multicast face
41+ ccndstatus | grep 224.0.23.170:59695 | awk '{print $2}' | xargs ccndc destroy face
Alexander Afanasyeva556d7e2012-10-03 17:35:08 -070042+ exit 1
43+fi
44+
45+echo Setting default route to a local hub: "$info"
46+echo "$info" | xargs ccndc add / udp
Alexander Afanasyev72af1bf2012-10-04 12:14:10 -070047+
48+# destroying multicast face
49+ccndstatus | grep 224.0.23.170:59695 | awk '{print $2}' | xargs ccndc destroy face
50+
Alexander Afanasyeva556d7e2012-10-03 17:35:08 -070051diff --git csrc/util/ccnd-publish-local-info.sh csrc/util/ccnd-publish-local-info.sh
52new file mode 100755
Alexander Afanasyev72af1bf2012-10-04 12:14:10 -070053index 0000000..b433f69
Alexander Afanasyeva556d7e2012-10-03 17:35:08 -070054--- /dev/null
55+++ csrc/util/ccnd-publish-local-info.sh
56@@ -0,0 +1,34 @@
57+# Source file: util/ccnd-autoconfig.sh
58+#
59+# Script to publish information about local ccnd gateway in local repo (should be run only on ccnd gateway nodes)
60+#
61+# Part of the CCNx distribution.
62+#
63+# Copyright (C) 2012 Palo Alto Research Center, Inc.
64+#
65+# This work is free software; you can redistribute it and/or modify it under
66+# the terms of the GNU General Public License version 2 as published by the
67+# Free Software Foundation.
68+# This work is distributed in the hope that it will be useful, but WITHOUT ANY
69+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
70+# FOR A PARTICULAR PURPOSE.
71+
72+# This script should be installed in the same place as ccnd, ccndc, ccndsmoketest, ...
73+# adjust the path to get consistency.
74+D=`dirname "$0"`
75+export PATH="$D:$PATH"
76+
77+#
78+
79+udp_face_info=$1
80+local_prefix=$2
81+
82+if [ "x$udp_face_info" = "x" -o "x$local_prefix" = "x" ]; then
83+ echo "Usage: "
84+ echo " " $0 " <udp_face_info> <routable_prefix>"
85+ exit 1
86+fi
87+
Alexander Afanasyev72af1bf2012-10-04 12:14:10 -070088+echo $udp_face_info | ccnseqwriter -c 1 -r -x 5 "/local/ndn/udp"
89+echo $local_prefix | ccnseqwriter -c 1 -r -x 5 "/local/ndn/prefix"
Alexander Afanasyeva556d7e2012-10-03 17:35:08 -070090+
91diff --git csrc/util/dir.mk csrc/util/dir.mk
92index f29038f..94bc7b6 100644
93--- csrc/util/dir.mk
94+++ csrc/util/dir.mk
95@@ -14,8 +14,10 @@
96
97 SCRIPTSRC = shebang \
98 ccndstart.sh ccndstop.sh ccndstatus.sh ccndlogging.sh ccnget.sh ccnput.sh \
99- ccntestloop-trampoline
100-PROGRAMS = ccndstart ccndstop ccndstatus ccntestloop ccndlogging ccnget ccnput
101+ ccntestloop-trampoline \
102+ ccnd-autoconfig.sh ccnd-publish-local-info.sh
103+
104+PROGRAMS = ccndstart ccndstop ccndstatus ccntestloop ccndlogging ccnget ccnput ccnd-autoconfig ccnd-publish-local-info
105 INSTALLED_PROGRAMS = $(PROGRAMS)
106
107 default all: $(SCRIPTSRC) $(PROGRAMS)