print textual name of messages exchanged.

This commit is contained in:
Nikos Mavrogiannopoulos
2014-01-12 18:23:29 +01:00
parent 39572b3d48
commit 823190475b
7 changed files with 42 additions and 9 deletions

View File

@@ -24,6 +24,42 @@
#include <sys/socket.h>
#include "common.h"
const char* cmd_request_to_str(unsigned _cmd)
{
cmd_request_t cmd = _cmd;
switch(cmd) {
case AUTH_INIT:
return "auth init";
case AUTH_REP:
return "auth reply";
case AUTH_REQ:
return "auth request";
case AUTH_COOKIE_REQ:
return "auth cookie request";
case AUTH_MSG:
return "auth msg";
case RESUME_STORE_REQ:
return "resume data store request";
case RESUME_DELETE_REQ:
return "resume data delete request";
case RESUME_FETCH_REQ:
return "resume data fetch request";
case RESUME_FETCH_REP:
return "resume data fetch reply";
case CMD_UDP_FD:
return "udp fd";
case CMD_TUN_MTU:
return "tun mtu change";
case CMD_TERMINATE:
return "terminate";
case CMD_SESSION_INFO:
return "session info";
default:
return "unknown";
}
}
ssize_t force_write(int sockfd, const void *buf, size_t len)
{
int left = len;

View File

@@ -50,5 +50,7 @@ int recv_msg(int fd, uint8_t cmd,
int recv_socket_msg(int fd, uint8_t cmd,
int *socketfd, void** msg, unpack_func);
const char* cmd_request_to_str(unsigned cmd);
#endif

View File

@@ -384,7 +384,8 @@ int handle_commands(main_server_st *s, struct proc_st* proc)
return ERR_BAD_COMMAND;
}
mslog(s, proc, LOG_DEBUG, "main received message %u of %u bytes\n", (unsigned)cmd, (unsigned)length);
mslog(s, proc, LOG_DEBUG, "main received message '%s' of %u bytes\n",
cmd_request_to_str(cmd), (unsigned)length);
raw = malloc(length);
if (raw == NULL) {

View File

@@ -259,7 +259,7 @@ inline static
int send_msg_to_worker(main_server_st* s, struct proc_st* proc, uint8_t cmd,
const void* msg, pack_size_func get_size, pack_func pack)
{
mslog(s, proc, LOG_DEBUG, "sending message %u to worker", (unsigned)cmd);
mslog(s, proc, LOG_DEBUG, "sending message '%s' to worker", cmd_request_to_str(cmd));
return send_msg(proc->fd, cmd, msg, get_size, pack);
}

View File

@@ -405,8 +405,6 @@ int auth_cookie(worker_st * ws, void *cookie, size_t cookie_size)
msg.cookie.data = cookie;
msg.cookie.len = cookie_size;
oclog(ws, LOG_DEBUG, "sending cookie authentication request");
ret = send_msg_to_main(ws, AUTH_COOKIE_REQ, &msg,
(pack_size_func)
auth_cookie_request_msg__get_packed_size,

View File

@@ -93,8 +93,6 @@ SessionResumeFetchMsg msg = SESSION_RESUME_FETCH_MSG__INIT;
msg.session_id.len = key.size;
msg.session_id.data = key.data;
oclog(ws, LOG_DEBUG, "sending resumption request (fetch)");
ret = send_msg_to_main(ws, RESUME_FETCH_REQ, &msg,
(pack_size_func)session_resume_fetch_msg__get_packed_size,
(pack_func)session_resume_fetch_msg__pack);
@@ -158,8 +156,6 @@ SessionResumeFetchMsg msg = SESSION_RESUME_FETCH_MSG__INIT;
msg.session_id.len = key.size;
msg.session_id.data = key.data;
oclog(ws, LOG_DEBUG, "sending resumption request (delete)");
ret = send_msg_to_main(ws, RESUME_DELETE_REQ, &msg,
(pack_size_func)session_resume_fetch_msg__get_packed_size,
(pack_func)session_resume_fetch_msg__pack);

View File

@@ -194,7 +194,7 @@ inline static
int send_msg_to_main(worker_st *ws, uint8_t cmd,
const void* msg, pack_size_func get_size, pack_func pack)
{
oclog(ws, LOG_DEBUG, "sending message %u to main", (unsigned)cmd);
oclog(ws, LOG_DEBUG, "sending message '%s' to main", cmd_request_to_str(cmd));
return send_msg(ws->cmd_fd, cmd, msg, get_size, pack);
}