Skip to content

Instantly share code, notes, and snippets.

Last active Aug 29, 2015
What would you like to do?
ICMP raw receive
package main
import (
func main() {
fd, _ := syscall.Socket(syscall.AF_INET, syscall.SOCK_RAW, syscall.IPPROTO_ICMP)
f := os.NewFile(uintptr(fd), fmt.Sprintf("fd %d", fd))
for {
buf := make([]byte, 1024)
numRead, err := f.Read(buf)
if err != nil {
fmt.Printf("% X\n", buf[:numRead])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment