Example #1
0
func main() {
	file := "../../1.pcap"
	outfile := "o.pcap"

	err := golibwireshark.Init(file, outfile)
	if err != nil {
		fmt.Printf("open file failed\n")
		return
	}
	defer golibwireshark.Clean()

	//golibwireshark.PrintPacket()

	var p golibwireshark.Packet

	for {
		p.GetPacket()
		if p.Edt == nil {
			break
		}

		p.WriteToFile()

		p.FreePacket()

	}
}
Example #2
0
func main() {
	file := "../../1.pcap"
	key := "ip.addr"

	golibwireshark.Init(file, "")
	defer golibwireshark.Clean()

	var p golibwireshark.Packet

	for {
		p.GetPacket()
		if p.Edt == nil {
			break
		}

		if valueList, ok := p.IsKey(key); ok {
			for _, v := range valueList {
				fmt.Printf("[%s] %s\n", key, v)
			}
		}

		p.FreePacket()

	}
}
Example #3
0
func Example() {
	file := "1.pcap"
	outfile := "o.pcap"
	key := "ip.addr"

	err := golibwireshark.Init(file, outfile)
	if err != nil {
		fmt.Printf("open file failed\n")
		return
	}
	defer golibwireshark.Clean()

	var p golibwireshark.Packet

	for {
		p.GetPacket()
		if p.Edt == nil {
			break
		}

		if _, ok := p.IsKey(key); ok {
			p.WriteToFile()
		}

		p.FreePacket()
	}
}
func TestMain(m *testing.M) {
	file := "1.pcap"
	err := golibwireshark.Init(file, "o.pcap")
	if err != nil {
		fmt.Println("open file error")
		os.Exit(1)
	}

	golibwireshark.CloseInputFile()
	golibwireshark.CloseOutputFile()

	m.Run()

	golibwireshark.Clean()
}
Example #5
0
func main() {
	file := "../../1.pcap"

	err := golibwireshark.Init(file, "")
	if err != nil {
		fmt.Printf("open file failed\n")
		return
	}
	defer golibwireshark.Clean()

	var p golibwireshark.Packet

	for {
		p.GetPacket()
		if p.Edt == nil {
			break
		}

		fmt.Println(p)

		p.FreePacket()

	}
}