Developing lightweight computation at the DSG edge

Commit d596e704 authored by Alirie Gray's avatar Alirie Gray Committed by Cameron Sparr
Browse files

Fix runtime panic

parent 3eec4c7c
...@@ -442,7 +442,7 @@ func (p *Pinger) processPacket(recv *packet) error { ...@@ -442,7 +442,7 @@ func (p *Pinger) processPacket(recv *packet) error {
var proto int var proto int
if p.ipv4 { if p.ipv4 {
if p.network == "ip" { if p.network == "ip" {
bytes = ipv4Payload(recv.bytes) bytes = ipv4Payload(recv)
} else { } else {
bytes = recv.bytes bytes = recv.bytes
} }
...@@ -591,11 +591,13 @@ func byteSliceOfSize(n int) []byte { ...@@ -591,11 +591,13 @@ func byteSliceOfSize(n int) []byte {
return b return b
} }
func ipv4Payload(b []byte) []byte { func ipv4Payload(recv *packet) []byte {
b := recv.bytes
if len(b) < ipv4.HeaderLen { if len(b) < ipv4.HeaderLen {
return b return b
} }
hdrlen := int(b[0]&0x0f) << 2 hdrlen := int(b[0]&0x0f) << 2
recv.nbytes -= hdrlen
return b[hdrlen:] return b[hdrlen:]
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment