21 |
|
#ifndef ETHER_H |
22 |
|
#define ETHER_H |
23 |
|
|
24 |
+ |
struct sockaddr_in; |
25 |
+ |
|
26 |
+ |
extern void EtherInit(void); |
27 |
+ |
extern void EtherExit(void); |
28 |
+ |
|
29 |
|
extern int16 EtherOpen(uint32 pb, uint32 dce); |
30 |
|
extern int16 EtherControl(uint32 pb, uint32 dce); |
31 |
|
extern void EtherReadPacket(uint8 **src, uint32 &dest, uint32 &len, uint32 &remaining); |
32 |
|
|
33 |
|
// System specific and internal functions/data |
29 |
– |
extern void EtherInit(void); |
30 |
– |
extern void EtherExit(void); |
34 |
|
extern void EtherReset(void); |
35 |
|
extern void EtherInterrupt(void); |
36 |
|
|
37 |
+ |
extern bool ether_init(void); |
38 |
+ |
extern void ether_exit(void); |
39 |
|
extern int16 ether_add_multicast(uint32 pb); |
40 |
|
extern int16 ether_del_multicast(uint32 pb); |
41 |
|
extern int16 ether_attach_ph(uint16 type, uint32 handler); |
42 |
|
extern int16 ether_detach_ph(uint16 type); |
43 |
|
extern int16 ether_write(uint32 wds); |
44 |
+ |
extern bool ether_start_udp_thread(int socket_fd); |
45 |
+ |
extern void ether_stop_udp_thread(void); |
46 |
+ |
extern void ether_udp_read(uint8 *packet, int length, struct sockaddr_in *from); |
47 |
|
|
48 |
< |
extern uint8 ether_addr[6]; // Ethernet address (set by EtherInit()) |
41 |
< |
extern bool net_open; // Flag: initialization succeeded, network device open (set by EtherInit()) |
48 |
> |
extern uint8 ether_addr[6]; // Ethernet address (set by ether_init()) |
49 |
|
|
50 |
|
// Ethernet driver data in MacOS RAM |
51 |
|
enum { |
60 |
|
|
61 |
|
extern uint32 ether_data; // Mac address of driver data in MacOS RAM |
62 |
|
|
63 |
+ |
// Copy packet data from WDS to linear buffer (must hold at least 1514 bytes), |
64 |
+ |
// returns packet length |
65 |
+ |
static inline int ether_wds_to_buffer(uint32 wds, uint8 *p) |
66 |
+ |
{ |
67 |
+ |
int len = 0; |
68 |
+ |
while (len < 1514) { |
69 |
+ |
int w = ReadMacInt16(wds); |
70 |
+ |
if (w == 0) |
71 |
+ |
break; |
72 |
+ |
Mac2Host_memcpy(p, ReadMacInt32(wds + 2), w); |
73 |
+ |
len += w; |
74 |
+ |
p += w; |
75 |
+ |
wds += 6; |
76 |
+ |
} |
77 |
+ |
return len; |
78 |
+ |
} |
79 |
+ |
|
80 |
|
#endif |