summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorJay Sorg <jay.sorg@gmail.com>2013-10-02 16:27:12 -0700
committerJay Sorg <jay.sorg@gmail.com>2013-10-02 16:27:12 -0700
commit25369460a1b2f204d03a6bc4821251d7ef2d7adf (patch)
treed0c1ad0dac826abfa34c15e4b9b06dc76f2352c6 /common
parent7176f1464710fd809af92ae3c2fcf9412eda9ace (diff)
downloadxrdp-proprietary-25369460a1b2f204d03a6bc4821251d7ef2d7adf.tar.gz
xrdp-proprietary-25369460a1b2f204d03a6bc4821251d7ef2d7adf.zip
log client ip with pid, etc
Diffstat (limited to 'common')
-rw-r--r--common/os_calls.c35
-rw-r--r--common/os_calls.h2
-rw-r--r--common/trans.c7
-rw-r--r--common/trans.h2
-rw-r--r--common/xrdp_client_info.h2
5 files changed, 46 insertions, 2 deletions
diff --git a/common/os_calls.c b/common/os_calls.c
index 3ed08a97..2d5b4280 100644
--- a/common/os_calls.c
+++ b/common/os_calls.c
@@ -970,6 +970,41 @@ g_tcp_accept(int sck)
}
/*****************************************************************************/
+int APP_CC
+g_sck_accept(int sck, char *addr, int addr_bytes, char *port, int port_bytes)
+{
+ int ret;
+ char ipAddr[256];
+ struct sockaddr_in s;
+#if defined(_WIN32)
+ signed int i;
+#else
+ unsigned int i;
+#endif
+
+ i = sizeof(struct sockaddr_in);
+ memset(&s, 0, i);
+ ret = accept(sck, (struct sockaddr *)&s, &i);
+ if (ret > 0)
+ {
+ g_snprintf(ipAddr, 255, "A connection received from: %s port %d",
+ inet_ntoa(s.sin_addr), ntohs(s.sin_port));
+ log_message(LOG_LEVEL_INFO,ipAddr);
+ if (s.sin_family == AF_INET)
+ {
+ g_snprintf(addr, addr_bytes, "%s", inet_ntoa(s.sin_addr));
+ g_snprintf(port, port_bytes, "%d", ntohs(s.sin_port));
+ }
+ if (s.sin_family == AF_UNIX)
+ {
+ g_strncpy(addr, "", addr_bytes - 1);
+ g_strncpy(port, "", port_bytes - 1);
+ }
+ }
+ return ret;
+}
+
+/*****************************************************************************/
void APP_CC
g_write_ip_address(int rcv_sck, char *ip_address, int bytes)
{
diff --git a/common/os_calls.h b/common/os_calls.h
index 8085911d..b6e1c91a 100644
--- a/common/os_calls.h
+++ b/common/os_calls.h
@@ -62,6 +62,8 @@ int APP_CC g_tcp_local_bind(int sck, const char* port);
int APP_CC g_tcp_bind_address(int sck, const char* port, const char* address);
int APP_CC g_tcp_listen(int sck);
int APP_CC g_tcp_accept(int sck);
+int APP_CC g_sck_accept(int sck, char *addr, int addr_bytes,
+ char *port, int port_bytes);
int APP_CC g_tcp_recv(int sck, void* ptr, int len, int flags);
int APP_CC g_tcp_send(int sck, const void* ptr, int len, int flags);
int APP_CC g_tcp_last_error_would_block(int sck);
diff --git a/common/trans.c b/common/trans.c
index 5d5c6125..bb349298 100644
--- a/common/trans.c
+++ b/common/trans.c
@@ -197,7 +197,8 @@ trans_check_wait_objs(struct trans *self)
{
if (g_tcp_can_recv(self->sck, 0))
{
- in_sck = g_tcp_accept(self->sck);
+ in_sck = g_sck_accept(self->sck, self->addr, sizeof(self->addr),
+ self->port, sizeof(self->port));
if (in_sck == -1)
{
@@ -223,6 +224,8 @@ trans_check_wait_objs(struct trans *self)
in_trans->type1 = TRANS_TYPE_SERVER;
in_trans->status = TRANS_STATUS_UP;
in_trans->is_term = self->is_term;
+ g_strncpy(in_trans->addr, self->addr, sizeof(self->addr) - 1);
+ g_strncpy(in_trans->port, self->port, sizeof(self->port) - 1);
if (self->trans_conn_in(self, in_trans) != 0)
{
@@ -466,7 +469,7 @@ trans_write_copy(struct trans *self)
{
temp_s = (struct stream *) (temp_s->next_packet);
}
- temp_s->next_packet = wait_s;
+ temp_s->next_packet = (char *) wait_s;
}
return 0;
}
diff --git a/common/trans.h b/common/trans.h
index b7b9c20d..350f05cc 100644
--- a/common/trans.h
+++ b/common/trans.h
@@ -55,6 +55,8 @@ struct trans
char* listen_filename;
tis_term is_term; /* used to test for exit */
struct stream* wait_s;
+ char addr[256];
+ char port[256];
};
struct trans* APP_CC
diff --git a/common/xrdp_client_info.h b/common/xrdp_client_info.h
index 43ff3f82..2dff7358 100644
--- a/common/xrdp_client_info.h
+++ b/common/xrdp_client_info.h
@@ -93,6 +93,8 @@ struct xrdp_client_info
int pointer_flags; /* 0 color, 1 new, 2 no new */
int use_fast_path;
int require_credentials; /* when true, credentials *must* be passed on cmd line */
+ char client_addr[256];
+ char client_port[256];
};
#endif