Esempio n. 1
0
void RouteRequestRx(uint8_t *rreq, uint8_t len) {
    uint8_t i,j,k;
    uint8_t *uID, *rrDest;

    uID = rreq + 2 ;
    rrDest = rreq + 1 ;

//Check if the unique ID packet has already been seen recently.

    for(i=0; i<MaxuIDTrack; i++)
    {
        if(*uID == uniqueIDsRREQ[i]) {
            return;
        }
    }
//Add it to unique ID
    for(i=0; i<MaxuIDTrack; i++)
    {
        if(uniqueIDsRREQ[i]==0) {
            uniqueIDsRREQ[i]=*uID;
            break;
        }
    }
//Check if the packect is destined for ownself
    if(*rrDest == MyOwnAddress)
    {
        uint8_t temp[szMax];
        for(j=0; j<len; j++) {
            temp[j]=rreq[j];
        }
        temp[j]=MyOwnAddress;
        RouteReplyTx(temp,len+1,0);
        return;
    }
//Check for the cache to the destination existence

    for(i=0; i<MaxHopsPossible; i++)
    {
        if(*rrDest == cache[i])
        {
            uint8_t temp[szMax];
            for(j=0; j<len; j++) {
                temp[j]=rreq[j];
            }
            for(k=0; k<i+1; k++) {
                temp[j]=cache[k];
                j++;
            }
            RouteReplyTx(temp,len+i+1,i);
            return;
        }
    }
//broadcast the packet forward
    RouteRequestTx(rreq,len);
    return;
}
Esempio n. 2
0
void RouteReplyRx(uint8_t *rrep, uint8_t len) {
    uint8_t i,j,k,m,z,zz ;
    i=1;
    while(rrep[i] != MyOwnAddress) {
        i++;
    }
    if(i>1) {
        RouteReplyTx(rrep,len,0);
    }

    if(cache[0]==0)
    {
        for(j=0; j<len-1; j++) {
            cache[j]=rrep[i];
            i++;
        }
check:
        for(k=0; k<j; k++) {
            for(m=k+1; m<j; m++) {
                if(cache[k]==cache[m])
                {
                    zz=k+1;
                    for(z=m+1; z<j; z++) {
                        cache[zz++]=cache[z];
                    }
                    j = zz;
                    goto check;
                }
            }
        }
    }
    return;
}
Esempio n. 3
0
void RouteRequestRx(uint8_t *rreq, uint8_t len){
	uint8_t i,j,k;
	uint8_t *uID, *rrDest;

	uID     = rreq + 2 ;
	rrDest  = rreq + 1 ;

	//Check if the unique ID packet has already been seen recently.
	for(i=0;i<MaxuIDTrack;i++)
	{
		if(*uID == uniqueIDsRREQ[i]){return();}
	}
	//Add it to unique ID
	for(i=0;i<MaxuIDTrack;i++)
	{
		if(uniqueIDsRREQ[i]==0){uniqueIDsRREQ[i]=*uID;break;}
	}
	//Check if the packect is destined for ownself
	if(*rrDest == MyOwnAddress)
	{
		uint8_t temp[len+1];
		for(j=0;j<len;j++){temp[j]=rreq[j];}
		temp[j]=MyOwnAddress;
		RouteReplyTx(temp,len+1,0);
		return();
	}