Add more debug information

This commit is contained in:
Kioubit 2021-12-24 13:02:57 -05:00
parent 99e48b6103
commit f69d8c190e
3 changed files with 10 additions and 2 deletions

View File

@ -56,7 +56,7 @@ func (obj *ResponderObj) start() {
}()
go respond(obj.iface, requests, ndp_ADV, obj.filter, obj.autosense, obj.stopWG, obj.stopChan)
go listen(obj.iface, requests, ndp_SOL, obj.stopWG, obj.stopChan)
fmt.Println("Started responder instance")
fmt.Println("Started responder instance on interface ", obj.iface)
<-obj.stopChan
}
@ -122,6 +122,7 @@ func (obj *ProxyObj) start() {
go listen(obj.iface2, req_iface2_adv_iface1, ndp_ADV, obj.stopWG, obj.stopChan)
go respond(obj.iface1, req_iface2_adv_iface1, ndp_ADV, nil, "", obj.stopWG, obj.stopChan)
fmt.Println("Started Proxy instance for interfaces: ", obj.iface1, " and ", obj.iface2)
<-obj.stopChan
}

View File

@ -62,7 +62,9 @@ func listen(iface string, responder chan *ndpRequest, requestType ndpType, stopW
syscall.Close(fd)
stopWG.Done() // syscall.read does not release when the file descriptor is closed
}()
fmt.Println("Obtained fd ", fd)
if GlobalDebug {
fmt.Println("Obtained fd ", fd)
}
if len([]byte(iface)) > syscall.IFNAMSIZ {
panic("Interface size larger then maximum allowed by the kernel")
@ -113,6 +115,7 @@ func listen(iface string, responder chan *ndpRequest, requestType ndpType, stopW
panic(err)
}
if GlobalDebug {
fmt.Println("Got packet on", iface, "of type", requestType)
fmt.Println("Source IP:")
fmt.Printf("% X\n", buf[:numRead][22:38])
fmt.Println("Destination IP:")

View File

@ -87,6 +87,10 @@ func respond(iface string, requests chan *ndpRequest, respondType ndpType, filte
}
}
if GlobalDebug {
fmt.Println("Getting ready to send packet of type", respondType, "out on interface", iface)
}
if n.sourceIface == iface {
pkt(fd, result, n.srcIP, n.answeringForIP, niface.HardwareAddr, respondType)
} else {