Beispiel #1
0
/* Tell the client that the server is done executing some packet events. */
static int wire_server_send_packets_done(struct wire_server *wire_server,
					 int result,
					 const char *error)
{
	struct wire_packets_done done;
	int status;
	int error_len = strlen(error) + 1;	/* +1 for '\0' */
	int buf_len = sizeof(done) + error_len;
	char *buf = malloc(buf_len);

	done.result	= htonl(result);
	done.num_events	= htonl(wire_server->num_events);
	memcpy(buf, &done, sizeof(done));
	memcpy(buf + sizeof(done), error, error_len);

	if (wire_conn_write(wire_server->wire_conn,
			    WIRE_PACKETS_DONE,
			    buf, buf_len)) {
		fprintf(stderr, "error sending WIRE_PACKETS_DONE\n");
		status = STATUS_ERR;
	} else {
		status = STATUS_OK;
	}

	free(buf);
	return status;
}
Beispiel #2
0
/* Tell server that client is starting script execution. */
void wire_client_send_client_starting(struct wire_client *wire_client)
{
	if (wire_conn_write(wire_client->wire_conn,
	                    WIRE_CLIENT_STARTING,
	                    NULL, 0))
		wire_client_die(wire_client,
		                "error sending WIRE_CLIENT_STARTING");
}
Beispiel #3
0
/* Send the ASCII contents of the script we're about to run. */
static void wire_client_send_script(struct wire_client *wire_client,
                                    const struct script *script)
{
	if (wire_conn_write(wire_client->wire_conn,
	                    WIRE_SCRIPT,
	                    script->buffer, script->length))
		wire_client_die(wire_client,
		                "error sending WIRE_SCRIPT");
}
Beispiel #4
0
/* Send back to the client a human-readable warning about a fishy packet. */
static int wire_server_send_packet_warning(struct wire_server *wire_server,
					   const char *warning)
{
	if (wire_conn_write(wire_server->wire_conn, WIRE_PACKETS_WARN,
			    warning, strlen(warning))) {
		fprintf(stderr, "error sending WIRE_PACKETS_WARN\n");
		return STATUS_ERR;
	}
	return STATUS_OK;
}
Beispiel #5
0
/* Send a message to tell the client we're ready to excecute the script. */
static int wire_server_send_server_ready(struct wire_server *wire_server)
{
	if (wire_conn_write(wire_server->wire_conn,
				    WIRE_SERVER_READY,
				    NULL, 0)) {
		fprintf(stderr, "error sending WIRE_SERVER_READY\n");
		return STATUS_ERR;
	}
	return STATUS_OK;
}
Beispiel #6
0
/* Send a client request for the server to execute some packet events. */
static void wire_client_send_packets_start(struct wire_client *wire_client)
{
	struct wire_packets_start start;
	start.num_events = htonl(wire_client->num_events);
	if (wire_conn_write(wire_client->wire_conn,
	                    WIRE_PACKETS_START,
	                    &start, sizeof(start)))
		wire_client_die(wire_client,
		                "error sending WIRE_PACKETS_START");
}
Beispiel #7
0
/* Send the ethernet address to which the server should send packets. */
static void wire_client_send_hw_address(struct wire_client *wire_client,
                                        const struct config *config)
{
	if (wire_conn_write(wire_client->wire_conn,
	                    WIRE_HARDWARE_ADDR,
	                    &wire_client->client_ether_addr,
	                    sizeof(wire_client->client_ether_addr)))
		wire_client_die(wire_client,
		                "error sending WIRE_HARDWARE_ADDR");
}
Beispiel #8
0
/* Send the path name of the script we're about to run. */
static void wire_client_send_script_path(struct wire_client *wire_client,
                                         const struct config *config)
{
	if (wire_conn_write(wire_client->wire_conn,
	                    WIRE_SCRIPT_PATH,
	                    config->script_path,
	                    strlen(config->script_path)))
		wire_client_die(wire_client,
		                "error sending WIRE_SCRIPT_PATH");
}
Beispiel #9
0
/* Send a WIRE_COMMAND_LINE_ARGS message with our command line
 * arguments as a single serialized string.
 */
static void wire_client_send_args(struct wire_client *wire_client,
                                  const struct config *config)
{
	char *args = NULL;
	int args_len = 0;

	wire_client_serialize_argv(config->argv, &args, &args_len);

	if (wire_conn_write(wire_client->wire_conn,
	                    WIRE_COMMAND_LINE_ARGS,
	                    args, args_len))
		wire_client_die(wire_client,
		                "error sending WIRE_COMMAND_LINE_ARGS");
	free(args);
}