def parse_network_data(data_packet=None,<EOL>include_filter_key=None,<EOL>filter_keys=[],<EOL>record_tcp=True,<EOL>record_udp=True,<EOL>record_arp=True,<EOL>record_icmp=True):
node = {"<STR_LIT:id>": build_key(),<EOL>"<STR_LIT>": UNKNOWN,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": SIZE_ETH_HEADER,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT:status>": INVALID}<EOL>err = "<STR_LIT>"<EOL>if not data_packet:<EOL><INDENT>node["<STR_LIT:error>"] = err<EOL>return node<EOL><DEDENT>try:<EOL><INDENT>err = "<STR_LIT>"<EOL>packet = data_packet[<NUM_LIT:0>]<EOL>if len(packet) < <NUM_LIT>:<EOL><INDENT>node["<STR_LIT:status>"] = INVALID<EOL>node["<STR_LIT:error>"] = "<STR_LIT>".format(packet)<EOL>return node<EOL><DEDENT>err = "<STR_LIT>"<EOL>eth_packet_min = <NUM_LIT:0><EOL>eth_packet_max = eth_packet_min + node["<STR_LIT>"]<EOL>log.info(("<STR_LIT>")<EOL>.format(eth_packet_min,<EOL>eth_packet_max))<EOL>eth_datagram = packet[eth_packet_min:eth_packet_max]<EOL>eth_header = unpack(ETH_HEADER_FORMAT, eth_datagram)<EOL>node["<STR_LIT>"] = socket.ntohs(eth_header[<NUM_LIT:2>])<EOL>node["<STR_LIT>"] = eth_addr(packet[<NUM_LIT:0>:<NUM_LIT:6>])<EOL>node["<STR_LIT>"] = eth_addr(packet[<NUM_LIT:6>:<NUM_LIT:12>])<EOL>log.debug(("<STR_LIT>")<EOL>.format(node["<STR_LIT>"],<EOL>node["<STR_LIT>"],<EOL>node["<STR_LIT>"]))<EOL>node["<STR_LIT>"] = SIZE_ETH_HEADER<EOL>if node["<STR_LIT>"] == IP_PROTO_ETH:<EOL><INDENT>ip_packet_min = SIZE_ETH_HEADER<EOL>ip_packet_max = SIZE_ETH_HEADER + <NUM_LIT:20><EOL>log.info(("<STR_LIT>")<EOL>.format(ip_packet_min,<EOL>ip_packet_max))<EOL>err = ("<STR_LIT>").format(<EOL>ip_packet_min,<EOL>ip_packet_max)<EOL>ip_datagram = packet[ip_packet_min:ip_packet_max]<EOL>ip_header = unpack(IP_HEADER_FORMAT, ip_datagram)<EOL>node["<STR_LIT>"] = SIZE_IP_HEADER<EOL>node["<STR_LIT>"] = ip_header[<NUM_LIT:0>]<EOL>node["<STR_LIT>"] = node["<STR_LIT>"] >> <NUM_LIT:4><EOL>node["<STR_LIT>"] = node["<STR_LIT>"] & <NUM_LIT><EOL>node["<STR_LIT>"] = node["<STR_LIT>"] * <NUM_LIT:4><EOL>node["<STR_LIT>"] = ip_header[<NUM_LIT:1>]<EOL>node["<STR_LIT>"] = ip_header[<NUM_LIT:2>]<EOL>node["<STR_LIT>"] = ip_header[<NUM_LIT:3>]<EOL>node["<STR_LIT>"] = ip_header[<NUM_LIT:4>]<EOL>node["<STR_LIT>"] = ip_header[<NUM_LIT:5>]<EOL>node["<STR_LIT>"] = ip_header[<NUM_LIT:6>]<EOL>node["<STR_LIT>"] = socket.inet_ntoa(ip_header[<NUM_LIT:8>])<EOL>node["<STR_LIT>"] = socket.inet_ntoa(ip_header[<NUM_LIT:9>])<EOL>log.debug("<STR_LIT>")<EOL>log.debug("<STR_LIT>")<EOL>log.debug("<STR_LIT>")<EOL>log.debug("<STR_LIT>".format(node["<STR_LIT>"]))<EOL>log.debug("<STR_LIT>".format(node["<STR_LIT>"]))<EOL>log.debug("<STR_LIT>".format(node["<STR_LIT>"]))<EOL>log.debug("<STR_LIT>".format(node["<STR_LIT>"]))<EOL>log.debug("<STR_LIT>".format(node["<STR_LIT>"]))<EOL>log.debug("<STR_LIT>".format(node["<STR_LIT>"]))<EOL>log.debug("<STR_LIT>".format(node["<STR_LIT>"]))<EOL>log.debug("<STR_LIT>".format(node["<STR_LIT>"]))<EOL>log.debug("<STR_LIT>".format(node["<STR_LIT>"]))<EOL>log.debug("<STR_LIT>")<EOL>log.debug("<STR_LIT>")<EOL>tcp_data = None<EOL>udp_data = None<EOL>arp_data = None<EOL>icmp_data = None<EOL>target_data = None<EOL>eh = node["<STR_LIT>"]<EOL>ih = node["<STR_LIT>"]<EOL>log.debug(("<STR_LIT>")<EOL>.format(node["<STR_LIT>"]))<EOL>if node["<STR_LIT>"] == TCP_PROTO_IP:<EOL><INDENT>packet_min = node["<STR_LIT>"] + node["<STR_LIT>"]<EOL>packet_max = packet_min + <NUM_LIT:20><EOL>log.info(("<STR_LIT>")<EOL>.format(packet_min,<EOL>packet_max))<EOL>err = ("<STR_LIT>").format(<EOL>packet_min,<EOL>packet_max)<EOL>tcp_datagram = packet[packet_min:packet_max]<EOL>log.debug(("<STR_LIT>")<EOL>.format(tcp_datagram))<EOL>tcp_header = unpack(TCP_HEADER_FORMAT, tcp_datagram)<EOL>node["<STR_LIT>"] = tcp_header[<NUM_LIT:0>]<EOL>node["<STR_LIT>"] = tcp_header[<NUM_LIT:1>]<EOL>node["<STR_LIT>"] = tcp_header[<NUM_LIT:2>]<EOL>node["<STR_LIT>"] = tcp_header[<NUM_LIT:3>]<EOL>node["<STR_LIT>"] = tcp_header[<NUM_LIT:4>]<EOL>node["<STR_LIT>"] = node["<STR_LIT>"] >> <NUM_LIT:4><EOL>node["<STR_LIT>"] = tcp_header[<NUM_LIT:5>]<EOL>node["<STR_LIT>"] = tcp_header[<NUM_LIT:6>]<EOL>node["<STR_LIT>"] = tcp_header[<NUM_LIT:7>]<EOL>flag_data = unshift_flags(node["<STR_LIT>"])<EOL>node["<STR_LIT>"] = flag_data[<NUM_LIT:0>]<EOL>node["<STR_LIT>"] = flag_data[<NUM_LIT:1>]<EOL>node["<STR_LIT>"] = flag_data[<NUM_LIT:2>]<EOL>node["<STR_LIT>"] = flag_data[<NUM_LIT:3>]<EOL>node["<STR_LIT>"] = flag_data[<NUM_LIT:4>]<EOL>node["<STR_LIT>"] = flag_data[<NUM_LIT:5>]<EOL>node["<STR_LIT>"] = SIZE_TCP_HEADER<EOL>log.debug(("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL>.format(node["<STR_LIT>"],<EOL>node["<STR_LIT>"],<EOL>node["<STR_LIT>"],<EOL>node["<STR_LIT>"],<EOL>node["<STR_LIT>"],<EOL>node["<STR_LIT>"],<EOL>node["<STR_LIT>"],<EOL>node["<STR_LIT>"],<EOL>node["<STR_LIT>"],<EOL>node["<STR_LIT>"],<EOL>node["<STR_LIT>"],<EOL>node["<STR_LIT>"],<EOL>node["<STR_LIT>"]))<EOL>err = "<STR_LIT>"<EOL>node["<STR_LIT>"] = TCP<EOL>node["<STR_LIT>"] = (<EOL>node["<STR_LIT>"] + (node["<STR_LIT>"] * <NUM_LIT:4>))<EOL>node["<STR_LIT>"] = len(packet) - node["<STR_LIT>"]<EOL>th = node["<STR_LIT>"]<EOL>node["<STR_LIT>"] = eh + ih + th<EOL>log.info(("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>.format(node["<STR_LIT>"],<EOL>node["<STR_LIT>"],<EOL>node["<STR_LIT>"],<EOL>node["<STR_LIT>"],<EOL>tcp_data))<EOL>err = "<STR_LIT>"<EOL>tcp_data = packet[node["<STR_LIT>"]:]<EOL>target_data = tcp_data<EOL>node["<STR_LIT:error>"] = "<STR_LIT>"<EOL>node["<STR_LIT:status>"] = VALID<EOL><DEDENT>elif node["<STR_LIT>"] == UDP_PROTO_IP:<EOL><INDENT>packet_min = node["<STR_LIT>"] + node["<STR_LIT>"]<EOL>packet_max = packet_min + <NUM_LIT:8><EOL>log.info(("<STR_LIT>")<EOL>.format(packet_min,<EOL>packet_max))<EOL>err = ("<STR_LIT>").format(<EOL>packet_min,<EOL>packet_max)<EOL>udp_datagram = packet[packet_min:packet_max]<EOL>log.info(("<STR_LIT>")<EOL>.format(udp_datagram))<EOL>udp_header = unpack(UDP_HEADER_FORMAT, udp_datagram)<EOL>node["<STR_LIT>"] = SIZE_UDP_HEADER<EOL>node["<STR_LIT>"] = udp_header[<NUM_LIT:0>]<EOL>node["<STR_LIT>"] = udp_header[<NUM_LIT:1>]<EOL>node["<STR_LIT>"] = udp_header[<NUM_LIT:2>]<EOL>node["<STR_LIT>"] = udp_header[<NUM_LIT:3>]<EOL>node["<STR_LIT>"] = UDP<EOL>uh = node["<STR_LIT>"]<EOL>node["<STR_LIT>"] = eh + ih + uh<EOL>node["<STR_LIT>"] = len(packet) - node["<STR_LIT>"]<EOL>log.info(("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>.format(node["<STR_LIT>"],<EOL>node["<STR_LIT>"],<EOL>node["<STR_LIT>"],<EOL>node["<STR_LIT>"],<EOL>udp_data))<EOL>err = "<STR_LIT>"<EOL>udp_data = packet[node["<STR_LIT>"]:]<EOL>target_data = udp_data<EOL>node["<STR_LIT:error>"] = "<STR_LIT>"<EOL>node["<STR_LIT:status>"] = VALID<EOL><DEDENT>elif node["<STR_LIT>"] == ICMP_PROTO_IP:<EOL><INDENT>packet_min = node["<STR_LIT>"] + node["<STR_LIT>"]<EOL>packet_max = packet_min + <NUM_LIT:4><EOL>log.info(("<STR_LIT>")<EOL>.format(packet_min,<EOL>packet_max))<EOL>err = ("<STR_LIT>").format(<EOL>packet_min,<EOL>packet_max)<EOL>icmp_datagram = packet[packet_min:packet_max]<EOL>log.info(("<STR_LIT>")<EOL>.format(icmp_datagram))<EOL>icmp_header = unpack(ICMP_HEADER_FORMAT, icmp_datagram)<EOL>node["<STR_LIT>"] = SIZE_ICMP_HEADER<EOL>node["<STR_LIT>"] = icmp_header[<NUM_LIT:0>]<EOL>node["<STR_LIT>"] = icmp_header[<NUM_LIT:1>]<EOL>node["<STR_LIT>"] = icmp_header[<NUM_LIT:2>]<EOL>node["<STR_LIT>"] = ICMP<EOL>ah = node["<STR_LIT>"]<EOL>node["<STR_LIT>"] = eh + ih + ah<EOL>node["<STR_LIT>"] = len(packet) - node["<STR_LIT>"]<EOL>log.info(("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>.format(node["<STR_LIT>"],<EOL>node["<STR_LIT>"],<EOL>node["<STR_LIT>"],<EOL>node["<STR_LIT>"],<EOL>icmp_data))<EOL>err = "<STR_LIT>"<EOL>icmp_data = packet[node["<STR_LIT>"]:]<EOL>target_data = icmp_data<EOL>node["<STR_LIT:error>"] = "<STR_LIT>"<EOL>node["<STR_LIT:status>"] = VALID<EOL><DEDENT>else:<EOL><INDENT>node["<STR_LIT:error>"] = ("<STR_LIT>").format(<EOL>node["<STR_LIT>"])<EOL>node["<STR_LIT:status>"] = IP_UNSUPPORTED<EOL><DEDENT>if node["<STR_LIT:status>"] == VALID:<EOL><INDENT>log.debug("<STR_LIT>")<EOL>if filter_keys:<EOL><INDENT>err = "<STR_LIT>".format(len(filter_keys))<EOL>log.debug(err)<EOL>for f in filter_keys:<EOL><INDENT>if target_data:<EOL><INDENT>if str(f) in str(target_data):<EOL><INDENT>log.info(("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>.format(f,<EOL>target_data))<EOL>node["<STR_LIT:error>"] = "<STR_LIT>"<EOL>node["<STR_LIT:status>"] = FILTERED<EOL>node["<STR_LIT>"] = f<EOL>break<EOL><DEDENT><DEDENT><DEDENT><DEDENT>log.debug(("<STR_LIT>")<EOL>.format(node["<STR_LIT>"]))<EOL>if not node["<STR_LIT>"]:<EOL><INDENT>err = "<STR_LIT>"<EOL>log.debug(("<STR_LIT>")<EOL>.format(target_data))<EOL>stream_size = <NUM_LIT:0><EOL>if target_data:<EOL><INDENT>try:<EOL><INDENT>err = ("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>node["<STR_LIT>"] = target_data.hex()<EOL><DEDENT>except Exception as e:<EOL><INDENT>log.info(("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>.format(target_data,<EOL>e))<EOL>err = "<STR_LIT>"<EOL>node["<STR_LIT>"] = target_data<EOL><DEDENT>stream_size += len(node["<STR_LIT>"])<EOL><DEDENT>log.debug(("<STR_LIT>")<EOL>.format(node["<STR_LIT>"]))<EOL>node_json = json.dumps(node)<EOL>data_stream = str("<STR_LIT>").format(node_json,<EOL>include_filter_key)<EOL>log.debug("<STR_LIT>")<EOL>if stream_size:<EOL><INDENT>node["<STR_LIT>"] = data_stream<EOL><DEDENT><DEDENT>log.debug("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>log.error(("<STR_LIT>")<EOL>.format(node["<STR_LIT>"]))<EOL><DEDENT><DEDENT>elif node["<STR_LIT>"] == ARP_PROTO_ETH:<EOL><INDENT>arp_packet_min = SIZE_ETH_HEADER<EOL>arp_packet_max = SIZE_ETH_HEADER + <NUM_LIT><EOL>log.info(("<STR_LIT>")<EOL>.format(arp_packet_min,<EOL>arp_packet_max))<EOL>err = ("<STR_LIT>").format(<EOL>arp_packet_min,<EOL>arp_packet_max)<EOL>arp_datagram = packet[arp_packet_min:arp_packet_max]<EOL>arp_header = unpack(ARP_HEADER_FORMAT, arp_datagram)<EOL>node["<STR_LIT>"] = SIZE_ARP_HEADER<EOL>node["<STR_LIT>"] = arp_header[<NUM_LIT:0>].hex()<EOL>node["<STR_LIT>"] = arp_header[<NUM_LIT:1>].hex()<EOL>node["<STR_LIT>"] = arp_header[<NUM_LIT:2>].hex()<EOL>node["<STR_LIT>"] = arp_header[<NUM_LIT:3>].hex()<EOL>node["<STR_LIT>"] = arp_header[<NUM_LIT:4>].hex()<EOL>node["<STR_LIT>"] = arp_header[<NUM_LIT:5>].hex()<EOL>node["<STR_LIT>"] = socket.inet_ntoa(arp_header[<NUM_LIT:6>])<EOL>node["<STR_LIT>"] = arp_header[<NUM_LIT:7>].hex()<EOL>node["<STR_LIT>"] = socket.inet_ntoa(arp_header[<NUM_LIT:8>])<EOL>arp_data = "<STR_LIT>"<EOL>node["<STR_LIT>"] = arp_data<EOL>node["<STR_LIT>"] = arp_data<EOL>node["<STR_LIT>"] = ARP<EOL>node["<STR_LIT:status>"] = VALID<EOL>node["<STR_LIT>"] = len(packet) - node["<STR_LIT>"]<EOL>node_json = json.dumps(node)<EOL>data_stream = str("<STR_LIT>").format(node_json,<EOL>include_filter_key)<EOL>node["<STR_LIT>"] = data_stream<EOL><DEDENT>else:<EOL><INDENT>node["<STR_LIT:error>"] = ("<STR_LIT>").format(<EOL>node["<STR_LIT>"])<EOL>node["<STR_LIT:status>"] = ETH_UNSUPPORTED<EOL>log.error(node["<STR_LIT:error>"])<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>node["<STR_LIT:status>"] = ERROR<EOL>node["<STR_LIT:error>"] = "<STR_LIT>".format(err,<EOL>e)<EOL>log.error(node["<STR_LIT:error>"])<EOL><DEDENT>return node<EOL>
build_node

    :param data_packet: raw recvfrom data
    :param filter_keys: list of strings to filter
                        and remove baby-birding
                        packets to yourself
    :param record_tcp: want to record TCP frames?
    :param record_udp: want to record UDP frames?
    :param record_arp: want to record ARP frames?
    :param record_icmp: want to record ICMP frames?