--- BasiliskII/src/include/ether.h 1999/10/03 14:16:26 1.1 +++ BasiliskII/src/include/ether.h 2005/01/30 21:42:15 1.8 @@ -1,7 +1,7 @@ /* * ether.h - Ethernet device driver * - * Basilisk II (C) 1997-1999 Christian Bauer + * Basilisk II (C) 1997-2005 Christian Bauer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,24 +21,32 @@ #ifndef ETHER_H #define ETHER_H +struct sockaddr_in; + +extern void EtherInit(void); +extern void EtherExit(void); + extern int16 EtherOpen(uint32 pb, uint32 dce); extern int16 EtherControl(uint32 pb, uint32 dce); extern void EtherReadPacket(uint8 **src, uint32 &dest, uint32 &len, uint32 &remaining); // System specific and internal functions/data -extern void EtherInit(void); -extern void EtherExit(void); extern void EtherReset(void); extern void EtherInterrupt(void); +extern bool ether_init(void); +extern void ether_exit(void); +extern void ether_reset(void); extern int16 ether_add_multicast(uint32 pb); extern int16 ether_del_multicast(uint32 pb); extern int16 ether_attach_ph(uint16 type, uint32 handler); extern int16 ether_detach_ph(uint16 type); extern int16 ether_write(uint32 wds); +extern bool ether_start_udp_thread(int socket_fd); +extern void ether_stop_udp_thread(void); +extern void ether_udp_read(uint8 *packet, int length, struct sockaddr_in *from); -extern uint8 ether_addr[6]; // Ethernet address (set by EtherInit()) -extern bool net_open; // Flag: initialization succeeded, network device open (set by EtherInit()) +extern uint8 ether_addr[6]; // Ethernet address (set by ether_init()) // Ethernet driver data in MacOS RAM enum { @@ -53,4 +61,21 @@ enum { extern uint32 ether_data; // Mac address of driver data in MacOS RAM +// Copy packet data from WDS to linear buffer (must hold at least 1514 bytes), +// returns packet length +static inline int ether_wds_to_buffer(uint32 wds, uint8 *p) +{ + int len = 0; + while (len < 1514) { + int w = ReadMacInt16(wds); + if (w == 0) + break; + Mac2Host_memcpy(p, ReadMacInt32(wds + 2), w); + len += w; + p += w; + wds += 6; + } + return len; +} + #endif