BlinkenArea - GitList
Repositories
Blog
Wiki
bluebox
Code
Commits
Branches
Tags
Search
Tree:
fd252ce
Branches
Tags
master
bluebox
BlueDataDistributor
firmware
ethernet.c
initial commit of files from bluebox project
Stefan Schuermans
commited
fd252ce
at 2015-12-19 20:16:38
ethernet.c
Blame
History
Raw
/* BlueDataDistributor - data distribution module from ethernet to 32 serial ports * version 0.1.1 date 2006-10-07 * Copyright (C) 2006 Stefan Schuermans <stefan@blinkenarea.org> * a BlinkenArea project - http://www.blinkenarea.org/ */ #include "arp.h" #include "config.h" #include "ethernet.h" #include "ip.h" #include "macros.h" #include "nethelp.h" #include "rtl8019.h" // process a received ethernet packet void EthernetRecv( unsigned char * pData, unsigned short Length ) // (extern) { struct EthernetPacket * pEthPack; // packet too short if( Length < sizeof( struct EthernetPacket ) ) return; // convert pointer to ethernet packet // (this saves us from always casting pData) pEthPack = (struct EthernetPacket *)pData; // branch according to packet type switch( pEthPack->EthHdr.Type ) { // ARP case htons( 0x0806 ): ArpRecv( pData, Length ); break; // IP case htons( 0x0800 ): IpRecv( pData, Length ); break; } } // send an ethernet packet // pData must point to a struct EthernetPacket with EthHdr.Dest and EthHdr.Type already initialized void EthernetSend( unsigned char * pData, unsigned short Length ) // (extern) { struct EthernetPacket * pEthPack; // packet too short if( Length < sizeof( struct EthernetPacket ) ) return; // convert pointer to ethernet packet // (this saves us from always casting pData) pEthPack = (struct EthernetPacket *)pData; // fill in source address mac_cpy( pEthPack->EthHdr.Src, ConfigMac ); // send packet RtlWriteFrame( pData, Length ); }