-
Notifications
You must be signed in to change notification settings - Fork 0
/
tracert.c
33 lines (30 loc) · 960 Bytes
/
tracert.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "../libs/headers.h"
#define SZPDATA 1514
int main(int argc, char * argv[])
{
if(argc!=2){printf("[Dos argumentos]\n\n");return 0;}
if(atoi(argv[1])>255){printf("Límite: 255\n\n");return 0;}
srand(time(NULL));
genif s_echo;
struct pingdata pingst;
int packet_socket,index,ping_iter;
unsigned char pdataS[SZPDATA],pdataR[SZPDATA];
packet_socket = socket(PF_PACKET,SOCK_RAW,htons(ETH_P_ALL));
if(packet_socket==-1) printf("\n[Error al abrir el socket]\n");
else
{
printf("\n[Éxito al abrir el socket]\n");
if(index=socketData(packet_socket,&s_echo))//Check socket
{
fmtpSocketInfo(s_echo); //Print socket info
tgt_arp(&s_echo,pdataS,pdataR,packet_socket,index,'g'); //Get gateway
IP_d(s_echo.tgt_ip,argv[1],'m');
pingst.s_echo = &s_echo;
pingst.socket_id = packet_socket;
pingst.index_sd = index;
tracertTool(&pingst,pdataS,pdataR,30);
}
}
close(packet_socket);
return 1;
}