Makefile: Add a rule to build TAGS.
Makefile: Use $(MAKE) rather than make.
ocproxy/Makefile: Cleanup.

Remove unnecessary header paths, libraries, etc.
ocproxy: Remove unnecessary LWIP components.
Makefile: Always link with libpthread.
Switch build system to GNU autotools

This provides a more familiar interface for users, and makes it easier
to create packages for distributions.  It also provides a number of useful
features for free, such as "make TAGS" / "make ctags" / "make dist".

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Move contrib/ports/unix/proj/ocproxy/ sources to src/

This makes it easier to update lwIP and to find our code.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
buildsys: Move LWIP_STATS_DISPLAY setting into our Makefile

This lets us use the stock <lwip/opt.h> as-is without making local
changes.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Delete the netmask and gateway options

These don't actually have an effect on VPN, because our "next hop" is
always the VPN gateway host, regardless of the destination IP, and we are
not using ARP.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
buildsys: Add "make update-lwip" target

This fetches the latest head of tree from the LWIP maintainers and
overwrites the contents of lwip/ and contrib/.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
lwip: Update to the latest upstream head of tree

This uses lwip.git rev e7f32240917cc912eb6e3e36780ecb3c4a06f264 and
lwip-contrib.git rev 36eab8918473ab575ed11c87cee33954a52e6a1d.  The
most recent release was 1.4.1 (Sept 2012) and a number of fixes have
been added since then.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Remove thread size definitions

We aren't using threads anymore so these should not matter.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
lwip: dns: Fix handling of dns_seqno wraparound

Upstream report: https://savannah.nongnu.org/patch/index.php?8480

lseq represents the number of DNS transactions that have occurred since
dns_table[lseqi] was started.  This should be a positive number.  But
gcc promotes (dns_seqno - pEntry->seqno) to a signed int, causing lseq
to be compared against negative values in some situations:

  dns_seqno = 1
  dns_table[0].seqno =   0, state = DNS_STATE_ASKING
  dns_table[1].seqno = 253, state = DNS_STATE_DONE
  dns_table[2].seqno = 254, state = DNS_STATE_DONE
  dns_table[3].seqno = 255, state = DNS_STATE_DONE

In this case, lseq == 0 and the function returns ERR_MEM, despite the
fact that entries 1..3 are available for reuse.

Fix this by explicitly casting the "age" result to a u8_t.
Fix error handling on DNS table full

This currently just hangs the connection (bad).  Let's make it abort
cleanly, and send an error indication on SOCKS.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
lwipopts: Minor cleanups

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
lwipopts: Increase DNS_TABLE_SIZE to 128

The default value is 4, which results in lots of bogus "invalid hostname"
errors (caused by ERR_MEM) when using ocproxy for general web surfing.
128 ought to be enough for anybody.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Bump up MAX_IOVEC and MAX_CONN again

These numbers are getting a little ridiculous, but we're hitting the
limits during normal web surfing (with many tabs open).  It looks like
FoxyProxy leaves multiple SOCKS connections open on each tab, even if
there are no active HTTP requests.

FWIW, each instance of Firefox appears to be capped at ~256 open
connections.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Show mem stats on SIGUSR1

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Track the current/max number of open connections

These can be displayed via "killall -USR1 ocproxy".

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Add CHANGES file

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>