Rev 365 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Giacomo Guidi <giacomo@gandalf.sssup.it>
* (see the web pages for full authors list)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://shark.sssup.it
*/
/*
* Copyright (C) 2002 Paolo Gai
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <ll/sys/types.h>
#include <stdlib.h>
#define UDP_MAXSIZE 1400
struct tracer_udp_header
{
char id
[12];
unsigned int pkt_number
;
unsigned int number_of_events
;
unsigned int total_size
;
};
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;
struct tracer_udp_header head
= {"TRACER-V1.0",0,0,0};
struct tracer_udp_header
*phead
= (struct tracer_udp_header
*)(pkt
);
int err
;
if (total_pkt_size
+ size
< UDP_MAXSIZE
) {
if (total_pkt_size
== 0) {
memcpy(pkt
,&head
,sizeof(struct tracer_udp_header
));
current
= pkt
;
current
+= sizeof(struct tracer_udp_header
);
total_pkt_size
+= sizeof(struct tracer_udp_header
);
phead
->total_size
= total_pkt_size
;
packet_number
++;
phead
->pkt_number
= packet_number
;
}
events_number
++;
phead
->number_of_events
= events_number
;
total_pkt_size
+= size
;
phead
->total_size
= total_pkt_size
;
//Copy the event
memcpy(current
,p
,size
);
current
+= size
;
return 0;
} else {
//err = udp_sentto();
events_number
= 0;
total_pkt_size
= 0;
current
= pkt
;
send_udp_event
(p
,size
);
return err
;
}
return -1;
}