2019-12-09 11:14:01 +00:00
|
|
|
package dhcpv4
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2023-09-02 15:17:51 +00:00
|
|
|
"github.com/maride/pancap/common"
|
2019-12-09 11:14:01 +00:00
|
|
|
"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 {
|
2020-12-14 13:27:49 +00:00
|
|
|
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))
|
2019-12-09 11:14:01 +00:00
|
|
|
}
|