1
0
mirror of https://git.zx2c4.com/wireguard-go synced 2024-11-15 01:05:15 +01:00

wintun: Cleanup

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2019-02-20 18:38:18 +01:00
parent b7025b5627
commit 040da43889

View File

@ -239,7 +239,7 @@ func (tun *nativeTun) Read(buff []byte, offset int) (int, error) {
} }
// Copy data. // Copy data.
copy(buff[offset:], (*(*[packetSizeMax]byte)(unsafe.Pointer(&tun.rdBuff.data[tun.rdBuff.offset+4])))[:size]) copy(buff[offset:], tun.rdBuff.data[tun.rdBuff.offset+4:][:size])
tun.rdBuff.offset += pSize tun.rdBuff.offset += pSize
return int(size), nil return int(size), nil
} }
@ -331,7 +331,7 @@ func (tun *nativeTun) putTunPacket(buff []byte) error {
// Write packet to the exchange buffer. // Write packet to the exchange buffer.
*(*uint32)(unsafe.Pointer(&tun.wrBuff.data[tun.wrBuff.offset])) = size *(*uint32)(unsafe.Pointer(&tun.wrBuff.data[tun.wrBuff.offset])) = size
copy((*(*[packetSizeMax]byte)(unsafe.Pointer(&tun.wrBuff.data[tun.wrBuff.offset+4])))[:size], buff) copy(tun.wrBuff.data[tun.wrBuff.offset+4:][:size], buff)
tun.wrBuff.packetNum++ tun.wrBuff.packetNum++
tun.wrBuff.offset += pSize tun.wrBuff.offset += pSize