/**
   * Internal function to format the status flags of the bundle
   *
   * @param bundle Bundle to get the flags values
   * @return Formatted value of the flags
   */
  protected static int format_srr_flags(final Bundle bundle) {
    int srr_flags = 0;

    if (bundle.receive_rcpt())
      srr_flags |= BundleProtocol.bundle_processing_report_flag_t.REQUEST_STATUS_RECEIVED.getCode();

    if (bundle.custody_rcpt())
      srr_flags |=
          BundleProtocol.bundle_processing_report_flag_t.REQUEST_STATUS_CUSTODY_ACCEPTED.getCode();

    if (bundle.forward_rcpt())
      srr_flags |=
          BundleProtocol.bundle_processing_report_flag_t.REQUEST_STATUS_FORWARDED.getCode();

    if (bundle.delivery_rcpt())
      srr_flags |=
          BundleProtocol.bundle_processing_report_flag_t.REQUEST_STATUS_DELIVERED.getCode();

    if (bundle.deletion_rcpt())
      srr_flags |= BundleProtocol.bundle_processing_report_flag_t.REQUEST_STATUS_DELETED.getCode();

    return srr_flags;
  }
  /**
   * Check the validity of the Primary block
   *
   * @param bundle Bundle to check the generic validity of block
   * @param block_list List of Blocks
   * @param block Block to check if it's valid or not
   * @param reception_reason If block is not valid then reception reason
   * @param deletion_reason If block is not balid then deletion reason
   * @return True if the block is valid else false
   */
  public boolean validate(
      final Bundle bundle,
      BlockInfoVec block_list,
      BlockInfo block,
      status_report_reason_t[] reception_reason,
      status_report_reason_t[] deletion_reason) {
    // Make sure all four EIDs are valid.
    boolean eids_valid = true;
    eids_valid &= bundle.source().valid();
    eids_valid &= bundle.dest().valid();
    eids_valid &= bundle.custodian().valid();
    eids_valid &= bundle.replyto().valid();

    if (!eids_valid) {
      Log.e(TAG, "bad value for one or more EIDs");
      deletion_reason[0] = status_report_reason_t.REASON_BLOCK_UNINTELLIGIBLE;
      return false;
    }

    // According to BP section 3.3, there are certain things that a bundle
    // with a null source EID should not try to do. Check for these cases
    // and reject the bundle if any is true.

    Log.d(TAG, "Going to check null eid");
    if (bundle.source().equals(EndpointID.NULL_EID())) {
      Log.d(TAG, "Inside of Going to check null eid");
      if (bundle.receipt_requested() || bundle.app_acked_rcpt()) {
        Log.e(TAG, "bundle with null source eid has requested a report; reject it");
        deletion_reason[0] = status_report_reason_t.REASON_BLOCK_UNINTELLIGIBLE;
        return false;
      }

      if (bundle.custody_requested()) {
        Log.e(TAG, "bundle with null source eid has requested custody transfer; reject it");
        deletion_reason[0] = status_report_reason_t.REASON_BLOCK_UNINTELLIGIBLE;
        return false;
      }

      if (!bundle.do_not_fragment()) {
        Log.e(
            TAG, "bundle with null source eid has not set " + "'do-not-fragment' flag; reject it");
        deletion_reason[0] = status_report_reason_t.REASON_BLOCK_UNINTELLIGIBLE;
        return false;
      }
    }

    Log.d(TAG, "Out of Going to check null eid");
    // Admin bundles cannot request custody transfer.
    if (bundle.is_admin()) {
      if (bundle.custody_requested()) {
        Log.e(TAG, "admin bundle requested custody transfer; reject it");
        deletion_reason[0] = status_report_reason_t.REASON_BLOCK_UNINTELLIGIBLE;
        return false;
      }

      if (bundle.receive_rcpt()
          || bundle.custody_rcpt()
          || bundle.forward_rcpt()
          || bundle.delivery_rcpt()
          || bundle.deletion_rcpt()
          || bundle.app_acked_rcpt()) {
        Log.e(TAG, "admin bundle has requested a report; reject it");
        deletion_reason[0] = status_report_reason_t.REASON_BLOCK_UNINTELLIGIBLE;
        return false;
      }
    }

    return true;
  }