3 # Test for correct name resolution behavior
7 # Wireshark - Network traffic analyzer
8 # By Gerald Combs <gerald@wireshark.org>
9 # Copyright 2005 Ulf Lamping
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License
13 # as published by the Free Software Foundation; either version 2
14 # of the License, or (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 # common exit status values
31 #TS_ARGS="-Tfields -e frame.number -e frame.time_epoch -e frame.time_delta"
32 TS_NR_ARGS
="-r $CAPTURE_DIR/dns+icmp.pcapng.gz"
34 CUSTOM_PROFILE_NAME
="Custom-$$"
36 # nameres.network_name: True
37 # nameres.use_external_name_resolver: False
38 # nameres.hosts_file_handling: False
40 name_resolution_net_t_ext_f_hosts_f_global
() {
41 env
$TS_NR_ENV $TSHARK $TS_NR_ARGS \
42 -o "nameres.network_name: TRUE" \
43 -o "nameres.use_external_name_resolver: FALSE" \
44 -o "nameres.hosts_file_handling: FALSE" \
45 |
grep global-8-8-8-8
> /dev
/null
2>&1
47 if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
48 test_step_failed
"Failed to resolve 8.8.8.8 using global hosts file."
54 # nameres.network_name: True
55 # nameres.use_external_name_resolver: False
56 # nameres.hosts_file_handling: False
58 name_resolution_net_t_ext_f_hosts_f_personal
() {
59 env
$TS_NR_ENV $TSHARK $TS_NR_ARGS \
60 -o "nameres.network_name: TRUE" \
61 -o "nameres.use_external_name_resolver: FALSE" \
62 -o "nameres.hosts_file_handling: FALSE" \
63 |
grep personal-8-8-4-4
> /dev
/null
2>&1
65 if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
66 test_step_failed
"Failed to resolve 8.8.4.4 using personal hosts file."
72 # nameres.network_name: True
73 # nameres_use_external_name_resolver: False
74 # nameres.hosts_file_handling: False
76 name_resolution_net_t_ext_f_hosts_f_custom
() {
77 env
$TS_NR_ENV $TSHARK $TS_NR_ARGS \
78 -o "nameres.network_name: TRUE" \
79 -o "nameres.use_external_name_resolver: FALSE" \
80 -o "nameres.hosts_file_handling: FALSE" \
81 -C "$CUSTOM_PROFILE_NAME" \
82 |
grep custom-4-2-2-2
> /dev
/null
2>&1
84 if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
85 test_step_failed
"Failed to resolve 4.2.2.2 using profile $CUSTOM_PROFILE_NAME."
91 # nameres.network_name: True
92 # nameres.use_external_name_resolver: False
93 # nameres.hosts_file_handling: True
95 name_resolution_net_t_ext_f_hosts_t_global
() {
96 env
$TS_NR_ENV $TSHARK $TS_NR_ARGS \
97 -o "nameres.network_name: TRUE" \
98 -o "nameres.use_external_name_resolver: FALSE" \
99 -o "nameres.hosts_file_handling: TRUE" \
100 |
grep global-8-8-8-8
> /dev
/null
2>&1
102 if [ ! $RETURNVALUE -ne $EXIT_OK ]; then
103 test_step_failed
"Global hosts information showed up when it shouldn't."
109 # nameres.network_name: True
110 # nameres.use_external_name_resolver: False
111 # nameres.hosts_file_handling: True
113 name_resolution_net_t_ext_f_hosts_t_personal
() {
114 env
$TS_NR_ENV $TSHARK $TS_NR_ARGS \
115 -o "nameres.network_name: TRUE" \
116 -o "nameres.use_external_name_resolver: FALSE" \
117 -o "nameres.hosts_file_handling: TRUE" \
118 |
grep personal-8-8-4-4
> /dev
/null
2>&1
120 if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
121 test_step_failed
"Personal hosts information showed up when it shouldn't."
127 # nameres.network_name: True
128 # nameres_use_external_name_resolver: False
129 # nameres.hosts_file_handling: True
131 name_resolution_net_t_ext_f_hosts_t_custom
() {
132 env
$TS_NR_ENV $TSHARK $TS_NR_ARGS \
133 -o "nameres.network_name: TRUE" \
134 -o "nameres.use_external_name_resolver: FALSE" \
135 -o "nameres.hosts_file_handling: TRUE" \
136 -C "$CUSTOM_PROFILE_NAME" \
137 |
grep custom-4-2-2-2
> /dev
/null
2>&1
139 if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
140 test_step_failed
"Failed to resolve 4.2.2.2 using profile $CUSTOM_PROFILE_NAME."
146 tshark_name_resolution_suite
() {
147 test_step_add
"Name resolution, no external, no profile hosts, global profile" name_resolution_net_t_ext_f_hosts_f_global
148 test_step_add
"Name resolution, no external, no profile hosts, personal profile" name_resolution_net_t_ext_f_hosts_f_personal
149 test_step_add
"Name resolution, no external, no profile hosts, custom profile" name_resolution_net_t_ext_f_hosts_f_custom
151 test_step_add
"Name resolution, no external, profile hosts, global profile" name_resolution_net_t_ext_f_hosts_t_global
152 test_step_add
"Name resolution, no external, profile hosts, personal profile" name_resolution_net_t_ext_f_hosts_t_personal
153 test_step_add
"Name resolution, no external, profile hosts, custom profile" name_resolution_net_t_ext_f_hosts_t_custom
156 name_resolution_cleanup_step
() {
157 rm -f $WS_BIN_PATH/hosts
160 name_resolution_prep_step
() {
161 CUSTOM_PROFILE_PATH
="$CONF_PATH/profiles/$CUSTOM_PROFILE_NAME"
162 TS_NR_ENV
="WIRESHARK_RUN_FROM_BUILD_DIRECTORY=1 ${HOME_ENV}=${HOME_PATH}"
164 name_resolution_cleanup_step
165 mkdir
-p "$CUSTOM_PROFILE_PATH"
166 cp "$TESTS_DIR/hosts.global" "$WS_BIN_PATH/hosts"
167 cp "$TESTS_DIR/hosts.personal" "$CONF_PATH/hosts"
168 cp "$TESTS_DIR/hosts.custom" "$CUSTOM_PROFILE_PATH/hosts"
171 name_resolution_suite
() {
172 test_step_set_pre name_resolution_prep_step
173 test_step_set_post name_resolution_cleanup_step
174 test_suite_add
"TShark name resolution" tshark_name_resolution_suite
178 # Editor modelines - http://www.wireshark.org/tools/modelines.html
183 # indent-tabs-mode: t
186 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
187 # :indentSize=8:tabSize=8:noTabs=false: