Subversion Repositories shark

Rev

Blame | Last modification | View Log | RSS feed

/*
 * Project: S.Ha.R.K.
 *
 * Coordinators:
 *   Giorgio Buttazzo    <giorgio@sssup.it>
 *   Paolo Gai           <pj@gandalf.sssup.it>
 *
 * Authors     :
 *   Massimiliano Giorgi <massy@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
 */


#include <ll/sys/types.h>
#include <ll/stdlib.h>

#include <kernel/func.h>
#include <kernel/mem.h>
#include <kernel/log.h>

#include <drivers/udpip.h>

#include <trace/types.h>
#include <trace/trace.h>
#include <trace/queues.h>

#include <fs/fs.h>

#include <unistd.h>
#include <fcntl.h>
#include <limits.h>

typedef struct TAGudp_queue_t {
  UDP_ADDR    addr;
  trc_event_t evt;
} udp_queue_t;

static trc_event_t *udp_get(udp_queue_t *queue)
{
  return &queue->evt;
}

static int udp_post(udp_queue_t *queue)
{
  //int s=0;
  /* s ??? */
  //udp_sendto(s,&queue->evt,sizeof(trc_event_t),&queue->addr);
  return 0;
}

static int udp_create(trc_queue_t *queue, TRC_UDP_PARMS *args)
{
  udp_queue_t *ptr;

  if (args==NULL) return -1;
 
  ptr=(udp_queue_t*)kern_alloc(sizeof(udp_queue_t));
  if (ptr==NULL) return -1;
   
  queue->get=(trc_event_t*(*)(void*))udp_get;
  queue->post=(int(*)(void*))udp_post;
  queue->data=ptr;

  memcpy(&ptr->addr,&args->addr,sizeof(UDP_ADDR));
 
  return 0;
}

static int udp_activate(udp_queue_t *queue)
{
  return 0;
}

static int udp_terminate(udp_queue_t *queue)
{
  return 0;
}

int trc_register_udp_queue(void)
{
  int res;
 
  res=trc_register_queuetype(TRC_UDP_QUEUE,
                             (int(*)(trc_queue_t*,void*))udp_create,
                             (int(*)(void*))udp_activate,
                             (int(*)(void*))udp_terminate
                             );  
  if (res!=0) printk(KERN_WARNING "can't register tracer udp queue");
  return res;
}