Esempio n. 1
0
static void
nw_entryHashItemInsert(
    v_networkHashValue hashValue,
    const c_char *partitionName,
    const c_char *topicName,
    v_networkReaderEntry entry,
    nw_entryHashItem *prevNextPtr)
{
    nw_entryHashItem newItem;

    NW_CONFIDENCE(prevNextPtr != NULL);
    newItem = (nw_entryHashItem)os_malloc(sizeof(*newItem));
    if (newItem != NULL) {
        newItem->hashValue = hashValue;
        newItem->partitionName = (const char *)nw_stringDup(partitionName);
        newItem->topicName = (const char *)nw_stringDup(topicName);
        newItem->entry = entry;
        newItem->next = *prevNextPtr;
        *prevNextPtr = newItem;
    }
}
Esempio n. 2
0
void
nw_plugChannelInitialize(
    nw_plugChannel channel,
    nw_seqNr seqNr,
    nw_networkId nodeId,
    nw_communicationKind communication,
    nw_plugPartitions partitions,
    nw_userData *userDataPtr,
    const char *pathName,
    nw_onFatalCallBack onFatal,
    c_voidp onFatalUsrData)
{
    nw_size fragmentLength;
    nw_bool reliable;
    nw_bool controlNeeded;
    static sk_portNr sendingPortNr = NWCF_DEF(PortNr);
    static sk_portNr receivingPortNr = NWCF_DEF(PortNr);
    sk_portNr newPortNr;
    nw_plugInterChannel *interChannelPtr = (nw_plugInterChannel *)userDataPtr;
    char *defaultPartitionAddress;

    /* Simple attributes */
    channel->name = nw_stringDup(pathName);
    channel->Id = seqNr;
    channel->nodeId = nodeId;
    channel->communication = communication;
    channel->partitions = partitions;

    /* Attributes to be read from config */
    /* QoS-es*/
    reliable = NWCF_SIMPLE_ATTRIB(Bool, pathName, reliable);
    if (reliable) {
        channel->reliabilityOffered = NW_REL_RELIABLE;
        controlNeeded = TRUE;
        /* Create object for inter-channel communication */
        nw_plugInterChannelIncarnate(interChannelPtr, pathName);
        channel->interChannelComm = *interChannelPtr;
    } else {
        channel->reliabilityOffered = NW_REL_BEST_EFFORT;
        controlNeeded = FALSE;
        /* NO object needed for inter-channel communication */
        channel->interChannelComm = NULL;
    }
    /* Default, to be implemented */
    channel->priorityOffered = NW_PRIORITY_UNDEFINED;
    channel->latencyBudgetOffered = NW_LATENCYBUDGET_UNDEFINED;

    /* Network fragment length */
    fragmentLength = (nw_size)NWCF_SIMPLE_PARAM(Size, pathName, FragmentSize);

    /* CHECKME, NWCF_MIN(FragmentSize) must be larger dealing with encryption */
    if (fragmentLength < NWCF_MIN(FragmentSize)) {
        NW_REPORT_WARNING_3("initializing network",
            "Channel \"%s\": requested value %u for fragment size is too small, "
            "using %u instead",
            pathName, fragmentLength, NWCF_MIN(FragmentSize));
        fragmentLength = NWCF_MIN(FragmentSize);
    }
    else if(fragmentLength > NWCF_MAX(FragmentSize)) {
        NW_REPORT_WARNING_3("initializing network",
            "Channel \"%s\": requested value " PA_SIZEFMT " for fragment size is too big, "
            "using %u instead",
            pathName, fragmentLength, NWCF_MAX(FragmentSize));
        fragmentLength = NWCF_MAX(FragmentSize);
    }
    /* FIXME, this rounds up to multiple of 4, but it should round down to
     * meet network constraints (??) */
    /* round to lowest NW_FRAG_BOUNDARY multiplication higher than
     * fragmentLength */
    channel->fragmentLength =
    NW_ALIGN(NW_PLUGDATABUFFER_ALIGNMENT, (nw_length)fragmentLength);

    /* What is the base adress of the socket wee need ? */
    nw_plugPartitionsGetDefaultPartition(partitions, &defaultPartitionAddress, NULL /* SecurityProfile not of interest */ );

    switch (communication) {
    case NW_COMM_SEND:
        newPortNr = NWCF_DEFAULTED_PARAM(ULong, pathName, PortNr, sendingPortNr);
        if (newPortNr == sendingPortNr) {
            sendingPortNr+=2;
        }
        channel->socket = nw_socketSendNew(defaultPartitionAddress,
            newPortNr, controlNeeded, pathName);
    break;
    case NW_COMM_RECEIVE:
        newPortNr = NWCF_DEFAULTED_PARAM(
            ULong, pathName, PortNr, receivingPortNr);
        if (newPortNr == receivingPortNr) {
            receivingPortNr+=2;
        }
        channel->socket = nw_socketReceiveNew(defaultPartitionAddress, newPortNr,
            controlNeeded, pathName);
    break;
    default:
        NW_CONFIDENCE(FALSE);
    break;
    }

    channel->messageBox = nw_messageBoxNew();
    channel->onFatal = onFatal;
    channel->onFatalUsrData = onFatalUsrData;


    channel->reconnectAllowed = NWCF_SIMPLE_ATTRIB(Bool,NWCF_ROOT(General) NWCF_SEP NWCF_NAME(Reconnection),allowed);
    channel->crc = ut_crcNew(UT_CRC_KEY);
}