debug
This commit is contained in:
parent
0fa9cf9456
commit
8064268f6c
28
main.c
28
main.c
@ -27,8 +27,7 @@ int isinarray( int pid, int array[], int n )
|
|||||||
void getutmp( int pid, char user[], char host_ip[], char host_ipv6[], time_t * time )
|
void getutmp( int pid, char user[], char host_ip[], char host_ipv6[], time_t * time )
|
||||||
{
|
{
|
||||||
struct utmp * utmp;
|
struct utmp * utmp;
|
||||||
int ipv6_1;
|
int ipv6;
|
||||||
int ipv6_2;
|
|
||||||
int ipv4;
|
int ipv4;
|
||||||
int x;
|
int x;
|
||||||
char str[6];
|
char str[6];
|
||||||
@ -42,16 +41,16 @@ void getutmp( int pid, char user[], char host_ip[], char host_ipv6[], time_t * t
|
|||||||
sprintf(host_ip, "%s", utmp->ut_host); //got ip of origin
|
sprintf(host_ip, "%s", utmp->ut_host); //got ip of origin
|
||||||
if((utmp->ut_addr_v6[1] && utmp->ut_addr_v6[2] && utmp->ut_addr_v6[3]) == 0)
|
if((utmp->ut_addr_v6[1] && utmp->ut_addr_v6[2] && utmp->ut_addr_v6[3]) == 0)
|
||||||
{
|
{
|
||||||
ipv4 = (utmp->ut_addr_v6[0] & 0x00000000ff000000) >> 24;
|
ipv4 = utmp->ut_addr_v6[0] & 0x00000000000000ff;
|
||||||
sprintf( str, "%x.", ipv4);
|
|
||||||
strcat(host_ip, str);
|
|
||||||
ipv4 = (utmp->ut_addr_v6[0] & 0x0000000000ff0000) >> 16;
|
|
||||||
sprintf( str, "%x.", ipv4);
|
sprintf( str, "%x.", ipv4);
|
||||||
strcat(host_ip, str);
|
strcat(host_ip, str);
|
||||||
ipv4 = (utmp->ut_addr_v6[0] & 0x000000000000ff00) >> 8;
|
ipv4 = (utmp->ut_addr_v6[0] & 0x000000000000ff00) >> 8;
|
||||||
sprintf( str, "%x.", ipv4);
|
sprintf( str, "%x.", ipv4);
|
||||||
strcat(host_ip, str);
|
strcat(host_ip, str);
|
||||||
ipv4 = utmp->ut_addr_v6[0] & 0x00000000000000ff;
|
ipv4 = (utmp->ut_addr_v6[0] & 0x0000000000ff0000) >> 16;
|
||||||
|
sprintf( str, "%x.", ipv4);
|
||||||
|
strcat(host_ip, str);
|
||||||
|
ipv4 = (utmp->ut_addr_v6[0] & 0x00000000ff000000) >> 24;
|
||||||
sprintf( str, "%x", ipv4);
|
sprintf( str, "%x", ipv4);
|
||||||
strcat(host_ip, str);
|
strcat(host_ip, str);
|
||||||
|
|
||||||
@ -59,12 +58,17 @@ void getutmp( int pid, char user[], char host_ip[], char host_ipv6[], time_t * t
|
|||||||
{
|
{
|
||||||
for (x=0;x<4;x++)
|
for (x=0;x<4;x++)
|
||||||
{
|
{
|
||||||
|
ipv6 = utmp->ut_addr_v6[x] & 0x000000000000ffff;
|
||||||
ipv6_1 = (utmp->ut_addr_v6[x] & 0xffffffff00000000) >> 32;
|
sprintf( str, "%x:", ipv6);
|
||||||
sprintf( str, "%x:", ipv6_1);
|
|
||||||
strcat(host_ipv6, str);
|
strcat(host_ipv6, str);
|
||||||
ipv6_2 = utmp->ut_addr_v6[x] & 0x00000000ffffffff;
|
ipv6 = (utmp->ut_addr_v6[x] & 0x00000000ffff0000) >> 16;
|
||||||
sprintf( str, "%x:", ipv6_1);
|
sprintf( str, "%x:", ipv6);
|
||||||
|
strcat(host_ipv6, str);
|
||||||
|
ipv6 = (utmp->ut_addr_v6[x] & 0x0000ffff00000000) >> 32;
|
||||||
|
sprintf( str, "%x:", ipv6);
|
||||||
|
strcat(host_ipv6, str);
|
||||||
|
ipv6 = (utmp->ut_addr_v6[x] & 0xffff000000000000) >> 48;
|
||||||
|
sprintf( str, "%x:", ipv6);
|
||||||
strcat(host_ipv6, str);
|
strcat(host_ipv6, str);
|
||||||
}
|
}
|
||||||
host_ipv6[strlen(host_ipv6)-1] = '\0';
|
host_ipv6[strlen(host_ipv6)-1] = '\0';
|
||||||
|
Reference in New Issue
Block a user