# Path: fjospidie/Utils.py
# def get_md5(data):
#     """
#     Get the MD5sum of the passed data
#     """
#     md5 = hashlib.md5()
#     md5.update(data)
#     return md5.hexdigest()


import logging
import tempfile
import pcap
import subprocess
import threading
from fjospidie.Utils import get_md5
        while True:
            line = route.stdout.readline()
            if line != '':
                if line.startswith("default") or line.startswith("0.0.0.0"):
                    default = line
                    break
            else:
                break

        parts = default.split()
        if len(parts) >= 8:
            return parts[7]
        else:
            return parts[5]

    def stop(self):
        """
        Stop the tcpdump
        """
        self.p.breakloop()
        self.add_to_db()

    def add_to_db(self):
        """
        Add the pcap to the mongodb gridfs store
        """
        pcap_data = None
        with open(self.pcap_path, mode='rb') as f:
            pcap_data = f.read()
        self.logger.debug("Adding " + self.pcap_path + " to database")

# Path: fjospidie/Utils.py
# def get_md5(data):
#     """
#     Get the MD5sum of the passed data
#     """
#     md5 = hashlib.md5()
#     md5.update(data)
#     return md5.hexdigest()


# Path: fjospidie/engine/PcapEngine.py
import logging
import tempfile
import pcap
import subprocess
import threading
from fjospidie.Utils import get_md5

        while True:
            line = route.stdout.readline()
            if line != '':
                if line.startswith("default") or line.startswith("0.0.0.0"):
                    default = line
                    break
            else:
                break

        parts = default.split()
        if len(parts) >= 8:
            return parts[7]
        else:
            return parts[5]

    def stop(self):
        """
        Stop the tcpdump
        """
        self.p.breakloop()
        self.add_to_db()

    def add_to_db(self):
        """
        Add the pcap to the mongodb gridfs store
        """
        pcap_data = None
        with open(self.pcap_path, mode='rb') as f:
            pcap_data = f.read()
        self.logger.debug("Adding " + self.pcap_path + " to database")

        md5 = get_md5(pcap_data)