diff --git a/voltha/adapters/tlgs_onu/__init__.py b/voltha/adapters/tlgs_onu/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/voltha/adapters/tlgs_onu/__init__.py
diff --git a/voltha/adapters/tlgs_onu/tlgs_constants.py b/voltha/adapters/tlgs_onu/tlgs_constants.py
new file mode 100644
index 0000000..0729b42
--- /dev/null
+++ b/voltha/adapters/tlgs_onu/tlgs_constants.py
@@ -0,0 +1,300 @@
+#
+# Copyright 2017 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+from enum import Enum
+
+"""
+PAS5211 Constants
+"""
+
+# from enum PON_true_false_t
+PON_FALSE = 0
+PON_TRUE = 1
+
+# from enum PON_enable_disable_t
+PON_DISABLE = 0
+PON_ENABLE = 1
+
+# from enym PON_mac_t
+PON_MII = 0
+PON_GMII = 1
+PON_TBI = 2
+
+PON_POLARITY_ACTIVE_LOW = 0
+PON_POLARITY_ACTIVE_HIGH = 1
+
+PON_OPTICS_VOLTAGE_IF_UNDEFINED = 0
+PON_OPTICS_VOLTAGE_IF_CML = 1
+PON_OPTICS_VOLTAGE_IF_LVPECL = 2
+
+PON_SD_SOURCE_LASER_SD = 0
+PON_SD_SOURCE_BCDR_LOCK = 1
+PON_SD_SOURCE_BCDR_SD = 2
+
+PON_RESET_TYPE_DELAY_BASED = 0
+PON_RESET_TYPE_SINGLE_RESET = 1
+PON_RESET_TYPE_DOUBLE_RESET = 2
+
+PON_RESET_TYPE_NORMAL_START_BURST_BASED = 0
+PON_RESET_TYPE_NORMAL_END_BURST_BASED = 1
+
+PON_GPIO_LINE_0 = 0
+PON_GPIO_LINE_1 = 1
+PON_GPIO_LINE_2 = 2
+PON_GPIO_LINE_3 = 3
+PON_GPIO_LINE_4 = 4
+PON_GPIO_LINE_5 = 5
+PON_GPIO_LINE_6 = 6
+PON_GPIO_LINE_7 = 7
+def PON_EXT_GPIO_LINE(line):
+    return line + 8
+
+PON_ALARM_SOFTWARE_ERROR = 0
+PON_ALARM_LOS = 1
+PON_ALARM_LOSI = 2
+PON_ALARM_DOWI = 3
+PON_ALARM_LOFI = 4
+PON_ALARM_RDII = 5
+PON_ALARM_LOAMI = 6
+PON_ALARM_LCDGI = 7
+PON_ALARM_LOAI = 8
+PON_ALARM_SDI = 9
+PON_ALARM_SFI = 10
+PON_ALARM_PEE = 11
+PON_ALARM_DGI = 12
+PON_ALARM_LOKI = 13
+PON_ALARM_TIWI = 14
+PON_ALARM_TIA = 15
+PON_ALARM_AUTH_FAILED_IN_REGISTRATION_ID_MODE = 20
+PON_ALARM_SUFI = 21
+
+PON_ALARM_VIRTUAL_SCOPE_ONU_LASER_ALWAYS_ON = 16
+PON_ALARM_VIRTUAL_SCOPE_ONU_SIGNAL_DEGRADATION = 17
+PON_ALARM_VIRTUAL_SCOPE_ONU_EOL = 18
+PON_ALARM_VIRTUAL_SCOPE_ONU_EOL_DATABASE_IS_FULL = 19
+
+PON_ALARM_LAST_ALARM = 22
+
+# from enum PON_general_parameters_type_t
+PON_COMBINED_LOSI_LOFI = 1000
+PON_TX_ENABLE_DEFAULT = 1001
+
+# Enable or disable False queue full event from DBA
+PON_FALSE_Q_FULL_EVENT_MODE = 1002
+
+# Set PID_AID_MISMATCH min silence period. 0 - disable, Else - period in secs
+PON_PID_AID_MISMATCH_MIN_SILENCE_PERIOD = 1003
+
+# Set if FW generate clear alarm. 0 - generate clear alarm, Else - don't
+# generate clear alarm
+PON_ENABLE_CLEAR_ALARM = 1004
+
+# Enable or disabl send assign alloc id ploam. 0 - disable, 1 - enable
+PON_ASSIGN_ALLOC_ID_PLOAM = 1005
+
+# BIP error polling period, 200 - 65000, 0 - Disabled, Recommended: 5000
+# (default)
+PON_BIP_ERR_POLLING_PERIOD_MS = 1006
+
+# Ignore SN when decatived 0 - consider SN (deactivate the onu if received
+# same SN when activated (default)	1 - Ignore
+PON_IGNORE_SN_WHEN_ACTIVE = 1007
+
+# 0xffffffff - Disabled (default). Any other value (0 - 0xfffe) indicates
+# that PA delay is enabled, with the specified delay value and included in
+# the US_OVERHEAD PLOAM
+PON_ONU_PRE_ASSIGNED_DELAY = 1008
+
+# Enable or disable DS fragmentation, 0 disable, 1 enable
+PON_DS_FRAGMENTATION = 1009
+
+# Set if fw report rei alarm when errors is 0, 0 disable (default), 1 enable
+PON_REI_ERRORS_REPORT_ALL = 1010
+
+# Set if igonre sfi deactivation, 0 disable (default), 1 enable
+PON_IGNORE_SFI_DEACTIVATION = 1011
+
+# Allows to override the allocation overhead set by optic-params
+# configuration. This configuration is only allowed when the the pon channel
+# is disabled
+PON_OVERRIDE_ALLOCATION_OVERHEAD = 1012
+
+# Optics timeline offset, -128-127, : this parameter is very sensitive and
+# requires coordination with PMC
+PON_OPTICS_TIMELINE_OFFSET = 1013
+
+# Last general meter
+PON_LAST_GENERAL_PARAMETER = PON_OPTICS_TIMELINE_OFFSET
+
+# from enum PON_dba_mode_t
+PON_DBA_MODE_NOT_LOADED = 0
+PON_DBA_MODE_LOADED_NOT_RUNNING = 1
+PON_DBA_MODE_RUNNING = 2
+PON_DBA_MODE_LAST = 3
+
+# from enum type typedef enum PON_port_frame_destination_t
+PON_PORT_PON = 0
+PON_PORT_SYSTEM = 1
+
+PON_PORT_TYPE_GEM  = 0
+PON_PORT_TYPE_TDM  = 1
+PON_PORT_TYPE_OMCI = 2
+
+PON_PORT_DESTINATION_CNI0 = 0
+PON_PORT_DESTINATION_CNI1 = 1
+PON_PORT_DESTINATION_CNI2 = 2
+PON_PORT_DESTINATION_CPU  = 3
+
+# from enum PON_olt_hw_classification_t
+
+PON_OLT_HW_CLASSIFICATION_PAUSE = 0
+PON_OLT_HW_CLASSIFICATION_LINK_CONSTRAINT = 1
+PON_OLT_HW_CLASSIFICATION_IGMP = 2
+PON_OLT_HW_CLASSIFICATION_MPCP = 3
+PON_OLT_HW_CLASSIFICATION_OAM = 4
+PON_OLT_HW_CLASSIFICATION_802_1X = 5
+PON_OLT_HW_CLASSIFICATION_PPPOE_DISCOVERY = 6
+PON_OLT_HW_CLASSIFICATION_PPPOE_SESSION = 7
+PON_OLT_HW_CLASSIFICATION_DHCP_V4 = 8
+PON_OLT_HW_CLASSIFICATION_PIM  = 9
+PON_OLT_HW_CLASSIFICATION_DHCP_V6 = 10
+PON_OLT_HW_CLASSIFICATION_ICMP_V4 = 11
+PON_OLT_HW_CLASSIFICATION_MLD = 12
+PON_OLT_HW_CLASSIFICATION_ARP = 13
+PON_OLT_HW_CLASSIFICATION_CONF_DA = 14
+PON_OLT_HW_CLASSIFICATION_CONF_RULE = 15
+PON_OLT_HW_CLASSIFICATION_DA_EQ_SA = 16
+PON_OLT_HW_CLASSIFICATION_DA_EQ_MAC = 17
+PON_OLT_HW_CLASSIFICATION_DA_EQ_SEC_MAC = 18
+PON_OLT_HW_CLASSIFICATION_SA_EQ_MAC = 19
+PON_OLT_HW_CLASSIFICATION_SA_EQ_SEC_MAC = 20
+PON_OLT_HW_CLASSIFICATION_ETHERNET_MANAGEMENT = 100
+PON_OLT_HW_CLASSIFICATION_IPV4_LOCAL_MULTICAST = 101
+PON_OLT_HW_CLASSIFICATION_IPV4_MANAGEMENT = 102
+PON_OLT_HW_CLASSIFICATION_ALL_IPV4_MULTICAST  = 103
+PON_OLT_HW_CLASSIFICATION_IPV6_LOCAL_MULTICAST = 104
+PON_OLT_HW_CLASSIFICATION_IPV6_MANAGEMENT = 105
+PON_OLT_HW_CLASSIFICATION_ALL_IPV6_MULTICAST = 106
+PON_OLT_HW_CLASSIFICATION_OTHER	 = 107
+PON_OLT_HW_CLASSIFICATION_LAST_RULE  = 108
+
+PON_ACTIVATION_AUTH_AUTO = 0
+PON_ACTIVATION_AUTH_HOST_CONTROLLED_SEPARATE_EVENTS = 1 # Host controlled: Separate events
+PON_ACTIVATION_AUTH_HOST_CONTROLLED_LUMPED_SN = 2 # Host controlled: Lumped-SN-Response
+PON_ACTIVATION_AUTH_REGISTRATION_ID_RAW = 3 # Registration-ID Raw
+PON_ACTIVATION_AUTH_REGISTRATION_ID_LEARN = 4  # Registration-ID Learn
+
+PON_LOGICAL_OBJECT_TYPE_ALLOC_ID = 0
+PON_LOGICAL_OBJECT_TYPE_ONU_ID_BY_ALLOC_ID  = 1
+PON_LOGICAL_OBJECT_TYPE_MAX	= PON_LOGICAL_OBJECT_TYPE_ONU_ID_BY_ALLOC_ID
+
+PMC_OFAL_MAX_BI_DIRECTIONAL_FLOW_PER_ONU = 16
+PMC_OFAL_START_FLOW_ID_BASE = 1000
+
+PON_DL_VLAN_SVLAN_REMOVE = 3
+PON_DL_VLAN_CVLAN_NO_CHANGE = 0
+
+PON_VLAN_DONT_CHANGE_TAG = 0
+PON_VLAN_CHANGE_TAG = 1
+PON_VLAN_CHANGE_OTHER_TAG = 2
+PON_VLAN_CHANGE_REMOVE_TAG = 3
+
+PON_VLAN_UNUSED_TAG = -1
+PON_VLAN_DEST_DATAPATH = 1
+PON_VLAN_UNCHANGED_PRIORITY = -1
+PON_VLAN_REPLACE_PRIORITY = -2
+PON_VLAN_UNUSED_PRIORITY = -1
+
+PON_OUTPUT_VLAN_PRIO_HANDLE_DONT_CHANGE = 0
+PON_OUTPUT_VLAN_PRIO_HANDLE_INCOMING_VLAN = 1
+PON_OUTPUT_VLAN_PRIO_HANDLE_DL_VLAN_TABLE  = 2
+
+PON_N_TO_1_VLAN_MODE = 0
+PON_1_TO_1_VLAN_MODE = 1
+
+# OMCI
+
+OMCI_8021P_MSP_UNMARKED_FRAME_TAG_FRAME = 1
+OMCI_8021P_MSP_TP_TYPE_NULL = 0
+
+# GEM interworking option for MAC Bridge LAN
+OMCI_GEM_IWTP_IW_OPT_8021P_MAPPER = 5
+#LLC frame encapsulation method
+OMCI_MAC_BRIDGE_PCD_ENCAP_METHOD_LLC = 1
+# Frame Check Sequence will forward
+OMCI_MAC_BRIDGE_PCD_LANFCS_FORWARDED = 0
+# in DS, perform the inverse of US operation
+OMCI_EX_VLAN_TAG_OCD_DS_MODE_US_INVERSE = 0
+# Physical path termination point Ethernet UNI
+OMCI_EX_VLAN_TAG_OCD_ASSOCIATION_TYPE_PPTP_ETH_UNI = 2
+
+# GEM Port Network CTP
+
+# Direction definitions
+GEM_DIR_BIDIRECT = 3 # bi-directional
+
+# PMC
+PMC_UPSTREAM_PORT = 129
+
+# SLA
+
+PYTHAGORAS_UPDATE_AID_SLA = 21
+PYTHAGORAS_DBA_DATA_COS = 0
+PYTHAGORAS_DBA_STATUS_REPORT_NSR = 0
+PYTHAGORAS_SET_SLA_RESP_SIZE = 10
+
+# Random values found in PMC code
+SLA_gr_bw_gros = 30
+SLA_be_bw_gros = 300
+SLA_gr_bw_fine = 0
+SLA_be_bw_fine = 0
+
+PON_MAX_DS_POLICING_CONFIGURATION_INDEX = 255
+PMC_OFAL_NO_POLICY = PON_MAX_DS_POLICING_CONFIGURATION_INDEX+1
+
+#Enum classes to set alarm parameters
+
+class AlarmEventType(Enum):
+    COMMUNICATION = 0
+    ENVIRONMENT = 1
+    EQUIPTMENT = 2
+    SERVICE = 3
+    PROCESSING = 4
+    SECURITY = 5
+
+class AlarmEventCategory(Enum):
+    PON = 0
+
+class AlarmEventState(Enum):
+    RAISED = 1
+    CLEARED = 0
+
+class AlarmEventSeverity(Enum):
+    INDETERMINATE = 0
+    WARNING = 1
+    MINOR = 2
+    MAJOR = 3
+    CRITICAL = 4
+
+AlarmEventStateDefault = 1
+
+UPSTREAM = 1
+DOWNSTREAM = 2
+
+PASCOMM_RETRIES = 5
+
+# Number of ONU LAN PORTS
+PORT_NUMBER = 1
+
diff --git a/voltha/adapters/tlgs_onu/tlgs_onu.py b/voltha/adapters/tlgs_onu/tlgs_onu.py
new file mode 100644
index 0000000..11fff22
--- /dev/null
+++ b/voltha/adapters/tlgs_onu/tlgs_onu.py
@@ -0,0 +1,1524 @@
+#
+# Copyright 2017 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+"""
+PMC Sierra ONU adapter
+"""
+
+import structlog
+from twisted.internet import reactor
+from twisted.internet.defer import DeferredQueue, inlineCallbacks, returnValue
+from zope.interface import implementer
+import voltha.core.flow_decomposer as fd
+
+from voltha.adapters.interface import IAdapterInterface
+
+from voltha.extensions.omci.omci_frame import OmciFrame
+from voltha.extensions.omci.omci_entities import Ieee8021pMapperServiceProfile
+
+from voltha.protos import third_party
+from voltha.protos.adapter_pb2 import Adapter
+from voltha.protos.adapter_pb2 import AdapterConfig
+from voltha.protos.common_pb2 import LogLevel, ConnectStatus, AdminState, OperStatus
+from voltha.protos.device_pb2 import DeviceType, DeviceTypes, Port
+from voltha.protos.health_pb2 import HealthStatus
+from voltha.protos.logical_device_pb2 import LogicalPort
+from voltha.protos.openflow_13_pb2 import OFPPF_10GB_FD, OFPPF_FIBER, ofp_port, OFPPS_LIVE, OFPXMC_OPENFLOW_BASIC
+
+from voltha.extensions.omci.omci_messages import OmciGet, OmciGetResponse, OmciCreate, OmciMibResetResponse, OmciSet, \
+    OmciSetResponse, OmciCreateResponse, OmciMibReset, OmciDelete, OmciDeleteResponse
+
+from voltha.adapters.microsemi_olt.PAS5211_comm import PAS5211Communication
+from voltha.registry import registry
+from voltha.extensions.omci.omci_entities import VlanTaggingOperation
+from voltha.protos.openflow_13_pb2 import Flows, FlowGroups
+
+from common.frameio.frameio import hexify
+
+from tlgs_constants import OMCI_GEM_IWTP_IW_OPT_8021P_MAPPER, PON_FALSE, \
+    GEM_DIR_BIDIRECT, OMCI_MAC_BRIDGE_PCD_LANFCS_FORWARDED, \
+    OMCI_MAC_BRIDGE_PCD_ENCAP_METHOD_LLC, OMCI_8021P_MSP_UNMARKED_FRAME_TAG_FRAME, OMCI_8021P_MSP_TP_TYPE_NULL, \
+    OMCI_EX_VLAN_TAG_OCD_ASSOCIATION_TYPE_PPTP_ETH_UNI, OMCI_EX_VLAN_TAG_OCD_DS_MODE_US_INVERSE, PMC_UPSTREAM_PORT, \
+    SLA_gr_bw_gros, SLA_be_bw_gros, SLA_gr_bw_fine, SLA_be_bw_fine, PORT_NUMBER
+
+import Queue
+from struct import pack, unpack
+
+_ = third_party
+log = structlog.get_logger()
+
+OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_NO_TAG = 15
+OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE = 4096
+OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE = 0
+OMCI_EX_VLAN_TAG_OCD_FILTER_ETYPE_NONE = 0
+OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_DEFAULT = 14
+OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_8100 = 4
+OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE = 15
+OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_OUTER = 1
+OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_COPY_FROM_INNER = 4096
+OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_INNER = 0
+OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_EQ_8100 = 4
+
+def sequence_generator(init):
+    num = init
+    while True:
+        yield num
+        num += 1
+
+
+@implementer(IAdapterInterface)
+class TlgsOnuAdapter(object):
+
+    name = 'tlgs_onu'
+
+    supported_device_types = [
+        DeviceType(
+            id=name,
+            adapter=name,
+            accepts_bulk_flow_update=True
+        )
+    ]
+
+
+    def __init__(self, adapter_agent, config):
+        self.omci_proxy = None
+        self.api_proxy = None
+        self.adapter_agent = adapter_agent
+        self.config = config
+        self.descriptor = Adapter(
+            id=self.name,
+            vendor='TLGS',
+            version='0.1',
+            config=AdapterConfig(log_level=LogLevel.INFO)
+        )
+
+        # self.incoming_messages = DeferredQueue()
+        #self.trangen = sequence_generator(1)
+
+        # As of broadcom_onu.py
+        # [channel_id] and [onu_id] -> BrcmOnuHandler()
+        self.device_handlers = dict()
+        # register for adapter messages
+        self.adapter_agent.register_for_inter_adapter_messages()
+
+        self.interface = registry('main').get_args().interface
+
+    def start(self):
+        log.debug('starting')
+        log.info('started')
+
+    def stop(self):
+        log.debug('stopping')
+        log.info('stopped')
+
+    def adapter_descriptor(self):
+        return self.descriptor
+
+    def device_types(self):
+        return DeviceTypes(items=self.supported_device_types)
+
+    def health(self):
+        return HealthStatus(state=HealthStatus.HealthState.HEALTHY)
+
+    def change_master_state(self, master):
+        raise NotImplementedError()
+
+    def create_tcont(self, device, tcont_data, traffic_descriptor_data):
+        raise NotImplementedError()
+
+    def update_tcont(self, device, tcont_data, traffic_descriptor_data):
+        raise NotImplementedError()
+
+    def remove_tcont(self, device, tcont_data, traffic_descriptor_data):
+        raise NotImplementedError()
+
+    def create_gemport(self, device, data):
+        raise NotImplementedError()
+
+    def update_gemport(self, device, data):
+        raise NotImplementedError()
+
+    def remove_gemport(self, device, data):
+        raise NotImplementedError()
+
+    def create_multicast_gemport(self, device, data):
+        raise NotImplementedError()
+
+    def update_multicast_gemport(self, device, data):
+        raise NotImplementedError()
+
+    def remove_multicast_gemport(self, device, data):
+        raise NotImplementedError()
+
+    def create_multicast_distribution_set(self, device, data):
+        raise NotImplementedError()
+
+    def update_multicast_distribution_set(self, device, data):
+        raise NotImplementedError()
+
+    def remove_multicast_distribution_set(self, device, data):
+        raise NotImplementedError()
+
+    def adopt_device(self, device):
+        log.debug('adopt-device', device=device)
+        # reactor.callLater(0.1, self._onu_device_activation, device)
+        # return device
+        # two level array channel
+
+        if device.proxy_address.channel_id not in self.device_handlers:
+            self.device_handlers[device.proxy_address.channel_id] = dict()
+
+        self.device_handlers[device.proxy_address.channel_id] = TlgsOnuHandler(self, device.id)
+
+        reactor.callLater(1, self.device_handlers[device.proxy_address.channel_id].activate, device)
+
+        return device
+
+    def reconcile_device(self, device):
+        raise NotImplementedError()
+
+    def abandon_device(self, device):
+        raise NotImplementedError()
+
+    def disable_device(self, device):
+        log.debug('disable-device', device=device.id)
+        reactor.callLater(0, self.device_handlers[device.proxy_address.channel_id].deactivate, device)
+
+    def reenable_device(self, device):
+        raise NotImplementedError()
+
+    def reboot_device(self, device):
+        raise NotImplementedError()
+
+    def download_image(self, device, request):
+        raise NotImplementedError()
+
+    def get_image_download_status(self, device, request):
+        raise NotImplementedError()
+
+    def cancel_image_download(self, device, request):
+        raise NotImplementedError()
+
+    def activate_image_update(self, device, request):
+        raise NotImplementedError()
+
+    def revert_image_update(self, device, request):
+        raise NotImplementedError()
+
+    def self_test_device(self, device):
+        log.debug('self-test-device', device=device.id)
+        raise NotImplementedError()
+
+    def delete_device(self, device):
+        log.debug('delete-device', device_id=device.id)
+        raise NotImplementedError()
+
+    def get_device_details(self, device):
+        raise NotImplementedError()
+
+    def deactivate(self, device):
+        try:
+            handler = self.device_handlers[
+                device.proxy_address.channel_id]
+            return handler.deactivate(device)
+        except Exception as e:
+            log.exception('failed-to-deactivate-onu', e=e)
+            raise e
+
+    def update_pm_config(self, device, pm_configs):
+        raise NotImplementedError()
+
+    def update_flows_bulk(self, device, flows, groups):
+        log.debug('onu-bulk-flow-update', device_id=device.id,
+            flows=flows, groups=groups)
+        log.debug(str(self.device_handlers.keys))
+        try:
+            assert len(groups.items) == 0
+            handler = self.device_handlers[
+                device.proxy_address.channel_id]
+            handler.update_flow_table(device, flows.items)
+        except Exception as e:
+            log.exception('failed-to-update-flow-table', e=e)
+            raise e
+
+    def update_flows_incrementally(self, device, flow_changes, group_changes):
+        raise NotImplementedError()
+
+    def send_proxied_message(self, proxy_address, msg):
+        log.debug("send-proxied-message in TLGS ONU")
+
+    def receive_proxied_message(self, proxy_address, msg):
+        log.debug('receive-proxied-message', msg=hexify(msg))
+
+        handler = self.device_handlers[
+            proxy_address.channel_id]
+
+        omci = OmciFrame(msg)
+        if omci is not None:
+            if omci.message_type in (16, 17):
+                return
+
+        handler.receive_message(msg)
+
+    def receive_packet_out(self, logical_device_id, egress_port_no, msg):
+        log.debug('packet-out', logical_device_id=logical_device_id,
+                 egress_port_no=egress_port_no, msg_len=len(msg))
+
+    def create_interface(self, device, data):
+        raise NotImplementedError()
+
+    def update_interface(self, device, data):
+        raise NotImplementedError()
+
+    def remove_interface(self, device, data):
+        raise NotImplementedError()
+
+    def receive_onu_detect_state(self, device_id, state):
+        raise NotImplementedError()
+
+    def receive_inter_adapter_message(self, msg):
+        raise NotImplementedError()
+
+    def suppress_alarm(self, filter):
+        raise NotImplementedError()
+
+    def unsuppress_alarm(self, filter):
+        raise NotImplementedError()
+
+    # Not used, delegated to handler
+    def update_flow_table(self, device, flows):
+        log.debug('update-flow-table', device_id=device.id, flows=flows)
+
+class TlgsOnuHandler(object):
+
+    def __init__(self, adapter, device_id):
+        self.adapter = adapter
+        self.adapter_agent = adapter.adapter_agent
+        self.device_id = device_id
+        self.log = structlog.get_logger(device_id=device_id)
+        self.incoming_messages = DeferredQueue()
+        self.event_messages = Queue.Queue()
+        self.proxy_address = None
+        self.tx_id = 0
+        self.trangen = sequence_generator(1)
+        self.port_id = None
+        self.alloc_id = None
+        self.cvlan_id = None
+        self.subsvlan_id = 0
+        self.bandwidth = None
+        self.flows_lock = 0
+        self.flows = None
+        self.policy_id = None
+        self.flow_queue = DeferredQueue()
+
+    def receive_message(self, msg):
+        log.debug("receive-message")
+        self.incoming_messages.put(msg)
+
+    @inlineCallbacks
+    def activate(self, device):
+        log.debug('activate-onu-handler', device=device)
+        try:
+            # register for proxied messages right away
+            self.proxy_address = device.proxy_address
+            self.adapter_agent.register_for_proxied_messages(device.proxy_address)
+
+            response = yield self.create_common_omci_config(device)
+
+            if response:
+                # First we verify that we got parent reference and proxy info
+                assert device.parent_id
+                assert device.proxy_address.device_id
+                # == 0 # We want to activate multiple ONT's
+                assert device.proxy_address.channel_id is not None
+                # to get onu_id = device.proxy_address.onu_id
+
+                # From PMC code:
+                self.port_id = 1000 + 16 * device.proxy_address.onu_id
+                self.alloc_id = self.port_id
+
+                device.model = 'GPON ONU'
+                device.hardware_version = 'tbd'
+                device.firmware_version = 'tbd'
+
+                device.connect_status = ConnectStatus.REACHABLE
+
+                uni_port = Port(port_no=1,
+                                label="{} ONU".format('TLGS'),
+                                type=Port.ETHERNET_UNI,
+                                admin_state=AdminState.ENABLED,
+                                oper_status=OperStatus.ACTIVE
+                                )
+
+                self.adapter_agent.add_port(device.id, uni_port)
+
+                log.debug('add-onu-port')
+
+                pon_port = Port(
+                                port_no=2,
+                                label='PON port',
+                                type=Port.PON_ONU,
+                                admin_state=AdminState.ENABLED,
+                                oper_status=OperStatus.ACTIVE,
+                                peers=[
+                                    Port.PeerPort(
+                                        device_id=device.parent_id,
+                                        port_no=device.parent_port_no
+                                    )
+                                ]
+                            )
+
+                self.adapter_agent.add_port(device.id, pon_port)
+
+                log.debug('add-onu-port')
+
+                # obtain logical device id
+                parent_device = self.adapter_agent.get_device(device.parent_id)
+                logical_device_id = parent_device.parent_id
+                assert logical_device_id
+                port_no = device.proxy_address.channel_id
+                cap = OFPPF_10GB_FD | OFPPF_FIBER
+
+                self.adapter_agent.add_logical_port(logical_device_id, LogicalPort(
+                    id=str(port_no),
+                    ofp_port=ofp_port(
+                        port_no=port_no,
+                        hw_addr=mac_str_to_tuple(device.mac_address),
+                        name='uni-{}'.format(port_no),
+                        config=0,
+                        state=OFPPS_LIVE,
+                        curr=cap,
+                        advertised=cap,
+                        peer=cap,
+                        curr_speed=OFPPF_10GB_FD,
+                        max_speed=OFPPF_10GB_FD
+                    ),
+                    device_id=device.id,
+                    device_port_no=uni_port.port_no
+                ))
+
+                log.debug('add-onu-logical-port')
+
+                # Input logical port from ONT
+                self.port_no = port_no
+
+                # Finally update to "ACTIVE"
+                device = self.adapter_agent.get_device(device.id)
+                # In broadcom_onu.py this state is DISCOVERED
+                device.oper_status = OperStatus.ACTIVE
+                self.adapter_agent.update_device(device)
+
+                log.info('Device activated', device=device)
+
+                reactor.callLater(0, self.wait_for_flow_events, device)
+
+            else:
+                raise Exception('Exception during onu activation')
+
+        except Exception as e:
+            log.exception('activate-failed', e=e)
+            raise Exception('Exception during onu activation')
+
+    @inlineCallbacks
+    def wait_for_flow_events(self, device):
+
+        log.debug('wait-for-flow-events')
+        event = yield self.flow_queue.get()
+        log.debug("unqueued-flow-event")
+
+        try:
+            if event['action'] == 'install':
+                response = yield self.install_flows_sequence(device, event['cvlan'], event['subsvlan'])
+            elif event['action'] == 'reinstall':
+                response = yield self.reinstall_flows_sequence(device, event['cvlan'], event['subsvlan'])
+            elif event['action'] == 'remove':
+                response = yield self.uninstall_flows_sequence(device)
+
+            if response:
+                log.debug("Event handled flow successfully")
+            else:
+                log.debug("Error handling flow event")
+
+        except Exception as e:
+            log.exception('wait-for-flow-events-exception', e=e)
+
+        reactor.callLater(0, self.wait_for_flow_events, device)
+
+    def deactivate(self, device):
+        log.debug('deactivate', device=device)
+        # Check parent reference and proxy info exists
+        assert device.parent_id
+        assert device.proxy_address.device_id
+
+        # unregister from proxy messages
+        self.adapter_agent.unregister_for_proxied_messages(device.proxy_address)
+        self.proxy_address = None
+
+        # Delete references to ports
+        onu_port = self.adapter_agent.get_ports(device.id, Port.ETHERNET_UNI)[0]
+        self.adapter_agent.delete_port_reference_from_parent(device.id, onu_port)
+
+        pon_port = self.adapter_agent.get_ports(device.id, Port.PON_ONU)[0]
+        self.adapter_agent.delete_port_reference_from_parent(device.id, pon_port)
+
+        # Delete device and logical ports
+        parent_device = self.adapter_agent.get_device(device.parent_id)
+        logical_device_id = parent_device.parent_id
+        # logical_device = self.adapter_agent.get_logical_device(logical_device_id)
+        # self.adapter_agent.delete_logical_device(logical_device)
+
+        logical_port = self.adapter_agent.get_logical_port(logical_device_id, self.port_no)
+        self.adapter_agent.delete_logical_port(logical_device_id, logical_port)
+
+        device = self.adapter_agent.get_device(device.id)
+        self.adapter_agent.update_child_device_state(device, connect_status=ConnectStatus.UNREACHABLE)
+
+        device = self.adapter_agent.get_device(device.id)
+        self.adapter_agent.update_child_device_state(device, oper_status=OperStatus.FAILED)
+        # device.connect_status = ConnectStatus.UNREACHABLE
+        # self.adapter_agent.update_device(device)
+
+        # Finally delete device
+        self.adapter_agent.delete_child_device(
+            parent_device_id=device.proxy_address.device_id,
+            child_device_id=device.id)
+
+        log.debug('deactivate ended')
+
+    # @inlineCallbacks
+    def update_flow_table(self, device, flows):
+        cvlan_found = None
+        subsvlan_found = 0
+
+        log.debug('onu-update-flow-table', device_id=device.id, flows=flows)
+        port_no = device.proxy_address.channel_id
+        log.debug('Checking {} flows for port:{}'.format(len(flows), port_no))
+
+        try:
+
+            for flow in flows:
+                # Look for inner VLAN:
+                for field in fd.get_ofb_fields(flow):
+
+                    if field.type == fd.IN_PORT and field.port == 1:
+                        if flow.table_id == 0:
+                            if flow.priority == 1000:
+                                for action in fd.get_actions(flow):
+                                    if action.type == fd.SET_FIELD:
+                                        cvlan_found = action.set_field.field.ofb_field.vlan_vid & 0xfff
+                                        log.debug('CVLAN found:{}'.format(cvlan_found))
+
+
+            if cvlan_found:
+                if cvlan_found != self.cvlan_id:
+                    if self.cvlan_id:
+
+                        log.debug('Reinstall flow triggered')
+                        flow_event = {'action': 'reinstall', 'cvlan': cvlan_found,
+                                'subsvlan': subsvlan_found}
+                        self.flow_queue.put(flow_event)
+                    else:
+                        log.debug('Flows installation triggered')
+                        flow_event = {'action': 'install', 'cvlan': cvlan_found,
+                                'subsvlan': subsvlan_found}
+                        self.flow_queue.put(flow_event)
+                else:
+                    log.debug('Flows already installed')
+            else:
+                if self.cvlan_id:
+                    log.debug('Flows deinstallation triggered')
+                    flow_event = {'action': 'remove', 'cvlan': self.cvlan_id,
+                                'subsvlan': self.subsvlan_id}
+                    self.flow_queue.put(flow_event)
+                else:
+                    log.debug('Incomplete flow')
+
+            self.cvlan_id = cvlan_found
+            self.subsvlan_id = subsvlan_found
+
+        except Exception as e:
+            log.exception('failed-to-launch-install-flow', e=e, flow=flows)
+
+    @inlineCallbacks
+    def uninstall_flows_sequence(self, device):
+        log.debug('init-flow-deinstallaton')
+        try:
+            response = yield self.delete_data_flow_omci_config(device)
+            returnValue(response)
+        except Exception as e:
+            log.exception('failed-to-launch-uninstall-flow', e=e)
+
+    @inlineCallbacks
+    def reinstall_flows_sequence(self, device, cvlan_id, subsvlan_id):
+        log.debug('init-flow-reinstallaton')
+        try:
+            response = yield self.uninstall_flows_sequence(device)
+            if response:
+                response = yield self.install_flows_sequence(device, cvlan_id, subsvlan_id)
+                returnValue(response)
+            returnValue(False)
+
+        except Exception as e:
+            log.exception('failed-to-launch-reinstall-flow', e=e)
+
+    @inlineCallbacks
+    def install_flows_sequence(self, device, cvlan_id, subsvlan_id):
+        log.debug('init-flow-installaton')
+        try:
+            log.debug("ONT flow OMCI config", device=device)
+            response = yield self.create_data_flow_omci_config(device, cvlan_id, subsvlan_id)
+            returnValue(response)
+        except Exception as e:
+            log.exception('failed-to-launch-install-flow', e=e)
+
+    @inlineCallbacks
+    def wait_for_omci_response(self):
+        log.debug('wait-for-response')
+        response = yield self.incoming_messages.get()
+        log.debug("unqueued-message", msg=hexify(response))
+        returnValue(OmciFrame(response))
+
+    @inlineCallbacks
+    def create_common_omci_config(self, device):
+        log.debug('create-common-omci-config')
+
+        alloc_id = 0x408 + device.proxy_address.onu_id
+
+        self.OMCI_ont_data_mib_reset(device)
+        response = yield self.wait_for_omci_response()
+
+        if OmciMibResetResponse not in response:
+            log.error("Failed to perform a MIB reset for {}".format(
+                device.proxy_address))
+            returnValue(False)
+        log.debug("[RESPONSE] OMCI_ont_data_mib_reset")
+
+        self.OMCI_tcont_set(device, alloc_id)
+        response = yield self.wait_for_omci_response()
+        if OmciSetResponse not in response:
+            log.error("Failed to set alloc id for {}".format(
+                device.proxy_address))
+            returnValue(False)
+        log.debug("[RESPONSE] OMCI_tcont_set")
+
+        self.pmc_omci_mac_bridge_sp_me_create(device)
+        response = yield self.wait_for_omci_response()
+        if OmciCreateResponse not in response:
+            log.error("Failed to set parameter on {}".format(
+                device.proxy_address))
+            returnValue(False)
+        log.debug("[RESPONSE] OMCI_mac_bridge_sp_me_create")
+
+        self.pmc_omci_mac_bridge_pcd_me_create(device)
+        response = yield self.wait_for_omci_response()
+        if OmciCreateResponse not in response:
+            log.error("Failed to set info for {}".format(device.proxy_address))
+            returnValue(False)
+        log.debug("[RESPONSE] OMCI_mac_bridge_pcd_me_create")
+
+        for port in range(1, PORT_NUMBER+1):
+            self.pmc_omci_mac_bridge_pcd_me_allocate(device, port)
+            response = yield self.wait_for_omci_response()
+            if OmciCreateResponse not in response:
+                log.error("Failed to create mac bridge pcd on {}".format(
+                    device.proxy_address))
+                returnValue(False)
+            log.debug("[RESPONSE] OMCI_mac_bridge_pcd_me_allocate")
+
+        returnValue(True)
+
+    @inlineCallbacks
+    def create_data_flow_omci_config(self, device, cvlan_id, subsvlan_id):
+
+        self.pmc_omci_8021p_msp_me_allocate(device)
+        response = yield self.wait_for_omci_response()
+        if OmciCreateResponse not in response:
+            log.error("Failed to create 8021p msp on {}".format(
+                device.proxy_address))
+            if response is not None:
+                log.error("Response received: {}".format(response.summary())) 
+            returnValue(False)
+        log.debug("[RESPONSE] OMCI_8021p_msp_me_allocate")
+
+        self.send_create_vlan_tagging_filter_data(device, cvlan_id)
+        response = yield self.wait_for_omci_response()
+        if OmciCreateResponse not in response:
+            log.error("Failed to set vlan tagging filter in {}".format(
+                device.proxy_address))
+            returnValue(False)
+        log.debug("[RESPONSE] OMCI_send_create_vlan_tagging_filter_data")
+
+        for port in range(1, PORT_NUMBER+1):
+            self.pmc_omci_evto_create(device, port)
+            response = yield self.wait_for_omci_response()
+            if OmciCreateResponse not in response:
+                log.error("Failed to set association info for {}".format(
+                    device.proxy_address))
+                returnValue(False)
+            log.debug("[RESPONSE] OMCI_evto_create")
+
+            self.pmc_omci_evto_set(device, port)
+            response = yield self.wait_for_omci_response()
+            if OmciSetResponse not in response:
+                log.error("Failed to set association tpid info for {}".format(
+                    device.proxy_address))
+                returnValue(False)
+            log.debug("[RESPONSE] OMCI_evto_set")
+
+            response = yield self.send_set_extended_vlan_tagging_operation_vlan_configuration_data(
+            device, cvlan_id, subsvlan_id, port)
+
+            if not response:
+                returnValue(False)
+            log.debug("[RESPONSE] OMCI_send_set_extended_vlan_tagging")
+
+        self.pmc_omci_gem_nctp_me_allocate(device)
+        response = yield self.wait_for_omci_response()
+        if OmciCreateResponse not in response:
+            log.error("Failed to Create gem nctp on {}".format(
+                device.proxy_address))
+            returnValue(False)
+        log.debug("[RESPONSE] OMCI_gem_nctp_me_allocate")
+
+        self.pmc_omci_gem_iwtp_me_allocate(device)
+        response = yield self.wait_for_omci_response()
+        if OmciCreateResponse not in response:
+            log.error("Failed to Create gem iwtp on {}".format(
+                device.proxy_address))
+            returnValue(False)
+        log.debug("[RESPONSE] OMCI_gem_iwtp_me_allocate")
+
+        self.pmc_omci_8021p_msp_me_assign(device)
+        response = yield self.wait_for_omci_response()
+        if OmciSetResponse not in response:
+            log.error("Failed to assign sp {}".format(
+                device.proxy_address))
+            returnValue(False)
+        log.debug("[RESPONSE] OMCI_8021p_msp_me_assign")
+
+        returnValue(True)
+
+    @inlineCallbacks
+    def delete_data_flow_omci_config(self, device):
+        for port in range(1, PORT_NUMBER+1):
+            self.pmc_omci_evto_deallocate(device, port)
+            response = yield self.wait_for_omci_response()
+            if OmciDeleteResponse not in response:
+                log.error(
+                    "Failed to deallocate evt for {}".format(device.proxy_address))
+                if response is not None:
+                    log.error("Response received: {}".format(response.summary()))
+                returnValue(False)
+            log.debug("[RESPONSE] pmc_omci_evto_deallocate", device=device)
+
+        self.pmc_omci_gem_iwtp_me_deallocate(device)
+        response = yield self.wait_for_omci_response()
+        if OmciDeleteResponse not in response:
+            log.error(
+                "Failed to deallocate iwtp for {}".format(device.proxy_address))
+            if response is not None:
+                log.error("Response received: {}".format(response.summary())) 
+            returnValue(False)
+        log.debug("[RESPONSE] pmc_omci_gem_iwtp_me_deallocate", device=device)
+
+        self.pmc_omci_gem_nctp_me_deallocate(device)
+        response = yield self.wait_for_omci_response()
+        if OmciDeleteResponse not in response:
+            log.error(
+                "Failed to deallocate nctp for {}".format(device.proxy_address))
+            returnValue(False)
+        log.debug("[RESPONSE] pmc_omci_gem_nctp_me_deallocate", device=device)
+
+        self.pmc_omci_vlan_tagging_filter_me_deallocate(device)
+        response = yield self.wait_for_omci_response()
+        if OmciDeleteResponse not in response:
+            log.error(
+                "Failed to deallocate vlan tagging for {}".format(device.proxy_address))
+            returnValue(False)
+        log.debug("[RESPONSE] pmc_omci_vlan_tagging_filter_me_deallocate", device=device)
+
+        self.pmc_omci_8021p_msp_me_deallocate(device)
+        response = yield self.wait_for_omci_response()
+        if OmciDeleteResponse not in response:
+            log.error(
+                "Failed to deallocate msp for {}".format(device.proxy_address))
+            returnValue(False)
+        log.debug("[RESPONSE] pmc_omci_8021p_msp_me_deallocate", device=device)
+
+        returnValue(True)
+
+    """ -   -   -   -   -   -   -   create_common_omci_config   -   -   -   -   -   -   - """
+
+    def OMCI_ont_data_mib_reset(self, device):
+        # DO things to the ONU
+        # |###[ OmciFrame ]###
+        #     |  transaction_id= 1
+        #     |  message_type= 79
+        #     |  omci      = 10
+        #     |  \omci_message\
+        #     |   |###[ OmciMibReset ]###
+        #     |   |  entity_class= 2
+        #     |   |  entity_id = 0
+        #     |  omci_trailer= 40
+
+        # OmciMibReset
+
+        msg = OmciMibReset(entity_class=2, entity_id=0)
+        frame = OmciFrame(transaction_id=self.trangen.next(),
+                          message_type=OmciMibReset.message_id,
+                          omci_message=msg)
+        _frame = hexify(str(frame))
+        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+        log.debug("[SENT] OMCI_ont_data_mib_reset")
+
+    def OMCI_tcont_set(self, device, alloc_id):
+        # | ###[ OmciFrame ]###
+        # | transaction_id = 2
+        # | message_type = 72
+        # | omci = 10
+        # |   \omci_message \
+        #      | |  ###[ OmciSet ]###
+        # | | entity_class = 262
+        # | | entity_id = 32769
+        # | | attributes_mask = 32768
+        # | | data = {'alloc_id': 1000}
+        # | omci_trailer = 40
+
+        # tcont_id = 1; //one tcont for one ONU.
+        # slot_id = 128; /* represent the ONT as a whole entinty */
+        # entity_instance = ((slot_id<<8) | tcont_id); /* Compose entity
+        # instance by the slot-id and t-cont id*/
+
+        # OmciSet
+        # TODO: maskdata
+        msg = OmciSet(entity_class=262, entity_id=32769, attributes_mask=32768,
+                      data=dict(
+                          alloc_id=alloc_id
+                      ))
+        frame = OmciFrame(transaction_id=self.trangen.next(),
+                          message_type=OmciSet.message_id,
+                          omci_message=msg)
+        _frame = hexify(str(frame))
+        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+        log.debug("[SENT] OMCI_tcont_set")
+
+    def pmc_omci_mac_bridge_sp_me_create(self, device):
+        # length = 44
+        # port_type = 0
+        # port_id = 0
+        # management_frame = 1
+        # \frame \
+        #  |  ###[ OmciFrame ]###
+        # | transaction_id = 3
+        # | message_type = 68
+        # | omci = 10
+        # |   \omci_message \
+        #      | |  ###[ OmciCreate ]###
+        # | | entity_class = 45
+        # | | entity_id = 1
+        # | | data = {'max_age': 5120, 'hello_time': 512, 'priority': 32768, 'port_bridging_ind': 0,
+        #             'spanning_tree_ind': 0, 'unknown_mac_address_discard': 0, 'mac_learning_depth': 128,
+        #             'learning_ind': 0, 'forward_delay': 3840}
+        # | |  ###[ Raw ]###
+        # | | load = '\x00\x00\x00\n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
+        # | omci_trailer = 40
+
+        # Found in method: pmc_omci_mac_bridge_sp_me_create from: PMC_OFAL.c
+        # Params
+        #   - priority: The bridge priority set on the LAN card
+        #   - max_age: The maximum age for an entry in the spanning tree listing
+        #   - hello_time: The time interval between hello packets
+        #   - forward_delay: The time that the bridge on the Ethernet card in the ONT retains a packet before forwarding it
+        #   - unknown_mac_address_discard: frames with unknown destination addresses will be forwarded to all allowed ports
+
+        msg = OmciCreate(entity_class=45, entity_id=1,
+                         data=dict(
+                             max_age=5120,
+                             hello_time=512,
+                             priority=32768,
+                             port_bridging_ind=PON_FALSE,
+                             spanning_tree_ind=PON_FALSE,
+                             unknown_mac_address_discard=0,
+                             mac_learning_depth=128,
+                             learning_ind=PON_FALSE,
+                             forward_delay=3840
+                         ))
+        frame = OmciFrame(transaction_id=self.trangen.next(),
+                          message_type=OmciCreate.message_id,
+                          omci_message=msg)
+        _frame = hexify(str(frame))
+        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+        log.debug("[SENT] pmc_omci_mac_bridge_sp_me_create")
+
+    def pmc_omci_mac_bridge_pcd_me_create(self, device):
+
+        # |###[ OmciFrame ]###
+        #     |  transaction_id= 4
+        #     |  message_type= 68
+        #     |  omci      = 10
+        #     |  \omci_message\
+        #     |   |###[ OmciCreate ]###
+        #     |   |  entity_class= 47
+        #     |   |  entity_id = 0
+        #     |   |  data      = {'tp_pointer': 257, 'encapsulation_methods': 1, 'port_num': 0, 'port_priority': 10, 'tp_type': 1, 'port_path_cost': 100, 'port_spanning_tree_in': 0, 'lan_fcs_ind': 0, 'bridge_id_pointer': 1}
+        #     |  omci_trailer= 40
+
+        # Found in method: pmc_omci_mac_bridge_pcd_me_create from: PMC_OFAL.c
+        # Params
+        #   - port_path_cost: The cost contribution of the port to the path cost towards the spanning tree root bridge
+        #   - bridge_id_pointer: MAC bridge controlling the port
+
+        msg = OmciCreate(entity_class=47, entity_id=0,
+                         data=dict(
+                             tp_pointer=1,
+                             encapsulation_methods=OMCI_MAC_BRIDGE_PCD_ENCAP_METHOD_LLC,
+                             port_num=0,
+                             port_priority=10,
+                             tp_type=3,
+                             port_path_cost=100,
+                             port_spanning_tree_in=PON_FALSE,
+                             lan_fcs_ind=OMCI_MAC_BRIDGE_PCD_LANFCS_FORWARDED,
+                             bridge_id_pointer=1
+                         ))
+
+        frame = OmciFrame(transaction_id=self.trangen.next(),
+                          message_type=OmciCreate.message_id,
+                          omci_message=msg)
+        _frame = hexify(str(frame))
+        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+        log.debug("[SENT] pmc_omci_mac_bridge_pcd_me_create")
+
+    def pmc_omci_evto_create(self, device, port):
+        # |###[ OmciFrame ]###
+        # |  transaction_id= 5
+        # |  message_type= 68
+        # |  omci      = 10
+        # |  \omci_message\
+        # |   |###[ OmciCreate ]###
+        # |   |  entity_class= 171
+        # |   |  entity_id = 0
+        # |   |  data      = {'association_type': 2, 'associated_me_pointer': 257}
+        # |  omci_trailer= 40
+
+        # Found in method: pmc_omci_evto_create from: PMC_OFAL.c
+        msg = OmciCreate(entity_class=171, entity_id=port,
+                         data=dict(
+                             association_type=OMCI_EX_VLAN_TAG_OCD_ASSOCIATION_TYPE_PPTP_ETH_UNI,
+                             associated_me_pointer=0x100+port
+                         ))
+
+        frame = OmciFrame(transaction_id=self.trangen.next(),
+                          message_type=OmciCreate.message_id,
+                          omci_message=msg)
+        _frame = hexify(str(frame))
+        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+        log.debug("[SENT] pmc_omci_evto_create")
+
+    def pmc_omci_evto_set(self, device, port):
+        # |###[ OmciFrame ]###
+        # |  transaction_id= 6
+        # |  message_type= 72
+        # |  omci      = 10
+        # |  \omci_message\
+        # |   |###[ OmciSet ]###
+        # |   |  entity_class= 171
+        # |   |  entity_id = 0
+        # |   |  attributes_mask= 47616
+        # |   |  data      = {'association_type': 2, 'input_tpid': 33024, 'associated_me_pointer': 257, 'downstream_mode': 0, 'output_tpid': 33024}
+        # |  omci_trailer= 40
+
+        # Found in method: pmc_omci_evto_set from: PMC_OFAL.c
+        msg = OmciSet(entity_class=171, entity_id=port, attributes_mask=47616,
+                      data=dict(
+                          association_type=OMCI_EX_VLAN_TAG_OCD_ASSOCIATION_TYPE_PPTP_ETH_UNI,
+                          input_tpid=0x8100,
+                          associated_me_pointer=0x100+port,
+                          downstream_mode=OMCI_EX_VLAN_TAG_OCD_DS_MODE_US_INVERSE,
+                          output_tpid=0x8100
+                      ))
+
+        frame = OmciFrame(transaction_id=self.trangen.next(),
+                          message_type=OmciSet.message_id,
+                          omci_message=msg)
+        _frame = hexify(str(frame))
+        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+        log.debug("[SENT] pmc_omci_evto_set")
+
+    """ -   -   -   -   -   -   -     END create_common_omci_config     -   -   -   -   -   -   - """
+
+    """ -   -   -   -   -   -   create_default_data_flow_omci_config    -   -   -   -   -   -   - """
+
+    def pmc_omci_8021p_msp_me_allocate(self, device):
+        # |###[ OmciFrame ]###
+        # |  transaction_id= 7
+        # |  message_type= 68
+        # |  omci      = 10
+        # |  \omci_message\
+        # |   |###[ OmciCreate ]###
+        # |   |  entity_class= 130
+        # |   |  entity_id = 1
+        # |   |  data      = {'tp_pointer': 65535, 'unmarked_frame_option': 1, 'interwork_tp_pointer_for_p_bit_priority_6': 65535,
+        #          'interwork_tp_pointer_for_p_bit_priority_7': 65535, 'interwork_tp_pointer_for_p_bit_priority_4': 65535,
+        #           'interwork_tp_pointer_for_p_bit_priority_5': 65535, 'interwork_tp_pointer_for_p_bit_priority_2': 65535,
+        #           'interwork_tp_pointer_for_p_bit_priority_3': 65535, 'interwork_tp_pointer_for_p_bit_priority_0': 65535,
+        #           'interwork_tp_pointer_for_p_bit_priority_1': 65535, 'tp_type': 0, 'default_p_bit_marking': 0}
+        # |  omci_trailer= 40
+
+        # Found in method: pmc_omci_8021p_msp_me_create from: PMC_OFAL.c
+        msg = OmciCreate(entity_class=130, entity_id=1,
+                         data=dict(
+                             tp_pointer=65535,
+                             unmarked_frame_option=OMCI_8021P_MSP_UNMARKED_FRAME_TAG_FRAME,
+                             interwork_tp_pointer_for_p_bit_priority_6=65535,
+                             interwork_tp_pointer_for_p_bit_priority_7=65535,
+                             interwork_tp_pointer_for_p_bit_priority_4=65535,
+                             interwork_tp_pointer_for_p_bit_priority_5=65535,
+                             interwork_tp_pointer_for_p_bit_priority_2=65535,
+                             interwork_tp_pointer_for_p_bit_priority_3=65535,
+                             interwork_tp_pointer_for_p_bit_priority_0=65535,
+                             interwork_tp_pointer_for_p_bit_priority_1=65535,
+                             tp_type=OMCI_8021P_MSP_TP_TYPE_NULL,
+                             default_p_bit_marking=0
+                         ))
+
+        frame = OmciFrame(transaction_id=self.trangen.next(),
+                          message_type=OmciCreate.message_id,
+                          omci_message=msg)
+        _frame = hexify(str(frame))
+        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+        log.debug("[SENT] pmc_omci_8021p_msp_me_allocate")
+
+    def pmc_omci_mac_bridge_pcd_me_allocate(self, device, port):
+        # |###[ OmciFrame ]###
+        # |  transaction_id= 8
+        # |  message_type= 68
+        # |  omci      = 10
+        # |  \omci_message\
+        # |   |###[ OmciCreate ]###
+        # |   |  entity_class= 130
+        # |   |  entity_id = 1
+        # |   |  data      = {'tp_pointer': 1, 'encapsulation_methods': 1, 'port_num': 1, 'port_priority': 3, 'tp_type': 5, 'port_path_cost': 32, 'port_spanning_tree_in': 1, 'lan_fcs_ind': 0, 'bridge_id_pointer': 1}
+        # |  omci_trailer= 40
+
+        # Found in method: pmc_omci_mac_bridge_pcd_me_create from: PMC_OFAL.c
+        # Params
+        #   - port_path_cost: The cost contribution of the port to the path cost towards the spanning tree root bridge
+        #   - bridge_id_pointer: MAC bridge controlling the port
+        msg = OmciCreate(entity_class=47, entity_id=port,
+                         data=dict(
+                             tp_pointer=0x100 + port,
+                             encapsulation_methods=OMCI_MAC_BRIDGE_PCD_ENCAP_METHOD_LLC,
+                             port_num=port,
+                             port_priority=10,
+                             tp_type=1,
+                             port_path_cost=100,
+                             port_spanning_tree_in=PON_FALSE,
+                             lan_fcs_ind=OMCI_MAC_BRIDGE_PCD_LANFCS_FORWARDED,
+                             bridge_id_pointer=1
+                         ))
+
+        frame = OmciFrame(transaction_id=self.trangen.next(),
+                          message_type=OmciCreate.message_id,
+                          omci_message=msg)
+        _frame = hexify(str(frame))
+        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+        log.debug("[SENT] pmc_omci_mac_bridge_pcd_me_allocate")
+
+    def pmc_omci_gem_nctp_me_allocate(self, device):
+        # |###[ OmciFrame ]###
+        # |  transaction_id= 9
+        # |  message_type= 68
+        # |  omci      = 10
+        # |  \omci_message\
+        # |   |###[ OmciCreate ]###
+        # |   |  entity_class= 268
+        # |   |  entity_id = 1
+        # |   |  data      = {'priority_queue_pointer_downstream': 0, 'direction': 3, 'tcont_pointer': 32769, 'traffic_descriptor_profile_pointer': 0, 'traffic_management_pointer_upstream': 4, 'port_id': 1000}
+        # |  omci_trailer= 40
+
+        # Found in method: pmc_omci_gem_nctp_create from: PMC_OFAL.c
+        msg = OmciCreate(entity_class=268, entity_id=1,
+                         data=dict(
+                             priority_queue_pointer_downstream=0,   # 0 for default
+                             direction=GEM_DIR_BIDIRECT,
+                             tcont_pointer=32769,
+                             traffic_descriptor_profile_pointer=0,
+                             traffic_management_pointer_upstream=4,  # 4 for default
+                             # Same as GEM port
+                             # port_id=(1000 + device.proxy_address.onu_id)
+                             port_id = self.port_id
+                         ))
+
+        frame = OmciFrame(transaction_id=self.trangen.next(),
+                          message_type=OmciCreate.message_id,
+                          omci_message=msg)
+        _frame = hexify(str(frame))
+        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+        log.debug("[SENT] pmc_omci_gem_nctp_me_allocate")
+
+    def pmc_omci_gem_iwtp_me_allocate(self, device):
+        # |###[ OmciFrame ]###
+        # |  transaction_id= 10
+        # |  message_type= 68
+        # |  omci      = 10
+        # |  \omci_message\
+        # |   |###[ OmciCreate ]###
+        # |   |  entity_class= 266
+        # |   |  entity_id = 1
+        # |   |  data      = {'gem_port_network_ctp_pointer': 1, 'gal_profile_pointer': 0, 'service_profile_pointer': 1, 'interworking_option': 5, 'interworking_tp_pointer': 0}
+        # |  omci_trailer= 40
+
+        # Found in method: pmc_omci_gem_iwtp_me_create from: PMC_OFAL.c
+        # Params
+        #   - gem_port_network_ctp_pointer: An instance identifier of the GEM Port Network CTP that is associated with this GEM Interworking Termination Point
+        #   - service_profile_pointer: The service profile type and a pointer to the instance of a service profile
+        #   - interworking_tp_pointer: Used for in the case of Circuit Emulation Services and 802.1p mapper service
+        #   - gal_profile_pointer: A pointer to an instance of the GAL Profile
+
+        msg = OmciCreate(entity_class=266, entity_id=1,
+                         data=dict(
+                             gem_port_network_ctp_pointer=1,
+                             gal_profile_pointer=0,
+                             service_profile_pointer=1,
+                             interworking_option=OMCI_GEM_IWTP_IW_OPT_8021P_MAPPER,
+                             interworking_tp_pointer=0
+                         ))
+
+        frame = OmciFrame(transaction_id=self.trangen.next(),
+                          message_type=OmciCreate.message_id,
+                          omci_message=msg)
+        _frame = hexify(str(frame))
+        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+        log.debug("[SENT] pmc_omci_gem_iwtp_me_allocate")
+
+    """ -   -   -   -   -   -    END create_default_data_flow_omci_config   -   -   -   -   -   - """
+
+    """ -   -   -   -   -   -   -     create_data_flow_omci_config      -   -   -   -   -   -   - """
+
+    @inlineCallbacks
+    def send_set_extended_vlan_tagging_operation_vlan_configuration_data(self, device, cvlan_id, subs_vlan, port):
+        # ###[ PAS5211MsgSendFrame ]###
+        #            length    = 44
+        #            port_type = 0
+        #            port_id   = 0
+        #            management_frame= 1
+        #            \frame     \
+        #             |###[ OmciFrame ]###
+        #             |  transaction_id= 14
+        #             |  message_type= 72
+        #             |  omci      = 10
+        #             |  \omci_message\
+        #             |   |###[ OmciSet ]###
+        #             |   |  entity_class= 171
+        #             |   |  entity_id = 0
+        #             |   |  attributes_mask= 1024
+        #             |   |  data      = {'received_frame_vlan_tagging_operation_table': '\xf8\x00\x00\x00\x00\x00@\x00@\x0f\x00\x04\x00\x00\x00\x0c'}
+        #             |  omci_trailer= 40
+
+        self.send_vlan_tagging_operation_msg(device,
+            VlanTaggingOperation(
+                filter_outer_priority=OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_NO_TAG,
+                filter_outer_vid=OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE,
+                filter_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE,
+
+                filter_inner_priority=0,
+                filter_inner_vid=subs_vlan,
+                filter_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_8100,
+                filter_ether_type=OMCI_EX_VLAN_TAG_OCD_FILTER_ETYPE_NONE,
+
+                treatment_tags_to_remove=1,
+                treatment_outer_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE,
+                treatment_outer_vid=0,
+                treatment_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_EQ_8100,
+
+                treatment_inner_priority=0,
+                treatment_inner_vid=cvlan_id,
+                treatment_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_EQ_8100
+            ), port)
+        response = yield self.wait_for_omci_response()
+
+        log.debug(
+            "[SENT] send_set_extended_vlan_tagging_operation_vlan_configuration_data")
+
+        if OmciSetResponse not in response:
+            log.error("Failed to set vlan extended table entry {}".format(
+                device.proxy_address))
+            returnValue(False)
+
+        log.debug(
+            "[RESPONSE] send_set_extended_vlan_tagging_operation_vlan_configuration_data")
+
+        self.send_vlan_tagging_operation_msg(device,
+            VlanTaggingOperation(
+                filter_outer_priority=OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_NO_TAG,
+                filter_outer_vid=OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE,
+                filter_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE,
+
+                filter_inner_priority=OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_NO_TAG,
+                filter_inner_vid=OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE,
+                filter_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE,
+                filter_ether_type=OMCI_EX_VLAN_TAG_OCD_FILTER_ETYPE_NONE,
+
+                treatment_tags_to_remove=3,
+                treatment_outer_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE,
+                treatment_outer_vid=0,
+                treatment_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_OUTER,
+
+                treatment_inner_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE,
+                treatment_inner_vid=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_COPY_FROM_INNER,
+                treatment_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_INNER
+            ), port)
+
+        log.debug(
+            "[SENT] send_set_extended_vlan_tagging_operation_vlan_configuration_data")
+
+        response = yield self.wait_for_omci_response()
+        if OmciSetResponse not in response:
+            log.error("Failed to set vlan extended table entry {}".format(
+                device.proxy_address))
+            returnValue(False)
+
+        log.debug(
+            "[RESPONSE] send_set_extended_vlan_tagging_operation_vlan_configuration_data")
+
+        self.send_vlan_tagging_operation_msg(device,
+            VlanTaggingOperation(
+                filter_outer_priority=OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_NO_TAG,
+                filter_outer_vid=OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE,
+                filter_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE,
+
+                filter_inner_priority=OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_DEFAULT,
+                filter_inner_vid=OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE,
+                filter_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE,
+                filter_ether_type=OMCI_EX_VLAN_TAG_OCD_FILTER_ETYPE_NONE,
+
+                treatment_tags_to_remove=3,
+                treatment_outer_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE,
+                treatment_outer_vid=0,
+                treatment_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_OUTER,
+
+                treatment_inner_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE,
+                treatment_inner_vid=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_COPY_FROM_INNER,
+                treatment_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_INNER
+            ), port)
+
+        log.debug(
+            "[SENT] send_set_extended_vlan_tagging_operation_vlan_configuration_data")
+
+        response = yield self.wait_for_omci_response()
+        if OmciSetResponse not in response:
+            log.error("Failed to set vlan extended table entry {}".format(
+                device.proxy_address))
+            returnValue(False)
+
+        log.debug(
+            "[RESPONSE] send_set_extended_vlan_tagging_operation_vlan_configuration_data")
+
+        self.send_vlan_tagging_operation_msg(device,
+            VlanTaggingOperation(
+                filter_outer_priority=OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_DEFAULT,
+                filter_outer_vid=OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE,
+                filter_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE,
+
+                filter_inner_priority=OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_DEFAULT,
+                filter_inner_vid=OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE,
+                filter_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE,
+                filter_ether_type=OMCI_EX_VLAN_TAG_OCD_FILTER_ETYPE_NONE,
+
+                treatment_tags_to_remove=3,
+                treatment_outer_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE,
+                treatment_outer_vid=0,
+                treatment_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_OUTER,
+
+                treatment_inner_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE,
+                treatment_inner_vid=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_COPY_FROM_INNER,
+                treatment_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_INNER
+            ), port)
+
+        log.debug(
+            "[SENT] send_set_extended_vlan_tagging_operation_vlan_configuration_data")
+
+        response = yield self.wait_for_omci_response()
+        if OmciSetResponse not in response:
+            log.error("Failed to set vlan extended table entry {}".format(
+                device.proxy_address))
+            returnValue(False)
+        log.debug(
+            "[RESPONSE] send_set_extended_vlan_tagging_operation_vlan_configuration_data")
+
+        returnValue(True)
+
+    def send_vlan_tagging_operation_msg(self, device, vlan_tagging_operation_table, port):
+
+        data = dict(
+            received_frame_vlan_tagging_operation_table=vlan_tagging_operation_table
+        )
+
+        msg = OmciSet(
+            entity_class=171,
+            entity_id=port,
+            attributes_mask=1024,
+            data=data
+        )
+
+        frame = OmciFrame(
+            transaction_id=self.trangen.next(),
+            message_type=OmciSet.message_id,
+            omci_message=msg
+        )
+        _frame = hexify(str(frame))
+        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+        log.debug("[SENT] create_vlan_tagging_filter_data")
+
+    def send_create_vlan_tagging_filter_data(self, device, cvlan_id):
+        # ###[ PAS5211MsgSendFrame ]###
+        #    length    = 44
+        #    port_type = 0
+        #    port_id   = 0
+        #    management_frame= 1
+        #    \frame     \
+        #     |###[ OmciFrame ]###
+        #     |  transaction_id= 18
+        #     |  message_type= 68
+        #     |  omci      = 10
+        #     |  \omci_message\
+        #     |   |###[ OmciCreate ]###
+        #     |   |  entity_class= 84
+        #     |   |  entity_id = 2
+        #     |   |  data      = {'vlan_filter_0': 1, 'vlan_filter_1': 0, 'vlan_filter_2': 0, 'vlan_filter_3': 0, 'vlan_filter_4': 0, 'vlan_filter_5': 0, 'vlan_filter_6': 0, 'vlan_filter_7': 0, 'vlan_filter_8': 0, 'vlan_filter_9': 0, 'number_of_entries': 1, 'forward_operation': 16, 'vlan_filter_10': 0, 'vlan_filter_11': 0}
+        #     |  omci_trailer= 40
+
+        data = dict(
+            vlan_filter_0=cvlan_id,
+            forward_operation=16,
+            number_of_entries=1
+        )
+
+        msg = OmciCreate(
+            entity_class=84,
+            entity_id=1,
+            data=data
+        )
+
+        frame = OmciFrame(
+            transaction_id=self.trangen.next(),
+            message_type=OmciCreate.message_id,
+            omci_message=msg
+        )
+        _frame = hexify(str(frame))
+        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+        log.debug("[SENT] create_vlan_tagging_filter_data")
+
+    @inlineCallbacks
+    def pmc_omci_vlan_tagging_filter_me_allocate(self, device):  # TODO
+
+        self.OMCI_vlan_tagging_filter_get(device)
+        response = yield self.incoming_messages.get()
+        if OmciGetResponse not in response:
+            log.error("Failed to Get vlan tagging filter {}".format(
+                device.proxy_address))
+            return
+
+        # if: # OMCI Get is sucessfull
+        #     # OMCI_vlan_tagging_filter_create
+        # else:
+        #     # OMCI_vlan_tagging_filter_set
+        log.debug("[SENT] pmc_omci_vlan_tagging_filter_me_allocate")
+        pass
+
+    def pmc_omci_8021p_msp_me_assign(self, device):
+
+        # ###[ PAS5211MsgSendFrame ]###
+        #    length    = 44
+        #    port_type = 0
+        #    port_id   = 0
+        #    management_frame= 1
+        #    \frame     \
+        #     |###[ OmciFrame ]###
+        #     |  transaction_id= 21
+        #     |  message_type= 72
+        #     |  omci      = 10
+        #     |  \omci_message\
+        #     |   |###[ OmciSet ]###
+        #     |   |  entity_class= 130
+        #     |   |  entity_id = 2
+        #     |   |  attributes_mask= 16472
+        #     |   |  data      = {'tp_type': 0, 'unmarked_frame_option': 1, 'interwork_tp_pointer_for_p_bit_priority_0': 2, 'default_p_bit_marking': 0}
+        #     |  omci_trailer= 40
+
+        data = dict(tp_type=0,
+                    output_tpid=33024,
+                    unmarked_frame_option=1,
+                    interwork_tp_pointer_for_p_bit_priority_0=1,
+                    default_p_bit_marking=0
+                    )
+
+        msg = OmciSet(entity_class=130,
+                      entity_id=1,
+                      attributes_mask=16472,
+                      data=data
+                      )
+
+        frame = OmciFrame(
+            transaction_id=self.trangen.next(),
+            message_type=OmciSet.message_id,
+            omci_message=msg
+        )
+        _frame = hexify(str(frame))
+        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+
+        log.debug("[SENT] pmc_omci_8021p_msp_me_assign")
+
+    def pmc_ofal_recover_default_onu_flow_omci(self, device):
+        log.debug("[SENT] pmc_ofal_recover_default_onu_flow_omci")
+        pass
+
+    def OMCI_vlan_tagging_filter_get(self, device):
+        # entity_class: OMCI_ENT_VLAN_TAGGING_FILT_DATA
+        # entity_instance: mac_bridge_pcd
+        # attr_mask = 0
+        # attr_mask | OMCI_ATTR_BIT(OMCI_VLAN_TAG_FILTER_ATTR_FILTER_TABLE);
+        # attr_mask | OMCI_ATTR_BIT(OMCI_VLAN_TAG_FILTER_ATTR_FWD_OP);
+        # attr_mask | OMCI_ATTR_BIT(OMCI_VLAN_TAG_FILTER_ATTR_NOF_ENTRIES);
+        log.debug("[SENT] OMCI_vlan_tagging_filter_get")
+        pass
+
+    def OMCI_vlan_tagging_filter_create(self, device):  # TODO
+        log.debug("[SENT] OMCI_vlan_tagging_filter_create")
+        pass
+
+    def OMCI_vlan_tagging_filter_set(self, device):  # TODO
+        log.debug("[SENT] OMCI_vlan_tagging_filter_set")
+        pass
+
+    """ -   -   -   -   -   -   -    END create_data_flow_omci_config      -   -   -   -   -   -   - """
+
+    """ -   -   -   -   -   -   -   delete_data_flow_omci_config   -   -   -   -   -   -   - """
+
+    def pmc_omci_gem_iwtp_me_deallocate(self, device):
+        # |###[ OmciFrame ]###
+        # |  transaction_id= 34
+        # |  message_type= 70
+        # |  omci      = 10
+        # |  \omci_message\
+        # |   |###[ OmciDelete ]###
+        # |   |  entity_class= 266
+        # |   |  entity_id = 2
+        # |  omci_trailer= 40
+        msg = OmciDelete(entity_class=266, entity_id=1)
+
+        frame = OmciFrame(transaction_id=self.trangen.next(),
+                          message_type=OmciDelete.message_id,
+                          omci_message=msg)
+        _frame = hexify(str(frame))
+        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+        log.debug("[SENT] pmc_omci_gem_iwtp_me_deallocate")
+
+    def pmc_omci_gem_nctp_me_deallocate(self, device):
+        # |###[ OmciFrame ]###
+        # |  transaction_id= 35
+        # |  message_type= 70
+        # |  omci      = 10
+        # |  \omci_message\
+        # |   |###[ OmciDelete ]###
+        # |   |  entity_class= 268
+        # |   |  entity_id = 2
+        # |  omci_trailer= 40
+        msg = OmciDelete(entity_class=268, entity_id=1)
+
+        frame = OmciFrame(transaction_id=self.trangen.next(),
+                          message_type=OmciDelete.message_id,
+                          omci_message=msg)
+        _frame = hexify(str(frame))
+        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+        log.debug("[SENT] pmc_omci_gem_nctp_me_allocate")
+
+    def pmc_omci_vlan_tagging_filter_me_deallocate(self, device):
+        # |###[ OmciFrame ]###
+        # |  transaction_id= 36
+        # |  message_type= 70
+        # |  omci      = 10
+        # |  \omci_message\
+        # |   |###[ OmciDelete ]###
+        # |   |  entity_class= 84
+        # |   |  entity_id = 2
+        # |  omci_trailer= 40
+        msg = OmciDelete(entity_class=84, entity_id=1)
+
+        frame = OmciFrame(transaction_id=self.trangen.next(),
+                          message_type=OmciDelete.message_id,
+                          omci_message=msg)
+        _frame = hexify(str(frame))
+        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+        log.debug("[SENT] pmc_omci_vlan_tagging_filter_me_deallocate")
+
+
+    def pmc_omci_mac_bridge_pcd_me_deallocate(self, device):
+        # |###[ OmciFrame ]###
+        # |  transaction_id= 37
+        # |  message_type= 70
+        # |  omci      = 10
+        # |  \omci_message\
+        # |   |###[ OmciDelete ]###
+        # |   |  entity_class= 47
+        # |   |  entity_id = 2
+        # |  omci_trailer= 40
+        msg = OmciDelete(entity_class=47, entity_id=1)
+
+        frame = OmciFrame(transaction_id=self.trangen.next(),
+                          message_type=OmciDelete.message_id,
+                          omci_message=msg)
+        _frame = hexify(str(frame))
+        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+        log.debug("[SENT] pmc_omci_mac_bridge_pcd_me_deallocate")
+
+
+
+    def pmc_omci_8021p_msp_me_deallocate(self, device):
+        # |###[ OmciFrame ]###
+        # |  transaction_id= 38
+        # |  message_type= 70
+        # |  omci      = 10
+        # |  \omci_message\
+        # |   |###[ OmciDelete ]###
+        # |   |  entity_class= 130
+        # |   |  entity_id = 2
+        # |  omci_trailer= 40
+        msg = OmciDelete(entity_class=130, entity_id=1)
+
+        frame = OmciFrame(transaction_id=self.trangen.next(),
+                          message_type=OmciDelete.message_id,
+                          omci_message=msg)
+        _frame = hexify(str(frame))
+        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+        log.debug("[SENT] pmc_omci_8021p_msp_me_deallocate")
+
+    def pmc_omci_evto_deallocate(self, device, port):
+
+        msg = OmciDelete(entity_class=171, entity_id=port)
+
+        frame = OmciFrame(transaction_id=self.trangen.next(),
+                          message_type=OmciDelete.message_id,
+                          omci_message=msg)
+        _frame = hexify(str(frame))
+        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+        log.debug("[SENT] pmc_omci_evto_deallocate")
+
+
+    """ -   -   -   -   -   -   -   END delete_data_flow_omci_config   -   -   -   -   -   -   - """
+
+def mac_str_to_tuple(mac):
+    return tuple(int(d, 16) for d in mac.split(':'))
