Squelch msp logging output

This commit is contained in:
Jeremy Lakeman 2014-05-23 11:00:41 +09:30
parent be4f7ad42d
commit 61bab9d6d6

View File

@ -25,6 +25,7 @@
#include "mdp_client.h"
#include "msp_client.h"
#include "socket.h"
#include "conf.h"
struct buffer{
size_t position;
@ -203,7 +204,8 @@ static void remote_shutdown(struct connection *conn)
WARNF_perror("shutdown(%d)", conn->alarm_out.poll.fd);
}
msp_get_remote(conn->sock, &remote);
INFOF(" - Connection with %s:%d remote shutdown", alloca_tohex_sid_t(remote.sid), remote.port);
if (config.debug.msp)
DEBUGF(" - Connection with %s:%d remote shutdown", alloca_tohex_sid_t(remote.sid), remote.port);
}
static void local_shutdown(struct connection *conn)
@ -211,7 +213,8 @@ static void local_shutdown(struct connection *conn)
struct mdp_sockaddr remote;
msp_get_remote(conn->sock, &remote);
msp_shutdown(conn->sock);
INFOF(" - Connection with %s:%d local shutdown", alloca_tohex_sid_t(remote.sid), remote.port);
if (config.debug.msp)
DEBUGF(" - Connection with %s:%d local shutdown", alloca_tohex_sid_t(remote.sid), remote.port);
}
static size_t msp_handler(MSP_SOCKET sock, msp_state_t state, const uint8_t *payload, size_t len, void *context)
@ -255,9 +258,10 @@ static size_t msp_handler(MSP_SOCKET sock, msp_state_t state, const uint8_t *pay
if (state & MSP_STATE_CLOSED){
struct mdp_sockaddr remote;
msp_get_remote(sock, &remote);
INFOF(" - Connection with %s:%d closed %s",
alloca_tohex_sid_t(remote.sid), remote.port,
(state & MSP_STATE_STOPPED) ? "suddenly":"gracefully");
if (config.debug.msp)
DEBUGF(" - Connection with %s:%d closed %s",
alloca_tohex_sid_t(remote.sid), remote.port,
(state & MSP_STATE_STOPPED) ? "suddenly":"gracefully");
conn->sock = MSP_SOCKET_NULL;
if (is_watching(&conn->alarm_in))
@ -293,7 +297,8 @@ static size_t msp_listener(MSP_SOCKET sock, msp_state_t state, const uint8_t *pa
struct mdp_sockaddr remote;
msp_get_remote(sock, &remote);
INFOF(" - New connection from %s:%d", alloca_tohex_sid_t(remote.sid), remote.port);
if (config.debug.msp)
DEBUGF(" - New connection from %s:%d", alloca_tohex_sid_t(remote.sid), remote.port);
int fd_in = STDIN_FILENO;
int fd_out = STDOUT_FILENO;
@ -494,7 +499,8 @@ static void listen_poll(struct sched_ent *alarm)
WHYF_perror("accept(%d)", alarm->poll.fd);
return;
}
INFOF("- Incoming TCP connection from %s", alloca_socket_address(&addr));
if (config.debug.msp)
DEBUGF("- Incoming TCP connection from %s", alloca_socket_address(&addr));
watch(&mdp_sock);
MSP_SOCKET sock = msp_socket(mdp_sock.poll.fd, 0);
if (msp_socket_is_null(sock))
@ -611,7 +617,8 @@ int app_msp_connection(const struct cli_parsed *parsed, struct cli_context *UNUS
if (socket_listen(listen_alarm.poll.fd, 0)==-1)
goto end;
watch(&listen_alarm);
INFOF("- Forwarding from %s to %s:%d", alloca_socket_address(&ip_addr), alloca_tohex_sid_t(addr.sid), addr.port);
if (config.debug.msp)
DEBUGF("- Forwarding from %s to %s:%d", alloca_socket_address(&ip_addr), alloca_tohex_sid_t(addr.sid), addr.port);
}else{
watch(&mdp_sock);
sock = msp_socket(mdp_sock.poll.fd, 0);
@ -621,7 +628,8 @@ int app_msp_connection(const struct cli_parsed *parsed, struct cli_context *UNUS
goto end;
msp_set_handler(sock, msp_handler, conn);
msp_connect(sock, &addr);
INFOF("- Connecting to %s:%d", alloca_tohex_sid_t(addr.sid), addr.port);
if (config.debug.msp)
DEBUGF("- Connecting to %s:%d", alloca_tohex_sid_t(addr.sid), addr.port);
}
}else{
watch(&mdp_sock);
@ -635,10 +643,12 @@ int app_msp_connection(const struct cli_parsed *parsed, struct cli_context *UNUS
listener=sock;
if (local_port_string){
INFOF("- Forwarding from port %d to %s", addr.port, alloca_socket_address(&ip_addr));
if (config.debug.msp)
DEBUGF("- Forwarding from port %d to %s", addr.port, alloca_socket_address(&ip_addr));
}else{
once = 1;
INFOF(" - Listening on port %d", addr.port);
if (config.debug.msp)
DEBUGF(" - Listening on port %d", addr.port);
}
}