forked from cgutman/USBIPServerForAndroid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major rework to support Linux's in-box USB/IP implementation. It stil…
…l works best on Windows, but interrupt devices seem to do fine on Linux
- Loading branch information
Showing
25 changed files
with
463 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include $(call all-subdir-makefiles) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Application.mk for USB/IP Server | ||
|
||
# Our minimum version is Android 3.1 | ||
APP_PLATFORM := android-12 | ||
|
||
# Build for all ABIs | ||
APP_ABI := all | ||
|
||
# We want an optimized build | ||
APP_OPTIM := release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Android.mk for errno | ||
MY_LOCAL_PATH := $(call my-dir) | ||
|
||
include $(call all-subdir-makefiles) | ||
|
||
LOCAL_PATH := $(MY_LOCAL_PATH) | ||
|
||
include $(CLEAR_VARS) | ||
LOCAL_MODULE := errno | ||
LOCAL_SRC_FILES := errno_jni.c | ||
|
||
include $(BUILD_SHARED_LIBRARY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include <stdlib.h> | ||
#include <jni.h> | ||
|
||
#include <errno.h> | ||
|
||
JNIEXPORT jint JNICALL | ||
Java_org_cgutman_usbip_errno_Errno_getErrno( | ||
JNIEnv *env, jobject this) | ||
{ | ||
return errno; | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.cgutman.usbip.errno; | ||
|
||
public class Errno { | ||
static { | ||
System.loadLibrary("errno"); | ||
} | ||
|
||
// This is a really nasty hack to try to grab the error | ||
// from a USB API request. It may return an undefined result | ||
// if say the GC runs before this gets called. | ||
public static native int getErrno(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/org/cgutman/usbip/server/protocol/dev/UsbIpUnlinkUrb.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.cgutman.usbip.server.protocol.dev; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.ByteBuffer; | ||
import java.nio.ByteOrder; | ||
|
||
import org.cgutman.usbip.utils.StreamUtils; | ||
|
||
public class UsbIpUnlinkUrb extends UsbIpDevicePacket { | ||
public int seqNumToUnlink; | ||
|
||
public static final int WIRE_SIZE = 4; | ||
|
||
public UsbIpUnlinkUrb(byte[] header) { | ||
super(header); | ||
} | ||
|
||
public static UsbIpUnlinkUrb read(byte[] header, InputStream in) throws IOException { | ||
UsbIpUnlinkUrb msg = new UsbIpUnlinkUrb(header); | ||
|
||
byte[] continuationHeader = new byte[WIRE_SIZE]; | ||
StreamUtils.readAll(in, continuationHeader); | ||
|
||
ByteBuffer bb = ByteBuffer.wrap(continuationHeader).order(ByteOrder.BIG_ENDIAN); | ||
msg.seqNumToUnlink = bb.getInt(); | ||
|
||
// Finish reading the remaining bytes of the header as padding | ||
for (int i = 0; i < UsbIpDevicePacket.USBIP_HEADER_SIZE - (header.length + bb.position()); i++) { | ||
in.read(); | ||
} | ||
|
||
return msg; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(super.toString()); | ||
sb.append(String.format("Sequence number to unlink: %d\n", seqNumToUnlink)); | ||
return sb.toString(); | ||
} | ||
|
||
@Override | ||
protected byte[] serializeInternal() { | ||
throw new UnsupportedOperationException("Serializing not supported"); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/org/cgutman/usbip/server/protocol/dev/UsbIpUnlinkUrbReply.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.cgutman.usbip.server.protocol.dev; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.nio.ByteOrder; | ||
|
||
public class UsbIpUnlinkUrbReply extends UsbIpDevicePacket { | ||
public int status; | ||
|
||
public UsbIpUnlinkUrbReply(int seqNum, int devId, int dir, int ep) { | ||
super(UsbIpDevicePacket.USBIP_RET_UNLINK, seqNum, devId, dir, ep); | ||
} | ||
|
||
protected byte[] serializeInternal() { | ||
ByteBuffer bb = ByteBuffer.allocate(UsbIpDevicePacket.USBIP_HEADER_SIZE - 20).order(ByteOrder.BIG_ENDIAN); | ||
|
||
bb.putInt(status); | ||
|
||
return bb.array(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(super.toString()); | ||
sb.append(String.format("Status: 0x%x\n", status)); | ||
return sb.toString(); | ||
} | ||
} |
Oops, something went wrong.