ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/dummy/ether_dummy.cpp
(Generate patch)

Comparing BasiliskII/src/dummy/ether_dummy.cpp (file contents):
Revision 1.3 by cebix, 2001-02-02T20:52:59Z vs.
Revision 1.6 by cebix, 2001-07-15T02:26:20Z

# Line 19 | Line 19
19   */
20  
21   #include "sysdeps.h"
22 +
23 + #if SUPPORTS_UDP_TUNNEL
24 + #include <netinet/in.h>
25 + #include <sys/socket.h>
26 + #endif
27 +
28   #include "cpu_emulation.h"
29   #include "main.h"
30   #include "macos_util.h"
# Line 33 | Line 39
39   #define MONITOR 0
40  
41  
42 + // Global variables
43 + #if SUPPORTS_UDP_TUNNEL
44 + static int fd = -1;                                             // UDP tunnel socket fd
45 + static bool udp_tunnel_active = false;
46 + #endif
47 +
48 +
49   /*
50   *  Initialization
51   */
52  
53 < void EtherInit(void)
53 > bool ether_init(void)
54   {
55 +        return true;
56   }
57  
58  
# Line 46 | Line 60 | void EtherInit(void)
60   *  Deinitialization
61   */
62  
63 < void EtherExit(void)
63 > void ether_exit(void)
64   {
65   }
66  
# Line 55 | Line 69 | void EtherExit(void)
69   *  Reset
70   */
71  
72 < void EtherReset(void)
72 > void ether_reset(void)
73   {
74   }
75  
# Line 114 | Line 128 | int16 ether_write(uint32 wds)
128  
129  
130   /*
131 + *  Start UDP packet reception thread
132 + */
133 +
134 + bool ether_start_udp_thread(int socket_fd)
135 + {
136 + #if SUPPORTS_UDP_TUNNEL
137 +        fd = socket_fd;
138 +        udp_tunnel_active = true;
139 +        return true;
140 + #else
141 +        return false;
142 + #endif
143 + }
144 +
145 +
146 + /*
147 + *  Stop UDP packet reception thread
148 + */
149 +
150 + void ether_stop_udp_thread(void)
151 + {
152 + #if SUPPORTS_UDP_TUNNEL
153 +        udp_tunnel_active = false;
154 + #endif
155 + }
156 +
157 +
158 + /*
159   *  Ethernet interrupt - activate deferred tasks to call IODone or protocol handlers
160   */
161  
162   void EtherInterrupt(void)
163   {
164 + #if SUPPORTS_UDP_TUNNEL
165 +        if (udp_tunnel_active) {
166 +                uint8 packet[1514];
167 +                ssize_t length;
168 +
169 +                // Read packets from socket and hand to ether_udp_read() for processing
170 +                while (true) {
171 +                        struct sockaddr_in from;
172 +                        socklen_t from_len = sizeof(from);
173 +                        length = recvfrom(fd, packet, 1514, 0, (struct sockaddr *)&from, &from_len);
174 +                        if (length < 14)
175 +                                break;
176 +                        ether_udp_read(packet, length, &from);
177 +                }
178 +        }
179 + #endif
180   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines