Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 369 → Rev 368

/shark/trunk/tracer/newtrace/udp.c
37,23 → 37,15
 
#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;
65,7 → 57,7
unsigned int total_size;
};
 
int init_udp_tracer(char *l_ip, char *t_ip) {
int init_udp_tracer(char *local_ip, char *target_ip) {
 
SYS_FLAGS f;
73,27 → 65,18
 
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) {
ll_frestore(f);
if (net_init(&m) != 1)
return -1;
}
 
sleep(1);
 
ip_str2addr(local_ip,&(local.s_addr));
local.s_port = TRACER_PORT+1;
local.s_port = TRACER_PORT;
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;
106,7 → 89,9
 
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;
144,13 → 129,8
 
} else {
 
#ifdef TRACER_UDP_DEBUG
cprintf("Packet Sent - Nr %d Size %d\n",packet_number,total_pkt_size);
#endif
udp_sendto(socket, pkt, total_pkt_size, &target);
 
if (TracerUDPInit == 1)
udp_sendto(socket, pkt, total_pkt_size, &target);
 
events_number = 0;
total_pkt_size = 0;
current = pkt;
164,14 → 144,3
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);
}
 
}