Storing data from sniff in a dict
===

I am trying to capture data using sniff and then filter it according to IP and MAC address and then store it in a buffer implemented using dict. But I am not able to achieve the data storing part. Below is the code.

        import sys
        from scapy.all import*

        class SniffRun(): ##Class to Sniff Packets, Display and Filter
            def __init__(self):
            pass

       def sniff_func(self):
           pkt=sniff(prn=lambda x:x.sprintf("{IP : %IP.src%  %IP.dst%\n\n}"),count=10,iface="eth0",store=1)
           ##Above line to sniff packets using filter parameters
           pkt.nsummary() ##Display the packet summary
           wrpcap("C:\snifftest.cap",pkt) ##Writing the packets to a PCap file
           f=open("C:\snifftest.cap",'rU') ##Opening the PCap file
           print "\n\nThe packets stored are\n",f.read() ##Displaying the PCap file
            
           print"\n\n"
           for src in pkt:
              print src.sprintf(r"Source Ethernet Address %Ether.src% \\") ##Filtering Source MAC
              self.sniffbuf(src.sprintf(r"Source Ethernet Address %Ether.src% \\"))
              print src.sprintf(r"Source IP Address %IP.src% \\") ##Filtering Source IP
              self.sniffbuf(src.sprintf(r"Source IP Address %IP.src% \\"))
           self.printdict()
  
           print"\n\n"
           for dst in pkt:
              print dst.sprintf(r"Destination Ethernet Address %Ether.dst% \\") ##Filtering Dest MAC
              print dst.sprintf(r"Destination IP Address %IP.dst% \\") ##Filtering Dest IP
           self.printdict()

        
        def sniffbuf(self,snifdat):
            snifdict={}
            for index in range(0,10):
                snifdict['%d'%index]=snifdat


        def printdict(self):
            print self.sniffbuf.snifdict

 

def main():
    sniff=SniffRun()
    sniff
    sniff.sniff_func()

    return

if __name__=='__main__':
    main()