Ember+ loadable plugin
Source
/*
** Copyright (C) 2001-2024 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
package asn1
import (
"encoding/asn1"
"golang.zabbix.com/sdk/errs"
)
// GetData returns all data contained in the encoder.
func (c *Encoder) GetData() []byte {
return c.data.Bytes()
}
// WriteRequest writes a request into the encoder buffer, for the provided element type, currently supports parameters,
// qualified parameters, nodes qualified nodes and functions.
func (c *Encoder) WriteRequest(path []int, tag string, cmd int) error {
c.openSequence(ApplicationByte(RootElementCollectionTag))
defer c.closeSequence()
c.openSequence(ApplicationByte(RootElementTag))
defer c.closeSequence()
c.openSequence(ContextByte(0))
defer c.closeSequence()
switch tag {
case ParameterType, QualifiedParameterType:
c.openSequence(ApplicationByte(QualifiedParameterTag))
case NodeType, QualifiedNodeType:
c.openSequence(ApplicationByte(QualifiedNodeTag))
case FunctionType:
c.openSequence(ApplicationByte(functionTag))
default:
return errs.Errorf("unknown application tag %s", tag)
}
defer c.closeSequence()
c.openSequence(ContextByte(0))
defer c.closeSequence()
c.WriteUniversal(path)
c.openSequence(ContextByte(2))
defer c.closeSequence()
c.openSequence(ApplicationByte(elementCollectionTag))
defer c.closeSequence()