Ejemplo n.º 1
0
/**
 * Endianess independent Getters.
 */
c_long
v_messageQos_getTransportPriority(
    v_messageQos qos)
{
    c_long priority;
    c_octet *dst = (c_octet *)&priority;
    c_octet *src = &((c_octet *)qos)[2];
    _COPY4_(dst,src);
    return priority;
}
Ejemplo n.º 2
0
c_long
v_messageQos_getOwnershipStrength(
    v_messageQos qos)
{
    c_long strength;
    c_octet *dst;
    c_octet *src;

    if (v_messageQos_isExclusive(qos)) {
        dst = (c_octet *)&strength;
        src = &(((c_octet *)qos))[6];
        _COPY4_(dst,src);
    } else {
        strength = 0; /* don't care value */
    }
    return strength;
}
Ejemplo n.º 3
0
v_messageQos
in_messageQos_new(
    in_connectivityPeerWriter writer, c_base base)
{

    in_ddsiDiscoveredWriterData i =
        in_connectivityPeerWriterGetInfo(writer);

    /* inefficient, should be permenanent */
    c_type type;
    v_messageQos _this ;
    c_long transportQosValue = 0; /* TODO */
#ifdef _FAST_ACCESS_
    c_long offset            = 10, /* byte0 + byte1 + transport_priority + 4*time_offsets */
#else
    c_long offset            = 6, /* byte0 + byte1 + transport_priority */
#endif
           strength_offset   = 0,
           latency_offset    = 0,
           deadline_offset   = 0,
           liveliness_offset = 0,
           lifespan_offset   = 0;

    c_octet byte0 = 0,
            byte1 = 0;

    c_octet *dst, *src;

    type = c_metaArrayTypeNew(c_metaObject(base),
                              "C_ARRAY<c_octet>",
                              c_octet_t(base),
                              0);

    _this = c_newArray((c_collectionType)type,offset);
    c_free(type); /* remove if "type" becomes permenanent */

    if (_this) {
        byte0 |= _LSHIFT_(i->topicData.info.reliability.kind,
                          MQ_BYTE0_RELIABILITY_OFFSET);
        byte0 |= _LSHIFT_(i->topicData.info.ownership.kind,
                          MQ_BYTE0_OWNERSHIP_OFFSET);
        byte0 |= _LSHIFT_(i->topicData.info.destination_order.kind,
                          MQ_BYTE0_ORDERBY_OFFSET);
        byte0 |= _LSHIFT_(i->topicData.info.lifecycle.autodispose_unregistered_instances,
                          MQ_BYTE0_AUTODISPOSE_OFFSET);
        byte1 |= _LSHIFT_(i->topicData.info.durability.kind,
                          MQ_BYTE1_DURABILITY_OFFSET);
        byte1 |= _LSHIFT_(i->topicData.info.liveliness.kind,
                          MQ_BYTE1_LIVELINESS_OFFSET);
        byte1 |= _LSHIFT_(i->topicData.info.presentation.access_scope,
                          MQ_BYTE1_PRESENTATION_OFFSET);
        byte1 |= _LSHIFT_(i->topicData.info.presentation.coherent_access,
                          MQ_BYTE1_ORDERED_ACCESS_OFFSET);
        byte1 |= _LSHIFT_(i->topicData.info.presentation.ordered_access,
                          MQ_BYTE1_COHERENT_ACCESS_OFFSET);

        if (i->topicData.info.ownership.kind == V_OWNERSHIP_EXCLUSIVE) {
            strength_offset = offset;
            offset += sizeof(i->topicData.info.ownership_strength.value);
        }

        if (c_timeIsZero(i->topicData.info.latency_budget.duration)) {
            byte0 |= _LSHIFT_(1,MQ_BYTE0_LATENCY_OFFSET);
        } else {
            latency_offset = offset;
            offset += sizeof(i->topicData.info.latency_budget.duration);
        }
        if (c_timeIsInfinite(i->topicData.info.deadline.period)) {
            byte0 |= _LSHIFT_(1,MQ_BYTE0_DEADLINE_OFFSET);
        } else {
            deadline_offset = offset;
            offset += sizeof(i->topicData.info.deadline.period);
        }
        if (c_timeIsInfinite(i->topicData.info.liveliness.lease_duration)) {
            byte0 |= _LSHIFT_(1,MQ_BYTE0_LIVELINESS_OFFSET);
        } else {
            liveliness_offset = offset;
            offset += sizeof(i->topicData.info.liveliness.lease_duration);
        }
        if (c_timeIsInfinite(i->topicData.info.lifespan.duration)) {
            byte0 |= _LSHIFT_(1,MQ_BYTE0_LIFESPAN_OFFSET);
        } else {
            lifespan_offset = offset;
            offset += sizeof(i->topicData.info.lifespan.duration);
        }

        ((c_octet *)_this)[0] = byte0;
        ((c_octet *)_this)[1] = byte1;

        src = (c_octet *)&(transportQosValue); /* TODO fix*/
        dst = (c_octet *)&((c_octet *)_this)[2];
        _COPY4_(dst,src);

        if (strength_offset) {
            src = (c_octet *)&(i->topicData.info.ownership_strength.value);
            dst = (c_octet *)&((c_octet *)_this)[strength_offset];
            _COPY4_(dst,src);
        }
        if (latency_offset) {
            src = (c_octet *)&(i->topicData.info.latency_budget.duration);
            dst = (c_octet *)&((c_octet *)_this)[latency_offset];
            _COPY8_(dst,src);
        }
        if (deadline_offset) {
            src = (c_octet *)&(i->topicData.info.deadline.period);
            dst = (c_octet *)&((c_octet *)_this)[deadline_offset];
            _COPY8_(dst,src);
        }
        if (liveliness_offset) {
            src = (c_octet *)&(i->topicData.info.liveliness.lease_duration);
            dst = (c_octet *)&((c_octet *)_this)[liveliness_offset];
            _COPY8_(dst,src);
        }
        if (lifespan_offset) {
            src = (c_octet *)&(i->topicData.info.lifespan.duration);
            dst = (c_octet *)&((c_octet *)_this)[lifespan_offset];
            _COPY8_(dst,src);
        }
    } else {
        assert(FALSE);
    }

    return _this;
}
Ejemplo n.º 4
0
v_messageQos
v_messageQos_from_wqos_new(
    v_writerQos wqos,
    c_type msgQosType,
    v_presentationKind access_scope,
    c_bool coherent_access,
    c_bool ordered_access)
{
    v_messageQos _this;
    c_base base;
    v_duration tdur;
    c_ulong offset    = 6, /* byte0 + byte1 + transport_priority */
    strength_offset   = 0,
    latency_offset    = 0,
    deadline_offset   = 0,
    liveliness_offset = 0,
    lifespan_offset   = 0;

    c_octet byte0, byte1;

    c_octet *dst, *src;

    assert(C_TYPECHECK(wqos,v_writerQos));

    base = c_getBase(wqos);

    if (msgQosType == NULL) {
        msgQosType = c_metaArrayTypeNew(c_metaObject(base),
                                  "C_ARRAY<c_octet>",
                                  c_octet_t(base),
                                  0);
    }
    byte0 = (c_octet) (_LSHIFT_(wqos->reliability.v.kind, MQ_BYTE0_RELIABILITY_OFFSET) |
                       _LSHIFT_(wqos->ownership.v.kind, MQ_BYTE0_OWNERSHIP_OFFSET) |
                       _LSHIFT_(wqos->orderby.v.kind, MQ_BYTE0_ORDERBY_OFFSET) |
                       _LSHIFT_(wqos->lifecycle.v.autodispose_unregistered_instances, MQ_BYTE0_AUTODISPOSE_OFFSET));
    byte1 = (c_octet) (_LSHIFT_(wqos->durability.v.kind, MQ_BYTE1_DURABILITY_OFFSET) |
                       _LSHIFT_(wqos->liveliness.v.kind, MQ_BYTE1_LIVELINESS_OFFSET) |
                       /* writer->resend._d contains the access_scope of the publisher-QoS */
                       _LSHIFT_(access_scope, MQ_BYTE1_PRESENTATION_OFFSET) |
                       _LSHIFT_(coherent_access, MQ_BYTE1_COHERENT_ACCESS_OFFSET) |
                       _LSHIFT_(ordered_access, MQ_BYTE1_ORDERED_ACCESS_OFFSET));

    if (wqos->ownership.v.kind == V_OWNERSHIP_EXCLUSIVE) {
        strength_offset = offset;
        offset += (c_ulong) sizeof(wqos->strength.v.value);
    }
    if (OS_DURATION_ISZERO(wqos->latency.v.duration)) {
        byte0 = (c_octet) (byte0 | _LSHIFT_(1,MQ_BYTE0_LATENCY_OFFSET));
    } else {
        latency_offset = offset;
        offset += (c_ulong) sizeof(wqos->latency.v.duration);
    }
    if (OS_DURATION_ISINFINITE(wqos->deadline.v.period)) {
        byte0 = (c_octet) (byte0 | _LSHIFT_(1,MQ_BYTE0_DEADLINE_OFFSET));
    } else {
        deadline_offset = offset;
        offset += (c_ulong) sizeof(wqos->deadline.v.period);
    }
    if (OS_DURATION_ISINFINITE(wqos->liveliness.v.lease_duration)) {
        byte0 = (c_octet) (byte0 | _LSHIFT_(1,MQ_BYTE0_LIVELINESS_OFFSET));
    } else {
        liveliness_offset = offset;
        offset += (c_ulong) sizeof(wqos->liveliness.v.lease_duration);
    }
    if (OS_DURATION_ISINFINITE(wqos->lifespan.v.duration)) {
        byte0 = (c_octet) (byte0 | _LSHIFT_(1,MQ_BYTE0_LIFESPAN_OFFSET));
    } else {
        lifespan_offset = offset;
        offset += (c_ulong) sizeof(wqos->lifespan.v.duration);
    }

    _this = c_newArray((c_collectionType)msgQosType,offset);

    if (_this) {
        ((c_octet *)_this)[0] = byte0;
        ((c_octet *)_this)[1] = byte1;
        src = (c_octet *)&wqos->transport.v.value;
        dst = (c_octet *)&((c_octet *)_this)[2];
        _COPY4_(dst,src);

        if (strength_offset) {
            src = (c_octet *)&wqos->strength.v.value;
            dst = (c_octet *)&((c_octet *)_this)[strength_offset];
            _COPY4_(dst,src);
        }
        if (latency_offset) {
            tdur = v_durationFromOsDuration(wqos->latency.v.duration);
            src = (c_octet *)&tdur;
            dst = (c_octet *)&((c_octet *)_this)[latency_offset];
            _COPY8_(dst,src);
        }
        if (deadline_offset) {
            tdur = v_durationFromOsDuration(wqos->deadline.v.period);
            src = (c_octet *)&tdur;
            dst = (c_octet *)&((c_octet *)_this)[deadline_offset];
            _COPY8_(dst,src);
        }
        if (liveliness_offset) {
            tdur = v_durationFromOsDuration(wqos->liveliness.v.lease_duration);
            src = (c_octet *)&tdur;
            dst = (c_octet *)&((c_octet *)_this)[liveliness_offset];
            _COPY8_(dst,src);
        }
        if (lifespan_offset) {
            tdur = v_durationFromOsDuration(wqos->lifespan.v.duration);
            src = (c_octet *)&tdur;
            dst = (c_octet *)&((c_octet *)_this)[lifespan_offset];
            _COPY8_(dst,src);
        }
    } else {
        OS_REPORT(OS_CRITICAL,
                  "v_messageQos_new",V_RESULT_INTERNAL_ERROR,
                  "Failed to allocate messageQos.");
        assert(FALSE);
    }
    return _this;
}