writing callback function used in pcap_loop() for each packet