static int ccn_parse_Signature(struct ccn_buf_decoder *d, struct ccn_parsed_ContentObject *x) { int res = -1; int i; struct ccn_parsed_ContentObject dummy; if (x == NULL) x = &dummy; for (i = CCN_PCO_B_Signature; i <= CCN_PCO_E_Signature; i++) { x->offset[i] = d->decoder.token_index; } if (ccn_buf_match_dtag(d, CCN_DTAG_Signature)) { res = d->decoder.element_index; ccn_buf_advance(d); x->offset[CCN_PCO_B_DigestAlgorithm] = d->decoder.token_index; ccn_parse_optional_tagged_UDATA(d, CCN_DTAG_DigestAlgorithm); x->offset[CCN_PCO_E_DigestAlgorithm] = d->decoder.token_index; x->offset[CCN_PCO_B_Witness] = d->decoder.token_index; ccn_parse_optional_tagged_BLOB(d, CCN_DTAG_Witness, 8, -1); x->offset[CCN_PCO_E_Witness] = d->decoder.token_index; x->offset[CCN_PCO_B_SignatureBits] = d->decoder.token_index; ccn_parse_required_tagged_BLOB(d, CCN_DTAG_SignatureBits, 16, -1); x->offset[CCN_PCO_E_SignatureBits] = d->decoder.token_index; ccn_buf_check_close(d); x->offset[CCN_PCO_E_Signature] = d->decoder.token_index; } if (d->decoder.state < 0) return (d->decoder.state); return(res); }
int ccn_parse_Link(struct ccn_buf_decoder *d, struct ccn_parsed_Link *link, struct ccn_indexbuf *components) { int ncomp = 0; int res; if (ccn_buf_match_dtag(d, CCN_DTAG_Link)) { if (components == NULL) { /* We need to have the component offsets. */ components = ccn_indexbuf_create(); if (components == NULL) return(-1); res = ccn_parse_Link(d, link, components); ccn_indexbuf_destroy(&components); return(res); } ccn_buf_advance(d); link->offset[CCN_PL_B_Name] = d->decoder.element_index; link->offset[CCN_PL_B_Component0] = d->decoder.index; ncomp = ccn_parse_Name(d, components); if (d->decoder.state < 0) { memset(link->offset, 0, sizeof(link->offset)); return(d->decoder.state); } link->offset[CCN_PL_E_ComponentLast] = d->decoder.token_index - 1; link->offset[CCN_PL_E_Name] = d->decoder.token_index; link->name_ncomps = ncomp; /* parse optional Label string */ link->offset[CCN_PL_B_Label] = d->decoder.token_index; res = ccn_parse_optional_tagged_UDATA(d, CCN_DTAG_Label); link->offset[CCN_PL_E_Label] = d->decoder.token_index; /* parse optional LinkAuthenticator LinkAuthenticatorType */ if (ccn_buf_match_dtag(d, CCN_DTAG_LinkAuthenticator)) res = ccn_parse_LinkAuthenticator(d, link); ccn_buf_check_close(d); } else return (d->decoder.state = -__LINE__); if (d->decoder.state < 0) return (d->decoder.state); return(ncomp); }