/*
 * Copyright (c) 2018 - present.  Boling Consulting Solutions (bcsw.net)
 * Copyright 2020-present Open Networking Foundation
 *
 * 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.
 */
/*
 * NOTE: This file was generated, manual edits will be overwritten!
 *
 * Generated by 'goCodeGenerator.py':
 *              https://github.com/cboling/OMCI-parser/README.md
 */

package generated

import "github.com/deckarep/golang-set"

// GemPortNetworkCtpClassID is the 16-bit ID for the OMCI
// Managed entity GEM port network CTP
const GemPortNetworkCtpClassID = ClassID(268) // 0x010c

var gemportnetworkctpBME *ManagedEntityDefinition

// GemPortNetworkCtp (Class ID: #268 / 0x010c)
//	This ME represents the termination of a GEM port on an ONU. This ME aggregates connectivity
//	functionality from the network view and alarms from the network element view as well as
//	artefacts from trails.
//
//	Instances of the GEM port network CTP ME are created and deleted by the OLT. An instance of GEM
//	port network CTP can be deleted only when no GEM IW TP or GEM port network CTP PM history data
//	are associated with it. It is the responsibility of the OLT to make sure that the ONU
//	configuration meets this condition.
//
//	In ITU-T G.984 systems, when a GEM port network CTP is created, its encryption state is by
//	default not encrypted. If the OLT wishes to configure the GEM port to use encryption, it must
//	send the appropriate PLOAM message. This applies equally to new CTPs and to CTPs that are re-
//	created after an MIB reset.
//
//	In ITU-T G.987 systems, GEM ports are dynamically encrypted. If it is intended to encrypt the
//	GEM port, the OLT must configure a key ring to be used, and the key must be known to the ONU at
//	run time.
//
//	Relationships
//		An instance of the GEM port network CTP ME may be associated with an instance of the T-CONT and
//		GEM IW TP MEs.
//
//	Attributes
//		Managed Entity Id
//			This attribute uniquely identifies each instance of this ME. (R, setbycreate) (mandatory)
//			(2-bytes)
//
//		Port_Id
//			Port-ID:	This attribute is the port-ID of the GEM port associated with this CTP. (RWSC)
//			(mandatory) (2-bytes)
//
//			NOTE 1 - While nothing forbids the existence of several GEM port network CTPs with the same
//			port-ID value, downstream traffic is modelled as being delivered to all such GEM port network
//			CTPs. Be aware of potential difficulties associated with defining downstream flows and
//			aggregating PM statistics.
//
//		T_Cont Pointer
//			T-CONT pointer: This attribute points to a T-CONT instance. (R,-W, setbycreate) (mandatory)
//			(2-bytes)
//
//		Direction
//			This attribute specifies whether the GEM port is used for UNI-to-ANI (1), ANI-to-UNI (2), or
//			bidirectional (3) connection. (R,-W, setbycreate) (mandatory) (1-byte)
//
//		Traffic Management Pointer For Upstream
//			If the traffic management option attribute in the ONU-G ME is 0 (priority controlled) or 2
//			(priority and rate controlled), this pointer specifies the priority queue ME serving this GEM
//			port network CTP. If the traffic management option attribute is 1 (rate controlled), this
//			attribute redundantly points to the TCONT serving this GEM port network CTP. (R,-W, setbycreate)
//			(mandatory) (2-bytes)
//
//		Traffic Descriptor Profile Pointer For Upstream
//			See also Appendix II.
//
//			This attribute points to the instance of the traffic descriptor ME that contains the upstream
//			traffic parameters for this GEM port network CTP. This attribute is used when the traffic
//			management option attribute in the ONU-G ME is 1 (rate controlled), specifying the PIR/PBS to
//			which the upstream traffic is shaped. This attribute is also used when the traffic management
//			option attribute in the ONU-G ME is 2 (priority and rate controlled), specifying the
//			CIR/CBS/PIR/PBS to which the upstream traffic is policed. (R,-W, setbycreate) (optional)
//			(2-bytes)
//
//		Uni Counter
//			This attribute reports the number of instances of UNI-G ME associated with this GEM port network
//			CTP. (R) (optional) (1-byte)
//
//		Priority Queue Pointer For Down Stream
//			Priority queue pointer for downstream: This attribute points to the instance of the priority
//			queue used for this GEM port network CTP in the downstream direction. It is the responsibility
//			of the OLT to provision the downstream pointer in a way that is consistent with the bridge and
//			mapper connectivity. If the pointer is null, downstream queueing is determined by other
//			mechanisms in the ONU. (R,-W, setbycreate) (mandatory) (2-bytes)
//
//			NOTE 2 - If the GEM port network CTP is associated with more than one UNI (downstream
//			multicast), the downstream priority queue pointer defines a pattern (e.g., queue number 3 for a
//			given UNI) to be replicated (i.e., to queue number 3) at the other affected UNIs.
//
//		Encryption State
//			This attribute indicates the current state of the GEM port network CTP's encryption. Legal
//			values are defined to be the same as those of the security mode attribute of the ONU2-G, with
//			the exception that attribute value 0 indicates an unencrypted GEM port. (R) (optional) (1-byte)
//
//		Traffic Descriptor Profile Pointer For Downstream
//			This attribute points to the instance of the traffic descriptor ME that contains the downstream
//			traffic parameters for this GEM port network CTP. This attribute is used when the traffic
//			management option attribute in the ONU-G ME is 1 (rate controlled), specifying the PIR/PBS to
//			which the downstream traffic is shaped. This attribute is also used when the traffic management
//			option attribute in the ONU-G ME is 2 (priority and rate controlled), specifying the
//			CIR/CBS/PIR/PBS to which the downstream traffic is policed. (R,-W, setbycreate) (optional)
//			(2-bytes)
//
//			See also Appendix II.
//
//		Encryption Key Ring
//			This attribute is defined in ITU-T G.987 systems only. It specifies whether the associated GEM
//			port is encrypted, and if so, which key ring it uses. (R, W, setbycreate) (optional) (1 byte)
//
//			0	(default) No encryption. The downstream key index is ignored, and upstream traffic is
//			transmitted with key index 0.
//
//			1	Unicast payload encryption in both directions. Keys are generated by the ONU and transmitted
//			to the OLT via the PLOAM channel.
//
//			2	Broadcast (multicast) encryption. Keys are generated by the OLT and distributed via the OMCI.
//
//			3	Unicast encryption, downstream only. Keys are generated by the ONU and transmitted to the OLT
//			via the PLOAM channel.
//
//			Other values are reserved.
//
type GemPortNetworkCtp struct {
	ManagedEntityDefinition
	Attributes AttributeValueMap
}

// Attribute name constants

const GemPortNetworkCtp_PortId = "PortId"
const GemPortNetworkCtp_TContPointer = "TContPointer"
const GemPortNetworkCtp_Direction = "Direction"
const GemPortNetworkCtp_TrafficManagementPointerForUpstream = "TrafficManagementPointerForUpstream"
const GemPortNetworkCtp_TrafficDescriptorProfilePointerForUpstream = "TrafficDescriptorProfilePointerForUpstream"
const GemPortNetworkCtp_UniCounter = "UniCounter"
const GemPortNetworkCtp_PriorityQueuePointerForDownStream = "PriorityQueuePointerForDownStream"
const GemPortNetworkCtp_EncryptionState = "EncryptionState"
const GemPortNetworkCtp_TrafficDescriptorProfilePointerForDownstream = "TrafficDescriptorProfilePointerForDownstream"
const GemPortNetworkCtp_EncryptionKeyRing = "EncryptionKeyRing"

func init() {
	gemportnetworkctpBME = &ManagedEntityDefinition{
		Name:    "GemPortNetworkCtp",
		ClassID: GemPortNetworkCtpClassID,
		MessageTypes: mapset.NewSetWith(
			Create,
			Delete,
			Get,
			Set,
		),
		AllowedAttributeMask: 0xffc0,
		AttributeDefinitions: AttributeDefinitionMap{
			0:  Uint16Field(ManagedEntityID, PointerAttributeType, 0x0000, 0, mapset.NewSetWith(Read, SetByCreate), false, false, false, 0),
			1:  Uint16Field(GemPortNetworkCtp_PortId, UnsignedIntegerAttributeType, 0x8000, 0, mapset.NewSetWith(Read, SetByCreate, Write), false, false, false, 1),
			2:  Uint16Field(GemPortNetworkCtp_TContPointer, PointerAttributeType, 0x4000, 0, mapset.NewSetWith(Read, SetByCreate, Write), false, false, false, 2),
			3:  ByteField(GemPortNetworkCtp_Direction, EnumerationAttributeType, 0x2000, 3, mapset.NewSetWith(Read, SetByCreate, Write), false, false, false, 3),
			4:  Uint16Field(GemPortNetworkCtp_TrafficManagementPointerForUpstream, PointerAttributeType, 0x1000, 0, mapset.NewSetWith(Read, SetByCreate, Write), false, false, false, 4),
			5:  Uint16Field(GemPortNetworkCtp_TrafficDescriptorProfilePointerForUpstream, PointerAttributeType, 0x0800, 0, mapset.NewSetWith(Read, SetByCreate, Write), false, true, false, 5),
			6:  ByteField(GemPortNetworkCtp_UniCounter, UnsignedIntegerAttributeType, 0x0400, 0, mapset.NewSetWith(Read), false, true, false, 6),
			7:  Uint16Field(GemPortNetworkCtp_PriorityQueuePointerForDownStream, PointerAttributeType, 0x0200, 0, mapset.NewSetWith(Read, SetByCreate, Write), false, false, false, 7),
			8:  ByteField(GemPortNetworkCtp_EncryptionState, EnumerationAttributeType, 0x0100, 0, mapset.NewSetWith(Read), false, true, false, 8),
			9:  Uint16Field(GemPortNetworkCtp_TrafficDescriptorProfilePointerForDownstream, PointerAttributeType, 0x0080, 0, mapset.NewSetWith(Read, SetByCreate, Write), false, true, false, 9),
			10: ByteField(GemPortNetworkCtp_EncryptionKeyRing, EnumerationAttributeType, 0x0040, 0, mapset.NewSetWith(Read, SetByCreate, Write), false, true, false, 10),
		},
		Access:  CreatedByOlt,
		Support: UnknownSupport,
		Alarms: AlarmMap{
			5: "End-to-end loss of continuity",
		},
	}
}

// NewGemPortNetworkCtp (class ID 268) creates the basic
// Managed Entity definition that is used to validate an ME of this type that
// is received from or transmitted to the OMCC.
func NewGemPortNetworkCtp(params ...ParamData) (*ManagedEntity, OmciErrors) {
	return NewManagedEntity(*gemportnetworkctpBME, params...)
}
