summaryrefslogtreecommitdiff
path: root/cleopatre/devkit/plcdrv/gidel/src/processing.c
diff options
context:
space:
mode:
Diffstat (limited to 'cleopatre/devkit/plcdrv/gidel/src/processing.c')
-rw-r--r--cleopatre/devkit/plcdrv/gidel/src/processing.c204
1 files changed, 0 insertions, 204 deletions
diff --git a/cleopatre/devkit/plcdrv/gidel/src/processing.c b/cleopatre/devkit/plcdrv/gidel/src/processing.c
deleted file mode 100644
index 4ff9af3c12..0000000000
--- a/cleopatre/devkit/plcdrv/gidel/src/processing.c
+++ /dev/null
@@ -1,204 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file processing.c
- * \brief Processing layer for the PLC driver.
- * \ingroup Cleopatre - Isis
- *
- * this layer is used to check every packet received by CESAR or TUN/TAP
- * and sometime drop it.
- */
-
-#define DEBUG 1
-
-#include "common.h"
-#include "processing.h"
-#include <stdio.h>
-#ifndef __UTESTS__
-#include "mailbox.h"
-#include "plc_drv.h"
-#else
-#include "mailbox_stub.h"
-#include "plc_drv_stub.h"
-#endif
-
-#define ETH_SRC_ADDR_OFFSET 0
-#define ETH_SRC_ADDR_SIZE 6
-#define ETH_DST_ADDR_OFFSET ETH_SRC_ADDR_SIZE
-#define ETH_DST_ADDR_SIZE 6
-#define ETH_TYPE_OFFSET ETH_DST_ADDR_OFFSET + ETH_DST_ADDR_SIZE
-#define ETH_TYPE_SIZE 2
-#define ETH_MME_VERSION_OFFSET ETH_TYPE_OFFSET + ETH_TYPE_SIZE
-#define ETH_MME_VERSION_SIZE 1
-#define ETH_MME_TYPE_OFFSET ETH_MME_VERSION_OFFSET + ETH_MME_VERSION_SIZE
-#define ETH_MME_TYPE_SIZE 2
-#define ETH_MME_FMI_OFFSET ETH_MME_TYPE_OFFSET + ETH_MME_TYPE_SIZE
-#define ETH_MME_FMI_SIZE 2
-
-#define ETH_MME_HPAV_TYPE 0x88E1
-#define MME_HPAV_TYPE_FCALL 0xABCD
-#define MME_HPAV_TYPE_SNIFFER 0xA02C
-
-/**
- * Find the Ethernet source Address.
- */
-void get_eth_src_addr(uint8_t* eth_frame, uint8_t source[6])
-{
- uint8_t i;
- for(i=0;i<ETH_SRC_ADDR_SIZE;i++)
- {
- source[ETH_SRC_ADDR_SIZE - 1 - i] = *(eth_frame + i + ETH_SRC_ADDR_OFFSET);
- }
-}
-
-/**
- * Find the Ethernet source Address.
- */
-void get_eth_dst_addr(uint8_t* eth_frame, uint8_t dest[6])
-{
- uint8_t i;
- for(i=0;i<ETH_DST_ADDR_SIZE;i++)
- {
- dest[ETH_DST_ADDR_OFFSET -1 - i] = *(eth_frame + i + ETH_DST_ADDR_OFFSET);
- }
-}
-
-/**
- * Find the Ethernet type.
- */
-uint16_t get_eth_type(uint8_t* eth_frame)
-{
- uint16_t type = 0;
- type = (*(eth_frame + ETH_TYPE_OFFSET) << 8);
- type |= *(eth_frame + ETH_TYPE_OFFSET + 1);
- return type;
-}
-
-/**
- * Find the Ethernet MME version.
- */
-uint8_t get_eth_mme_version(uint8_t* eth_frame)
-{
- return *(eth_frame + ETH_TYPE_OFFSET);
-}
-
-/**
- * Find the Ethernet MME type.
- */
-uint16_t get_eth_mme_type(uint8_t* eth_frame)
-{
- uint16_t type = 0;
- type = (*(eth_frame + ETH_MME_TYPE_OFFSET + 1) << 8);
- type |= *(eth_frame + ETH_MME_TYPE_OFFSET);
- return type;
-}
-
-/**
- * Find the Ethernet MME type.
- */
-uint16_t get_eth_mme_fmi(uint8_t* eth_frame)
-{
- uint16_t fmi = 0;
- fmi = (*(eth_frame + ETH_MME_FMI_OFFSET) << 8);
- fmi |= *(eth_frame + ETH_MME_FMI_OFFSET + 1);
- return fmi;
-}
-
-
-/**
- * Initialize the processing layer.
- *
- * \param init user information.
- */
-void processing_init (struct init_info *init)
-{
- //Init lower layers
- mailbox_init(init);
-}
-
-/**
- * UnInitialize the processing layer.
- */
-void processing_uninit (void)
-{
- //Uninit lower layers
- mailbox_uninit();
-}
-
-/**
- * Processing procedure for a A->L message.
- *
- * \param pointer packet pointer.
- * \param length length of the packet pointed.
- * \return status queue.
- */
-int processing_send (void *pointer, int length)
-{
- int result;
- uint16_t type;
-
- //TODO:if frame not ok drop it (for Gidel : do nothing)
-
- //Check which type of frame is it and send it
- if(get_eth_type((uint8_t*)pointer) == ETH_MME_HPAV_TYPE)
- {
- type = get_eth_mme_type((uint8_t*)pointer);
- if((type == MME_HPAV_TYPE_FCALL) || (type == MME_HPAV_TYPE_SNIFFER))
- {
- TRACE("In the processing_send : INTERFACE\n");
- result = mailbox_send(pointer, length, INTERFACE);
- }
- else
- {
- TRACE("In the processing_send : MME\n");
- result = mailbox_send(pointer, length, MME);
- }
- }
- else
- {
- TRACE("In the processing_send : DATA\n");
- result = mailbox_send(pointer, length, DATA);
- }
- return result;
-}
-
-/**
- * Processing procedure for a L->A message
- *
- * \param pointer packet pointer.
- * \param length length of the packet pointed.
- * \param type type of message.
- * \return error code.
- */
-int processing_receive (void *pointer, int length, enum buffer_type type)
-{
- //TODO:Check which type of frame is it
-
- //TODO:if frame not ok drop it (for Gidel : do nothing)
-
- //TODO:Send the packet to the TX part with processing_send(pointer, length)
-
-
- if(type == INTERFACE)
- {
- TRACE("In the processing_receive : INTERFACE\n");
- }
- else if(type == MME)
- {
- TRACE("In the processing_receive : MME\n");
- }
- else if(type == DATA)
- {
- TRACE("In the processing_receive : DATA\n");
- }
-
-
- //Or Send packet to the upper layers
- return plcdrv_rx(pointer, length);
-}
-