X-Git-Url: https://git.llucax.com/z.facultad/66.09/etherled.git/blobdiff_plain/cbf2122a2f610a2b92f1dfcb0f554b4bf7c4757e..2cf7241a2ec32fd51b6d859c2eb0317b23739609:/src/eth.c?ds=inline diff --git a/src/eth.c b/src/eth.c index 6b9e162..ee40aac 100644 --- a/src/eth.c +++ b/src/eth.c @@ -1,5 +1,6 @@ // vim: set et sw=4 sts=4 : +#include "debug.h" #include "netdev.h" #include "eth.h" @@ -16,15 +17,16 @@ bool eth_read_frame_header() { /* variable para iterar */ byte i; + netdev_read_start(ETH_HEADER_SIZE); /* descarto MAC de destino, acepto broadcasts */ for (i = 0; i < ETH_ADDR_SIZE; ++i) - netdev_recv_byte(); + netdev_read_byte(); /* obtenemos MAC de origen */ for (i = 0; i < ETH_ADDR_SIZE; ++i) - eth_addr_remote[i] = netdev_recv_byte(); + eth_addr_remote[i] = netdev_read_byte(); /* obtenemos tipo de protocolo transportado por el frame, (sólo * aceptamos IP y ARP) */ - switch (netdev_recv_word()) + switch (netdev_read_word()) { case IP: eth_proto = ETH_IP; @@ -33,8 +35,10 @@ bool eth_read_frame_header() eth_proto = ETH_ARP; break; default: + netdev_read_end(); return false; /* drop */ } + netdev_read_end(); return true; } @@ -42,13 +46,15 @@ void eth_write_frame_header() { /* variable para iterar */ byte i; + netdev_write_start(ETH_HEADER_SIZE); /* mandamos como MAC de destino la remota */ for (i = 0; i < ETH_ADDR_SIZE; ++i) - netdev_send_byte(eth_addr_remote[i]); + netdev_write_byte(eth_addr_remote[i]); /* y como fuente la nuestra */ for (i = 0; i < ETH_ADDR_SIZE; ++i) - netdev_send_byte(eth_addr_local[i]); + netdev_write_byte(eth_addr_local[i]); /* escribimos el tipo de paquete que transporta el frame */ - netdev_send_word((eth_proto == ETH_IP) ? IP : ARP); + netdev_write_word((eth_proto == ETH_IP) ? IP : ARP); + netdev_write_end(); }