Exemplo n.º 1
0
  @Override
  protected void handle_bundle_received(BundleReceivedEvent event) {
    boolean should_route = true;

    Bundle bundle = event.bundle();
    Log.d(TAG, String.format("handle bundle received: bundle %d", bundle.bundleid()));

    EndpointID remote_eid = EndpointID.NULL_EID();

    if (event.link() != null) {
      remote_eid = event.link().remote_eid();
    }

    if (!reception_cache_.add_entry(bundle, remote_eid)) {
      Log.i(TAG, String.format("ignoring duplicate bundle: bundle %d", bundle.bundleid()));
      BundleDaemon.getInstance()
          .post_at_head(
              new BundleDeleteRequest(
                  bundle, BundleProtocol.status_report_reason_t.REASON_NO_ADDTL_INFO));
      return;
    }

    if (should_route) {
      route_bundle(bundle);
    } else {
      BundleDaemon.getInstance()
          .post_at_head(
              new BundleDeleteRequest(
                  bundle, BundleProtocol.status_report_reason_t.REASON_NO_ADDTL_INFO));
    }
  }
Exemplo n.º 2
0
  /** "Remove matching deferred transmission entries." [DTN2] */
  void remove_from_deferred(final Bundle bundle, int actions) {

    ContactManager cm = BundleDaemon.getInstance().contactmgr();

    cm.get_lock().lock();
    try {
      final LinkSet links = cm.links();
      Iterator<Link> iter = links.iterator();

      while (iter.hasNext()) {
        Link link = iter.next();

        // "a bundle might be deleted immediately after being loaded
        // from storage, meaning that remove_from_deferred is called
        // before the deferred list is created (since the link isn't
        // fully set up yet). so just skip the link if there's no
        // router info, and therefore no deferred list" [DTN2]
        if (link.router_info() == null) {
          continue;
        }

        DeferredList deferred = deferred_list(link);
        ForwardingInfo info = deferred.find(bundle);
        if (info != null) {
          if ((info.action().getCode() & actions) > 0) {
            Log.d(
                TAG, String.format("removing bundle %s from link %s deferred list", bundle, link));
            deferred.del(bundle);
          }
        }
      }
    } finally {
      cm.get_lock().unlock();
    }
  }