diff options
author | Nicola Ruggero <nicola@nxnt.org> | 2010-11-04 12:14:03 +0100 |
---|---|---|
committer | Nicola Ruggero <nicola@nxnt.org> | 2010-11-04 12:14:03 +0100 |
commit | d797b2cf497587355bbf25cd27d59edd1c3f2915 (patch) | |
tree | 8a706ce33714460c948c7d7d762e7b5ece23dec1 /common | |
parent | 87297c5014695da08815fca9c410505237162f24 (diff) | |
download | xrdp-proprietary-d797b2cf497587355bbf25cd27d59edd1c3f2915.tar.gz xrdp-proprietary-d797b2cf497587355bbf25cd27d59edd1c3f2915.zip |
Implemented client IP logging
Diffstat (limited to 'common')
-rw-r--r-- | common/os_calls.c | 29 | ||||
-rw-r--r-- | common/os_calls.h | 2 |
2 files changed, 31 insertions, 0 deletions
diff --git a/common/os_calls.c b/common/os_calls.c index 617f3d60..4004fdfc 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -494,6 +494,35 @@ g_tcp_accept(int sck) /*****************************************************************************/ void APP_CC +g_write_ip_address(int rcv_sck, char* ip_address) +{ + struct sockaddr_in s; + struct in_addr in; + int len; + int ip_port; + + memset(&s,0,sizeof(&s)); + len = sizeof(s); + getpeername(rcv_sck,(struct sockaddr*)&s, &len); + + memset(&in,0,sizeof(in)); + in.s_addr = s.sin_addr.s_addr; + + ip_port = ntohs(s.sin_port); + + if (ip_port != 0) + { + sprintf(ip_address, "%s:%d - socket: %d", inet_ntoa(in), ip_port, rcv_sck); + } + else + { + sprintf(ip_address, "NULL:NULL - socket: %d", rcv_sck); + } + +} + +/*****************************************************************************/ +void APP_CC g_sleep(int msecs) { #if defined(_WIN32) diff --git a/common/os_calls.h b/common/os_calls.h index 377b1174..e550cecf 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -100,6 +100,8 @@ g_tcp_can_recv(int sck, int millis); int APP_CC g_tcp_select(int sck1, int sck2); void APP_CC +g_write_ip_address(int rcv_sck, char* ip_address); +void APP_CC g_sleep(int msecs); tbus APP_CC g_create_wait_obj(char* name); |