Skip to content

Commit

Permalink
calculate TCP payload slice sizes for Ethernet II packets less than 6…
Browse files Browse the repository at this point in the history
…4 octets (#326)

* remove unused bCLRF var.

* calculate TCP payload slice sizes for Ethernet II packets less than 64 octets

* simplify slicing off padding for Ethernet link packets less than 61 octets in length.

* Make IPv4 header stripping comments more accurate.
  • Loading branch information
joekiller authored and buger committed Jul 6, 2016
1 parent 1ed8691 commit c128d46
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 6 additions & 1 deletion raw_socket_listener/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,12 @@ func (t *Listener) readPcap() {

srcIP = data[12:16]
dstIP = data[16:20]
data = data[ihl*4:]
// Stripping off the IP header
if len(packet.Data()) <= 60 && decoder == layers.LinkTypeEthernet { // Small Ethernet packets have padding
data = data[ihl * 4: int(binary.BigEndian.Uint16(data[2:4]))]
} else {
data = data[ihl * 4:]
}
} else {
// Truncated IP info
if len(data) < 40 {
Expand Down
1 change: 0 additions & 1 deletion raw_socket_listener/tcp_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ func (t *TCPMessage) checkSeqIntegrity() {
t.seqMissing = false
}

var bCLRF = []byte("\r\n")
var bEmptyLine = []byte("\r\n\r\n")
var bChunkEnd = []byte("0\r\n\r\n")

Expand Down

0 comments on commit c128d46

Please sign in to comment.