Pass more arguments to fio_init_net_cmd()
authorJens Axboe <axboe@kernel.dk>
Sat, 1 Oct 2011 04:24:17 +0000 (22:24 -0600)
committerJens Axboe <axboe@kernel.dk>
Sat, 1 Oct 2011 04:24:17 +0000 (22:24 -0600)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
client.c
server.c
server.h

index d9e3857ee05e264d8ee8beb0ca2e0a4bc14a4083..f9154648cbbb4c7e1921e57cd7e90cae5e3852e5 100644 (file)
--- a/client.c
+++ b/client.c
@@ -62,12 +62,7 @@ static int send_file_buf(char *buf, off_t size)
 
        cmd = malloc(sizeof(*cmd) + size);
 
-       fio_init_net_cmd(cmd);
-       cmd->opcode     = cpu_to_le16(FIO_NET_CMD_JOB_END);
-       cmd->pdu_len    = cpu_to_le32(size);
-
-       memcpy(&cmd->payload, buf, size);
-
+       fio_init_net_cmd(cmd, FIO_NET_CMD_JOB_END, buf, size);
        fio_net_cmd_crc(cmd);
 
        ret = fio_send_data(fio_client_fd, cmd, sizeof(*cmd) + size);
index a70dc14f414aefad94812840b20b2c326e6b76cf..8bbac70f2225fedd7399db511ea9b4b7a4f3f5d8 100644 (file)
--- a/server.c
+++ b/server.c
@@ -373,11 +373,7 @@ int fio_server_text_output(const char *buf, unsigned int len)
        int size = sizeof(*cmd) + len;
 
        cmd = malloc(size);
-       fio_init_net_cmd(cmd);
-       cmd->opcode     = cpu_to_le16(FIO_NET_CMD_TEXT);
-       cmd->pdu_len    = cpu_to_le32(len);
-       memcpy(&cmd->payload, buf, len);
-
+       fio_init_net_cmd(cmd, FIO_NET_CMD_TEXT, buf, len);
        fio_net_cmd_crc(cmd);
 
        fio_send_data(server_fd, cmd, size);
index 969659ddb94b24f97f42ae92f588def5538a7e17..79449a635315b26c9c5aecde52751ff9dde2426f 100644 (file)
--- a/server.h
+++ b/server.h
@@ -68,10 +68,18 @@ extern int fio_net_port;
 #error "Endianness not detected"
 #endif
 
-static inline void fio_init_net_cmd(struct fio_net_cmd *cmd)
+static inline void fio_init_net_cmd(struct fio_net_cmd *cmd, uint16_t opcode,
+                                   const void *pdu, uint32_t pdu_len)
 {
        memset(cmd, 0, sizeof(*cmd));
-       cmd->version = cpu_to_le16(FIO_SERVER_VER1);
+
+       cmd->version    = cpu_to_le16(FIO_SERVER_VER1);
+       cmd->opcode     = cpu_to_le16(FIO_NET_CMD_TEXT);
+
+       if (pdu) {
+               cmd->pdu_len    = cpu_to_le32(pdu_len);
+               memcpy(&cmd->payload, pdu, pdu_len);
+       }
 }
 
 #endif