ndn_Error
ndn_Tlv0_2WireFormat_decodeControlParameters
(struct ndn_ControlParameters *controlParameters, const uint8_t *input,
 size_t inputLength)
{
    struct ndn_TlvDecoder decoder;
    ndn_TlvDecoder_initialize(&decoder, input, inputLength);
    return ndn_decodeTlvControlParameters(controlParameters, &decoder);
}
Exemple #2
0
ndn_Error
ndn_decodeTlvControlResponse
  (struct ndn_ControlResponse *controlResponse, struct ndn_TlvDecoder *decoder)
{
  ndn_Error error;
  size_t endOffset;
  int gotExpectedType;
  uint64_t statusCode;

  if ((error = ndn_TlvDecoder_readNestedTlvsStart
       (decoder, ndn_Tlv_NfdCommand_ControlResponse, &endOffset)))
    return error;

  if ((error = ndn_TlvDecoder_readNonNegativeIntegerTlv
       (decoder, ndn_Tlv_NfdCommand_StatusCode, &statusCode)))
    return error;
  controlResponse->statusCode = (int)statusCode;
  if ((error = ndn_TlvDecoder_readBlobTlv
       (decoder, ndn_Tlv_NfdCommand_StatusText, &controlResponse->statusText)))
    return error;

  // Decode the body.
  if ((error = ndn_TlvDecoder_peekType
       (decoder, ndn_Tlv_ControlParameters_ControlParameters, endOffset,
        &gotExpectedType)))
    return error;
  if (gotExpectedType) {
    controlResponse->hasBodyAsControlParameters = 1;
    if ((error = ndn_decodeTlvControlParameters
         (&controlResponse->bodyAsControlParameters, decoder)))
      return error;
  }
  else
    controlResponse->hasBodyAsControlParameters = 0;

  if ((error = ndn_TlvDecoder_finishNestedTlvs(decoder, endOffset)))
    return error;

  return NDN_ERROR_success;
}