Project

General

Profile

« Previous | Next » 

Revision d318da67

Added by Renato Botelho about 12 years ago

Add scope to target when it is a link-local, it helps ticket #3150

View differences:

usr/local/www/diag_testport.php
200 200
				$ifaddr = ($sourceip == "any") ? "" : get_interface_ip($sourceip);
201 201
				$nc_args .= " -4";
202 202
			} elseif (is_ipaddrv6($host)) {
203
				$ifaddr = ($sourceip == "any") ? "" : get_interface_ipv6($sourceip);
203
				if ($sourceip == "any")
204
					$ifaddr = "";
205
				else if (is_linklocal($sourceip))
206
					$ifaddr = $sourceip;
207
				else
208
					$ifaddr = get_interface_ipv6($sourceip);
204 209
				$nc_args .= " -6";
205 210
			} else {
206 211
				switch ($ipprotocol) {
......
209 214
						$nc_ipproto = " -4";
210 215
						break;
211 216
					case "ipv6":
212
						$ifaddr = get_interface_ipv6($sourceip);
217
						$ifaddr = (is_linklocal($sourceip) ? $sourceip : get_interface_ipv6($sourceip));
213 218
						$nc_ipproto = " -6";
214 219
						break;
215 220
					case "any":
216 221
						$ifaddr = get_interface_ip($sourceip);
217 222
						$nc_ipproto = (!empty($ifaddr)) ? " -4" : "";
218 223
						if (empty($ifaddr)) {
219
							$ifaddr = get_interface_ipv6($sourceip);
224
							$ifaddr = (is_linklocal($sourceip) ? $sourceip : get_interface_ipv6($sourceip));
220 225
							$nc_ipproto = (!empty($ifaddr)) ? " -6" : "";
221 226
						}
222 227
						break;
......
237 242
				}
238 243
			}
239 244
			/* Only add on the interface IP if we managed to find one. */
240
			if (!empty($ifaddr))
245
			if (!empty($ifaddr)) {
241 246
				$nc_args .= " -s " . escapeshellarg($ifaddr) . " ";
247
				$scope = get_ll_scope($ifaddr);
248
				if (!empty($scope) && !strstr($host, "%"))
249
					$host .= "%{$scope}";
250
			}
242 251

  
243 252
			$nc_cmd = "{$nc_base_cmd} {$nc_args} " . escapeshellarg($host) . " " . escapeshellarg($port) . " 2>&1";
244 253
			exec($nc_cmd, $result, $retval);

Also available in: Unified diff