Exemplo n.º 1
0
// write Content payload *before* buf[offs], adjust offs and return bytes used
int
ccnl_ccntlv_prependContent(struct ccnl_prefix_s *name,
                           unsigned char *payload, int paylen,
                           unsigned int *lastchunknum, int *contentpos,
                           int *offset, unsigned char *buf)
{
    int tloffset = *offset;

    if (contentpos)
        *contentpos = *offset - paylen;

    // fill in backwards
    if (ccnl_ccntlv_prependBlob(CCNX_TLV_M_Payload, payload, paylen,
                                                        offset, buf) < 0)
        return -1;

    if (ccnl_ccntlv_prependName(name, offset, buf, lastchunknum))
        return -1;

    if (ccnl_ccntlv_prependTL(CCNX_TLV_TL_Object,
                                        tloffset - *offset, offset, buf) < 0)
        return -1;

    return tloffset - *offset;
}
Exemplo n.º 2
0
// write Content payload *before* buf[offs], adjust offs and return bytes used
int8_t
ccnl_ccntlv_prependContent(struct ccnl_prefix_s *name,
                           uint8_t *payload, size_t paylen,
                           uint32_t *lastchunknum, size_t *contentpos,
                           size_t *offset, uint8_t *buf, size_t *reslen)
{
    size_t tloffset = *offset;

    if (contentpos) {
        *contentpos = *offset - paylen;
    }

    // fill in backwards
    if (ccnl_ccntlv_prependBlob(CCNX_TLV_M_Payload, payload, paylen, offset, buf)) {
        return -1;
    }

    if (ccnl_ccntlv_prependName(name, offset, buf, lastchunknum)) {
        return -1;
    }

    if (ccnl_ccntlv_prependTL(CCNX_TLV_TL_Object, tloffset - *offset, offset, buf)) {
        return -1;
    }

    *reslen = tloffset - *offset;
    return 0;
}