37,15 → 37,23 |
|
#include <ll/sys/types.h> |
#include <stdlib.h> |
#include <string.h> |
#include <tracer.h> |
#include <unistd.h> |
|
#include <drivers/udpip.h> |
|
#define TRACER_UDP_DEBUG |
|
#define UDP_MAXSIZE 1400 |
#define TRACER_PORT 100 |
|
BYTE pkt[UDP_MAXSIZE]; |
int total_pkt_size = 0; |
|
int TracerUDPInit = 0; |
UDP_ADDR target,local; |
char local_ip[20],target_ip[20]; |
int socket; |
|
extern int TracerOutputType; |
57,7 → 65,7 |
unsigned int total_size; |
}; |
|
int init_udp_tracer(char *local_ip, char *target_ip) { |
int init_udp_tracer(char *l_ip, char *t_ip) { |
|
SYS_FLAGS f; |
|
65,18 → 73,27 |
|
f = ll_fsave(); |
|
strcpy(local_ip,l_ip); |
strcpy(target_ip,t_ip); |
|
net_setmode(m, TXTASK); |
net_setudpip(m, local_ip, "255.255.255.255"); |
|
if (net_init(&m) != 1) |
if (net_init(&m) != 1) { |
ll_frestore(f); |
return -1; |
} |
|
sleep(1); |
|
ip_str2addr(local_ip,&(local.s_addr)); |
local.s_port = TRACER_PORT; |
local.s_port = TRACER_PORT+1; |
socket = udp_bind(&local, NULL); |
|
ip_str2addr(target_ip,&(target.s_addr)); |
target.s_port = TRACER_PORT; |
|
sleep(1); |
|
TracerOutputType = TRACER_UDP_OUTPUT; |
TracerUDPInit = 1; |
89,9 → 106,7 |
|
int send_udp_event(void *p, int size) { |
|
static BYTE pkt[UDP_MAXSIZE]; |
static BYTE *current = pkt; |
static int total_pkt_size = 0; |
static int events_number = 0; |
static int packet_number = 0; |
|
129,8 → 144,13 |
|
} else { |
|
udp_sendto(socket, pkt, total_pkt_size, &target); |
#ifdef TRACER_UDP_DEBUG |
cprintf("Packet Sent - Nr %d Size %d\n",packet_number,total_pkt_size); |
#endif |
|
if (TracerUDPInit == 1) |
udp_sendto(socket, pkt, total_pkt_size, &target); |
|
events_number = 0; |
total_pkt_size = 0; |
current = pkt; |
144,3 → 164,14 |
return -1; |
|
} |
|
void send_remaining_udp_buffer() { |
|
if (TracerUDPInit == 1 && total_pkt_size != 0) { |
#ifdef TRACER_UDP_DEBUG |
cprintf("Last Packet Sent - Size %d\n",total_pkt_size); |
#endif |
udp_sendto(socket, pkt, total_pkt_size, &target); |
} |
|
} |