Example #1
0
int unpack_integer(BUFFER *buf, RPC2_Integer *ptr)
{
    if (buf->buffer + 4 > buf->eob)
        return -1;
    *ptr = ntohl(*(RPC2_Integer *)(buf->buffer));
    buf->buffer += _PAD(4);
    return 0;
}
Example #2
0
int unpack_byte(BUFFER *buf, RPC2_Byte *ptr)
{
    if (buf->buffer + 1 > buf->eob)
        return -1;
    *(RPC2_Byte *)ptr = *(RPC2_Byte *)(buf->buffer);
    buf->buffer += _PAD(1);
    return 0;
}
Example #3
0
int unpack_unsigned(BUFFER *buf, RPC2_Unsigned *ptr)
{
    if (buf->buffer + 4 > buf->eob)
        return -1;
    *ptr = ntohl(*(RPC2_Unsigned *)(buf->buffer));
    buf->buffer += _PAD(4);
    return 0;
}
Example #4
0
int unpack_double(BUFFER *buf, RPC2_Double *ptr)
{
    if (buf->buffer + 8 > buf->eob)
        return -1;
    *ptr = *(RPC2_Double *)(buf->buffer);
    buf->buffer += _PAD(8);
    return 0;
}
Example #5
0
int unpack_bytes(BUFFER *buf, RPC2_ByteSeq ptr, RPC2_Unsigned len)
{
    if (buf->buffer + len > buf->eob)
        return -1;
    memcpy(ptr, buf->buffer, len);
    buf->buffer += _PAD(len);
    return 0;
}
Example #6
0
int unpack_encryptionKey(BUFFER *buf, RPC2_EncryptionKey key)
{
    if (buf->buffer + RPC2_KEYSIZE > buf->eob)
        return -1;
    memcpy(key, buf->buffer, RPC2_KEYSIZE);
    buf->buffer += _PAD(RPC2_KEYSIZE);
    return 0;
}
Example #7
0
int pack_integer(BUFFER *buf, RPC2_Integer value)
{
    if (buf->eob) {
        if (buf->buffer + 4 > buf->eob)
            return -1;
        *(RPC2_Integer *)(buf->buffer) = htonl(value);
    }
    buf->buffer += _PAD(4);
    return 0;
}
Example #8
0
int pack_byte(BUFFER *buf, RPC2_Byte value)
{
    if (buf->eob) {
        if (buf->buffer + 1 > buf->eob)
            return -1;
        *(RPC2_Byte *)(buf->buffer) = value;
    }
    buf->buffer += _PAD(1);
    return 0;
}
Example #9
0
int pack_double(BUFFER *buf, RPC2_Double value)
{
    if (buf->eob) {
        if (buf->buffer + 8 > buf->eob)
            return -1;
        *(RPC2_Double *)(buf->buffer) = value;
    }
    buf->buffer += _PAD(8);
    return 0;
}
Example #10
0
int pack_bytes(BUFFER *buf, RPC2_ByteSeq value, RPC2_Unsigned len)
{
    if (buf->eob) {
        if (buf->buffer + len > buf->eob)
            return -1;
        memcpy(buf->buffer, value, len);
    }
    buf->buffer += _PAD(len);
    return 0;
}
Example #11
0
int pack_unsigned(BUFFER *buf, RPC2_Unsigned value)
{
    if (buf->eob) {
        if (buf->buffer + 4 > buf->eob)
            return -1;
        *(RPC2_Unsigned *)(buf->buffer) = htonl(value);
    }
    buf->buffer += _PAD(4);
    return 0;
}
Example #12
0
int unpack_countedbs(BUFFER *buf, RPC2_CountedBS *ptr)
{
    if (unpack_unsigned(buf, &ptr->SeqLen))
        return -1;

    if (buf->buffer + ptr->SeqLen > buf->eob)
        return -1;

    ptr->SeqBody = (RPC2_Byte *)(buf->buffer);
    buf->buffer += _PAD(ptr->SeqLen);
    return 0;
}
Example #13
0
int pack_countedbs(BUFFER *buf, RPC2_CountedBS *ptr)
{
    if (pack_unsigned(buf, ptr->SeqLen))
        return -1;

    if (buf->eob) {
        if (buf->buffer + ptr->SeqLen > buf->eob)
            return -1;
        memcpy(buf->buffer, ptr->SeqBody, ptr->SeqLen);
    }
    buf->buffer += _PAD(ptr->SeqLen);
    return 0;
}
Example #14
0
int pack_string(BUFFER *buf, RPC2_String ptr)
{
    unsigned int length = strlen((const char *)ptr);

    if (pack_unsigned(buf, length))
        return -1;

    if (buf->eob) {
        if (buf->buffer + length + 1 > buf->eob)
            return -1;
        strcpy(buf->buffer, (const char *)ptr);
        *(buf->buffer + length) = '\0';
    }
    buf->buffer += _PAD(length + 1);
    return 0;
}
Example #15
0
int unpack_boundedbs(BUFFER *buf, MODE mode, RPC2_BoundedBS *ptr)
{
    unsigned int maxseqlen;
    unsigned int seqlen;

    if (unpack_unsigned(buf, &maxseqlen))
        return -1;
    if (unpack_unsigned(buf, &seqlen))
        return -1;

    if (buf->who == RP2_SERVER) {
        if (mode == IN_MODE) {
            ptr->MaxSeqLen = seqlen;
        } else {
            ptr->MaxSeqLen = maxseqlen;
        }
    }
    if ((buf->who == RP2_CLIENT && mode != IN_MODE) ||
        (buf->who == RP2_SERVER && mode != OUT_MODE)) {
        ptr->SeqLen = seqlen;
    } else {
        ptr->SeqLen = 0;
    }

    if (ptr->SeqLen > ptr->MaxSeqLen)
        return -1;
    if (buf->buffer + ptr->SeqLen > buf->eob)
        return -1;

    if (buf->who == RP2_SERVER) {
        if (ptr->MaxSeqLen > RPC2_MAXPACKETSIZE)
            return -1;

        ptr->SeqBody = calloc(1, ptr->MaxSeqLen);
        if (ptr->MaxSeqLen && ptr->SeqBody == NULL)
            return -1;
    }

    memcpy(ptr->SeqBody, buf->buffer, ptr->SeqLen);
    buf->buffer += _PAD(ptr->SeqLen);
    return 0;
}
Example #16
0
int unpack_string(BUFFER *buf, RPC2_String *ptr)
{
    unsigned int length = 0;

    if (unpack_unsigned(buf, &length))
        return -1;
    if ((buf->buffer + length + 1) > buf->eob)
        return -1;
    if (*(buf->buffer + length) != '\0')
        return -1;
    /* If RPC2_String is the element of RPC2_Struct, mode should be NO_MODE. */
    /* So mode should not be examined here. */
    /* if (mode == IN_OUT_MODE && who == RP2_CLIENT) { */
    assert(buf->who != RP2_CLIENT);
    /* it's very dangerous to do memcpy in client mode */
    /* if (who == RP2_CLIENT) {
        memcpy(*ptr, buf->buffer, length);
        *ptr[length] = '\0';
    */
    *ptr = (RPC2_String)(buf->buffer);
    buf->buffer += _PAD(length + 1);
    return 0;
}
Example #17
0
#define _(from, x) { #x, offsetof(struct from, x), sizeof(((struct from*)NULL)->x), 1, NORMAL }
#define _ARRAY(from, x) { #x, offsetof(struct from, x), sizeof(((struct from*)NULL)->x[0]), \
			  sizeof(((struct from*)NULL)->x)/sizeof(((struct from*)NULL)->x[0]), ARRAY }

struct struct_define defines_bsp[] = {
{ "mpeg1/2 bsp", {
#define STRUCT mpeg12_picparm_bsp
	_(STRUCT, width),
	_(STRUCT, height),
	_(STRUCT, picture_structure),
	_(STRUCT, picture_coding_type),
	_(STRUCT, intra_dc_precision),
	_(STRUCT, frame_pred_frame_dct),
	_(STRUCT, concealment_motion_vectors),
	_(STRUCT, intra_vlc_format),
	_PAD(STRUCT, pad),
	_ARRAY(STRUCT, f_code[0]),
	_ARRAY(STRUCT, f_code[1]),
#undef STRUCT
}},
{ "vc-1 bsp", {
}},
{ "h264 bsp", {
#define STRUCT h264_picparm_bsp
	_(STRUCT, unk00),
	_(STRUCT, log2_max_frame_num_minus4),
	_(STRUCT, pic_order_cnt_type),
	_(STRUCT, log2_max_pic_order_cnt_lsb_minus4),
	_(STRUCT, delta_pic_order_always_zero_flag),
	_(STRUCT, frame_mbs_only_flag),
	_(STRUCT, direct_8x8_inference_flag),