X-Git-Url: https://git.llucax.com/z.facultad/66.09/etherled.git/blobdiff_plain/05000dec2685a88aaf9bd3c20c8861e62c94696c..ab12c9208b125b42786a69291a96959cd295b19d:/src/eth.c diff --git a/src/eth.c b/src/eth.c index 9085dbb..ee40aac 100644 --- a/src/eth.c +++ b/src/eth.c @@ -17,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; @@ -34,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; } @@ -43,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(); }