本文整理汇总了Golang中github.com/google/gopacket.NewFlow函数的典型用法代码示例。如果您正苦于以下问题:Golang NewFlow函数的具体用法?Golang NewFlow怎么用?Golang NewFlow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewFlow函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: getFlow
func (p *processor) getFlow(pkt gopacket.Packet) gopacket.Flow {
mu := moldudp64Layer(pkt)
//p.flowBufSrc.Reset()
//p.flowBufSrc.Write(pkt.NetworkLayer().NetworkFlow().Src().Raw())
//p.flowBufSrc.Write(pkt.TransportLayer().TransportFlow().Src().Raw())
//p.flowBufSrc.Write(mu.Flow().Src().Raw())
p.flowBufDst.Reset()
p.flowBufDst.Write(pkt.NetworkLayer().NetworkFlow().Dst().Raw())
p.flowBufDst.Write(pkt.TransportLayer().TransportFlow().Dst().Raw())
p.flowBufDst.Write(mu.Flow().Dst().Raw())
return gopacket.NewFlow(packet.EndpointCombinedSession, p.flowBufSrc.Bytes(), p.flowBufDst.Bytes())
}
开发者ID:ikravets,项目名称:ev,代码行数:12,代码来源:copying_processor.go
示例2: TransportFlow
func (t *TCP) TransportFlow() gopacket.Flow {
return gopacket.NewFlow(EndpointTCPPort, t.sPort, t.dPort)
}
开发者ID:cdshann,项目名称:minimega,代码行数:3,代码来源:tcp.go
示例3: NetworkFlow
func (i *IPv4) NetworkFlow() gopacket.Flow {
return gopacket.NewFlow(EndpointIPv4, i.SrcIP, i.DstIP)
}
开发者ID:nhooyr,项目名称:gopacket,代码行数:3,代码来源:ip4.go
示例4: LayerType
// PPP is the layer for PPP encapsulation headers.
type PPP struct {
BaseLayer
PPPType PPPType
}
// PPPEndpoint is a singleton endpoint for PPP. Since there is no actual
// addressing for the two ends of a PPP connection, we use a singleton value
// named 'point' for each endpoint.
var PPPEndpoint = gopacket.NewEndpoint(EndpointPPP, nil)
// PPPFlow is a singleton flow for PPP. Since there is no actual addressing for
// the two ends of a PPP connection, we use a singleton value to represent the
// flow for all PPP connections.
var PPPFlow = gopacket.NewFlow(EndpointPPP, nil, nil)
// LayerType returns LayerTypePPP
func (p *PPP) LayerType() gopacket.LayerType { return LayerTypePPP }
// LinkFlow returns PPPFlow.
func (p *PPP) LinkFlow() gopacket.Flow { return PPPFlow }
func decodePPP(data []byte, p gopacket.PacketBuilder) error {
ppp := &PPP{}
if data[0]&0x1 == 0 {
if data[1]&0x1 == 0 {
return errors.New("PPP has invalid type")
}
ppp.PPPType = PPPType(binary.BigEndian.Uint16(data[:2]))
ppp.Contents = data[:2]
开发者ID:CNDonny,项目名称:scope,代码行数:30,代码来源:ppp.go
示例5: TransportFlow
func (u *UDP) TransportFlow() gopacket.Flow {
return gopacket.NewFlow(EndpointUDPPort, u.sPort, u.dPort)
}
开发者ID:read-later,项目名称:gopacket,代码行数:3,代码来源:udp.go
示例6: TransportFlow
// TransportFlow returns a flow based on the source and destination SCTP port.
func (s *SCTP) TransportFlow() gopacket.Flow {
return gopacket.NewFlow(EndpointSCTPPort, s.sPort, s.dPort)
}
开发者ID:cdshann,项目名称:minimega,代码行数:4,代码来源:sctp.go
示例7: scan
// scan scans the dst IP address of this scanner.
func (s *scanner) scan() error {
// First off, get the MAC address we should be sending packets to.
hwaddr, err := s.getHwAddr()
if err != nil {
return err
}
// Construct all the network layers we need.
eth := layers.Ethernet{
SrcMAC: s.iface.HardwareAddr,
DstMAC: hwaddr,
EthernetType: layers.EthernetTypeIPv4,
}
ip4 := layers.IPv4{
SrcIP: s.src,
DstIP: s.dst,
Version: 4,
TTL: 64,
Protocol: layers.IPProtocolTCP,
}
tcp := layers.TCP{
SrcPort: 54321,
DstPort: 0, // will be incremented during the scan
SYN: true,
}
tcp.SetNetworkLayerForChecksum(&ip4)
// Create the flow we expect returning packets to have, so we can check
// against it and discard useless packets.
ipFlow := gopacket.NewFlow(layers.EndpointIPv4, s.dst, s.src)
start := time.Now()
for {
// Send one packet per loop iteration until we've sent packets
// to all of ports [1, 65535].
if tcp.DstPort < 65535 {
start = time.Now()
tcp.DstPort++
if err := s.send(ð, &ip4, &tcp); err != nil {
log.Printf("error sending to port %v: %v", tcp.DstPort, err)
}
}
// Time out 5 seconds after the last packet we sent.
if time.Since(start) > time.Second*5 {
log.Printf("timed out for %v, assuming we've seen all we can", s.dst)
return nil
}
// Read in the next packet.
data, _, err := s.handle.ReadPacketData()
if err == pcap.NextErrorTimeoutExpired {
continue
} else if err != nil {
log.Printf("error reading packet: %v", err)
continue
}
// Parse the packet. We'd use DecodingLayerParser here if we
// wanted to be really fast.
packet := gopacket.NewPacket(data, layers.LayerTypeEthernet, gopacket.NoCopy)
// Find the packets we care about, and print out logging
// information about them. All others are ignored.
if net := packet.NetworkLayer(); net == nil {
// log.Printf("packet has no network layer")
} else if net.NetworkFlow() != ipFlow {
// log.Printf("packet does not match our ip src/dst")
} else if tcpLayer := packet.Layer(layers.LayerTypeTCP); tcpLayer == nil {
// log.Printf("packet has not tcp layer")
} else if tcp, ok := tcpLayer.(*layers.TCP); !ok {
// We panic here because this is guaranteed to never
// happen.
panic("tcp layer is not tcp layer :-/")
} else if tcp.DstPort != 54321 {
// log.Printf("dst port %v does not match", tcp.DstPort)
} else if tcp.RST {
log.Printf(" port %v closed", tcp.SrcPort)
} else if tcp.SYN && tcp.ACK {
log.Printf(" port %v open", tcp.SrcPort)
} else {
// log.Printf("ignoring useless packet")
}
}
}
开发者ID:CNDonny,项目名称:scope,代码行数:83,代码来源:main.go
示例8: IPFlow
func IPFlow(addr *net.UDPAddr) gopacket.Flow {
return gopacket.NewFlow(layers.EndpointIPv4, nil, addr.IP.To4())
}
开发者ID:ikravets,项目名称:ev,代码行数:3,代码来源:channels.go
示例9: UDPFlow
func UDPFlow(addr *net.UDPAddr) gopacket.Flow {
portBytes := []byte{byte(addr.Port >> 8), byte(addr.Port)}
return gopacket.NewFlow(layers.EndpointUDPPort, nil, portBytes)
}
开发者ID:ikravets,项目名称:ev,代码行数:4,代码来源:channels.go
示例10: LinkFlow
// LinkFlow returns a new flow of type EndpointMAC.
func (f *FDDI) LinkFlow() gopacket.Flow {
return gopacket.NewFlow(EndpointMAC, f.SrcMAC, f.DstMAC)
}
开发者ID:hgGeorg,项目名称:mongo,代码行数:4,代码来源:fddi.go
示例11: SubchannelFlow
func SubchannelFlow(s int) gopacket.Flow {
b := make([]byte, 4)
binary.LittleEndian.PutUint32(b, uint32(s))
return gopacket.NewFlow(EndpointSubchannel, nil, b)
}
开发者ID:ikravets,项目名称:ev,代码行数:5,代码来源:channels.go
示例12: TransportFlow
func (r *RUDP) TransportFlow() gopacket.Flow {
return gopacket.NewFlow(EndpointRUDPPort, []byte{byte(r.SrcPort)}, []byte{byte(r.DstPort)})
}
开发者ID:CNDonny,项目名称:scope,代码行数:3,代码来源:rudp.go
示例13: LinkFlow
func (sll *LinuxSLL) LinkFlow() gopacket.Flow {
return gopacket.NewFlow(EndpointMAC, sll.Addr, nil)
}
开发者ID:CNDonny,项目名称:scope,代码行数:3,代码来源:linux_sll.go
示例14: Flow
func (m *Mach) Flow() gopacket.Flow {
session := []byte{m.SessionNumber}
return gopacket.NewFlow(EndpointMachSession, session, session)
}
开发者ID:ikravets,项目名称:ev,代码行数:4,代码来源:mach.go
示例15: Flow
func (m *MoldUDP64) Flow() gopacket.Flow {
session := m.Contents[0:10]
return gopacket.NewFlow(EndpointMoldUDP64Session, session, session)
}
开发者ID:ikravets,项目名称:ev,代码行数:4,代码来源:moldudp64.go
示例16: LinkFlow
func (e *Ethernet) LinkFlow() gopacket.Flow {
return gopacket.NewFlow(EndpointMAC, e.SrcMAC, e.DstMAC)
}
开发者ID:CNDonny,项目名称:scope,代码行数:3,代码来源:ethernet.go
注:本文中的github.com/google/gopacket.NewFlow函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论