예제 #1
0
        private static void decodeControlParameters(
				ControlParameters controlParameters, TlvDecoder decoder,
				bool copy)
        {
            controlParameters.clear();

            int endOffset = decoder
                    .readNestedTlvsStart(net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_ControlParameters);

            // decode name
            if (decoder.peekType(net.named_data.jndn.encoding.tlv.Tlv.Name, endOffset)) {
                Name name = new Name();
                decodeName(name, new int[1], new int[1], decoder, copy);
                controlParameters.setName(name);
            }

            // decode face ID
            controlParameters.setFaceId((int) decoder
                    .readOptionalNonNegativeIntegerTlv(
                            net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_FaceId, endOffset));

            // decode URI
            if (decoder.peekType(net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Uri, endOffset)) {
                // Set copy false since we just immediately get the string.
                Blob uri = new Blob(decoder.readOptionalBlobTlv(
                        net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Uri, endOffset), false);
                controlParameters.setUri("" + uri);
            }

            // decode integers
            controlParameters.setLocalControlFeature((int) decoder
                    .readOptionalNonNegativeIntegerTlv(
                            net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_LocalControlFeature, endOffset));
            controlParameters.setOrigin((int) decoder
                    .readOptionalNonNegativeIntegerTlv(
                            net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Origin, endOffset));
            controlParameters.setCost((int) decoder
                    .readOptionalNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Cost,
                            endOffset));

            // set forwarding flags
            if (decoder.peekType(net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Flags, endOffset)) {
                ForwardingFlags flags = new ForwardingFlags();
                flags.setNfdForwardingFlags((int) decoder
                        .readNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Flags));
                controlParameters.setForwardingFlags(flags);
            }

            // decode strategy
            if (decoder.peekType(net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Strategy, endOffset)) {
                int strategyEndOffset = decoder
                        .readNestedTlvsStart(net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Strategy);
                decodeName(controlParameters.getStrategy(), new int[1], new int[1],
                        decoder, copy);
                decoder.finishNestedTlvs(strategyEndOffset);
            }

            // decode expiration period
            controlParameters.setExpirationPeriod(decoder
                    .readOptionalNonNegativeIntegerTlv(
                            net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_ExpirationPeriod, endOffset));

            decoder.finishNestedTlvs(endOffset);
        }