Example #1
0
JNIEXPORT jint JNICALL
Java_OnloadTemplateSend_Alloc ( JNIEnv* env, jclass cls,
                                jint fd, jobject out, jobject data,
                                jint flags )
{
	jint rval = 0;
	onload_template_handle handle = 0;
	struct iovec initial_msg;

	initial_msg.iov_base = (*env)->GetDirectBufferAddress( env, data );
	if ( !initial_msg.iov_base )
		return -ENOMEM;
	initial_msg.iov_len = (*env)->GetDirectBufferCapacity( env, data );
	if ( initial_msg.iov_len < 1 )
		return -ENOMEM;

	rval = onload_msg_template_alloc(fd, &initial_msg, 1, &handle, flags );

	if ( rval >= 0 ) {
		SetLongOnObject( env, out, "opaque", (long)handle );
		SetIntOnObject( env, out, "fd", fd );
	} else {
		SetLongOnObject( env, out, "opaque", -1 );
		SetIntOnObject( env, out, "fd", -1 );
	}

	return rval;
}
Example #2
0
int templated_send(int handle, struct iovec* iov)
{
  onload_template_handle tmpl;
  struct onload_template_msg_update_iovec update;

  struct iovec initial;
  initial.iov_base = iov->iov_base;
  initial.iov_len = iov->iov_len;

  update.otmu_base = iov->iov_base;
  update.otmu_len = iov->iov_len;
  update.otmu_offset = 0;
  update.otmu_flags = 0;

  /* Note: This is initialising, and then updating to the same values.
   * A real application would update only a subset of the values, and
   * usually with different values.
   */
  TRY( onload_msg_template_alloc(handle, &initial, 1, &tmpl, 0));
  return onload_msg_template_update(handle, tmpl, &update, 1,
                                    ONLOAD_TEMPLATE_FLAGS_SEND_NOW);
}