コード例 #1
0
ndn_Error
ndn_Tlv0_2WireFormat_encodeControlParameters
(const struct ndn_ControlParameters *controlParameters,
 struct ndn_DynamicUInt8Array *output, size_t *encodingLength)
{
    ndn_Error error;
    struct ndn_TlvEncoder encoder;
    ndn_TlvEncoder_initialize(&encoder, output);
    error = ndn_encodeTlvControlParameters(controlParameters, &encoder);
    *encodingLength = encoder.offset;

    return error;
}
コード例 #2
0
/**
 * This private function is called by ndn_TlvEncoder_writeNestedTlv to write the TLVs
 * in the body of the ControlResponse value.
 * @param context This is the ndn_ControlResponse struct pointer which
 * was passed to writeTlv.
 * @param encoder the ndn_TlvEncoder which is calling this.
 * @return 0 for success, else an error code.
 */
static ndn_Error
encodeControlResponseValue(const void *context, struct ndn_TlvEncoder *encoder)
{
  struct ndn_ControlResponse *controlResponse =
    (struct ndn_ControlResponse *)context;
  ndn_Error error;
  struct ndn_ForwardingFlags defaultFlags;

  if ((error = ndn_TlvEncoder_writeNonNegativeIntegerTlv
       (encoder, ndn_Tlv_NfdCommand_StatusCode,
        controlResponse->statusCode)))
    return error;
  if ((error = ndn_TlvEncoder_writeBlobTlv
       (encoder, ndn_Tlv_NfdCommand_StatusText, &controlResponse->statusText)))
    return error;
  if (controlResponse->hasBodyAsControlParameters) {
    if ((error = ndn_encodeTlvControlParameters
         (&controlResponse->bodyAsControlParameters, encoder)))
      return error;
  }

  return NDN_ERROR_success;
}