25 lines
465 B
Go
25 lines
465 B
Go
package tap
|
|
|
|
type Interface struct {
|
|
Name string
|
|
MTU int
|
|
fd int
|
|
}
|
|
|
|
// Open creates a TAP interface on Linux. On other platforms it returns an error.
|
|
func Open(name string, mtu int) (*Interface, error) {
|
|
return openTap(name, mtu)
|
|
}
|
|
|
|
func (t *Interface) Read(buf []byte) (int, error) {
|
|
return readBuf(t.fd, buf)
|
|
}
|
|
|
|
func (t *Interface) Write(buf []byte) (int, error) {
|
|
return writeBuf(t.fd, buf)
|
|
}
|
|
|
|
func (t *Interface) Close() error {
|
|
return closeFD(t.fd)
|
|
}
|