Skip to content

Commit

Permalink
Android supported
Browse files Browse the repository at this point in the history
run succeed on android(arm-v7)
  • Loading branch information
olunx authored and olunx committed Feb 12, 2015
1 parent 423fb8c commit 1c5cc2b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@

#include <sys/time.h>
#include <netinet/in.h>
#ifndef __ANDROID__
#include <netinet/tcp.h>
#else
#include "tcp.h"
#endif
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
Expand Down
6 changes: 6 additions & 0 deletions src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
#include "log.h"
#include "utils.h"

#ifdef __ANDROID__
#include <android/log.h>
#define DEBUG(...) __android_log_print(ANDROID_LOG_DEBUG, "usbmuxd", __VA_ARGS__)
#endif

unsigned int log_level = LL_WARNING;

int log_syslog = 0;
Expand Down Expand Up @@ -89,6 +94,7 @@ void usbmuxd_log(enum loglevel level, const char *fmt, ...)
} else {
vfprintf(stderr, fs, ap);
}
DEBUG(fs, ap);
va_end(ap);

free(fs);
Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static void set_signal_handlers(void)
sigaction(SIGUSR2, &sa, NULL);
}

#if defined(__FreeBSD__) || defined(__APPLE__)
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__ANDROID__)
static int ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, const sigset_t *sigmask)
{
int ready;
Expand Down
36 changes: 36 additions & 0 deletions src/tcp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <endian.h>

typedef u_int32_t tcp_seq;

/*
* TCP header.
* Per RFC 793, September, 1981.
*/
struct tcphdr {
u_short th_sport; /* source port */
u_short th_dport; /* destination port */
tcp_seq th_seq; /* sequence number */
tcp_seq th_ack; /* acknowledgement number */
#if __BYTE_ORDER == __LITTLE_ENDIAN
u_int th_x2:4, /* (unused) */
th_off:4; /* data offset */
#endif
#if __BYTE_ORDER == __BIG_ENDIAN
u_int th_off:4, /* data offset */
th_x2:4; /* (unused) */
#endif
u_char th_flags;
#define TH_FIN 0x01
#define TH_SYN 0x02
#define TH_RST 0x04
#define TH_PUSH 0x08
#define TH_ACK 0x10
#define TH_URG 0x20
#define TH_ECE 0x40
#define TH_CWR 0x80
#define TH_FLAGS (TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG|TH_ECE|TH_CWR)

u_short th_win; /* window */
u_short th_sum; /* checksum */
u_short th_urp; /* urgent pointer */
};

0 comments on commit 1c5cc2b

Please sign in to comment.