Mihai Plasoianu 10 years ago
parent
commit
b0c929aa95

+ 3 - 3
native/Makefile

@@ -3,9 +3,9 @@ x86: CC = i686-linux-android-gcc
 mips: CC = mipsel-linux-android-gcc
 CFLAGS = -Wall -g
 LDFLAGS = -llog
-SRC = pp.c
+SRC = bind.c
 OBJ = $(SRC:.c=.o)
-EXE = pp
+EXE = bind
 
 arm x86 mips: $(SRC) $(EXE)
 
@@ -19,4 +19,4 @@ clean:
 	rm -f *.o $(EXE)
 
 install:
-	adb push pp /data/local
+	adb push bind /data/local

+ 6 - 5
native/pp.c → native/bind.c

@@ -43,7 +43,8 @@ int net_sock(int type, int port) {
 	int reuseaddr = 1;
 	struct sockaddr_in addr;
 
-	if ((fd = socket(AF_INET, (type == 1 ? SOCK_STREAM : SOCK_DGRAM), 0)) == -1) {
+	if ((fd = socket(AF_INET, (type == 1 ? SOCK_STREAM : SOCK_DGRAM), 0))
+			== -1) {
 		perror("Unable to create net socket");
 		return -1;
 	}
@@ -54,8 +55,8 @@ int net_sock(int type, int port) {
 	addr.sin_port = htons(port);
 
 	if (type == 1) {
-		if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, sizeof(reuseaddr))
-				== -1) {
+		if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuseaddr,
+				sizeof(reuseaddr)) == -1) {
 			perror("Unable to set socket options");
 			return -1;
 		}
@@ -114,9 +115,9 @@ int main(int argc, char *argv[]) {
 		exit(EXIT_FAILURE);
 	}
 
-	if (strncmp(argv[1], TCP) == 0) {
+	if (strncmp(argv[1], TCP, 3) == 0) {
 		type = 1;
-	} else if (strncmp(argv[1], UDP) == 0) {
+	} else if (strncmp(argv[1], UDP, 3) == 0) {
 		type = 0;
 	} else {
 		exit(EXIT_FAILURE);

+ 0 - 1
src/de/tudarmstadt/informatik/hostage/net/MyDatagramSocketFactory.java

@@ -17,7 +17,6 @@ public class MyDatagramSocketFactory {
 		DatagramSocket socket = null;
 		if (port > 1023) {
 			socket = new DatagramSocket();
-			socket.setReuseAddress(true);
 			socket.bind(new InetSocketAddress(port));
 		} else if (Device.isPPInstalled()) {
 			FileDescriptor fd = new PrivilegedPort(TYPE.UDP, port).getFD();

+ 2 - 2
src/de/tudarmstadt/informatik/hostage/system/PrivilegedPort.java

@@ -26,7 +26,7 @@ public class PrivilegedPort implements Runnable {
 	private FileDescriptor fd;
 
 	public PrivilegedPort(TYPE type, int port) {
-		LOG_TAG = String.format("hostage (pp %s %d)", type.toString(), port);
+		LOG_TAG = String.format("hostage (porthack %s %d)", type.toString(), port);
 		this.type = type;
 		this.port = port;
 		try {
@@ -52,7 +52,7 @@ public class PrivilegedPort implements Runnable {
 
 	@Override
 	public void run() {
-		String command = String.format("/data/local/pp %s %d", type.toString(), port);
+		String command = String.format("/data/local/bind %s %d", type.toString(), port);
 		try {
 			Process p = new ProcessBuilder("su", "-c", command).start();
 			if (p.waitFor() != 0) {