mirror of
https://github.com/maride/pancap.git
synced 2024-11-24 01:34:26 +00:00
26 lines
658 B
Go
26 lines
658 B
Go
package dhcpv4
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/maride/pancap/common"
|
|
"github.com/google/gopacket/layers"
|
|
)
|
|
|
|
// Processes the DHCP request packet handed over
|
|
func (p *Protocol) processRequestPacket(dhcppacket layers.DHCPv4) {
|
|
p.requestMAC = common.AppendIfUnique(dhcppacket.ClientHWAddr.String(), p.requestMAC)
|
|
}
|
|
|
|
// Generates the summary of all DHCP request packets
|
|
func (p *Protocol) generateRequestSummary() string {
|
|
reqAmount := len(p.requestMAC)
|
|
|
|
// Check if there were requests
|
|
if reqAmount == 0 {
|
|
// No, don't print a summary then.
|
|
return ""
|
|
}
|
|
|
|
return fmt.Sprintf("%d unique DHCP requests\n%s", reqAmount, common.GenerateTree(p.requestMAC))
|
|
}
|