902aa402b3830b9c9aa26758390b6eb93b42a0f5
Stefan Schuermans added file headers

Stefan Schuermans authored 12 years ago

1) /* MIPS I system
Stefan Schuermans replace email address in he...

Stefan Schuermans authored 12 years ago

2)  * Copyright 2011-2012 Stefan Schuermans <stefan@blinkenarea.org>
Stefan Schuermans added file headers

Stefan Schuermans authored 12 years ago

3)  * Copyleft GNU public license V2 or later
4)  *          http://www.gnu.org/copyleft/gpl.html
5)  */
6) 
Stefan Schuermans implementation of ethernet...

Stefan Schuermans authored 12 years ago

7) /* flpDistriR25S - flexipix distributor for pixels round 25mm with switch
8)  * version 1.0.0 date 2011-06-12
Stefan Schuermans replace email address in he...

Stefan Schuermans authored 12 years ago

9)  * created by Stefan Schuermans <stefan@blinkenarea.org>
Stefan Schuermans implementation of ethernet...

Stefan Schuermans authored 12 years ago

10)  * Copyright (C) 2006-2011 flexipix GbR, Germany
11)  */
12) 
13) #include "arp.h"
14) #include "config.h"
15) #include "eth.h"
16) #include "ethernet.h"
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

17) #include "ip.h"
Stefan Schuermans implementation of ethernet...

Stefan Schuermans authored 12 years ago

18) #include "macros.h"
19) #include "nethelp.h"
20) 
21) /**
22)  * @brief process a received ethernet packet
23)  * @param[in] ptr pointer to data of packet
24)  * @param[in] sz size of packet
25)  */
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

26) void ethernet_recv(void *ptr, unsigned int sz)
Stefan Schuermans implementation of ethernet...

Stefan Schuermans authored 12 years ago

27) {
28)   struct ethernet_packet *eth_pack;
29) 
30)   // packet too short
31)   if (sz < sizeof(struct ethernet_packet))
32)     return;
33) 
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

34)   eth_pack = ptr;
Stefan Schuermans implementation of ethernet...

Stefan Schuermans authored 12 years ago

35) 
36)   // branch according to packet type
37)   switch (eth_pack->eth_hdr.type)
38)   {
39)     // ARP
40)     case htons(0x0806):
41)       arp_recv(ptr, sz);
42)       break;
43)     // IP
44)     case htons(0x0800):
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

45)       ip_recv(ptr, sz);
Stefan Schuermans implementation of ethernet...

Stefan Schuermans authored 12 years ago

46)       break;
47)   }
48) }
49) 
50) /**
51)  * @brief send an ethernet packet
52)  * @param[in] ptr pointer to data of packet
53)  * @param[in] sz size of packet
54)  *
Stefan Schuermans handle padding to minimum e...

Stefan Schuermans authored 12 years ago

55)  * ptr must point to a ethernet_packet
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

56)  * with eth_hdr.dest and eth_hdr.type already initialized
Stefan Schuermans implementation of ethernet...

Stefan Schuermans authored 12 years ago

57)  */
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

58) void ethernet_send(void *ptr, unsigned int sz)
Stefan Schuermans implementation of ethernet...

Stefan Schuermans authored 12 years ago

59) {
60)   struct ethernet_packet *eth_pack;
61) 
62)   // packet too short
63)   if (sz < sizeof(struct ethernet_packet))
64)     return;
65) 
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

66)   eth_pack = ptr;