3 # Test for correct name resolution behavior
5 # Wireshark - Network traffic analyzer
6 # By Gerald Combs <gerald@wireshark.org>
7 # Copyright 2005 Ulf Lamping
9 # SPDX-License-Identifier: GPL-2.0-or-later
12 # common exit status values
17 #TS_ARGS="-Tfields -e frame.number -e frame.time_epoch -e frame.time_delta"
18 TS_NR_ARGS="-r $CAPTURE_DIR/dns+icmp.pcapng.gz"
20 CUSTOM_PROFILE_NAME="Custom-$$"
22 # nameres.network_name: True
23 # nameres.use_external_name_resolver: False
24 # nameres.hosts_file_handling: False
26 name_resolution_net_t_ext_f_hosts_f_global() {
27 $TESTS_DIR/run_and_catch_crashes env $TS_NR_ENV $TSHARK $TS_NR_ARGS \
28 -o "nameres.network_name: TRUE" \
29 -o "nameres.use_external_name_resolver: FALSE" \
30 -o "nameres.hosts_file_handling: FALSE" \
31 | grep global-8-8-8-8 > /dev/null 2>&1
33 if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
34 test_step_failed "Failed to resolve 8.8.8.8 using global hosts file."
40 # nameres.network_name: True
41 # nameres.use_external_name_resolver: False
42 # nameres.hosts_file_handling: False
44 name_resolution_net_t_ext_f_hosts_f_personal() {
45 $TESTS_DIR/run_and_catch_crashes env $TS_NR_ENV $TSHARK $TS_NR_ARGS \
46 -o "nameres.network_name: TRUE" \
47 -o "nameres.use_external_name_resolver: FALSE" \
48 -o "nameres.hosts_file_handling: FALSE" \
49 | grep personal-8-8-4-4 > /dev/null 2>&1
51 if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
52 test_step_failed "Failed to resolve 8.8.4.4 using personal hosts file."
58 # nameres.network_name: True
59 # nameres_use_external_name_resolver: False
60 # nameres.hosts_file_handling: False
62 name_resolution_net_t_ext_f_hosts_f_custom() {
63 $TESTS_DIR/run_and_catch_crashes env $TS_NR_ENV $TSHARK $TS_NR_ARGS \
64 -o "nameres.network_name: TRUE" \
65 -o "nameres.use_external_name_resolver: FALSE" \
66 -o "nameres.hosts_file_handling: FALSE" \
67 -C "$CUSTOM_PROFILE_NAME" \
68 | grep custom-4-2-2-2 > /dev/null 2>&1
70 if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
71 test_step_failed "Failed to resolve 4.2.2.2 using profile $CUSTOM_PROFILE_NAME."
77 # nameres.network_name: True
78 # nameres.use_external_name_resolver: False
79 # nameres.hosts_file_handling: True
81 name_resolution_net_t_ext_f_hosts_t_global() {
82 $TESTS_DIR/run_and_catch_crashes env $TS_NR_ENV $TSHARK $TS_NR_ARGS \
83 -o "nameres.network_name: TRUE" \
84 -o "nameres.use_external_name_resolver: FALSE" \
85 -o "nameres.hosts_file_handling: TRUE" \
86 | grep global-8-8-8-8 > /dev/null 2>&1
88 if [ ! $RETURNVALUE -ne $EXIT_OK ]; then
89 test_step_failed "Global hosts information showed up when it shouldn't."
95 # nameres.network_name: True
96 # nameres.use_external_name_resolver: False
97 # nameres.hosts_file_handling: True
99 name_resolution_net_t_ext_f_hosts_t_personal() {
100 $TESTS_DIR/run_and_catch_crashes env $TS_NR_ENV $TSHARK $TS_NR_ARGS \
101 -o "nameres.network_name: TRUE" \
102 -o "nameres.use_external_name_resolver: FALSE" \
103 -o "nameres.hosts_file_handling: TRUE" \
104 | grep personal-8-8-4-4 > /dev/null 2>&1
106 if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
107 test_step_failed "Personal hosts information showed up when it shouldn't."
113 # nameres.network_name: True
114 # nameres_use_external_name_resolver: False
115 # nameres.hosts_file_handling: True
117 name_resolution_net_t_ext_f_hosts_t_custom() {
118 $TESTS_DIR/run_and_catch_crashes env $TS_NR_ENV $TSHARK $TS_NR_ARGS \
119 -o "nameres.network_name: TRUE" \
120 -o "nameres.use_external_name_resolver: FALSE" \
121 -o "nameres.hosts_file_handling: TRUE" \
122 -C "$CUSTOM_PROFILE_NAME" \
123 | grep custom-4-2-2-2 > /dev/null 2>&1
125 if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
126 test_step_failed "Failed to resolve 4.2.2.2 using profile $CUSTOM_PROFILE_NAME."
132 tshark_name_resolution_suite() {
133 test_step_add "Name resolution, no external, no profile hosts, global profile" name_resolution_net_t_ext_f_hosts_f_global
134 test_step_add "Name resolution, no external, no profile hosts, personal profile" name_resolution_net_t_ext_f_hosts_f_personal
135 test_step_add "Name resolution, no external, no profile hosts, custom profile" name_resolution_net_t_ext_f_hosts_f_custom
137 test_step_add "Name resolution, no external, profile hosts, global profile" name_resolution_net_t_ext_f_hosts_t_global
138 test_step_add "Name resolution, no external, profile hosts, personal profile" name_resolution_net_t_ext_f_hosts_t_personal
139 test_step_add "Name resolution, no external, profile hosts, custom profile" name_resolution_net_t_ext_f_hosts_t_custom
142 name_resolution_cleanup_step() {
143 rm -f $WS_BIN_PATH/hosts
146 name_resolution_prep_step() {
147 CUSTOM_PROFILE_PATH="$CONF_PATH/profiles/$CUSTOM_PROFILE_NAME"
148 TS_NR_ENV="${HOME_ENV}=${HOME_PATH}"
150 name_resolution_cleanup_step
151 mkdir -p "$CUSTOM_PROFILE_PATH"
152 cp "$TESTS_DIR/hosts.global" "$WS_BIN_PATH/hosts"
153 cp "$TESTS_DIR/hosts.personal" "$CONF_PATH/hosts"
154 cp "$TESTS_DIR/hosts.custom" "$CUSTOM_PROFILE_PATH/hosts"
157 name_resolution_suite() {
158 test_step_set_pre name_resolution_prep_step
159 test_step_set_post name_resolution_cleanup_step
160 test_suite_add "TShark name resolution" tshark_name_resolution_suite
164 # Editor modelines - http://www.wireshark.org/tools/modelines.html
169 # indent-tabs-mode: t
172 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
173 # :indentSize=8:tabSize=8:noTabs=false: