-
Notifications
You must be signed in to change notification settings - Fork 0
/
rndis.go
60 lines (52 loc) · 1.04 KB
/
rndis.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"bytes"
"encoding/binary"
)
type rndisMessage struct {
MsgType uint32
MsgLength uint32
DataOffset uint32
DataLength uint32
BandOffset uint32
BandLen uint32
OutBandElements uint32
PacketOffset uint32
PacketInfoLength uint32
ReservedFirst uint32
ReservedSecond uint32
}
type rndisInitMsg struct {
MsgType uint32
MsgLength uint32
RequestID uint32
MajorVersion uint32
MinorVersion uint32
MaxTransferSize uint32
}
type rndisSetMsg struct {
MsgType uint32
MsgLength uint32
RequestID uint32
OID uint32
Length uint32
Offset uint32
Reserved uint32
OIDp uint32
}
func makeRndis(length uint32) rndisMessage {
var rndis rndisMessage
rndis.MsgType = 1
rndis.MsgLength = length + 44
rndis.DataOffset = 0x24
rndis.DataLength = length
return rndis
}
func (msg rndisMessage) bytes() []byte {
buf := new(bytes.Buffer)
err := binary.Write(buf, binary.LittleEndian, msg)
if err != nil {
panic(err)
}
return buf.Bytes()
}