本文整理汇总了Golang中encoding/asn1.RawValue类的典型用法代码### 示例。如果您正苦于以下问题:Golang RawValue类的具体用法?Golang RawValue怎么用?Golang RawValue使用的例子?那么恭喜您, 这里精选的类代码### 示例或许可以为您提供帮助。

在下文中一共展示了RawValue类的6个代码### 示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码### 示例。

示例1: Marshal

func (msg *messageV3) Marshal() (b []byte, err error) {
    var buf []byte
    raw := asn1.RawValue{Class: classUniversal, Tag: tagSequence, IsCompound: true}

    buf, err = asn1.Marshal(msg.version)
    if err != nil {
        return
    }
    raw.Bytes = buf

    buf, err = msg.globalDataV3.Marshal()
    if err != nil {
        return
    }
    raw.Bytes = append(raw.Bytes, buf...)

    buf, err = msg.securityParameterV3.Marshal()
    if err != nil {
        return
    }
    raw.Bytes = append(raw.Bytes, buf...)

    raw.Bytes = append(raw.Bytes, msg.pduBytes...)
    return asn1.Marshal(raw)
}

开发者ID:mgenov,项目名称:snmpgo,代码行数:25,代码来源:message.go

示例2: convertClass

// convertClass converts the encoding of values in SNMP response from
// "custom" class to the corresponding "universal" class, thus enabling
// use of the asn1 parser from the encoding/asn1 package.
func convertClass(v *asn1.RawValue) {
    if v.Class != 1 {
        // Not a custom type.
        return
    }
    switch v.Tag {
    case 0, 4:
        // IpAddress ::= [APPLICATION 0] IMPLICIT OCTET STRING (SIZE (4))
        // Opaque ::= [APPLICATION 4] IMPLICIT OCTET STRING
        v.FullBytes[0] = 0x04
        v.Class = 0
        v.Tag = 4
    case 1, 2, 3, 6:
        // Counter32 ::= [APPLICATION 1] IMPLICIT INTEGER (0..4294967295)
        // Unsigned32 ::= [APPLICATION 2] IMPLICIT INTEGER (0..4294967295)
        // TimeTicks ::= [APPLICATION 3] IMPLICIT INTEGER (0..4294967295)
        // Counter64 ::= [APPLICATION 6] IMPLICIT INTEGER (0..18446744073709551615)
        v.FullBytes[0] = 0x02
        v.Class = 0
        v.Tag = 2
    }
}

开发者ID:mathpl,项目名称:bosun,代码行数:25,代码来源:snmp.go

示例3: Marshal

func (v *VarBind) Marshal() (b []byte, err error) {
    var buf []byte
    raw := asn1.RawValue{Class: classUniversal, Tag: tagSequence, IsCompound: true}

    if v.Oid == nil || v.Variable == nil {
        return asn1.Marshal(raw)
    }

    buf, err = v.Oid.Marshal()
    if err != nil {
        return
    }
    raw.Bytes = buf

    buf, err = v.Variable.Marshal()
    if err != nil {
        return
    }
    raw.Bytes = append(raw.Bytes, buf...)

    return asn1.Marshal(raw)
}

开发者ID:mgenov,项目名称:snmpgo,代码行数:22,代码来源:pdu.go

示例4: encrypt

func encrypt(msg *messageV3, proto PrivProtocol, key []byte) (err error) {
    var dst, priv []byte
    src := msg.PduBytes()

    switch proto {
    case Des:
        dst, priv, err = encryptDES(src, key, int32(msg.AuthEngineBoots), genSalt32())
    case Aes:
        dst, priv, err = encryptAES(
            src, key, int32(msg.AuthEngineBoots), int32(msg.AuthEngineTime), genSalt64())
    }
    if err != nil {
        return
    }

    raw := asn1.RawValue{Class: classUniversal, Tag: tagOctetString, IsCompound: false}
    raw.Bytes = dst
    dst, err = asn1.Marshal(raw)
    if err == nil {
        msg.SetPduBytes(dst)
        msg.PrivParameter = priv
    }
    return
}

开发者ID:mgenov,项目名称:snmpgo,代码行数:24,代码来源:security.go

示例5: Marshal

func (pdu *ScopedPdu) Marshal() (b []byte, err error) {
    var buf []byte
    raw := asn1.RawValue{Class: classUniversal, Tag: tagSequence, IsCompound: true}

    buf, err = asn1.Marshal(pdu.ContextEngineId)
    if err != nil {
        return
    }
    raw.Bytes = buf

    buf, err = asn1.Marshal(pdu.ContextName)
    if err != nil {
        return
    }
    raw.Bytes = append(raw.Bytes, buf...)

    buf, err = pdu.PduV1.Marshal()
    if err != nil {
        return
    }
    raw.Bytes = append(raw.Bytes, buf...)

    return asn1.Marshal(raw)
}

开发者ID:yulianghsueh,项目名称:snmpgo,代码行数:24,代码来源:pdu.go

最后编辑: kuteng  文档更新时间: 2021-08-23 19:14   作者:kuteng