This patch series adds native Java API wrappers for current libopenconnect functions. The eventual goal is to be able to use libopenconnect in an Android VpnService based client app, so it's still a work in progress and there is much more left to be done. I'm posting this now to gather feedback and to compare notes with anyone else who has been working on similar projects. The "LibTest" command-line program is able to successfully complete authentication and obtain VPN cookies through JNI. My initial attempt was based on SWIG, but I quickly discovered that SWIG was only helpful for the "easy" APIs like openconnect_get_version(). In general the automated conversion tools don't seem to cope well with variations on string allocation (caller-allocated buffers, callee-allocated but caller-frees, etc.) and they have no idea what to do with the four callback functions or the auth form structs. I also ran into problems with function name translation (SWIG would either let me prune the openconnect_ prefix, or re-capitalize the names into camelcase, but not both). And I couldn't seem to convince it to treat vpninfo as an instance variable so that the callers wouldn't have to explicitly pass it into every function. It wouldn't be too surprising to find memory leaks in jni.c, especially in the error paths, as I'm not 100% positive on the rules for freeing strings and objects provided by the JVM. Also, this code hasn't been run under Android's CheckJNI yet. The following changes since commit 6fc3a31095d02d03334fde283696f981a452638e: Tag version 5.01 (2013-06-01 21:21:19 +0100) are available in the git repository at: git://github.com/cernekee/openconnect master for you to fetch changes up to fb93f05172b220ff8070d022bb003c7137d748b3: JNI: Add demo program to illustrate library usage (2013-08-04 18:19:07 -0700) ---------------------------------------------------------------- Kevin Cernekee (6): Remove declaration for nonexistent openconnect_get_vpn_name() gitignore: Use absolute path for openconnect JNI: Initial commit of C and Java sources acinclude: Add AX_JNI_INCLUDE_DIR macro buildsys: Add JNI to libopenconnect build JNI: Add demo program to illustrate library usage .gitignore | 2 +- Makefile.am | 5 + acinclude.m4 | 119 ++++ configure.ac | 25 + jni.c | 871 +++++++++++++++++++++++++ libopenconnect.map.in | 5 + openconnect.h | 1 - org/example/LibTest.java | 145 ++++ org/infradead/openconnect/LibOpenConnect.java | 201 ++++++ 9 files changed, 1372 insertions(+), 2 deletions(-) create mode 100644 jni.c create mode 100644 org/example/LibTest.java create mode 100644 org/infradead/openconnect/LibOpenConnect.java -- 1.7.9.5