BlinkenArea - GitList
Repositories
Blog
Wiki
mips_sys
Code
Commits
Branches
Tags
Search
Tree:
902aa40
Branches
Tags
master
mips_sys
fw
ethernet.c
replace email address in headers with blinkenarea address
Stefan Schuermans
commited
902aa40
at 2012-05-21 17:42:50
ethernet.c
Blame
History
Raw
/* MIPS I system * Copyright 2011-2012 Stefan Schuermans <stefan@blinkenarea.org> * Copyleft GNU public license V2 or later * http://www.gnu.org/copyleft/gpl.html */ /* flpDistriR25S - flexipix distributor for pixels round 25mm with switch * version 1.0.0 date 2011-06-12 * created by Stefan Schuermans <stefan@blinkenarea.org> * Copyright (C) 2006-2011 flexipix GbR, Germany */ #include "arp.h" #include "config.h" #include "eth.h" #include "ethernet.h" #include "ip.h" #include "macros.h" #include "nethelp.h" /** * @brief process a received ethernet packet * @param[in] ptr pointer to data of packet * @param[in] sz size of packet */ void ethernet_recv(void *ptr, unsigned int sz) { struct ethernet_packet *eth_pack; // packet too short if (sz < sizeof(struct ethernet_packet)) return; eth_pack = ptr; // branch according to packet type switch (eth_pack->eth_hdr.type) { // ARP case htons(0x0806): arp_recv(ptr, sz); break; // IP case htons(0x0800): ip_recv(ptr, sz); break; } } /** * @brief send an ethernet packet * @param[in] ptr pointer to data of packet * @param[in] sz size of packet * * ptr must point to a ethernet_packet * with eth_hdr.dest and eth_hdr.type already initialized */ void ethernet_send(void *ptr, unsigned int sz) { struct ethernet_packet *eth_pack; // packet too short if (sz < sizeof(struct ethernet_packet)) return; eth_pack = ptr; // fill in source address mac_cpy(eth_pack->eth_hdr.src, config_mac.mac); // transmit packet eth_tx(ptr, sz); }