1
0
This commit is contained in:
Daniel Tartavel 2020-05-08 12:43:55 +02:00
parent 71111356d9
commit 7590b67eff

12
main.c
View File

@ -42,16 +42,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
if((utmp->ut_addr_v6[1] && utmp->ut_addr_v6[2] && utmp->ut_addr_v6[3]) == 0)
{
ipv4 = (utmp->ut_addr_v6[0] & 0xff000000) >> 6;
ipv4 = (utmp->ut_addr_v6[0] & 0x00000000ff000000) >> 6;
sprintf( str, "%x.", ipv4);
strcat(host_ip, str);
ipv4 = (utmp->ut_addr_v6[0] & 0x00ff0000) >> 4;
ipv4 = (utmp->ut_addr_v6[0] & 0x0000000000ff0000) >> 4;
sprintf( str, "%x.", ipv4);
strcat(host_ip, str);
ipv4 = (utmp->ut_addr_v6[0] & 0x0000ff00) >> 2;
ipv4 = (utmp->ut_addr_v6[0] & 0x000000000000ff00) >> 2;
sprintf( str, "%x.", ipv4);
strcat(host_ip, str);
ipv4 = utmp->ut_addr_v6[0] & 0x000000ff;
ipv4 = utmp->ut_addr_v6[0] & 0x00000000000000ff;
sprintf( str, "%x", ipv4);
strcat(host_ip, str);
@ -60,10 +60,10 @@ void getutmp( int pid, char user[], char host_ip[], char host_ipv6[], time_t * t
for (x=0;x<4;x++)
{
ipv6_1 = (utmp->ut_addr_v6[x] & 0xffff0000) >> 4;
ipv6_1 = (utmp->ut_addr_v6[x] & 0xffffffff00000000) >> 8;
sprintf( str, "%x:", ipv6_1);
strcat(host_ipv6, str);
ipv6_2 = utmp->ut_addr_v6[x] & 0x0000ffff;
ipv6_2 = utmp->ut_addr_v6[x] & 0x00000000ffffffff;
sprintf( str, "%x:", ipv6_1);
strcat(host_ipv6, str);
}