blob: 9c0d1169f5c37c3ab7763ad366578039caf67519 [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
3index 0000000..de31ba8
4--- /dev/null
5+++ csrc/util/ccnd-autoconfig.sh
6@@ -0,0 +1,34 @@
7+# 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+
27+# Set temporary multicast face
28+ccndc -t 10 add "/local/ndn" udp 224.0.23.170 59695
29+
30+# Get info from local hub, if available
31+info=`ccncat -s 2 /local/ndn/udp`
32+if [ "x$info" = "x" ]; then
33+ echo "Local hub is not availble, trying to use DNS to get local configuration"
34+ # Try to use DNS search list to get default route information
35+ ccndc srv
36+ exit 1
37+fi
38+
39+echo Setting default route to a local hub: "$info"
40+echo "$info" | xargs ccndc add / udp
41diff --git csrc/util/ccnd-publish-local-info.sh csrc/util/ccnd-publish-local-info.sh
42new file mode 100755
43index 0000000..056ebde
44--- /dev/null
45+++ csrc/util/ccnd-publish-local-info.sh
46@@ -0,0 +1,34 @@
47+# Source file: util/ccnd-autoconfig.sh
48+#
49+# Script to publish information about local ccnd gateway in local repo (should be run only on ccnd gateway nodes)
50+#
51+# Part of the CCNx distribution.
52+#
53+# Copyright (C) 2012 Palo Alto Research Center, Inc.
54+#
55+# This work is free software; you can redistribute it and/or modify it under
56+# the terms of the GNU General Public License version 2 as published by the
57+# Free Software Foundation.
58+# This work is distributed in the hope that it will be useful, but WITHOUT ANY
59+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
60+# FOR A PARTICULAR PURPOSE.
61+
62+# This script should be installed in the same place as ccnd, ccndc, ccndsmoketest, ...
63+# adjust the path to get consistency.
64+D=`dirname "$0"`
65+export PATH="$D:$PATH"
66+
67+#
68+
69+udp_face_info=$1
70+local_prefix=$2
71+
72+if [ "x$udp_face_info" = "x" -o "x$local_prefix" = "x" ]; then
73+ echo "Usage: "
74+ echo " " $0 " <udp_face_info> <routable_prefix>"
75+ exit 1
76+fi
77+
78+echo $udp_face_info | ccnseqwriter -r -x 5 "/local/ndn/udp"
79+echo $local_prefix | ccnseqwriter -r -x 5 "/local/ndn/prefix"
80+
81diff --git csrc/util/dir.mk csrc/util/dir.mk
82index f29038f..94bc7b6 100644
83--- csrc/util/dir.mk
84+++ csrc/util/dir.mk
85@@ -14,8 +14,10 @@
86
87 SCRIPTSRC = shebang \
88 ccndstart.sh ccndstop.sh ccndstatus.sh ccndlogging.sh ccnget.sh ccnput.sh \
89- ccntestloop-trampoline
90-PROGRAMS = ccndstart ccndstop ccndstatus ccntestloop ccndlogging ccnget ccnput
91+ ccntestloop-trampoline \
92+ ccnd-autoconfig.sh ccnd-publish-local-info.sh
93+
94+PROGRAMS = ccndstart ccndstop ccndstatus ccntestloop ccndlogging ccnget ccnput ccnd-autoconfig ccnd-publish-local-info
95 INSTALLED_PROGRAMS = $(PROGRAMS)
96
97 default all: $(SCRIPTSRC) $(PROGRAMS)