<commit_before>/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkPacketFileReader.h

  Copyright (c) <NAME>, <NAME>, <NAME>
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
// .NAME vtkPacketFileReader -
// .SECTION Description
//

#ifndef __vtkPacketFileReader_h
#define __vtkPacketFileReader_h

#include <pcap.h>
#include <string>

class vtkPacketFileReader
{
public:

  vtkPacketFileReader()
  {
    this->PCAPFile = 0;
  }

  ~vtkPacketFileReader()
  {
    this->Close();
  }

  bool Open(const std::string& filename)
  {
    char errbuff[PCAP_ERRBUF_SIZE];
    pcap_t *pcapFile = pcap_open_offline(filename.c_str (), errbuff);
    if (!pcapFile)
      {
      this->LastError = errbuff;<commit_msg>Re-add support for libpcap versions without PCAP_NETMASK_UNKNOWN<commit_after>/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkPacketFileReader.h

  Copyright (c) <NAME>, <NAME>, <NAME>
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
// .NAME vtkPacketFileReader -
// .SECTION Description
//

#ifndef __vtkPacketFileReader_h
#define __vtkPacketFileReader_h

#include <pcap.h>
#include <string>

// Some versions of libpcap do not have PCAP_NETMASK_UNKNOWN
#if !defined(PCAP_NETMASK_UNKNOWN)
  #define PCAP_NETMASK_UNKNOWN 0xffffffff
#endif

class vtkPacketFileReader
{
public:

  vtkPacketFileReader()
  {
    this->PCAPFile = 0;
  }

  ~vtkPacketFileReader()
  {
    this->Close();
  }

  bool Open(const std::string& filename)
  {
    char errbuff[PCAP_ERRBUF_SIZE];
    pcap_t *pcapFile = pcap_open_offline(filename.c_str (), errbuff);
    if (!pcapFile)
      {
      this->LastError = errbuff;
{'fraction_non_alphanumeric': 0.20378756689995883, 'fraction_numerical': 0.0012350761630300535, 'mean_word_length': 4.328947368421052, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7037376', 'n_tokens_mistral': 723, 'n_tokens_neox': 694, 'n_words': 183}