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.2 by cebix, 2000-04-10T18:53:21Z vs.
Revision 1.5 by cebix, 2001-07-14T20:01:20Z

# Line 1 | Line 1
1   /*
2   *  ether_dummy.cpp - Ethernet device driver, dummy implementation
3   *
4 < *  Basilisk II (C) 1997-2000 Christian Bauer
4 > *  Basilisk II (C) 1997-2001 Christian Bauer
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# 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   }
56  
# Line 46 | Line 59 | void EtherInit(void)
59   *  Deinitialization
60   */
61  
62 < void EtherExit(void)
62 > void ether_exit(void)
63   {
64   }
65  
# Line 55 | Line 68 | void EtherExit(void)
68   *  Reset
69   */
70  
71 < void EtherReset(void)
71 > void ether_reset(void)
72   {
73   }
74  
# 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