/// <summary> /// Constructs the byte representation of the SnmpPacket /// </summary> /// <returns>A Byte List which represents this ProtocolDataUnit as a SnmpPacket</returns> public List <byte> ToPacket(PmppEndPoint?EndPoint) { try { List <byte> Bytes = new List <byte>(); Bytes.AddRange(BasicEncodingRules.EncodeInteger32(this.version)); Bytes.AddRange(BasicEncodingRules.EncodeOctetString(this.CommunityName)); Bytes.AddRange(ToPdu()); Bytes.InsertRange(0, BasicEncodingRules.EncodeSequenceHeader(SnmpType.Sequence, Bytes.Count, true)); Bytes.TrimExcess(); if (EndPoint.HasValue) { Bytes = Bytes.PmppEncode(EndPoint.Value.Address, EndPoint.Value.Control, EndPoint.Value.ProtocolIdentifier); } return(Bytes); } catch { throw; } }
/// <summary> /// Creates a OctetString Variable /// </summary> /// <param name="value">The System.string Value of the Variable</param> /// <returns>A OctetString Variable with the given value</returns> public static Variable CreateOctetString(string value) { return(Variable.FromBytes(BasicEncodingRules.EncodeOctetString(value))); }