コード例 #1
0
extern eOresult_t eo_confman_ConfirmationRequest_Insert(EOconfirmationManager *p, eOropdescriptor_t* ropdesc)
{   
    if((NULL == p) || (NULL == ropdesc))
    {
        return(eores_NOK_generic);  
    }
    
    // if conf request is flagged on
    if(1 == ropdesc->control.rqstconf)
    {
        if(NULL != p->confrequests)
        { 
            eov_mutex_Take(p->mtx, eok_reltimeINFINITE);
            
            if(eobool_false == eo_vector_Full(p->confrequests))
            {
                eo_vector_PushBack(p->confrequests, ropdesc);
            }
            else
            {
                eov_mutex_Release(p->mtx);
                return(eores_NOK_generic); 
            }
            
            eov_mutex_Release(p->mtx);
        }        
    }
    
    return(eores_OK);
}
コード例 #2
0
//#warning --> make eo_transmitter_occasional_rops_Load obsolete ............. DO IT
extern eOresult_t eo_transmitter_occasional_rops_Load_without_data(EOtransmitter *p, eOropdescriptor_t* ropdesc, uint8_t itisobsolete)//eOropcode_t ropcode, eOnvEP_t nvep, eOnvID_t nvid, eOropconfig_t ropcfg)
{
//    eo_transm_regrop_info_t regropinfo;
    eOresult_t res;
    uint16_t usedbytes;
    uint16_t ropsize;
    uint16_t remainingbytes;

    if(NULL == p) 
    {
        return(eores_NOK_nullpointer);
    }  

    eov_mutex_Take(p->mtx_occasionals, eok_reltimeINFINITE);
   
    // prepare the rop in p->roptmp
    
    res = eo_agent_OutROPinit(p->theagent, p->nvscfg, 
                              p->ipv4addr, ropdesc, 
                              p->roptmp, &usedbytes);
                              
    if(eores_OK != res)
    {
        eov_mutex_Release(p->mtx_occasionals);
        return(res);
    }

    // put the rop inside the ropframe
    res = eo_ropframe_ROP_Add(p->ropframeoccasionals, p->roptmp, NULL, &ropsize, &remainingbytes);
    
    
    eov_mutex_Release(p->mtx_occasionals);
    
    return(res);   
}
コード例 #3
0
extern eOresult_t eo_transmitter_regular_rops_Refresh(EOtransmitter *p)
{
    if(NULL == p) 
    {
        return(eores_NOK_nullpointer);
    }  

    if(NULL == p->listofregropinfo)
    {
        // in such a case there is room for regular rops (for instance because the cfg->maxnumberofregularrops is zero)
        return(eores_OK);
    }
    
    eov_mutex_Take(p->mtx_regulars, eok_reltimeINFINITE);
    
    if(eobool_true == eo_list_Empty(p->listofregropinfo))
    {
        eov_mutex_Release(p->mtx_regulars);
        return(eores_OK);
    } 
    
    p->currenttime = eov_sys_LifeTimeGet(eov_sys_GetHandle());
    
    // for each element in the list ... i do: ... see function
    eo_list_ForEach(p->listofregropinfo, s_eo_transmitter_list_updaterop_in_ropframe, p);

    eov_mutex_Release(p->mtx_regulars);
    
    return(eores_OK);   
}
コード例 #4
0
extern eOresult_t eo_transmitter_outpacket_Prepare(EOtransmitter *p, uint16_t *numberofrops)
{
    uint16_t remainingbytes;


    if((NULL == p) || (NULL == numberofrops)) 
    {
        return(eores_NOK_nullpointer);
    }

    
    // clear the content of the ropframe to transmit which uses the same storage of the packet ...
    eo_ropframe_Clear(p->ropframereadytotx);
    
    // add to it the ropframe of regulars. keep it afterwards. dont clear it !!!
    eov_mutex_Take(p->mtx_regulars, eok_reltimeINFINITE);
    eo_ropframe_Append(p->ropframereadytotx, p->ropframeregulars, &remainingbytes);
    eov_mutex_Release(p->mtx_regulars);

    // add the ropframe of occasionals ... and then clear it
    eov_mutex_Take(p->mtx_occasionals, eok_reltimeINFINITE);
    eo_ropframe_Append(p->ropframereadytotx, p->ropframeoccasionals, &remainingbytes);
    eo_ropframe_Clear(p->ropframeoccasionals);
    eov_mutex_Release(p->mtx_occasionals);

    // add the ropframe of replies ... and then clear it
    eov_mutex_Take(p->mtx_replies, eok_reltimeINFINITE);
    eo_ropframe_Append(p->ropframereadytotx, p->ropframereplies, &remainingbytes);
    eo_ropframe_Clear(p->ropframereplies);
    eov_mutex_Release(p->mtx_replies);

    *numberofrops = eo_ropframe_ROP_NumberOf(p->ropframereadytotx);
    
    return(eores_OK);   
}
コード例 #5
0
extern eOresult_t eo_transmitter_regular_rops_Clear(EOtransmitter *p)
{
    if(NULL == p) 
    {
        return(eores_NOK_nullpointer);
    }  

    if(NULL == p->listofregropinfo)
    {
        // in such a case there is room for regular rops (for instance because the cfg->maxnumberofregularrops is zero)
        return(eores_OK);
    }
    
    eov_mutex_Take(p->mtx_regulars, eok_reltimeINFINITE);
    
    if(eobool_true == eo_list_Empty(p->listofregropinfo))
    {
        eov_mutex_Release(p->mtx_regulars);
        return(eores_OK);
    } 
    
    eo_list_Clear(p->listofregropinfo);
    
    eo_ropframe_Clear(p->ropframeregulars);

    eov_mutex_Release(p->mtx_regulars);
    
    return(eores_OK);   
}
コード例 #6
0
extern eOresult_t eo_confman_ConfirmationRequests_Process(EOconfirmationManager *p, eOipv4addr_t toipaddr)
{
    if(NULL == p)
    {
        return(eores_NOK_generic);  
    }
    
    eov_mutex_Take(p->mtx, eok_reltimeINFINITE);

    if(0 != eo_vector_Size(p->confrequests))
    {
        uint16_t size = eo_vector_Size(p->confrequests);
        uint16_t i=0;
        for(i=0; i<size; i++)
        {
            eOropdescriptor_t *ropdes = (eOropdescriptor_t*) eo_vector_At(p->confrequests, i);
            eo_confman_Confirmation_Requested(p, toipaddr, ropdes);            
        }       
        eo_vector_Clear(p->confrequests);   // remove the conf requests
    }
    
    eov_mutex_Release(p->mtx);
    
    return(eores_OK);    
}
コード例 #7
0
extern eOresult_t eo_fifo_Clear(EOfifo *fifo, eOreltime_t tout) 
{
    eOresult_t res = eores_NOK_generic;
    
    if(NULL == fifo) 
    {
        return(eores_NOK_nullpointer);
    }
    
    if(NULL == fifo->mutex)    
    {
        // the fifo is not protected with a mutex, thus it is simple.
        eo_deque_Clear(fifo->dek);
        res = eores_OK;    
    }
    else 
    {
        // the fifo is protected with a mutex, thus i need to check it
        // the mutex can be any type derived from mutexObj_t ... however, we use polymorphism
        if(eores_OK == eov_mutex_Take(fifo->mutex, tout)) 
        {
            eo_deque_Clear(fifo->dek);
            eov_mutex_Release(fifo->mutex);
            res = eores_OK;
        }
        else 
        {
            // unfortunately we did not get the mutex for timeout
            res = eores_NOK_timeout;
        }
    }

    return(res);    
}
コード例 #8
0
extern eOresult_t eo_fifo_Put(EOfifo *fifo, void *pitem, eOreltime_t tout) 
{
    eOresult_t res = eores_NOK_generic;
    

    if(NULL == fifo) 
    {
        return(eores_NOK_nullpointer);
    }
    
    if(NULL == fifo->mutex)    
    {
        // the fifo is not protected with a mutex, thus it is simple.
        if(eobool_false == eo_deque_Full(fifo->dek))
        {
            eo_deque_PushBack(fifo->dek, pitem);
            res = eores_OK;
        }
        else 
        {
            // queue is full
            res = eores_NOK_busy;
        }
    
    }
    else 
    {
        // the fifo is protected with a mutex, thus i need to check it
        // the mutex can be any type derived from mutexObj_t ... however, we use polymorphism
        if(eores_OK == eov_mutex_Take(fifo->mutex, tout)) 
        {
            // try to put item inside
            if(eobool_false == eo_deque_Full(fifo->dek))
            {
                eo_deque_PushBack(fifo->dek, pitem);
                res = eores_OK;
            }
            else 
            {
                // queue is full
                res = eores_NOK_busy;
            }        

            // release it
            eov_mutex_Release(fifo->mutex);

        }
        else 
        {
            // unfortunately we did not get the mutex for timeout
            res = eores_NOK_timeout;
        }
    }
    
    return(res);    
}
コード例 #9
0
extern eOresult_t eo_fifo_Get(EOfifo *fifo, const void **ppitem, eOreltime_t tout) 
{
    eOresult_t res = eores_NOK_generic;
    
    if((NULL == fifo) || (NULL == ppitem)) 
    {
        return(eores_NOK_nullpointer);
    }
    
    if(NULL == fifo->mutex)    
    {
        // the fifo is not protected with a mutex, thus it is simple.
        *ppitem = eo_deque_Front(fifo->dek);
        if(NULL != *ppitem) 
        {
            res = eores_OK;
        }
        else 
        {
             res = eores_NOK_nodata; // empty
        }    
    }
    else 
    {
        // the fifo is protected with a mutex, thus i need to check it
        // the mutex can be any type derived from mutexObj_t ... however, we use polymorphism
        if(eores_OK == eov_mutex_Take(fifo->mutex, tout)) 
        {
            *ppitem = eo_deque_Front(fifo->dek);
            eov_mutex_Release(fifo->mutex);
            if(NULL != *ppitem) 
            {
                res = eores_OK;
            }
            else 
            {
                 res = eores_NOK_nodata; // empty
            }    
        }
        else 
        {
            // unfortunately we did not get the mutex for timeout
            res = eores_NOK_timeout;
        }
    }
    
    return(res);    
}
コード例 #10
0
extern eOresult_t eo_transmitter_reply_ropframe_Load(EOtransmitter *p, EOropframe* ropframe)
{
    eOresult_t res;
    uint16_t remainingbytes;

    if(NULL == p) 
    {
        return(eores_NOK_nullpointer);
    }  

    eov_mutex_Take(p->mtx_replies, eok_reltimeINFINITE);
    res = eo_ropframe_Append(p->ropframereplies, ropframe, &remainingbytes);
    eov_mutex_Release(p->mtx_replies);

    return(res);     
}
コード例 #11
0
extern eOresult_t eo_transmitter_occasional_rops_Load(EOtransmitter *p, eOropdescriptor_t* ropdesc) //eOropcode_t ropcode, eOnvEP_t nvep, eOnvID_t nvid, eOropconfig_t ropcfg, uint8_t* data)
{
//    eo_transm_regrop_info_t regropinfo;
    eOnvOwnership_t nvownership;
    eOresult_t res;
    uint16_t usedbytes;
    uint16_t ropsize;
    uint16_t remainingbytes;
    
    
    uint16_t ondevindex;
    uint16_t onendpointindex;
    uint16_t onidindex;
    
    EOtreenode* treenode;
    EOnv nv;
    
    eObool_t hasdata2send = eobool_false;    

    if((NULL == p) || (NULL == ropdesc)) 
    {
        return(eores_NOK_nullpointer);
    }  
    
    if(NULL == ropdesc->data)
    {
        return(eo_transmitter_occasional_rops_Load_without_data(p, ropdesc, 0));
    }
    
    if((eo_ropcode_say == ropdesc->ropcode) || (eo_ropcode_sig == ropdesc->ropcode) || (eo_ropcode_set == ropdesc->ropcode))
    {
        hasdata2send = eobool_true;
    }   
    
    
    
    nvownership = eo_rop_hid_GetOwnership(ropdesc->ropcode, eo_ropconf_none, eo_rop_dir_outgoing);
      
    
    // retrieve the indices inside the nvscfg given the triple (ip, ep, id)
    res = eo_nvscfg_GetIndices( (p->nvscfg),  
                                (eo_nv_ownership_local == nvownership) ? (eok_ipv4addr_localhost) : (p->ipv4addr), 
                                ropdesc->ep, ropdesc->id, 
                                &ondevindex,
                                &onendpointindex,
                                &onidindex); 

    // if the nvscfg does not have the triple (ip, ep, id) then we return an error because we cannot form the rop
    if(eores_OK != res)
    {
        return(eores_NOK_generic);
    }

    // we need a treenode of the nv
    //treenode = eo_nvscfg_GetTreeNode(&(p->cfg.nvscfg), ondevindex, onendpointindex, onidindex);
    
    // we need the nv (but only if the rop needs data).
    treenode = NULL; // eo_nvscfg_GetNV() internally calls eo_nvscfg_GetTreeNode()
    eo_nvscfg_GetNV((p->nvscfg), ondevindex, onendpointindex, onidindex, treenode, &nv);
    
    // now we have the nv. we set its value in local ram
    if(eobool_true == hasdata2send)
    {       
        eo_nv_Set(&nv, ropdesc->data, eobool_true, eo_nv_upd_dontdo);   
    }


    eov_mutex_Take(p->mtx_occasionals, eok_reltimeINFINITE);
    
    // prepare the rop in p->roptmp
//     eOropconfig_t ropcfg;
//     ropcfg.confrqst = ropdesc->configuration.confrqst;
//     ropcfg.timerqst = ropdesc->configuration.timerqst;
//     ropcfg.plussign = ropdesc->configuration.plussign;
//     ropcfg.plustime = ropdesc->configuration.plustime;
    
    res = eo_agent_OutROPfromNV(p->theagent, &nv, ropdesc, p->roptmp, &usedbytes);    
    
    if(eores_OK != res)
    {
        eov_mutex_Release(p->mtx_occasionals);
        return(res);
    }

    // put the rop inside the ropframe
    res = eo_ropframe_ROP_Add(p->ropframeoccasionals, p->roptmp, NULL, &ropsize, &remainingbytes);
    
    
    eov_mutex_Release(p->mtx_occasionals);
   
    
    return(res);   
}
コード例 #12
0
extern eOresult_t eo_transmitter_regular_rops_Unload(EOtransmitter *p, eOropdescriptor_t* ropdesc)//eOropcode_t ropcode, eOnvEP_t nvep, eOnvID_t nvid)
{
    eo_transm_regrop_info_t regropinfo;
    eOropdescriptor_t ropdescriptor;
    EOlistIter *li = NULL;

    if(NULL == p) 
    {
        return(eores_NOK_nullpointer);
    }  

    if(NULL == p->listofregropinfo)
    {
        // in such a case there is room for regular rops (for instance because the cfg->maxnumberofregularrops is zero)
        return(eores_NOK_generic);
    }

    // work on the list ... 
    
    eov_mutex_Take(p->mtx_regulars, eok_reltimeINFINITE);
    
    if(eobool_true == eo_list_Empty(p->listofregropinfo))
    {
        eov_mutex_Release(p->mtx_regulars);
        return(eores_NOK_generic);
    }
    
    // need only ropcode, ep and id to search for inside the list listofregropinfo
    ropdescriptor.ropcode       = ropdesc->ropcode;
    ropdescriptor.ep            = ropdesc->ep;
    ropdescriptor.id            = ropdesc->id;

      
    // search for ropcode+nvep+nvid. if not found, then ... return OK and dont do anything.
    li = eo_list_Find(p->listofregropinfo, s_eo_transmitter_ropmatchingrule_rule, &ropdescriptor);
    if(NULL == li)
    {   // it is not inside ...
        eov_mutex_Release(p->mtx_regulars);
        return(eores_NOK_generic);
    }
    
    // copy what is inside the list into a temporary variable
    memcpy(&regropinfo, eo_list_At(p->listofregropinfo, li), sizeof(eo_transm_regrop_info_t));
    
    // for each element after li: (name is afterli) retrieve it and modify its content so that ropstarthere is decremented by regropinfo.ropsize ...
    eo_list_FromIterForEach(p->listofregropinfo, eo_list_Next(p->listofregropinfo, li), s_eo_transmitter_list_shiftdownropinfo, &regropinfo);
    
    // remove the element indexedby li
    eo_list_Erase(p->listofregropinfo, li);
    
    // inside the p->ropframeregulars: remove a rop of regropinfo.ropsize whcih starts at regropinfo.ropstartshere. use a _friend method in here defined.
    //                                  you must: decrement the nrops by 1, decrement the size by regropinfo.ropsize, ... else in header and private variable ...
    //                                            and finally make a memmove down by regropinfo.ropsize.
    
    eo_ropframe_ROP_Rem(p->ropframeregulars, regropinfo.ropstarthere, regropinfo.ropsize);
  

    eov_mutex_Release(p->mtx_regulars);
    
    return(eores_OK);   
}
コード例 #13
0
extern eOresult_t eo_transmitter_regular_rops_Load(EOtransmitter *p, eOropdescriptor_t* ropdesc)//eOropcode_t ropcode, eOnvEP_t nvep, eOnvID_t nvid, eOropconfig_t ropcfg)
{
    eo_transm_regrop_info_t regropinfo;
    eOropdescriptor_t ropdescriptor;
    eOresult_t res;
    uint16_t usedbytes;
    uint16_t remainingbytes;
    uint16_t ropstarthere;
    uint16_t ropsize;
    EOnv* tmpnvptr = NULL;

    if((NULL == p) || (NULL == ropdesc)) 
    {
        return(eores_NOK_nullpointer);
    }  

    if(NULL == p->listofregropinfo)
    {
        // in such a case there is room for regular rops (for instance because the cfg->maxnumberofregularrops is zero)
        return(eores_NOK_generic);
    }
    
    
    eov_mutex_Take(p->mtx_regulars, eok_reltimeINFINITE);

    // work on the list ... 
    
    if(eobool_true == eo_list_Full(p->listofregropinfo))
    {
        eov_mutex_Release(p->mtx_regulars);
        return(eores_NOK_generic);
    }
    

    // for searching inside listofregropinfo we need only those three fields: ropcode, id, ep
    ropdescriptor.ropcode   = ropdesc->ropcode;
    ropdescriptor.ep        = ropdesc->ep;
    ropdescriptor.id        = ropdesc->id;

    
    // search for ropcode+ep+id. if found, then ... return OK and dont do anything because it means that the rop is already inside
    if(NULL != eo_list_Find(p->listofregropinfo, s_eo_transmitter_ropmatchingrule_rule, &ropdescriptor))
    {   // it is already inside ...
        eov_mutex_Release(p->mtx_regulars);
        return(eores_NOK_generic);
    }    
    
    // else ... prepare a temporary variable eo_transm_regrop_info_t to be put inside the list.
    // and wait success of rop + insetrtion in frame
    
    // 1. prepare the rop to be put inside the ropframe. the rop contains also a reference to the associated netvar   
    res = eo_agent_OutROPinit(p->theagent, p->nvscfg, 
                              p->ipv4addr, ropdesc, 
                              p->roptmp, &usedbytes);     
    // if we cannot prepare the rop ... we quit
    if(eores_OK != res)
    {
        eov_mutex_Release(p->mtx_regulars);
        return(res);
    }
    // extract the reference to the associated netvar
    tmpnvptr = eo_rop_hid_NV_Get(p->roptmp);
    

    // 2. put the rop inside the ropframe
    res = eo_ropframe_ROP_Add(p->ropframeregulars, p->roptmp, &ropstarthere, &ropsize, &remainingbytes);
    // if we cannot add the rop we quit
    if(eores_OK != res)
    {
        eov_mutex_Release(p->mtx_regulars);
        return(res);
    }
    
    
    // 3. prepare a regropinfo variable to be put inside the list    
    
    regropinfo.ropcode                  = ropdesc->ropcode;    
    regropinfo.hasdata2update           = eo_rop_hid_DataField_is_Present(&(p->roptmp->stream.head)); 
    regropinfo.ropstarthere             = ropstarthere;
    regropinfo.ropsize                  = ropsize;
    regropinfo.timeoffsetinsiderop      = (0 == p->roptmp->stream.head.ctrl.plustime) ? (EOK_uint16dummy) : (ropsize - 8); //if we have time, then it is in teh last 8 bytes
    memcpy(&regropinfo.thenv, tmpnvptr, sizeof(EOnv));


    // 4. finally push back regropinfo inside the list.
    eo_list_PushBack(p->listofregropinfo, &regropinfo);
    
    eov_mutex_Release(p->mtx_regulars);    
    return(eores_OK);   
}
コード例 #14
0
extern eOresult_t eo_fifo_GetRem(EOfifo *fifo, void *pitem, eOreltime_t tout)
{

    eOresult_t res = eores_NOK_generic;
    void *dekitem;

    if((NULL == fifo) || (NULL == pitem)) 
    {
        return(eores_NOK_nullpointer);
    }
    
    if(NULL == fifo->mutex)    
    {
        // the fifo is not protected with a mutex, thus it is simple.
    	dekitem = eo_deque_Front(fifo->dek);
		if(NULL != dekitem)
        {
            res = eores_OK;
			//memcpy(pitem, dekitem, fifo->dek->item_size);

            if(NULL != fifo->dek->item_copy_fn) 
            {
                fifo->dek->item_copy_fn(pitem, dekitem);
            }
            else
            {
                memcpy(pitem, dekitem, fifo->dek->item_size);
            }

        	//eo_deque_PopFront(fifo->dek);
            eo_deque_hid_QuickPopFront(fifo->dek); // can safely use this one as we know that there is an item inside
        }
        else 
        {
             res = eores_NOK_nodata; // empty
        }  
    }
    else
    {
        // the fifo is protected with a mutex, thus i need to check it
        // the mutex can be any type derived from mutexObj_t ... however, we use polymorphism
        if(eores_OK == eov_mutex_Take(fifo->mutex, tout)) 
        {
    	    dekitem = eo_deque_Front(fifo->dek);
			if(NULL != dekitem)
	        {
	            res = eores_OK;
				//memcpy(pitem, dekitem, fifo->dek->item_size);

                if(NULL != fifo->dek->item_copy_fn) 
                {
                    fifo->dek->item_copy_fn(pitem, dekitem);
                }
                else
                {
                    memcpy(pitem, dekitem, fifo->dek->item_size);
                }


	        	//eo_deque_PopFront(fifo->dek);
                eo_deque_hid_QuickPopFront(fifo->dek); // can safely us this one as we know that there is an item inside
	        }
	        else 
	        {
	             res = eores_NOK_nodata; // empty
	        }  
            eov_mutex_Release(fifo->mutex);
        }
        else
        {
            // unfortunately we did not get the mutex for timeout
            res = eores_NOK_timeout;
        }
    }

    return(res);    
	
}