<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef CROFBASE_HPP_
#define CROFBASE_HPP_

#define OF_DPA

#include <sys/types.h>
#include <sys/wait.h>

#include <string>
#include <iostream>
#include <exception>

#include <rofl/common/crofbase.h>

#include "roflibs/netlink/cnetlink_observer.hpp"
#include "roflibs/netlink/ofdpa_bridge.hpp"
#include "roflibs/netlink/tap_manager.hpp"

namespace basebox {

class eBaseBoxBase : public std::runtime_error {
public:
  eBaseBoxBase(const std::string &__arg) : std::runtime_error(__arg) {}
};

static rofl::crofdpt invalid(NULL, rofl::cdptid(0));

class cbasebox : public rofl::crofbase,
                 public virtual rofl::cthread_env,
                 public rofcore::tap_callback,
                 public rofcore::auto_reg_cnetlink_common_observer {

  enum ExperimenterMessageType {
    QUERY_FLOW_ENTRIES, ///< query flow entries from controller
    RECEIVED_FLOW_ENTRIES_QUERY
  };

  enum ExperimenterId {
    BISDN = 0xFF0000B0 ///< should be registered as ONF-Managed Experimenter ID
                       ///(OUI)
  };

  static bool keep_on_running;
  rofl::cthread thread;

  /**
   *
   */
  cbasebox(const rofl::openflow::cofhello_elem_versionbitmap &versionbitmap =
               rofl::openflow::cofhello_elem_versionbitmap())
      : thread(this), fm_driver(), bridge(fm_driver) {
    rofl::crofbase::set_versionbitmap(versionbitmap);
    thread.start();
    tap_man = new rofcore::tap_manager();
  }

  /**
   *
   */
  ~cbasebox() override { delete tap_man; }

  /**
   *
   */
  cbasebox(const cbasebox &ethbase);

public:
  /**
   *
   */
  static cbasebox &get_instance(
      const rofl::openflow::cofhello_elem_versionbitmap &versionbitmap =
          rofl::openflow::cofhello_elem_versionbitmap()) {
    static cbasebox box(versionbitmap);
    return box;
  }

  static bool running() { return keep_on_running; }

  static void stop() { keep_on_running = false; };

protected:
  void handle_wakeup(rofl::cthread &thread) override;

  void handle_conn_established(rofl::crofdpt &dpt,<commit_msg>cbasebox: cleanup header<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef CROFBASE_HPP_
#define CROFBASE_HPP_

#include <sys/types.h>
#include <sys/wait.h>

#include <string>
#include <iostream>
#include <exception>

#include <rofl/common/crofbase.h>

#include "roflibs/netlink/cnetlink_observer.hpp"
#include "roflibs/netlink/ofdpa_bridge.hpp"
#include "roflibs/netlink/tap_manager.hpp"

namespace basebox {

class eBaseBoxBase : public std::runtime_error {
public:
  eBaseBoxBase(const std::string &__arg) : std::runtime_error(__arg) {}
};

static rofl::crofdpt invalid(NULL, rofl::cdptid(0));

class cbasebox : public rofl::crofbase,
                 public virtual rofl::cthread_env,
                 public rofcore::tap_callback,
                 public rofcore::auto_reg_cnetlink_common_observer {

  enum ExperimenterMessageType {
    QUERY_FLOW_ENTRIES, ///< query flow entries from controller
    RECEIVED_FLOW_ENTRIES_QUERY
  };

  enum ExperimenterId {
    BISDN = 0xFF0000B0 ///< should be registered as ONF-Managed Experimenter ID
                       ///(OUI)
  };

  static bool keep_on_running;
  rofl::cthread thread;

  /**
   *
   */
  cbasebox(const rofl::openflow::cofhello_elem_versionbitmap &versionbitmap =
               rofl::openflow::cofhello_elem_versionbitmap())
      : thread(this), fm_driver(), bridge(fm_driver) {
    rofl::crofbase::set_versionbitmap(versionbitmap);
    thread.start();
    tap_man = new rofcore::tap_manager();
  }

  /**
   *
   */
  ~cbasebox() override { delete tap_man; }

  /**
   *
   */
  cbasebox(const cbasebox &ethbase);

public:
  /**
   *
   */
  static cbasebox &get_instance(
      const rofl::openflow::cofhello_elem_versionbitmap &versionbitmap =
          rofl::openflow::cofhello_elem_versionbitmap()) {
    static cbasebox box(versionbitmap);
    return box;
  }

  static bool running() { return keep_on_running; }

  static void stop() { keep_on_running = false; }

protected:
  void handle_wakeup(rofl::cthread &thread) override;

  void handle_conn_established(rofl::crofdpt &dpt,
{'fraction_non_alphanumeric': 0.11589995533720411, 'fraction_numerical': 0.004912907548012505, 'mean_word_length': 3.6175257731958763, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '7534797', 'n_tokens_mistral': 1584, 'n_tokens_neox': 1531, 'n_words': 321}