Remove link desperation from java API

This commit is contained in:
Grant Limberg 2015-05-21 19:34:19 -07:00
parent c430d88bd4
commit 1e043a3f66
6 changed files with 10 additions and 18 deletions

View File

@ -73,7 +73,9 @@ include_directories(
add_library(${PROJECT_NAME} SHARED ${src_files}) add_library(${PROJECT_NAME} SHARED ${src_files})
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".jnilib") if(APPLE)
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".jnilib")
endif()
set(link_libs ) set(link_libs )

View File

@ -403,7 +403,6 @@ namespace {
int WirePacketSendFunction(ZT1_Node *node,void *userData,\ int WirePacketSendFunction(ZT1_Node *node,void *userData,\
const struct sockaddr_storage *address, const struct sockaddr_storage *address,
unsigned int linkDesparation,
const void *buffer, const void *buffer,
unsigned int bufferSize) unsigned int bufferSize)
{ {
@ -422,7 +421,7 @@ namespace {
} }
jmethodID packetSenderCallbackMethod = cache.findMethod(packetSenderClass, jmethodID packetSenderCallbackMethod = cache.findMethod(packetSenderClass,
"onSendPacketRequested", "(Ljava/net/InetSocketAddress;I[B)I"); "onSendPacketRequested", "(Ljava/net/InetSocketAddress;[B)I");
if(packetSenderCallbackMethod == NULL) if(packetSenderCallbackMethod == NULL)
{ {
LOGE("Couldn't find onSendPacketRequested method"); LOGE("Couldn't find onSendPacketRequested method");
@ -432,7 +431,7 @@ namespace {
jobject addressObj = newInetSocketAddress(env, *address); jobject addressObj = newInetSocketAddress(env, *address);
jbyteArray bufferObj = env->NewByteArray(bufferSize); jbyteArray bufferObj = env->NewByteArray(bufferSize);
env->SetByteArrayRegion(bufferObj, 0, bufferSize, (jbyte*)buffer); env->SetByteArrayRegion(bufferObj, 0, bufferSize, (jbyte*)buffer);
return env->CallIntMethod(ref->packetSender, packetSenderCallbackMethod, addressObj, linkDesparation, bufferObj); return env->CallIntMethod(ref->packetSender, packetSenderCallbackMethod, addressObj, bufferObj);
} }
typedef std::map<uint64_t, JniRef*> NodeMap; typedef std::map<uint64_t, JniRef*> NodeMap;
@ -700,7 +699,6 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket(
jlong id, jlong id,
jlong in_now, jlong in_now,
jobject in_remoteAddress, jobject in_remoteAddress,
jint in_linkDesparation,
jbyteArray in_packetData, jbyteArray in_packetData,
jlongArray out_nextBackgroundTaskDeadline) jlongArray out_nextBackgroundTaskDeadline)
{ {
@ -719,7 +717,6 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket(
} }
uint64_t now = (uint64_t)in_now; uint64_t now = (uint64_t)in_now;
unsigned int linkDesparation = (unsigned int)in_linkDesparation;
// get the java.net.InetSocketAddress class and getAddress() method // get the java.net.InetSocketAddress class and getAddress() method
jclass inetAddressClass = cache.findClass("java/net/InetAddress"); jclass inetAddressClass = cache.findClass("java/net/InetAddress");
@ -801,7 +798,6 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket(
node, node,
now, now,
&remoteAddress, &remoteAddress,
linkDesparation,
packetData, packetData,
packetLength, packetLength,
&nextBackgroundTaskDeadline); &nextBackgroundTaskDeadline);

View File

@ -34,10 +34,10 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processVirtualNetworkFrame
/* /*
* Class: com_zerotier_sdk_Node * Class: com_zerotier_sdk_Node
* Method: processWirePacket * Method: processWirePacket
* Signature: (JJLjava/net/InetSockAddress;I[B[J)Lcom/zerotier/sdk/ResultCode; * Signature: (JJLjava/net/InetSockAddress;[B[J)Lcom/zerotier/sdk/ResultCode;
*/ */
JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket
(JNIEnv *, jobject, jlong, jlong, jobject, jint, jbyteArray, jlongArray); (JNIEnv *, jobject, jlong, jlong, jobject, jbyteArray, jlongArray);
/* /*
* Class: com_zerotier_sdk_Node * Class: com_zerotier_sdk_Node

View File

@ -75,7 +75,7 @@ public class OneService extends Thread implements Runnable, PacketSender,
{ {
System.out.println("Got Data From: " + p.getAddress().toString() +":" + p.getPort()); System.out.println("Got Data From: " + p.getAddress().toString() +":" + p.getPort());
_node.processWirePacket(System.currentTimeMillis(), new InetSocketAddress(p.getAddress(), p.getPort()), 0, p.getData(), bgtask); _node.processWirePacket(System.currentTimeMillis(), new InetSocketAddress(p.getAddress(), p.getPort()), p.getData(), bgtask);
_nextBackgroundTaskDeadline = bgtask[0]; _nextBackgroundTaskDeadline = bgtask[0];
} }
} catch (SocketTimeoutException e) {} } catch (SocketTimeoutException e) {}
@ -148,8 +148,7 @@ public class OneService extends Thread implements Runnable, PacketSender,
} }
@Override @Override
public int onSendPacketRequested(InetSocketAddress addr, public int onSendPacketRequested(InetSocketAddress addr, byte[] packetData) {
int linkDesperation, byte[] packetData) {
System.out.println("onSendPacketRequested to: " + addr.getHostString() +":"+ addr.getPort() + " "); System.out.println("onSendPacketRequested to: " + addr.getHostString() +":"+ addr.getPort() + " ");
if(_udpSocket == null) if(_udpSocket == null)

View File

@ -163,7 +163,6 @@ public class Node {
* *
* @param now Current clock in milliseconds * @param now Current clock in milliseconds
* @param remoteAddress Origin of packet * @param remoteAddress Origin of packet
* @param linkDesperation Link desperation metric for link or protocol over which packet arrived
* @param packetData Packet data * @param packetData Packet data
* @param nextBackgroundTaskDeadline Value/result: set to deadline for next call to processBackgroundTasks() * @param nextBackgroundTaskDeadline Value/result: set to deadline for next call to processBackgroundTasks()
* @return OK (0) or error code if a fatal error condition has occurred * @return OK (0) or error code if a fatal error condition has occurred
@ -171,11 +170,10 @@ public class Node {
public ResultCode processWirePacket( public ResultCode processWirePacket(
long now, long now,
InetSocketAddress remoteAddress, InetSocketAddress remoteAddress,
int linkDesperation,
byte[] packetData, byte[] packetData,
long[] nextBackgroundTaskDeadline) { long[] nextBackgroundTaskDeadline) {
return processWirePacket( return processWirePacket(
nodeId, now, remoteAddress, linkDesperation, packetData, nodeId, now, remoteAddress, packetData,
nextBackgroundTaskDeadline); nextBackgroundTaskDeadline);
} }
@ -396,7 +394,6 @@ public class Node {
long nodeId, long nodeId,
long now, long now,
InetSocketAddress remoteAddress, InetSocketAddress remoteAddress,
int linkDesperation,
byte[] packetData, byte[] packetData,
long[] nextBackgroundTaskDeadline); long[] nextBackgroundTaskDeadline);

View File

@ -38,12 +38,10 @@ public interface PacketSender {
* delivery. It only means that the packet appears to have been sent.</p> * delivery. It only means that the packet appears to have been sent.</p>
* *
* @param addr {@link InetSocketAddress} to send to * @param addr {@link InetSocketAddress} to send to
* @param linkDesperation
* @param packetData data to send * @param packetData data to send
* @return 0 on success, any error code on failure. * @return 0 on success, any error code on failure.
*/ */
public int onSendPacketRequested( public int onSendPacketRequested(
InetSocketAddress addr, InetSocketAddress addr,
int linkDesperation,
byte[] packetData); byte[] packetData);
} }