00d70bee0c1121134e74c1402ebdc9b80807a3bf
Stefan Schuermans implementation of ethernet...

Stefan Schuermans authored 12 years ago

1) /* flpDistriR25S - flexipix distributor for pixels round 25mm with switch
2)  * version 1.0.0 date 2011-06-12
3)  * created by Stefan Schuermans <stefan@schuermans.info>
4)  * Copyright (C) 2006-2011 flexipix GbR, Germany
5)  */
6) 
7) #include "arp.h"
8) #include "config.h"
9) #include "eth.h"
10) #include "ethernet.h"
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

12) #include "macros.h"
13) #include "nethelp.h"
14) 
15) /**
16)  * @brief process a received ethernet packet
17)  * @param[in] ptr pointer to data of packet
18)  * @param[in] sz size of packet
19)  */
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

21) {
22)   struct ethernet_packet *eth_pack;
23) 
24)   // packet too short
25)   if (sz < sizeof(struct ethernet_packet))
26)     return;
27) 
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

29) 
30)   // branch according to packet type
31)   switch (eth_pack->eth_hdr.type)
32)   {
33)     // ARP
34)     case htons(0x0806):
35)       arp_recv(ptr, sz);
36)       break;
37)     // IP
38)     case htons(0x0800):
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

40)       break;
41)   }
42) }
43) 
44) /**
45)  * @brief send an ethernet packet
46)  * @param[in] ptr pointer to data of packet
47)  * @param[in] sz size of packet
48)  *
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

49)  * ptr must point to a ethernet_packet of sufficient size (ethernet padding)
50)  * with eth_hdr.dest and eth_hdr.type already initialized
Stefan Schuermans implementation of ethernet...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

53) {
54)   struct ethernet_packet *eth_pack;
55) 
56)   // packet too short
57)   if (sz < sizeof(struct ethernet_packet))
58)     return;
59) 
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

60)   eth_pack = ptr;