/[pearpc]/src/system/sysethtun.h
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /src/system/sysethtun.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Wed Sep 5 17:11:21 2007 UTC (13 years, 3 months ago) by dpavlin
File MIME type: text/plain
File size: 3363 byte(s)
import upstream CVS
1 /*
2 * PearPC
3 * sysethtun.h
4 *
5 * Abstraction for ethernet tunnel devices
6 *
7 * Copyright (C) 2003,2004 Stefan Weyergraf
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #ifndef __SYSETHTUN_H__
24 #define __SYSETHTUN_H__
25
26 #include "system/types.h"
27
28 // FIXME: reentrancy, threading specs
29
30 class PacketDevice {
31 public:
32 virtual ~PacketDevice() {}
33
34 /**
35 * Read a packet from the device into a buffer
36 *
37 * @param buf pointer to a buffer containing the packet data
38 * @param size size of the buffer
39 * @returns number of bytes received and written into buf
40 */
41 virtual uint recvPacket(void *buf, uint size) = 0;
42
43 /**
44 * Wait for a packet to be received
45 *
46 * This function blocks the calling thread until a packet is received
47 * or an error occurs. It should do this in a manner that consumes
48 * little to low CPU time.
49 * If the function succeeds the next call to recvPacket() is
50 * "very likely" to succeed as well.
51 *
52 * @returns 0 on success, non-zero in case of error (the result is
53 * an errno. Ie. you can use it in strerror())
54 */
55 virtual int waitRecvPacket() = 0;
56
57 /**
58 * Write a packet from a buffer into the device
59 *
60 * @param buf pointer to a buffer containing the packet data
61 * @param size size of the buffer
62 * @returns number of bytes sent and written into buf
63 */
64 virtual uint sendPacket(void *buf, uint size) = 0;
65 };
66
67 /**
68 * An ethernet tunnel is a virtual ethernet line connecting the operating
69 * system's networking stack with some other piece of software (as opposed
70 * to a physical ethernet cable, connecting two pieces of hardware).
71 *
72 * This class represents one end-point of the tunnel, the aforementioned
73 * "piece of software". Both sides should be configured to have their own
74 * separate network addresses (e.g. MAC and IP addresses).
75 *
76 * The packets sent and received are ethernet specific Ethernet-II
77 * frames with IEEE 802.3 MAC addresses, prefixed by a specific number of
78 * bytes (for use by the networking stack).
79 */
80 class EthTunDevice: public PacketDevice {
81 public:
82 virtual ~EthTunDevice() {}
83
84 /**
85 * Get driver-specific ethernet write frame prefix.
86 *
87 * When writing packets, a specific number of bytes in the packet
88 * buffer must be dedicated to the system's networking stack. The
89 * actual ethernet frame follows after this area.
90 *
91 * @returns number of bytes in write frame prefix
92 */
93 virtual uint getWriteFramePrefix() = 0;
94 /**
95 * Initialize the device.
96 *
97 * @returns init status (0 = ok)
98 */
99 virtual int initDevice() = 0;
100 /**
101 * Uninitialize the device.
102 *
103 * @returns shutdown status (0 = ok)
104 */
105 virtual int shutdownDevice() = 0;
106 };
107
108 /* system-dependent (implementation in $MYSYSTEM/ *.cc) */
109 extern EthTunDevice *createEthernetTunnel();
110
111 #endif /* __SYSETHTUN_H__ */

  ViewVC Help
Powered by ViewVC 1.1.26