<commit_before>/*
 * cethendpnt.hpp
 *
 *  Created on: 04.08.2014
 *      Author: andreas
 */

#ifndef CETHENDPNT_HPP_
#define CETHENDPNT_HPP_

#include <inttypes.h>
#include <exception>
#include <iostream>

#include <rofl/common/crofdpt.h>
#include <rofl/common/cdptid.h>
#include <rofl/common/protocols/fvlanframe.h>

#include "roflibs/netlink/clogging.hpp"
#include "roflibs/netlink/ccookiebox.hpp"

namespace roflibs {
namespace eth {

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

class cethendpnt : public roflibs::common::openflow::ccookie_owner {
public:

	/**
	 *
	 */
	cethendpnt() :
		dpt_state(STATE_IDLE),
		cookie_endpoint(roflibs::common::openflow::ccookie_owner::acquire_cookie()),
		vid(0xffff), tagged(false), table_id_eth_local(0)
	{};

	/**
	 *
	 */
	cethendpnt(
			const rofl::cdpid& dpid, uint8_t local_stage_table_id,
			const rofl::cmacaddr& hwaddr,
			uint16_t vid = 0xffff, bool tagged = true) :
		dpt_state(STATE_IDLE),
		dpid(dpid),
		cookie_endpoint(roflibs::common::openflow::ccookie_owner::acquire_cookie()),
		vid(vid), tagged(tagged),
		table_id_eth_local(local_stage_table_id),
		hwaddr(hwaddr)
	{};

	/**
	 *
	 */
	virtual
	~cethendpnt() {
		try {
			if (STATE_ATTACHED == dpt_state) {
				handle_dpt_close(rofl::crofdpt::get_dpt(dpid));
			}
		} catch (rofl::eRofDptNotFound& e) {};
	};

	/**
	 *
	 */
	cethendpnt(const cethendpnt& port) :
		cookie_endpoint(roflibs::common::openflow::ccookie_owner::acquire_cookie()),
	{ *this = port; };

	/**
	 *
	 */
	cethendpnt&
	operator= (const cethendpnt& port) {
		if (this == &port)
			return *this;
		dpt_state	= port.dpt_state;
		dpid 		= port.dpid;
		// do not copy cookies here!
		vid 		= port.vid;
		tagged 		= port.tagged;
		table_id_eth_local = port.table_id_eth_local;
		hwaddr		= port.hwaddr;<commit_msg>revising table strategy for ethcore<commit_after>/*
 * cethendpnt.hpp
 *
 *  Created on: 04.08.2014
 *      Author: andreas
 */

#ifndef CETHENDPNT_HPP_
#define CETHENDPNT_HPP_

#include <inttypes.h>
#include <exception>
#include <iostream>

#include <rofl/common/crofdpt.h>
#include <rofl/common/cdptid.h>
#include <rofl/common/protocols/fvlanframe.h>

#include "roflibs/netlink/clogging.hpp"
#include "roflibs/netlink/ccookiebox.hpp"

namespace roflibs {
namespace eth {

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

class cethendpnt : public roflibs::common::openflow::ccookie_owner {
public:

	/**
	 *
	 */
	cethendpnt() :
		dpt_state(STATE_IDLE),
		cookie_endpoint(roflibs::common::openflow::ccookie_owner::acquire_cookie()),
		vid(0xffff), tagged(false), table_id_eth_local(0)
	{};

	/**
	 *
	 */
	cethendpnt(
			const rofl::cdpid& dpid, uint8_t local_stage_table_id,
			const rofl::cmacaddr& hwaddr,
			uint16_t vid = 0xffff, bool tagged = true) :
		dpt_state(STATE_IDLE),
		dpid(dpid),
		cookie_endpoint(roflibs::common::openflow::ccookie_owner::acquire_cookie()),
		vid(vid), tagged(tagged),
		table_id_eth_local(local_stage_table_id),
		hwaddr(hwaddr)
	{};

	/**
	 *
	 */
	virtual
	~cethendpnt() {
		try {
			if (STATE_ATTACHED == dpt_state) {
				handle_dpt_close(rofl::crofdpt::get_dpt(dpid));
			}
		} catch (rofl::eRofDptNotFound& e) {};
	};

	/**
	 *
	 */
	cethendpnt(const cethendpnt& port) :
		cookie_endpoint(roflibs::common::openflow::ccookie_owner::acquire_cookie())
	{ *this = port; };

	/**
	 *
	 */
	cethendpnt&
	operator= (const cethendpnt& port) {
		if (this == &port)
			return *this;
		dpt_state	= port.dpt_state;
		dpid 		= port.dpid;
		// do not copy cookies here!
		vid 		= port.vid;
		tagged 		= port.tagged;
		table_id_eth_local = port.table_id_eth_local;
		hwaddr		= port.hwaddr;
{'fraction_non_alphanumeric': 0.14855875831485588, 'fraction_numerical': 0.006898250800689825, 'mean_word_length': 4.678321678321678, 'pattern_counts': {'":': 0, '<': 15, '<?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': '3379413', 'n_tokens_mistral': 1805, 'n_tokens_neox': 1635, 'n_words': 253}