func traceDNSResponses(data []byte, m *base.Monitor) {
	var eventRaw model.DNSResponseRaw
	if err := binary.Read(bytes.NewBuffer(data), utils.GetHostByteOrder(), &eventRaw); err != nil {
		netLogger.Errorf("failed to decode received data (DeviceEventRaw): %s\n", err)
		return
	}
	// Prepare event
	event := model.DNSResponseEvent{
		EventBase: model.EventBase{
			EventMonitorName: m.Name,
			EventType:        model.DNSResponseType,
			Timestamp:        m.Nsp.GetBootTime().Add(time.Duration(eventRaw.TimestampRaw) * time.Nanosecond),
		},
		DNSResponseRaw: &eventRaw,
		SourceMACAddr:  utils.Char6ToEth(eventRaw.SourceMACAddrRaw),
		DestMACAddr:    utils.Char6ToEth(eventRaw.DestMACAddrRaw),
		Domain:         utils.DecodeDNS(eventRaw.DNSResponseSpec.DNSKey.NameRaw),
		QueryTimestamp: m.Nsp.GetBootTime().Add(time.Duration(eventRaw.QueryTimestampRaw) * time.Nanosecond),
	}
	event.ResponseTime = event.Timestamp.Sub(event.QueryTimestamp)

	switch event.NProtocol {
	case kernel.EthPIP:
		event.SourceIP = utils.Uint64ToIPv4(eventRaw.SourceIPRaw[0])
		event.DestIP = utils.Uint64ToIPv4(eventRaw.DestIPRaw[0])
	case kernel.EthPIPV6:
		event.SourceIP = utils.Uint64sToIPv6(eventRaw.SourceIPRaw)
		event.DestIP = utils.Uint64sToIPv6(eventRaw.DestIPRaw)
	}

	switch event.DNSResponseSpec.Type {
	case kernel.ARecord:
		event.ResolvedIP = utils.Uint64ToIPv4(eventRaw.DNSResponseSpec.IPRaw[0])
	case kernel.AAAARecord:
		event.ResolvedIP = utils.Uint64sToIPv6(eventRaw.DNSResponseSpec.IPRaw)
	}

	// Dispatch event
	m.Nsp.DispatchEvent(&event)
}
// traceDNSResponses - Traces DNS responses
Traces DNS responses
// traceDNSResponses - Traces DNS responses
func traceDNSResponses(data []byte, m *base.Monitor) {
	var eventRaw model.DNSResponseRaw
	if err := binary.Read(bytes.NewBuffer(data), utils.GetHostByteOrder(), &eventRaw); err != nil {
		netLogger.Errorf("failed to decode received data (DeviceEventRaw): %s\n", err)
		return
	}
	event := model.DNSResponseEvent{
		EventBase: model.EventBase{
			EventMonitorName: m.Name,
			EventType:        model.DNSResponseType,
			Timestamp:        m.Nsp.GetBootTime().Add(time.Duration(eventRaw.TimestampRaw) * time.Nanosecond),
		},
		DNSResponseRaw: &eventRaw,
		SourceMACAddr:  utils.Char6ToEth(eventRaw.SourceMACAddrRaw),
		DestMACAddr:    utils.Char6ToEth(eventRaw.DestMACAddrRaw),
		Domain:         utils.DecodeDNS(eventRaw.DNSResponseSpec.DNSKey.NameRaw),
		QueryTimestamp: m.Nsp.GetBootTime().Add(time.Duration(eventRaw.QueryTimestampRaw) * time.Nanosecond),
	}
	event.ResponseTime = event.Timestamp.Sub(event.QueryTimestamp)
	switch event.NProtocol {
	case kernel.EthPIP:
		event.SourceIP = utils.Uint64ToIPv4(eventRaw.SourceIPRaw[0])
		event.DestIP = utils.Uint64ToIPv4(eventRaw.DestIPRaw[0])
	case kernel.EthPIPV6:
		event.SourceIP = utils.Uint64sToIPv6(eventRaw.SourceIPRaw)
		event.DestIP = utils.Uint64sToIPv6(eventRaw.DestIPRaw)
	}
	switch event.DNSResponseSpec.Type {
	case kernel.ARecord:
		event.ResolvedIP = utils.Uint64ToIPv4(eventRaw.DNSResponseSpec.IPRaw[0])
	case kernel.AAAARecord:
		event.ResolvedIP = utils.Uint64sToIPv6(eventRaw.DNSResponseSpec.IPRaw)
	}
	m.Nsp.DispatchEvent(&event)
}
func traceDNSResponses ( data [ ] byte , m * base . Monitor ) { var eventRaw model . DNSResponseRaw if err := binary . Read ( bytes . NewBuffer ( data ) , utils . GetHostByteOrder ( ) , & eventRaw ) ; err != nil { netLogger . Errorf ( " \n " , err ) return } event := model . DNSResponseEvent { EventBase : model . EventBase { EventMonitorName : m . Name , EventType : model . DNSResponseType , Timestamp : m . Nsp . GetBootTime ( ) . Add ( time . Duration ( eventRaw . TimestampRaw ) * time . Nanosecond ) , } , DNSResponseRaw : & eventRaw , SourceMACAddr : utils . Char6ToEth ( eventRaw . SourceMACAddrRaw ) , DestMACAddr : utils . Char6ToEth ( eventRaw . DestMACAddrRaw ) , Domain : utils . DecodeDNS ( eventRaw . DNSResponseSpec . DNSKey . NameRaw ) , QueryTimestamp : m . Nsp . GetBootTime ( ) . Add ( time . Duration ( eventRaw . QueryTimestampRaw ) * time . Nanosecond ) , } event . ResponseTime = event . Timestamp . Sub ( event . QueryTimestamp ) switch event . NProtocol { case kernel . EthPIP : event . SourceIP = utils . Uint64ToIPv4 ( eventRaw . SourceIPRaw [ 0 ] ) event . DestIP = utils . Uint64ToIPv4 ( eventRaw . DestIPRaw [ 0 ] ) case kernel . EthPIPV6 : event . SourceIP = utils . Uint64sToIPv6 ( eventRaw . SourceIPRaw ) event . DestIP = utils . Uint64sToIPv6 ( eventRaw . DestIPRaw ) } switch event . DNSResponseSpec . Type { case kernel . ARecord : event . ResolvedIP = utils . Uint64ToIPv4 ( eventRaw . DNSResponseSpec . IPRaw [ 0 ] ) case kernel . AAAARecord : event . ResolvedIP = utils . Uint64sToIPv6 ( eventRaw . DNSResponseSpec . IPRaw ) } m . Nsp . DispatchEvent ( & event ) }
Traces DNS responses
Traces DNS responses
// Prepare event // Dispatch event