title: create PCAP file for captured packet in c
body: <p>I am working on a tool though which I am able to capture incoming packets (l2 buffer and L2 length, payload) in an interface and I am able to print that packet on console.
  Now I want to write these packets to a <code>pcap</code> file so that I can transfer this file to other platform and read packet info.</p>
  
  <p>How I can open a pcap file and write packet buffer to pcap file?
  How can I fill <code>struct pcap_file_header</code>?</p>