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.4 by cebix, 2001-07-13T15:39:24Z vs.
Revision 1.5 by cebix, 2001-07-14T20:01: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   */
# Line 114 | Line 127 | int16 ether_write(uint32 wds)
127  
128  
129   /*
130 + *  Start UDP packet reception thread
131 + */
132 +
133 + bool ether_start_udp_thread(int socket_fd)
134 + {
135 + #if SUPPORTS_UDP_TUNNEL
136 +        fd = socket_fd;
137 +        udp_tunnel_active = true;
138 +        return true;
139 + #else
140 +        return false;
141 + #endif
142 + }
143 +
144 +
145 + /*
146 + *  Stop UDP packet reception thread
147 + */
148 +
149 + void ether_stop_udp_thread(void)
150 + {
151 + #if SUPPORTS_UDP_TUNNEL
152 +        udp_tunnel_active = false;
153 + #endif
154 + }
155 +
156 +
157 + /*
158   *  Ethernet interrupt - activate deferred tasks to call IODone or protocol handlers
159   */
160  
161   void EtherInterrupt(void)
162   {
163 + #if SUPPORTS_UDP_TUNNEL
164 +        if (udp_tunnel_active) {
165 +                uint8 packet[1514];
166 +                ssize_t length;
167 +
168 +                // Read packets from socket and hand to ether_udp_read() for processing
169 +                while (true) {
170 +                        struct sockaddr_in from;
171 +                        socklen_t from_len = sizeof(from);
172 +                        length = recvfrom(fd, packet, 1514, 0, (struct sockaddr *)&from, &from_len);
173 +                        if (length < 14)
174 +                                break;
175 +                        ether_udp_read(packet, length, &from);
176 +                }
177 +        }
178 + #endif
179   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines