2019-11-26 21:45:27 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-11-26 22:06:57 +00:00
|
|
|
"errors"
|
|
|
|
"fmt"
|
2019-11-28 12:45:32 +00:00
|
|
|
"git.darknebu.la/maride/pancap/ethernet"
|
2019-11-26 21:45:27 +00:00
|
|
|
"github.com/google/gopacket"
|
|
|
|
"github.com/google/gopacket/layers"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Analyzes the given packet source
|
|
|
|
func analyzePCAP(source *gopacket.PacketSource, linkType layers.LinkType) error {
|
2019-11-26 22:06:57 +00:00
|
|
|
// Switch over link type to determine correct module to ask for analysis
|
|
|
|
switch linkType {
|
|
|
|
case layers.LinkTypeEthernet:
|
|
|
|
// Ethernet
|
|
|
|
return ethernet.Analyze(source)
|
|
|
|
}
|
2019-11-26 21:45:27 +00:00
|
|
|
|
2019-11-26 22:06:57 +00:00
|
|
|
// if we reach this point, the given PCAP contains a link type we can't handle (yet).
|
|
|
|
errorMsg := fmt.Sprintf("Asked for link type %s (ID %d), but not supported by pancap. :( sorry!", linkType.String(), linkType)
|
|
|
|
return errors.New(errorMsg)
|
|
|
|
}
|