Exemplo n.º 1
0
/*
 * path-absolute = "/" [segment * ("/" segment)] 
 */
int 
isPathAbsolute(char *path)
{
	char *startp, *endp;

	startp = path;
	if (*startp != '/') {
		printf("b");
		return 0;
	}

	startp++;
	while((endp = strchr(startp, '/')) != NULL) {
		if (!isSegment(startp, endp -1)) {
			printf("c");
			return 0;
		}
		startp = endp + 1;
	}

	if (startp < path + strlen(path)) {
		return isSegment(startp, path + strlen(path) - 1);
	}

//	printf("d");
	return 1;
}
    shared_ptr<ndn::Data>
    NdnDataManager::operator[]( shared_ptr<const ndn::Interest> interest )
    {
            Name subname = interest->getName();
            auto it = subname.end()-1;

            while( ( it->isVersion() || it->isSegment()
                     || it->isSegmentOffset() || it->isTimestamp()
                     || it->isSequenceNumber() ) && ( it-- ) != subname.begin() );

            subname = subname.getPrefix( it - subname.begin() + 1 );

            if( m_producers.find( subname ) != m_producers.end() )
            {
                // find data producer
                auto producer = m_producers[subname];

                // if access level is 0, no access needs to be provided
                if( interest->getAuthTag().getAccessLevel() == 0 )
                {
                    Coordinator::
                    producerSatisfiedRequest( interest->getName().getPrefix( 2 ),
                                                interest->getName() );
                    return producer->makeData( interest );
                }

                // generate data packet
                shared_ptr<Data> data = producer->makeData( interest );

                // check that the interest's access rights
                // satisfy the data's requirements
                if( m_auth_manager->getTagAccess( interest->getAuthTag() )
                    < data->getAccessLevel() )
                {
                    Coordinator::
                    producerDeniedRequest( interest->getName().getPrefix( 2 ),
                                           interest->getName(),
                                           "Insufficient Auth" );
                    return makeNack( *data );
                }



                // check that the data satisfies interest
                if( interest->matchesData( *data ) )
                {
                    Coordinator::
                    producerSatisfiedRequest( interest->getName().getPrefix(2),
                                               interest->getName() );
                    return data;
                }
            }
           Coordinator::producerOther( interest->getName().getPrefix( 2 ),
                                       "No data matching "
                                       + interest->getName().toUri() );
           return NULL;

    };
Exemplo n.º 3
0
::std::string Path::toString() const
{
    if (size() == 0 && !isSegment())
    {
        return "/";
    }
    else
    {
        ::std::stringstream output;
        for (constPathIterator it = begin(); it != end(); ++it)
        {
            output << "/" << *it;
        }
        return output.str();
    }
}