ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/dummy/ether_dummy.cpp
Revision: 1.6
Committed: 2001-07-15T02:26:20Z (23 years, 4 months ago) by cebix
Branch: MAIN
Changes since 1.5: +1 -0 lines
Log Message:
return value from ether_init() was missing

File Contents

# User Rev Content
1 cebix 1.1 /*
2     * ether_dummy.cpp - Ethernet device driver, dummy implementation
3     *
4 cebix 1.3 * Basilisk II (C) 1997-2001 Christian Bauer
5 cebix 1.1 *
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
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19     */
20    
21     #include "sysdeps.h"
22 cebix 1.5
23     #if SUPPORTS_UDP_TUNNEL
24     #include <netinet/in.h>
25     #include <sys/socket.h>
26     #endif
27    
28 cebix 1.1 #include "cpu_emulation.h"
29     #include "main.h"
30     #include "macos_util.h"
31     #include "prefs.h"
32     #include "user_strings.h"
33     #include "ether.h"
34     #include "ether_defs.h"
35    
36     #define DEBUG 0
37     #include "debug.h"
38    
39     #define MONITOR 0
40    
41    
42 cebix 1.5 // 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 cebix 1.1 /*
50     * Initialization
51     */
52    
53 cebix 1.4 bool ether_init(void)
54 cebix 1.1 {
55 cebix 1.6 return true;
56 cebix 1.1 }
57    
58    
59     /*
60     * Deinitialization
61     */
62    
63 cebix 1.4 void ether_exit(void)
64 cebix 1.1 {
65     }
66    
67    
68     /*
69     * Reset
70     */
71    
72 cebix 1.4 void ether_reset(void)
73 cebix 1.1 {
74     }
75    
76    
77     /*
78     * Add multicast address
79     */
80    
81     int16 ether_add_multicast(uint32 pb)
82     {
83     return noErr;
84     }
85    
86    
87     /*
88     * Delete multicast address
89     */
90    
91     int16 ether_del_multicast(uint32 pb)
92     {
93     return noErr;
94     }
95    
96    
97     /*
98     * Attach protocol handler
99     */
100    
101     int16 ether_attach_ph(uint16 type, uint32 handler)
102     {
103     return noErr;
104     }
105    
106    
107     /*
108     * Detach protocol handler
109     */
110    
111     int16 ether_detach_ph(uint16 type)
112     {
113     return noErr;
114     }
115    
116    
117     /*
118     * Transmit raw ethernet packet
119     */
120    
121     int16 ether_write(uint32 wds)
122     {
123     // Set source address
124     uint32 hdr = ReadMacInt32(wds + 2);
125     memcpy(Mac2HostAddr(hdr + 6), ether_addr, 6);
126     return noErr;
127     }
128    
129    
130     /*
131 cebix 1.5 * 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 cebix 1.1 * Ethernet interrupt - activate deferred tasks to call IODone or protocol handlers
160     */
161    
162     void EtherInterrupt(void)
163     {
164 cebix 1.5 #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 cebix 1.1 }