param->local_address = value;
}
+ /* Device name to send from */
+ if (!strcmp(name, "local-device")) {
+ param->local_device = value;
+ }
+
/* Protocol for the probe */
if (!strcmp(name, "protocol")) {
if (!strcmp(value, "icmp")) {
}
#endif
+ if (param->local_device) {
+ if (setsockopt(stream_socket, SOL_SOCKET,
+ SO_BINDTODEVICE, param->local_device, strlen(param->local_device))) {
+ return -1;
+ }
+ }
+
return 0;
}
}
#endif
+ if (param->local_device) {
+ if (setsockopt(send_socket, SOL_SOCKET,
+ SO_BINDTODEVICE, param->local_device, strlen(param->local_device))) {
+ return -1;
+ }
+ }
+
/*
Bind src port when not using raw socket to pass in ICMP id, kernel
get ICMP id from src_port when using DGRAM socket.
}
#endif
+ if (param->local_device) {
+ if (setsockopt(send_socket,
+ SOL_SOCKET, SO_BINDTODEVICE, param->local_device,
+ strlen(param->local_device))) {
+ return -1;
+ }
+ }
+
return 0;
}
/* The local address from which to send probes */
const char *local_address;
+ /* The local device from which to send probes */
+ const char *local_device;
+
/* Protocol for the probe, using the IPPROTO_* defines */
int protocol;
strncat(command, argument, remaining_size);
}
+static
+void append_command_string_argument(
+ char *command,
+ int buffer_size,
+ char *name,
+ char *value)
+{
+ char argument[COMMAND_BUFFER_SIZE];
+ int remaining_size;
+
+ remaining_size = buffer_size - strlen(command) - 1;
+
+ snprintf(argument, buffer_size, " %s %s", name, value);
+ strncat(command, argument, remaining_size);
+}
+
/* Request a new probe from the "mtr-packet" child process */
void send_probe_command(
}
#endif
+ if (ctl->InterfaceName) {
+ append_command_string_argument(command, COMMAND_BUFFER_SIZE,
+ "local-device", ctl->InterfaceName);
+ }
+
remaining_size = COMMAND_BUFFER_SIZE - strlen(command) - 1;
strncat(command, "\n", remaining_size);