void cmd_tcp_eread(evutil_socket_t fd, short which, void *arg) { extern FILE *honeyd_servicefp; struct tcp_con *con = arg; char line[1024]; int nread; struct command *cmd = &con->cmd; TRACE(fd, nread = read(fd, line, sizeof(line))); if (nread <= 0) { if (cmd->fdwantclose) { /* Stdin is already closed */ cmd_free(&con->cmd); tcp_sendfin(con); } else { /* Now stdin will takes us down */ cmd->fdwantclose = 1; } return; } if (nread == sizeof(line)) nread--; line[nread] = '\0'; honeyd_log_service(honeyd_servicefp, IP_PROTO_TCP, &con->conhdr, line); TRACE(event_get_fd(cmd->peread), event_add(cmd->peread, NULL)); }
void cmd_udp_eread(int fd, short which, void *arg) { extern FILE *honeyd_servicefp; struct udp_con *con = arg; char line[1024]; int nread; struct command *cmd = &con->cmd; TRACE(fd, nread = read(fd, line, sizeof(line))); if (nread <= 0) { udp_free(con); return; } if (nread == sizeof(line)) nread--; line[nread] = '\0'; honeyd_log_service(honeyd_servicefp, IP_PROTO_UDP, &con->conhdr, line); event_add(&cmd->peread, NULL); }