Exemplo n.º 1
0
// write Content packet *before* buf[offs], adjust offs and return bytes used
int
ccnl_ccntlv_prependContentWithHdr(struct ccnl_prefix_s *name,
                                  unsigned char *payload, int paylen,
                                  unsigned int *lastchunknum, int *contentpos,
                                  int *offset, unsigned char *buf)
{
    int len, oldoffset;
    unsigned char hoplimit = 255; // setting to max (content has no hoplimit)

    oldoffset = *offset;

    len = ccnl_ccntlv_prependContent(name, payload, paylen, lastchunknum,
                                     contentpos, offset, buf);
    if (len < 0)
        return -1;

    if ((unsigned int)len >= ((uint32_t)1 << 16) - sizeof(struct ccnx_tlvhdr_ccnx2015_s))
        return -1;

    if (ccnl_ccntlv_prependFixedHdr(CCNX_TLV_V1, CCNX_PT_Data,
                                    len, hoplimit, offset, buf) < 0)
        return -1;

    return oldoffset - *offset;
}
Exemplo n.º 2
0
// write Content packet *before* buf[offs], adjust offs and return bytes used
int8_t
ccnl_ccntlv_prependContentWithHdr(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 len, oldoffset;
    uint8_t hoplimit = 255; // setting to max (content has no hoplimit)

    oldoffset = *offset;

    if (ccnl_ccntlv_prependContent(name, payload, paylen, lastchunknum,
                                   contentpos, offset, buf, &len)) {
        return -1;
    }

    if (len > (UINT16_MAX - sizeof(struct ccnx_tlvhdr_ccnx2015_s))) {
        return -1;
    }

    if (ccnl_ccntlv_prependFixedHdr(CCNX_TLV_V1, CCNX_PT_Data,
                                    len, hoplimit, offset, buf)) {
        return -1;
    }

    *reslen = oldoffset - *offset;
    return 0;
}
Exemplo n.º 3
0
// write Interest packet *before* buf[offs], adjust offs and return bytes used
int
ccnl_ccntlv_prependChunkInterestWithHdr(struct ccnl_prefix_s *name,
                                        int *offset, unsigned char *buf)
{
    int len, oldoffset;
    unsigned char hoplimit = 64; // setting hoplimit to max valid value?

    oldoffset = *offset;
    len = ccnl_ccntlv_prependInterest(name, offset, buf);
    if ( (unsigned int)len >= ((1 << 16) - sizeof(struct ccnx_tlvhdr_ccnx2015_s)))
        return -1;

    if (ccnl_ccntlv_prependFixedHdr(CCNX_TLV_V1, CCNX_PT_Interest,
                                    len, hoplimit, offset, buf) < 0)
        return -1;

    return oldoffset - *offset;
}
Exemplo n.º 4
0
// write Interest packet *before* buf[offs], adjust offs and return bytes used
int8_t
ccnl_ccntlv_prependChunkInterestWithHdr(struct ccnl_prefix_s *name,
                                        size_t *offset, uint8_t *buf, size_t *reslen)
{
    size_t len, oldoffset;
    uint8_t hoplimit = 64; // setting hoplimit to max valid value?

    oldoffset = *offset;
    if (ccnl_ccntlv_prependInterest(name, offset, buf, &len)) {
        return -1;
    }
    if (len > (UINT16_MAX - sizeof(struct ccnx_tlvhdr_ccnx2015_s))) {
        return -1;
    }

    if (ccnl_ccntlv_prependFixedHdr(CCNX_TLV_V1, CCNX_PT_Interest,
                                    len, hoplimit, offset, buf)) {
        return -1;
    }

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