(o pktOpts)
| 61 | } |
| 62 | |
| 63 | func makePkt(o pktOpts) []byte { |
| 64 | ipHL, tcpHL := 20, 20 |
| 65 | total := ipHL + tcpHL + len(o.payload) |
| 66 | b := make([]byte, total) |
| 67 | b[0] = 0x45 |
| 68 | binary.BigEndian.PutUint16(b[2:4], uint16(total)) |
| 69 | binary.BigEndian.PutUint16(b[4:6], 0x1111) |
| 70 | b[8] = 64 |
| 71 | b[9] = 6 |
| 72 | copy(b[12:16], o.src[:]) |
| 73 | copy(b[16:20], o.dst[:]) |
| 74 | binary.BigEndian.PutUint16(b[10:12], checksum(b[:ipHL])) |
| 75 | |
| 76 | t := b[ipHL:] |
| 77 | binary.BigEndian.PutUint16(t[0:2], o.srcPort) |
| 78 | binary.BigEndian.PutUint16(t[2:4], o.dport) |
| 79 | binary.BigEndian.PutUint32(t[4:8], o.seq) |
| 80 | binary.BigEndian.PutUint32(t[8:12], o.ack) |
| 81 | t[12] = byte((tcpHL / 4) << 4) |
| 82 | t[13] = o.flags |
| 83 | binary.BigEndian.PutUint16(t[14:16], 0x0800) |
| 84 | copy(t[tcpHL:], o.payload) |
| 85 | return b |
| 86 | } |
| 87 | |
| 88 | // verdictCounter wraps Verdict so tests can assert it was called exactly once. |
| 89 | type verdictCounter struct { |
no test coverage detected