Example #1
0
void
RibManager::unregisterEntry(const shared_ptr<const Interest>& request,
                            ControlParameters& params)
{
  ndn::nfd::RibUnregisterCommand command;

  // Passing all parameters gives error in validation,
  // so passing only the required arguments.
  ControlParameters parameters;
  parameters.setName(params.getName());

  if (params.hasFaceId()) {
    parameters.setFaceId(params.getFaceId());
  }

  if (params.hasOrigin()) {
    parameters.setOrigin(params.getOrigin());
  }

  if (!validateParameters(command, parameters)) {
    NFD_LOG_DEBUG("unregister result: FAIL reason: malformed");

    if (static_cast<bool>(request)) {
      sendResponse(request->getName(), 400, "Malformed command");
    }

    return;
  }

  bool isSelfRegistration = (!parameters.hasFaceId() || parameters.getFaceId() == 0);
  if (isSelfRegistration) {
    shared_ptr<lp::IncomingFaceIdTag> incomingFaceIdTag = request->getTag<lp::IncomingFaceIdTag>();
    if (incomingFaceIdTag == nullptr) {
      sendResponse(request->getName(), 503,
                   "requested self-registration, but IncomingFaceId is unavailable");
      return;
    }
    parameters.setFaceId(*incomingFaceIdTag);
  }

  // Respond since command is valid and authorized
  sendSuccessResponse(request, parameters);

  Route route;
  route.faceId = parameters.getFaceId();
  route.origin = parameters.getOrigin();

  NFD_LOG_INFO("Removing route " << parameters.getName() << " nexthop=" << route.faceId
                                                         << " origin=" << route.origin);

  RibUpdate update;
  update.setAction(RibUpdate::UNREGISTER)
        .setName(parameters.getName())
        .setRoute(route);

  m_managedRib.beginApplyUpdate(update,
                                bind(&RibManager::onRibUpdateSuccess, this, update),
                                bind(&RibManager::onRibUpdateFailure, this, update, _1, _2));
}
void processTeardown(RTSPClient *clientInfo, RTSPmsg msg) {

//	//pause
	printf("teardown1\n");
	pausePlayback(clientInfo->playback_timer);
	//set video to NULL if it's been allocated
	clientInfo->session_id = 0;	
	sendSuccessResponse(clientInfo->socket, msg.seq, msg.session_id);
	printf("teardown6\n");
}
void processSetup(RTSPClient *clientInfo, RTSPmsg msg)
{
	if (clientInfo->session_id)
	{
		pausePlayback(clientInfo->playback_timer);
	}
	if (clientInfo->current_file_path)
	{
		free(clientInfo->current_file_path);
	}
	int path_length = strlen(msg.file_path + 8);
	clientInfo->current_file_path = (char* ) calloc(path_length, sizeof(char));
	strcpy(clientInfo->current_file_path, msg.file_path + 8);
	clientInfo->current_frame_index = 0;
	if (!clientInfo->session_id)
	{
		int session_id = generateSessionId();
		clientInfo->session_id = session_id;
	}
	msg.session_id = clientInfo->session_id;
	sendSuccessResponse(clientInfo->socket, msg.seq, msg.session_id);
}
void processPause(RTSPClient *clientInfo, RTSPmsg msg){

	sendSuccessResponse(clientInfo->socket, msg.seq, msg.session_id);
	pausePlayback(clientInfo->playback_timer);
}
void processPlay(RTSPClient *clientInfo, RTSPmsg msg)
{
	sendSuccessResponse(clientInfo->socket, msg.seq, msg.session_id);
	clientInfo->scale = msg.scale;
	startPlayback(clientInfo);
}
Example #6
0
void
RibManager::registerEntry(const shared_ptr<const Interest>& request,
                          ControlParameters& parameters)
{
  ndn::nfd::RibRegisterCommand command;

  if (!validateParameters(command, parameters)) {
    NFD_LOG_DEBUG("register result: FAIL reason: malformed");

    if (static_cast<bool>(request)) {
      sendResponse(request->getName(), 400, "Malformed command");
    }

    return;
  }

  bool isSelfRegistration = (!parameters.hasFaceId() || parameters.getFaceId() == 0);
  if (isSelfRegistration) {
    shared_ptr<lp::IncomingFaceIdTag> incomingFaceIdTag = request->getTag<lp::IncomingFaceIdTag>();
    if (incomingFaceIdTag == nullptr) {
      sendResponse(request->getName(), 503,
                   "requested self-registration, but IncomingFaceId is unavailable");
      return;
    }
    parameters.setFaceId(*incomingFaceIdTag);
  }

  // Respond since command is valid and authorized
  sendSuccessResponse(request, parameters);

  Route route;
  route.faceId = parameters.getFaceId();
  route.origin = parameters.getOrigin();
  route.cost = parameters.getCost();
  route.flags = parameters.getFlags();

  if (parameters.hasExpirationPeriod() &&
      parameters.getExpirationPeriod() != time::milliseconds::max())
  {
    route.expires = time::steady_clock::now() + parameters.getExpirationPeriod();

    // Schedule a new event, the old one will be cancelled during rib insertion.
    scheduler::EventId eventId = scheduler::schedule(parameters.getExpirationPeriod(),
      bind(&Rib::onRouteExpiration, &m_managedRib, parameters.getName(), route));

    NFD_LOG_TRACE("Scheduled unregistration at: " << route.expires <<
                  " with EventId: " << eventId);

    // Set the  NewEventId of this entry
    route.setExpirationEvent(eventId);
  }
  else {
    route.expires = time::steady_clock::TimePoint::max();
  }

  NFD_LOG_INFO("Adding route " << parameters.getName() << " nexthop=" << route.faceId
                                                       << " origin=" << route.origin
                                                       << " cost=" << route.cost);

  RibUpdate update;
  update.setAction(RibUpdate::REGISTER)
        .setName(parameters.getName())
        .setRoute(route);

  m_managedRib.beginApplyUpdate(update,
                                bind(&RibManager::onRibUpdateSuccess, this, update),
                                bind(&RibManager::onRibUpdateFailure, this, update, _1, _2));

  m_registeredFaces.insert(route.faceId);
}