func (c *Component) setParameterFromBytes(b []byte) error {
	if b == nil {
		return io.ErrUnexpectedEOF
	}
	ies, err := ParseMultiIEs(b)
	if err != nil {
		logf("failed to parse given bytes, building it anyway: %v", err)
		c.Parameter = &IE{
			Tag:   NewUniversalConstructorTag(0x10),
			Value: b,
		}
		return nil
	}
	c.Parameter = &IE{
		Tag:   NewUniversalConstructorTag(0x10),
		Value: b,
		IE:    ies,
	}
	return nil
}
setParameterFromBytes sets the Parameter field from given bytes.

It sets the value as it is if the given bytes cannot be parsed as (a set of) IE.
package tcap
import (
	"fmt"
	"io"
)
const (
	Invoke int = iota + 1
	ReturnResultLast
	ReturnError
	Reject
	_
	_
	ReturnResultNotLast
)
const (
	GeneralProblem int = iota
	InvokeProblem
	ReturnResultProblem
	ReturnErrorProblem
)
const (
	UnrecognizedComponent uint8 = iota
	MistypedComponent
	BadlyStructuredComponent
)
const (
	InvokeProblemDuplicateInvokeID uint8 = iota
	InvokeProblemUnrecognizedOperation
	InvokeProblemMistypedParameter
	InvokeProblemResourceLimitation
	InvokeProblemInitiatingRelease
	InvokeProblemUnrecognizedLinkedID
	InvokeProblemLinkedResponseUnexpected
	InvokeProblemUnexpectedLinkedOperation
)
const (
	ResultProblemUnrecognizedInvokeID uint8 = iota
	ResultProblemReturnResultUnexpected
	ResultProblemMistypedParameter
)
const (
	ErrorProblemUnrecognizedInvokeID uint8 = iota
	ErrorProblemReturnErrorUnexpected
	ErrorProblemUnrecognizedError
	ErrorProblemUnexpectedError
	ErrorProblemMistypedParameter
)
type Components struct {
	Tag       Tag
	Length    uint8
	Component []*Component
}
type Component struct {
	Type          Tag
	Length        uint8
	InvokeID      *IE
	LinkedID      *IE
	ResultRetres  *IE
	SequenceTag   *IE
	OperationCode *IE
	ErrorCode     *IE
	ProblemCode   *IE
	Parameter     *IE
}
func NewComponents(comps ...*Component) *Components {
	c := &Components{
		Tag:       NewApplicationWideConstructorTag(12),
		Component: comps,
	}
	c.SetLength()
	return c
}
func NewInvoke(invID, lkID, opCode int, isLocal bool, param []byte) *Component {
	c := &Component{
		Type: NewContextSpecificConstructorTag(Invoke),
		InvokeID: &IE{
			Tag:    NewUniversalPrimitiveTag(2),
			Length: 1,
			Value:  []byte{uint8(invID)},
		},
		OperationCode: NewOperationCode(opCode, isLocal),
	}
	if lkID > 0 {
		c.LinkedID = &IE{
			Tag:    NewContextSpecificPrimitiveTag(0),
			Length: 1,
			Value:  []byte{uint8(lkID)},
		}
	}
	if param != nil {
		if err := c.setParameterFromBytes(param); err != nil {
			logf("failed to build Parameter: %v", err)
		}
	}
	c.SetLength()
	return c
}
func NewReturnResult(invID, opCode int, isLocal, isLast bool, param []byte) *Component {
	tag := ReturnResultNotLast
	if isLast {
		tag = ReturnResultLast
	}
	c := &Component{
		Type: NewContextSpecificConstructorTag(tag),
		ResultRetres: &IE{
			Tag: NewUniversalConstructorTag(0x10),
		},
		InvokeID: &IE{
			Tag:    NewUniversalPrimitiveTag(2),
			Length: 1,
			Value:  []byte{uint8(invID)},
		},
		OperationCode: NewOperationCode(opCode, isLocal),
	}
	if param != nil {
		if err := c.setParameterFromBytes(param); err != nil {
			logf("failed to build Parameter: %v", err)
		}
	}
	c.SetLength()
	return c
}
func NewReturnError(invID, errCode int, isLocal bool, param []byte) *Component {
	c := &Component{
		Type: NewContextSpecificConstructorTag(ReturnError),
		InvokeID: &IE{
			Tag:    NewUniversalPrimitiveTag(2),
			Length: 1,
			Value:  []byte{uint8(invID)},
		},
		ErrorCode: NewErrorCode(errCode, isLocal),
	}
	if param != nil {
		if err := c.setParameterFromBytes(param); err != nil {
			logf("failed to build Parameter: %v", err)
		}
	}
	c.SetLength()
	return c
}
func NewReject(invID, problemType int, problemCode uint8, param []byte) *Component {
	c := &Component{
		Type: NewContextSpecificConstructorTag(Invoke),
		InvokeID: &IE{
			Tag:    NewUniversalPrimitiveTag(2),
			Length: 1,
			Value:  []byte{uint8(invID)},
		},
		ProblemCode: &IE{
			Tag:    NewContextSpecificPrimitiveTag(problemType),
			Length: 1,
			Value:  []byte{problemCode},
		},
	}
	if param != nil {
		if err := c.setParameterFromBytes(param); err != nil {
			logf("failed to build Parameter: %v", err)
		}
	}
	c.SetLength()
	return c
}
func NewOperationCode(code int, isLocal bool) *IE {
	var tag = 6
	if isLocal {
		tag = 2
	}
	return &IE{
		Tag:    NewUniversalPrimitiveTag(tag),
		Length: 1,
		Value:  []byte{uint8(code)},
	}
}
func NewErrorCode(code int, isLocal bool) *IE {
	return NewOperationCode(code, isLocal)
}
func (c *Components) MarshalBinary() ([]byte, error) {
	b := make([]byte, c.MarshalLen())
	if err := c.MarshalTo(b); err != nil {
		return nil, err
	}
	return b, nil
}
func (c *Components) MarshalTo(b []byte) error {
	b[0] = uint8(c.Tag)
	b[1] = c.Length
	cursor := 2
	for _, comp := range c.Component {
		compLen := comp.MarshalLen()
		if err := comp.MarshalTo(b[cursor : cursor+compLen]); err != nil {
			return err
		}
		cursor += compLen
	}
	return nil
}
func (c *Component) MarshalBinary() ([]byte, error) {
	b := make([]byte, c.MarshalLen())
	if err := c.MarshalTo(b); err != nil {
		return nil, err
	}
	return b, nil
}
func (c *Component) MarshalTo(b []byte) error {
	b[0] = uint8(c.Type)
	b[1] = c.Length
	var offset = 2
	if field := c.InvokeID; field != nil {
		if err := field.MarshalTo(b[offset : offset+field.MarshalLen()]); err != nil {
			return err
		}
		offset += field.MarshalLen()
	}
	switch c.Type.Code() {
	case Invoke:
		if field := c.LinkedID; field != nil {
			if err := field.MarshalTo(b[offset : offset+field.MarshalLen()]); err != nil {
				return err
			}
			offset += field.MarshalLen()
		}
		if field := c.OperationCode; field != nil {
			if err := field.MarshalTo(b[offset : offset+field.MarshalLen()]); err != nil {
				return err
			}
			offset += field.MarshalLen()
		}
		if field := c.Parameter; field != nil {
			if err := field.MarshalTo(b[offset : offset+field.MarshalLen()]); err != nil {
				return err
			}
		}
	case ReturnResultLast, ReturnResultNotLast:
		if field := c.ResultRetres; field != nil {
			if err := field.MarshalTo(b[offset : offset+field.MarshalLen()]); err != nil {
				return err
			}
			offset += field.MarshalLen()
		}
		if field := c.OperationCode; field != nil {
			if err := field.MarshalTo(b[offset : offset+field.MarshalLen()]); err != nil {
				return err
			}
			offset += field.MarshalLen()
		}
		if field := c.Parameter; field != nil {
			if err := field.MarshalTo(b[offset : offset+field.MarshalLen()]); err != nil {
				return err
			}
		}
	case ReturnError:
		if field := c.ErrorCode; field != nil {
			if err := field.MarshalTo(b[offset : offset+field.MarshalLen()]); err != nil {
				return err
			}
			offset += field.MarshalLen()
		}
		if field := c.Parameter; field != nil {
			if err := field.MarshalTo(b[offset : offset+field.MarshalLen()]); err != nil {
				return err
			}
		}
	case Reject:
		if field := c.ProblemCode; field != nil {
			if err := field.MarshalTo(b[offset : offset+field.MarshalLen()]); err != nil {
				return err
			}
		}
	}
	return nil
}
func ParseComponents(b []byte) (*Components, error) {
	c := &Components{}
	if err := c.UnmarshalBinary(b); err != nil {
		return nil, err
	}
	return c, nil
}
func (c *Components) UnmarshalBinary(b []byte) error {
	if len(b) < 2 {
		return io.ErrUnexpectedEOF
	}
	c.Tag = Tag(b[0])
	c.Length = b[1]
	var offset = 2
	for {
		if len(b) < 2 {
			break
		}
		comp, err := ParseComponent(b[offset:])
		if err != nil {
			return err
		}
		c.Component = append(c.Component, comp)
		if len(b[offset:]) == int(comp.Length)+2 {
			break
		}
		b = b[offset+comp.MarshalLen()-2:]
	}
	return nil
}
func ParseComponent(b []byte) (*Component, error) {
	c := &Component{}
	if err := c.UnmarshalBinary(b); err != nil {
		return nil, err
	}
	return c, nil
}
func (c *Component) UnmarshalBinary(b []byte) error {
	if len(b) < 2 {
		return io.ErrUnexpectedEOF
	}
	c.Type = Tag(b[0])
	c.Length = b[1]
	var err error
	var offset = 2
	c.InvokeID, err = ParseIE(b[offset:])
	if err != nil {
		return err
	}
	offset += c.InvokeID.MarshalLen()
	switch c.Type.Code() {
	case Invoke:
		c.OperationCode, err = ParseIE(b[offset:])
		if err != nil {
			return err
		}
		offset += c.OperationCode.MarshalLen()
		if offset >= len(b) {
			return nil
		}
		c.Parameter, err = ParseIERecursive(b[offset:])
		if err != nil {
			return err
		}
	case ReturnResultLast, ReturnResultNotLast:
		c.ResultRetres, err = ParseIE(b[offset:])
		if err != nil {
			return err
		}
		offset = 0
		b = c.ResultRetres.Value[offset:]
		c.OperationCode, err = ParseIE(b[offset:])
		if err != nil {
			return err
		}
		offset += c.OperationCode.MarshalLen()
		if offset >= len(b) {
			return nil
		}
		c.Parameter, err = ParseIERecursive(b[offset:])
		if err != nil {
			return err
		}
	case ReturnError:
		c.ErrorCode, err = ParseIE(b[offset:])
		if err != nil {
			return err
		}
		offset += c.ErrorCode.MarshalLen()
		if offset >= len(b) {
			return nil
		}
		c.Parameter, err = ParseIERecursive(b[offset:])
		if err != nil {
			return err
		}
	case Reject:
		c.ProblemCode, err = ParseIE(b[offset:])
		if err != nil {
			return err
		}
	}
	return nil
}