# 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 dpkt
import datetime
from ovizart.modules.traffic.log.logger import Logger
        self.src_ip = None
        self.dst_ip = None
        self.sport = None
        self.dport = None
        self.ident = None
        self.length = None
        self.data = None
        self.log = Logger("TCP Protocol Handler", "DEBUG")
        self.log.message("TCP protocol handler called")

    def read_tcp(self, ts, buf):
        eth = self.get_eth(buf)
        if not eth:
            return False
        ip = self.get_ip(eth)
        if not ip:
            return False
        self.timestamp = datetime.datetime.fromtimestamp(float(ts))
        tcp = self.get_tcp(ip)
        return tcp

    def get_eth(self, buf):
        eth = dpkt.ethernet.Ethernet(buf)
        if eth.type != dpkt.ethernet.ETH_TYPE_IP:
            return False
        else:
            return eth

    def get_ip(self, eth):
        ip = eth.data

# 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/parser/tcp/handler.py
import dpkt
import datetime
from ovizart.modules.traffic.log.logger import Logger

        self.src_ip = None
        self.dst_ip = None
        self.sport = None
        self.dport = None
        self.ident = None
        self.length = None
        self.data = None
        self.log = Logger("TCP Protocol Handler", "DEBUG")
        self.log.message("TCP protocol handler called")

    def read_tcp(self, ts, buf):
        eth = self.get_eth(buf)
        if not eth:
            return False
        ip = self.get_ip(eth)
        if not ip:
            return False
        self.timestamp = datetime.datetime.fromtimestamp(float(ts))
        tcp = self.get_tcp(ip)
        return tcp

    def get_eth(self, buf):
        eth = dpkt.ethernet.Ethernet(buf)
        if eth.type != dpkt.ethernet.ETH_TYPE_IP:
            return False
        else:
            return eth

    def get_ip(self, eth):
        ip = eth.data

        self.length = ip.len