コード例 #1
0
ファイル: Schedule.cs プロジェクト: redfood/ndn-dot-net
        /// <summary>
        /// Encode the RepetitiveInterval as NDN-TLV to the encoder.
        /// </summary>
        ///
        /// <param name="repetitiveInterval">The RepetitiveInterval to encode.</param>
        /// <param name="encoder">The TlvEncoder to receive the encoding.</param>
        private static void encodeRepetitiveInterval(
            RepetitiveInterval repetitiveInterval, TlvEncoder encoder)
        {
            int saveLength = encoder.getLength();

            // Encode backwards.
            encoder.writeNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_RepeatUnit,
                                               repetitiveInterval.getRepeatUnit().getNumericType());
            encoder.writeNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_NRepeats,
                                               repetitiveInterval.getNRepeats());
            encoder.writeNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_IntervalEndHour,
                                               repetitiveInterval.getIntervalEndHour());
            encoder.writeNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_IntervalStartHour,
                                               repetitiveInterval.getIntervalStartHour());
            // Use Blob to convert the string to UTF8 encoding.
            encoder.writeBlobTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_EndDate, new Blob(
                                     toIsoString(repetitiveInterval.getEndDate())).buf());
            encoder.writeBlobTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_StartDate, new Blob(
                                     toIsoString(repetitiveInterval.getStartDate())).buf());

            encoder.writeTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_RepetitiveInterval,
                                       encoder.getLength() - saveLength);
        }
コード例 #2
0
        wireEncode()
        {
            TlvEncoder encoder    = new TlvEncoder(256);
            int        saveLength = encoder.getLength();

            // Encode backwards.
            if (!other_.isNull())
            {
                encoder.writeBlobTlv(ContentMetaInfo_Other, other_.buf());
            }
            if (hasSegments_)
            {
                encoder.writeTypeAndLength(ContentMetaInfo_HasSegments, 0);
            }
            encoder.writeNonNegativeIntegerTlv
                (ContentMetaInfo_Timestamp, (long)Math.Round(timestamp_));
            encoder.writeBlobTlv
                (ContentMetaInfo_ContentType, new Blob(contentType_).buf());

            encoder.writeTypeAndLength
                (ContentMetaInfo_ContentMetaInfo, encoder.getLength() - saveLength);
            return(new Blob(encoder.getOutput(), false));
        }
コード例 #3
0
        /// <summary>
        /// Encode this as an NDN-TLV SafeBag.
        /// </summary>
        ///
        /// <returns>The encoded byte array as a Blob.</returns>
        public Blob wireEncode()
        {
            // Encode directly as TLV. We don't support the WireFormat abstraction
            // because this isn't meant to go directly on the wire.
            TlvEncoder encoder    = new TlvEncoder(256);
            int        saveLength = encoder.getLength();

            // Encode backwards.
            encoder.writeBlobTlv(net.named_data.jndn.encoding.tlv.Tlv.SafeBag_EncryptedKeyBag, privateKeyBag_.buf());
            // Add the entire Data packet encoding as is.
            encoder.writeBuffer(certificate_.wireEncode(net.named_data.jndn.encoding.TlvWireFormat.get()).buf());

            encoder.writeTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.SafeBag_SafeBag, encoder.getLength()
                                       - saveLength);

            return(new Blob(encoder.getOutput(), false));
        }