# Path: ovizart/modules/traffic/log/logger.py
# class Logger:
# 
#     def __init__(self, log_name, log_mode):
#         logging.basicConfig(format='%(asctime)-6s: %(name)s - %(levelname)s - %(message)s')
#         self.mode = log_mode
#         self.log = logging.getLogger(log_name)
#         self.log.setLevel(log_mode)
# 
#     def set_log_level(self, level="DEBUG"):
#         self.log.setLevel(level)
# 
#     def message(self, message):
#         if self.mode == "DEBUG":
#             self.log.debug(message)
#         if self.mode == "ERROR":
#             self.log.error(message)
#         if self.mode == "INFO":
#             self.log.info(message)


import sys
import dpkt
from ovizart.modules.traffic.log.logger import Logger
    def get_filter_type(self):
        return self._filter_type

    def get_pcap(self):
        return self._pcap

    def get_eth(self, buf):
        eth = dpkt.ethernet.Ethernet(buf)
        if eth.type == dpkt.ethernet.ETH_TYPE_IP:
            return eth
        else:
            self._logger.set_log_level("ERROR")
            self._logger.message("No Eth is returned")
            return False

    def get_ip(self, eth):
        ip = eth.data
        if ip.p == dpkt.ip.IP_PROTO_TCP:
            return ip
        else:
            self._logger.set_log_level("ERROR")
            self._logger.message("No IP is returned")
            return False

    def get_tcp(self, ip):
        tcp = ip.data
        #self._logger.message(("TCP is returned %s") % (tcp))
        return tcp

    def get_udp(self, ip):

# Path: ovizart/modules/traffic/log/logger.py
# class Logger:
# 
#     def __init__(self, log_name, log_mode):
#         logging.basicConfig(format='%(asctime)-6s: %(name)s - %(levelname)s - %(message)s')
#         self.mode = log_mode
#         self.log = logging.getLogger(log_name)
#         self.log.setLevel(log_mode)
# 
#     def set_log_level(self, level="DEBUG"):
#         self.log.setLevel(level)
# 
#     def message(self, message):
#         if self.mode == "DEBUG":
#             self.log.debug(message)
#         if self.mode == "ERROR":
#             self.log.error(message)
#         if self.mode == "INFO":
#             self.log.info(message)


# Path: ovizart/modules/traffic/pcap/handler.py
import sys
import dpkt
from ovizart.modules.traffic.log.logger import Logger

    def get_filter_type(self):
        return self._filter_type

    def get_pcap(self):
        return self._pcap

    def get_eth(self, buf):
        eth = dpkt.ethernet.Ethernet(buf)
        if eth.type == dpkt.ethernet.ETH_TYPE_IP:
            return eth
        else:
            self._logger.set_log_level("ERROR")
            self._logger.message("No Eth is returned")
            return False

    def get_ip(self, eth):
        ip = eth.data
        if ip.p == dpkt.ip.IP_PROTO_TCP:
            return ip
        else:
            self._logger.set_log_level("ERROR")
            self._logger.message("No IP is returned")
            return False

    def get_tcp(self, ip):
        tcp = ip.data
        #self._logger.message(("TCP is returned %s") % (tcp))
        return tcp

    def get_udp(self, ip):

        udp = ip.data