diff options
Diffstat (limited to 'MetisForwarderAndroid')
63 files changed, 2118 insertions, 0 deletions
diff --git a/MetisForwarderAndroid/.gitignore b/MetisForwarderAndroid/.gitignore new file mode 100644 index 00000000..39fb081a --- /dev/null +++ b/MetisForwarderAndroid/.gitignore @@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/MetisForwarderAndroid/app/.gitignore b/MetisForwarderAndroid/app/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/MetisForwarderAndroid/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/MetisForwarderAndroid/app/CMakeLists.txt b/MetisForwarderAndroid/app/CMakeLists.txt new file mode 100644 index 00000000..dfe35997 --- /dev/null +++ b/MetisForwarderAndroid/app/CMakeLists.txt @@ -0,0 +1,75 @@ +# For more information about using CMake with Android Studio, read the +# documentation: https://d.android.com/studio/projects/add-native-code.html + +# Sets the minimum version of CMake required to build the native library. + +cmake_minimum_required(VERSION 3.4.1) + + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") +set_property(GLOBAL PROPERTY USE_FOLDERS ON) +set(CMAKE_FIND_ROOT_PATH "$ENV{DISTILLERY_ROOT_DIR}/usr_${CMAKE_SYSTEM_PROCESSOR};${CMAKE_FIND_ROOT_PATH}") + +# Creates and names a library, sets it as either STATIC +# or SHARED, and provides the relative paths to its source code. +# You can define multiple libraries, and CMake builds them for you. +# Gradle automatically packages shared libraries with your APK. + +find_package( LongBow REQUIRED ) +include_directories(${LONGBOW_INCLUDE_DIRS}) + +find_package( LibEvent REQUIRED ) +include_directories(${LIBEVENT_INCLUDE_DIRS}) + +find_package( Libparc REQUIRED ) +include_directories(${LIBPARC_INCLUDE_DIRS}) + +find_package( CCNX_Common REQUIRED ) +include_directories(${CCNX_COMMON_INCLUDE_DIRS}) + +find_package( CCNX_Transport_Rta REQUIRED ) +include_directories(${CCNX_TRANSPORT_RTA_INCLUDE_DIRS}) + +find_package( CCNX_Portal REQUIRED ) +include_directories(${CCNX_PORTAL_INCLUDE_DIRS}) + +find_package ( Threads REQUIRED ) + +find_package ( OpenSSL REQUIRED ) +find_package( Doxygen ) + +find_package( Metis REQUIRED) +include_directories(${Metis_INCLUDE_DIRS}) + +add_library( # Sets the name of the library. + forwarderWrap + + # Sets the library as a shared library. + SHARED + + # Provides a relative path to your source file(s). + src/main/jni/forwarderWrap.c) + +# Searches for a specified prebuilt library and stores the path as a +# variable. Because CMake includes system libraries in the search path by +# default, you only need to specify the name of the public NDK library +# you want to add. CMake verifies that the library exists before +# completing its build. + +find_library( # Sets the name of the path variable. + log-lib + + # Specifies the name of the NDK library that + # you want CMake to locate. + log ) + +# Specifies libraries CMake should link to your target library. You +# can link multiple libraries, such as libraries you define in this +# build script, prebuilt third-party libraries, or system libraries. + +target_link_libraries( # Specifies the target library. + forwarderWrap + + # Links the target library to the log library + # included in the NDK. + ${log-lib} ${LIBMETIS_LIBRARIES} ${CCNX_PORTAL_LIBRARIES} ${CCNX_TRANSPORT_RTA_LIBRARIES} ${CCNX_COMMON_LIBRARIES} ${LIBPARC_LIBRARIES} ${LONGBOW_LIBRARIES} ${LIBEVENT_LIBRARIES} ${OPENSSL_LIBRARIES})
\ No newline at end of file diff --git a/MetisForwarderAndroid/app/build.gradle b/MetisForwarderAndroid/app/build.gradle new file mode 100644 index 00000000..3d5d0915 --- /dev/null +++ b/MetisForwarderAndroid/app/build.gradle @@ -0,0 +1,70 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "icn.forwarder.com.icnforwarderandroid" + minSdkVersion 24 + targetSdkVersion 26 + versionCode 8 + + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + externalNativeBuild { + cmake { + cppFlags "-std=c++11 -frtti -fexceptions" + } + } + ndk { + // Specifies the ABI configurations of your native + // libraries Gradle should build and package with your APK. + abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' + } + } + + signingConfigs { + release { + storeFile file("metis.keystore") + storePassword "metisandroid" + keyAlias "metis" + keyPassword "metisandroid" + } + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + + android.applicationVariants.all { variant -> + variant.outputs.all { output -> + def outputFile = output.outputFile + if (outputFile != null && outputFile.name.endsWith('.apk')) { + project.ext { appName = 'metis' } + def fileName = outputFile.name.replace("app", + "$project.ext.appName") + outputFileName = fileName + + } + + } + } + + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'com.android.support:appcompat-v7:26.1.0' + implementation 'com.android.support.constraint:constraint-layout:1.0.2' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.1' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' +} diff --git a/MetisForwarderAndroid/app/cmake/Modules/FindCCNX_Common.cmake b/MetisForwarderAndroid/app/cmake/Modules/FindCCNX_Common.cmake new file mode 100644 index 00000000..2629c160 --- /dev/null +++ b/MetisForwarderAndroid/app/cmake/Modules/FindCCNX_Common.cmake @@ -0,0 +1,39 @@ +######################################## +# +# Find the Libparc libraries and includes +# This module sets: +# CCNX_COMMON_FOUND: True if Libparc was found +# CCNX_COMMON_LIBRARY: The Libparc library +# CCNX_COMMON_LIBRARIES: The Libparc library and dependencies +# CCNX_COMMON_INCLUDE_DIR: The Libparc include dir +# + +set(CCNX_COMMON_SEARCH_PATH_LIST + ${CCNX_COMMON_HOME} + $ENV{CCNX_COMMON_HOME} + $ENV{CCNX_HOME} + $ENV{PARC_HOME} + $ENV{FOUNDATION_HOME} + /usr/local/parc + /usr/local/ccnx + /usr/local/ccn + /usr/local + /opt + /usr + ) + +find_path(CCNX_COMMON_INCLUDE_DIR ccnx/common/libccnxCommon_About.h + HINTS ${CCNX_COMMON_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the Libccnx-common includes" ) + +find_library(CCNX_COMMON_LIBRARY NAMES ccnx_common + HINTS ${CCNX_COMMON_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the Libccnx-common libraries" ) + +set(CCNX_COMMON_LIBRARIES ${CCNX_COMMON_LIBRARY}) +set(CCNX_COMMON_INCLUDE_DIRS ${CCNX_COMMON_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(CCNX_Common DEFAULT_MSG CCNX_COMMON_LIBRARY CCNX_COMMON_INCLUDE_DIR) diff --git a/MetisForwarderAndroid/app/cmake/Modules/FindCCNX_Portal.cmake b/MetisForwarderAndroid/app/cmake/Modules/FindCCNX_Portal.cmake new file mode 100644 index 00000000..68384bab --- /dev/null +++ b/MetisForwarderAndroid/app/cmake/Modules/FindCCNX_Portal.cmake @@ -0,0 +1,40 @@ +######################################## +# +# Find the Libccnx-transport libraries and includes +# This module sets: +# CCNX_PORTAL_FOUND: True if Libparc was found +# CCNX_PORTAL_LIBRARY: The Libparc library +# CCNX_PORTAL_LIBRARIES: The Libparc library and dependencies +# CCNX_PORTAL_INCLUDE_DIR: The Libparc include dir +# + +set(CCNX_PORTAL_SEARCH_PATH_LIST + ${CCNX_PORTAL_HOME} + $ENV{CCNX_PORTAL_HOME} + $ENV{CCNX_HOME} + $ENV{PARC_HOME} + $ENV{FOUNDATION_HOME} + /usr/local/parc + /usr/local/ccnx + /usr/local/ccn + /usr/local + /opt + /usr + ) + +find_path(CCNX_PORTAL_INCLUDE_DIR ccnx/api/ccnx_Portal/ccnxPortal_About.h + HINTS ${CCNX_PORTAL_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the Libccnx-portal includes" ) + +find_library(CCNX_PORTAL_LIBRARY NAMES ccnx_api_portal + HINTS ${CCNX_PORTAL_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the Libccnx-portal libraries" ) + +set(CCNX_PORTAL_LIBRARIES ${CCNX_PORTAL_LIBRARY}) + +set(CCNX_PORTAL_INCLUDE_DIRS ${CCNX_PORTAL_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(CCNX_Portal DEFAULT_MSG CCNX_PORTAL_LIBRARY CCNX_PORTAL_INCLUDE_DIR) diff --git a/MetisForwarderAndroid/app/cmake/Modules/FindCCNX_Transport_Rta.cmake b/MetisForwarderAndroid/app/cmake/Modules/FindCCNX_Transport_Rta.cmake new file mode 100644 index 00000000..c43436d1 --- /dev/null +++ b/MetisForwarderAndroid/app/cmake/Modules/FindCCNX_Transport_Rta.cmake @@ -0,0 +1,50 @@ +######################################## +# +# Find the Libccnx-transport libraries and includes +# This module sets: +# CCNX_TRANSPORT_RTA_FOUND: True if Libparc was found +# CCNX_TRANSPORT_RTA_LIBRARY: The Libparc library +# CCNX_TRANSPORT_RTA_LIBRARIES: The Libparc library and dependencies +# CCNX_TRANSPORT_RTA_INCLUDE_DIR: The Libparc include dir +# + +set(CCNX_TRANSPORT_RTA_SEARCH_PATH_LIST + ${CCNX_TRANSPORT_RTA_HOME} + $ENV{CCNX_TRANSPORT_RTA_HOME} + $ENV{CCNX_HOME} + $ENV{PARC_HOME} + $ENV{FOUNDATION_HOME} + /usr/local/parc + /usr/local/ccnx + /usr/local/ccn + /usr/local + /opt + /usr + ) + +find_path(CCNX_TRANSPORT_RTA_INCLUDE_DIR ccnx/transport/librta_About.h + HINTS ${CCNX_TRANSPORT_RTA_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the Libccnx-transport-rta includes" ) + +find_library(CCNX_TRANSPORT_RTA_LIBRARY NAMES ccnx_transport_rta + HINTS ${CCNX_TRANSPORT_RTA_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the Libccnx-transport-rta libraries" ) + +find_library(CCNX_API_NOTIFY_LIBRARY NAMES ccnx_api_notify + HINTS ${CCNX_TRANSPORT_RTA_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the Libccnx-transport-rta libraries" ) + +find_library(CCNX_API_CONTROL_LIBRARY NAMES ccnx_api_control + HINTS ${CCNX_TRANSPORT_RTA_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the Libccnx-transport-rta libraries" ) + +set(CCNX_TRANSPORT_RTA_LIBRARIES ${CCNX_TRANSPORT_RTA_LIBRARY} ${CCNX_API_CONTROL_LIBRARY} ${CCNX_API_NOTIFY_LIBRARY}) + +set(CCNX_TRANSPORT_RTA_INCLUDE_DIRS ${CCNX_TRANSPORT_RTA_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(CCNX_Transport_Api DEFAULT_MSG CCNX_TRANSPORT_RTA_LIBRARY CCNX_TRANSPORT_RTA_INCLUDE_DIR) diff --git a/MetisForwarderAndroid/app/cmake/Modules/FindLibEvent.cmake b/MetisForwarderAndroid/app/cmake/Modules/FindLibEvent.cmake new file mode 100644 index 00000000..2d1ca4fe --- /dev/null +++ b/MetisForwarderAndroid/app/cmake/Modules/FindLibEvent.cmake @@ -0,0 +1,47 @@ +######################################## +# +# Find the LibEvent libraries and includes +# This module sets: +# LIBEVENT_FOUND: True if LibEvent was found +# LIBEVENT_LIBRARY: The LibEvent library +# LIBEVENT_LIBRARIES: The LibEvent library and dependencies +# LIBEVENT_INCLUDE_DIR: The LibEvent include dir +# +# This module will look for the libraries in various locations +# See the LIBEVENT_SEARCH_PATH_LIST for a full list. +# +# The caller can hint at locations using the following variables: +# +# LIBEVENT_HOME (passed as -D to cmake) +# CCNX_DEPENDENCIES (in environment) +# LIBEVENT_HOME (in environment) +# CCNX_HOME (in environment) +# + +set(LIBEVENT_SEARCH_PATH_LIST + ${LIBEVENT_HOME} + $ENV{CCNX_DEPENDENCIES} + $ENV{LIBEVENT_HOME} + $ENV{CCNX_HOME} + /usr/local/ccnx + /usr/local/ccn + /usr/local + /opt + /usr + ) + +find_path(LIBEVENT_INCLUDE_DIR event2/event.h + HINTS ${LIBEVENT_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the LibEvent includes" ) + +find_library(LIBEVENT_LIBRARY NAMES event + HINTS ${LIBEVENT_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the LibEvent libraries" ) + +set(LIBEVENT_LIBRARIES ${LIBEVENT_LIBRARY}) +set(LIBEVENT_INCLUDE_DIRS ${LIBEVENT_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LibEvent DEFAULT_MSG LIBEVENT_LIBRARY LIBEVENT_INCLUDE_DIR) diff --git a/MetisForwarderAndroid/app/cmake/Modules/FindLibicnet.cmake b/MetisForwarderAndroid/app/cmake/Modules/FindLibicnet.cmake new file mode 100644 index 00000000..4472060b --- /dev/null +++ b/MetisForwarderAndroid/app/cmake/Modules/FindLibicnet.cmake @@ -0,0 +1,39 @@ +######################################## +# +# Find the Libparc libraries and includes +# This module sets: +# LIBICNET_FOUND: True if Libconsumer-producer was found +# LIBICNETR_LIBRARY: The Libconsumer-producer library +# LIBICNET_LIBRARIES: The Libconsumer-producer library and dependencies +# LIBICNET_INCLUDE_DIR: The Libconsumer-producer include dir +# + +set(LIBICNET_SEARCH_PATH_LIST + ${LIBICNET_HOME} + $ENV{LIBICNETHOME} + $ENV{CCNX_HOME} + $ENV{PARC_HOME} + $ENV{FOUNDATION_HOME} + /usr/local/parc + /usr/local/ccnx + /usr/local/ccn + /usr/local + /opt + /usr + ) + +find_path(LIBICNET_INCLUDE_DIR icnet/icnet_transport_common.h + HINTS ${LIBICNET_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the libicnet includes") + +find_library(LIBICNET_LIBRARY NAMES icnet + HINTS ${LIBICNET_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the libicnet libraries") +message("---->${LIBICNET_LIBRARY} ${LIBICNET_INCLUDE_DIR}") +set(LIBICNET_LIBRARIES ${LIBICNET_LIBRARY}) +set(LIBICNET_INCLUDE_DIRS ${LIBICNET_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Libicnet DEFAULT_MSG LIBICNET_LIBRARY LIBICNET_INCLUDE_DIR)
\ No newline at end of file diff --git a/MetisForwarderAndroid/app/cmake/Modules/FindLibparc.cmake b/MetisForwarderAndroid/app/cmake/Modules/FindLibparc.cmake new file mode 100644 index 00000000..02835161 --- /dev/null +++ b/MetisForwarderAndroid/app/cmake/Modules/FindLibparc.cmake @@ -0,0 +1,39 @@ +######################################## +# +# Find the Libparc libraries and includes +# This module sets: +# LIBPARC_FOUND: True if Libparc was found +# LIBPARC_LIBRARY: The Libparc library +# LIBPARC_LIBRARIES: The Libparc library and dependencies +# LIBPARC_INCLUDE_DIR: The Libparc include dir +# + +set(LIBPARC_SEARCH_PATH_LIST + ${LIBPARC_HOME} + $ENV{LIBPARC_HOME} + $ENV{CCNX_HOME} + $ENV{PARC_HOME} + $ENV{FOUNDATION_HOME} + /usr/local/parc + /usr/local/ccnx + /usr/local/ccn + /usr/local + /opt + /usr + ) + +find_path(LIBPARC_INCLUDE_DIR parc/libparc_About.h + HINTS ${LIBPARC_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the Libparc includes" ) + +find_library(LIBPARC_LIBRARY NAMES parc + HINTS ${LIBPARC_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the Libparc libraries" ) + +set(LIBPARC_LIBRARIES ${LIBPARC_LIBRARY}) +set(LIBPARC_INCLUDE_DIRS ${LIBPARC_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Libparc DEFAULT_MSG LIBPARC_LIBRARY LIBPARC_INCLUDE_DIR) diff --git a/MetisForwarderAndroid/app/cmake/Modules/FindLongBow.cmake b/MetisForwarderAndroid/app/cmake/Modules/FindLongBow.cmake new file mode 100644 index 00000000..e35888eb --- /dev/null +++ b/MetisForwarderAndroid/app/cmake/Modules/FindLongBow.cmake @@ -0,0 +1,44 @@ +######################################## +# +# Find the LongBow libraries and includes +# This module sets: +# LONGBOW_FOUND: True if LongBow was found +# LONGBOW_LIBRARY: The LongBow library +# LONGBOW_LIBRARIES: The LongBow library and dependencies +# LONGBOW_INCLUDE_DIR: The LongBow include dir +# + +set(LONGBOW_SEARCH_PATH_LIST + ${LONGBOW_HOME} + $ENV{LONGBOW_HOME} + $ENV{CCNX_HOME} + $ENV{PARC_HOME} + $ENV{FOUNDATION_HOME} + /usr/local/parc + /usr/local/ccnx + /usr/local/ccn + /usr/local + /opt + /usr + ) + +find_path(LONGBOW_INCLUDE_DIR LongBow/longBow_About.h + HINTS ${LONGBOW_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the LongBow includes" ) + +find_library(LONGBOW_LIBRARY NAMES longbow + HINTS ${LONGBOW_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the LongBow libraries" ) + +find_library(LONGBOW_REPORT_LIBRARY NAMES longbow-textplain longbow-ansiterm + HINTS ${LONGBOW_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the LongBow report libraries" ) + +set(LONGBOW_LIBRARIES ${LONGBOW_LIBRARY} ${LONGBOW_REPORT_LIBRARY}) +set(LONGBOW_INCLUDE_DIRS ${LONGBOW_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LongBow DEFAULT_MSG LONGBOW_LIBRARY LONGBOW_INCLUDE_DIR) diff --git a/MetisForwarderAndroid/app/cmake/Modules/FindMetis.cmake b/MetisForwarderAndroid/app/cmake/Modules/FindMetis.cmake new file mode 100644 index 00000000..a3b4bff1 --- /dev/null +++ b/MetisForwarderAndroid/app/cmake/Modules/FindMetis.cmake @@ -0,0 +1,41 @@ +######################################## +# +# Find the LibMetis libraries and includes +# This module sets: +# LIBMETIS_FOUND: True if Libmetis was found +# LIBMETIS_LIBRARY: The Libmetis library +# LIBMETIS_LIBRARIES: The Libmetis library and dependencies +# LIBMETIS_INCLUDE_DIR: The Libmetis include dir +# + +set(METIS_SEARCH_PATH_LIST + +${LIBMETISHOME} +$ENV{LIBMETISHOME} +$ENV{CCNX_HOME} +$ENV{FOUNDATION_HOME} +/usr/local/ +/usr/local/ccnx +/usr/local/ccn +/usr/local +/opt +/usr +) + + + +find_path(METIS_INCLUDE_DIR ccnx/forwarder/metis/metis_About.h +HINTS ${METIS_SEARCH_PATH_LIST} +PATH_SUFFIXES include +DOC "Find the libmetis includes") + +find_library(LIBMETIS_LIBRARY NAMES metis +HINTS ${LIBMETIS_SEARCH_PATH_LIST} +PATH_SUFFIXES lib +DOC "Find the libmetis libraries") + +set(LIBMETIS_LIBRARIES ${LIBMETIS_LIBRARY}) +set(LIBMETIS_INCLUDE_DIRS ${LIBMETIS_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Libmetis DEFAULT_MSG LIBMETIS_LIBRARY LIBMETIS_INCLUDE_DIR) diff --git a/MetisForwarderAndroid/app/cmake/Modules/FindUncrustify.cmake b/MetisForwarderAndroid/app/cmake/Modules/FindUncrustify.cmake new file mode 100644 index 00000000..e53f65fe --- /dev/null +++ b/MetisForwarderAndroid/app/cmake/Modules/FindUncrustify.cmake @@ -0,0 +1,8 @@ +# Find uncrustify program +# +find_program( UNCRUSTIFY_BIN uncrustify + PATHS + $ENV{UNCRUSTIFY_HOME} + ) + +message( "-- UNCRUSTIFY found in ${UNCRUSTIFY_BIN}" ) diff --git a/MetisForwarderAndroid/app/cmake/Modules/detectCacheSize.cmake b/MetisForwarderAndroid/app/cmake/Modules/detectCacheSize.cmake new file mode 100644 index 00000000..469d2627 --- /dev/null +++ b/MetisForwarderAndroid/app/cmake/Modules/detectCacheSize.cmake @@ -0,0 +1,21 @@ +# Detect the cache size +# +# XXX: TODO: This is a bug when cross compiling. We are detecting the local +# Cache Line size and not the target cache line size. We should provide some +# way to define this + +set(LEVEL1_DCACHE_LINESIZE 32) + +if( APPLE ) + execute_process(COMMAND sysctl -n hw.cachelinesize + OUTPUT_VARIABLE LEVEL1_DCACHE_LINESIZE + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif( APPLE ) + +if( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" ) + execute_process(COMMAND getconf LEVEL1_DCACHE_LINESIZE + OUTPUT_VARIABLE LEVEL1_DCACHE_LINESIZE + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() + +message("-- Cache line size: ${LEVEL1_DCACHE_LINESIZE}") diff --git a/MetisForwarderAndroid/app/cmake/Modules/version.cmake b/MetisForwarderAndroid/app/cmake/Modules/version.cmake new file mode 100644 index 00000000..74831674 --- /dev/null +++ b/MetisForwarderAndroid/app/cmake/Modules/version.cmake @@ -0,0 +1,15 @@ +# +# Get a version to pass on the command line +# +execute_process(COMMAND ${PROJECT_SOURCE_DIR}/cmake/get_version.sh ${PROJECT_SOURCE_DIR} + OUTPUT_VARIABLE RELEASE_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) + +execute_process(COMMAND date -u +%Y-%m-%dT%H:%M:%SZ + OUTPUT_VARIABLE ISO_DATE + OUTPUT_STRIP_TRAILING_WHITESPACE) + +MESSAGE( STATUS "Configuring version ${RELEASE_VERSION}" ) + +add_definitions("-DRELEASE_VERSION=\"${RELEASE_VERSION}\"") + diff --git a/MetisForwarderAndroid/app/cmake/get_version.sh b/MetisForwarderAndroid/app/cmake/get_version.sh new file mode 100755 index 00000000..34c6ddb2 --- /dev/null +++ b/MetisForwarderAndroid/app/cmake/get_version.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +DATE_VERSION=`date "+%Y%m%d"` + +if [ ! -d $1 ]; then + echo 0.$DATE_VERSION + exit +fi + +if [ -f $1/BASE_VERSION ]; then + BASE_VERSION=`cat $1/BASE_VERSION`. +fi + +GIT=`which git` + +if test -x $GIT -a -f $1/.git/config; then + GIT_VERSION=.`git -C $1 rev-parse HEAD | cut -c 1-8` +fi + +echo $BASE_VERSION$DATE_VERSION$GIT_VERSION diff --git a/MetisForwarderAndroid/app/metis.keystore b/MetisForwarderAndroid/app/metis.keystore Binary files differnew file mode 100644 index 00000000..3cfa9030 --- /dev/null +++ b/MetisForwarderAndroid/app/metis.keystore diff --git a/MetisForwarderAndroid/app/proguard-rules.pro b/MetisForwarderAndroid/app/proguard-rules.pro new file mode 100644 index 00000000..f1b42451 --- /dev/null +++ b/MetisForwarderAndroid/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/MetisForwarderAndroid/app/src/androidTest/java/icn/forwarder/com/forwarderandroid/ExampleInstrumentedTest.java b/MetisForwarderAndroid/app/src/androidTest/java/icn/forwarder/com/forwarderandroid/ExampleInstrumentedTest.java new file mode 100644 index 00000000..6304d1b2 --- /dev/null +++ b/MetisForwarderAndroid/app/src/androidTest/java/icn/forwarder/com/forwarderandroid/ExampleInstrumentedTest.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2018 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package icn.forwarder.com.forwarderandroid; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("icn.forwarder.com.forwarderandroid", appContext.getPackageName()); + } +} diff --git a/MetisForwarderAndroid/app/src/main/AndroidManifest.xml b/MetisForwarderAndroid/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..eec39eb7 --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/AndroidManifest.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="icn.forwarder.com.forwarderandroid"> + + <application + android:allowBackup="true" + android:configChanges="orientation|screenSize|keyboard" + android:icon="@mipmap/ic_launcher" + android:label="@string/app_name" + android:roundIcon="@mipmap/ic_launcher_round" + android:supportsRtl="true" + android:theme="@style/AppTheme"> + <activity + android:name=".ForwarderAndroidActivity" + android:screenOrientation="portrait"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + <service android:name="icn.forwarder.com.service.ForwarderAndroidService" /> + </application> + + <uses-permission android:name="android.permission.INTERNET" /> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> + <uses-permission + android:name="android.permission.READ_EXTERNAL_STORAGE" + android:maxSdkVersion="21" /> + +</manifest>
\ No newline at end of file diff --git a/MetisForwarderAndroid/app/src/main/ic_launcher-web.png b/MetisForwarderAndroid/app/src/main/ic_launcher-web.png Binary files differnew file mode 100644 index 00000000..1c610caf --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/ic_launcher-web.png diff --git a/MetisForwarderAndroid/app/src/main/java/icn/forwarder/com/forwarderandroid/ForwarderAndroidActivity.java b/MetisForwarderAndroid/app/src/main/java/icn/forwarder/com/forwarderandroid/ForwarderAndroidActivity.java new file mode 100644 index 00000000..d64e37cc --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/java/icn/forwarder/com/forwarderandroid/ForwarderAndroidActivity.java @@ -0,0 +1,241 @@ +/* + * Copyright (c) 2018 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package icn.forwarder.com.forwarderandroid; + +import android.Manifest; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.pm.PackageManager; +import android.content.res.Configuration; +import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.CompoundButton; +import android.widget.EditText; +import android.widget.Spinner; +import android.widget.Switch; + +import java.net.Inet4Address; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.SocketException; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; + +import icn.forwarder.com.supportlibrary.Forwarder; +import icn.forwarder.com.utility.Constants; +import icn.forwarder.com.utility.ResourcesEnumerator; + +public class ForwarderAndroidActivity extends AppCompatActivity { + + private Spinner sourceIpSpinner; + private EditText sourcePortEditText; + private EditText nextHopIpEditText; + private EditText nextHopPortEditText; + private EditText configurationEditText; + private EditText prefixEditText; + private Switch forwarderSwitch; + private Button sourceIpRefreshButton; + private List<String> sourceIpArrayList = new ArrayList<String>(); + private List<String> sourceNetworkInterfaceArrayList = new ArrayList<>(); + private HashMap<String, String> addressesMap = new HashMap<String, String>(); + private SharedPreferences sharedPreferences; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_forwarder_android); + checkEnabledPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE); + checkEnabledPermission(Manifest.permission.READ_EXTERNAL_STORAGE); + init(); + } + + public HashMap<String, String> getLocalIpAddress() { + HashMap<String, String> addressesMap = new HashMap<String, String>(); + try { + for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) { + NetworkInterface intf = en.nextElement(); + for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements(); ) { + InetAddress inetAddress = enumIpAddr.nextElement(); + if (!inetAddress.isLoopbackAddress() && inetAddress instanceof Inet4Address) { + String[] addressSplitted = inetAddress.getHostAddress().toString().split("%"); + //addressesMap.put(addressSplitted[1], addressSplitted[0]); + addressesMap.put(intf.getName(), addressSplitted[0]); + } + } + } + } catch (SocketException ex) { + String LOG_TAG = null; + Log.e(LOG_TAG, ex.toString()); + } + return addressesMap; + } + + private void checkEnabledPermission(String permission) { + if (ContextCompat.checkSelfPermission(this, + permission) + != PackageManager.PERMISSION_GRANTED) { + if (ActivityCompat.shouldShowRequestPermissionRationale(this, + permission)) { + } else { + ActivityCompat.requestPermissions(this, + new String[]{permission}, + 1); + } + } + } + + private void init() { + sourceIpSpinner = (Spinner) findViewById(R.id.sourceIpSpinner); + sharedPreferences = getSharedPreferences(Constants.FORWARDER_PREFERENCES, MODE_PRIVATE); + addressesMap = getLocalIpAddress(); + for (String networkInterface : addressesMap.keySet()) { + sourceIpArrayList.add(networkInterface + ": " + addressesMap.get(networkInterface)); + sourceNetworkInterfaceArrayList.add(networkInterface); + } + if (addressesMap.size() > 0) { + ArrayAdapter<String> sourceIpSpinnerArrayAdapter = new ArrayAdapter<String>(this, + android.R.layout.simple_spinner_item, sourceIpArrayList); + sourceIpSpinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + sourceIpSpinnerArrayAdapter.setDropDownViewResource(R.layout.spinner_layout); + sourceIpSpinner.setAdapter(sourceIpSpinnerArrayAdapter); + if (sourceNetworkInterfaceArrayList.indexOf(sharedPreferences.getString(ResourcesEnumerator.SOURCE_NETWORK_INTERFACE.key(), Constants.DEFAULT_SOURCE_INTERFACE)) > -1) { + sourceIpSpinner.setSelection(sourceNetworkInterfaceArrayList.indexOf(sharedPreferences.getString(ResourcesEnumerator.SOURCE_NETWORK_INTERFACE.key(), Constants.DEFAULT_SOURCE_INTERFACE))); + } else { + sourceIpSpinner.setSelection(0); + } + } + sourcePortEditText = (EditText) findViewById(R.id.sourcePortEditText); + sourcePortEditText.setText(sharedPreferences.getString(ResourcesEnumerator.SOURCE_PORT.key(), Constants.DEFAULT_SOURCE_PORT)); + sourceIpRefreshButton = (Button) findViewById(R.id.sourceIpRefreshButton); + sourceIpRefreshButton.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + addressesMap = getLocalIpAddress(); + sourceIpArrayList.clear(); + sourceNetworkInterfaceArrayList.clear(); + for (String networkInterface : addressesMap.keySet()) { + sourceIpArrayList.add(networkInterface + ": " + addressesMap.get(networkInterface)); + sourceNetworkInterfaceArrayList.add(networkInterface); + } + if (addressesMap.size() > 0) { + ArrayAdapter<String> sourceIpComboArrayAdapter = new ArrayAdapter<String>(v.getContext(), + android.R.layout.simple_spinner_item, sourceIpArrayList); + sourceIpComboArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + sourceIpComboArrayAdapter.setDropDownViewResource(R.layout.spinner_layout); + sourceIpSpinner.setAdapter(sourceIpComboArrayAdapter); + if (sourceNetworkInterfaceArrayList.indexOf(sharedPreferences.getString(ResourcesEnumerator.SOURCE_NETWORK_INTERFACE.key(), Constants.DEFAULT_SOURCE_INTERFACE)) > -1) { + sourceIpSpinner.setSelection(sourceNetworkInterfaceArrayList.indexOf(sharedPreferences.getString(ResourcesEnumerator.SOURCE_NETWORK_INTERFACE.key(), Constants.DEFAULT_SOURCE_INTERFACE))); + } else { + sourceIpSpinner.setSelection(0); + } + } + } + }); + nextHopIpEditText = (EditText) findViewById(R.id.nextHopIpEditText); + nextHopIpEditText.setText(sharedPreferences.getString(ResourcesEnumerator.NEXT_HOP_IP.key(), Constants.DEFAULT_NEXT_HOP_IP)); + nextHopPortEditText = (EditText) findViewById(R.id.nextHopPortEditText); + nextHopPortEditText.setText(sharedPreferences.getString(ResourcesEnumerator.NEXT_HOP_PORT.key(), Constants.DEFAULT_NEXT_HOP_PORT)); + + configurationEditText = (EditText) findViewById(R.id.configurationEditText); + configurationEditText.setText(sharedPreferences.getString(ResourcesEnumerator.CONFIGURATION.key(), Constants.DEFAULT_CONFIGURATION)); + prefixEditText = (EditText) findViewById(R.id.prefixEditText); + prefixEditText.setText(sharedPreferences.getString(ResourcesEnumerator.PREFIX.key(), Constants.DEFAULT_PREFIX)); + forwarderSwitch = (Switch) findViewById(R.id.forwarderSwitch); + + forwarderSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + Log.v("Switch State=", "" + isChecked); + if (isChecked) { + forwarderSwitch.setText(Constants.ENABLED); + SharedPreferences.Editor sharedPreferencesEditor = getSharedPreferences(Constants.FORWARDER_PREFERENCES, MODE_PRIVATE).edit(); + sharedPreferencesEditor.putString(ResourcesEnumerator.SOURCE_NETWORK_INTERFACE.key(), sourceNetworkInterfaceArrayList.get(sourceIpSpinner.getSelectedItemPosition())); + sharedPreferencesEditor.putString(ResourcesEnumerator.SOURCE_IP.key(), addressesMap.get(sourceNetworkInterfaceArrayList.get(sourceIpSpinner.getSelectedItemPosition()))); + sharedPreferencesEditor.putString(ResourcesEnumerator.SOURCE_PORT.key(), sourcePortEditText.getText().toString()); + sharedPreferencesEditor.putString(ResourcesEnumerator.NEXT_HOP_IP.key(), nextHopIpEditText.getText().toString()); + sharedPreferencesEditor.putString(ResourcesEnumerator.NEXT_HOP_PORT.key(), nextHopPortEditText.getText().toString()); + sharedPreferencesEditor.putString(ResourcesEnumerator.CONFIGURATION.key(), configurationEditText.getText().toString()); + sharedPreferencesEditor.putString(ResourcesEnumerator.PREFIX.key(), prefixEditText.getText().toString()); + sharedPreferencesEditor.commit(); + + + String configuration = configurationEditText.getText().toString(); + configuration = configuration.replace(Constants.SOURCE_IP, addressesMap.get(sourceNetworkInterfaceArrayList.get(sourceIpSpinner.getSelectedItemPosition()))); + configuration = configuration.replace(Constants.SOURCE_PORT, sourcePortEditText.getText().toString()); + configuration = configuration.replace(Constants.NEXT_HOP_IP, nextHopIpEditText.getText().toString()); + configuration = configuration.replace(Constants.NEXT_HOP_PORT, nextHopPortEditText.getText().toString()); + configuration = configuration.replace(Constants.PREFIX, prefixEditText.getText().toString()); + configurationEditText.setText(configuration); + sourceIpSpinner.setEnabled(false); + sourceIpRefreshButton.setEnabled(false); + sourcePortEditText.setEnabled(false); + nextHopIpEditText.setEnabled(false); + nextHopPortEditText.setEnabled(false); + prefixEditText.setEnabled(false); + configurationEditText.setEnabled(false); + startForwarder(); + + } else { + configurationEditText.setText(sharedPreferences.getString(ResourcesEnumerator.CONFIGURATION.key(), Constants.DEFAULT_CONFIGURATION)); + forwarderSwitch.setText(Constants.DISABLED); + sourceIpSpinner.setEnabled(true); + sourceIpRefreshButton.setEnabled(true); + sourcePortEditText.setEnabled(true); + nextHopIpEditText.setEnabled(true); + nextHopPortEditText.setEnabled(true); + prefixEditText.setEnabled(true); + configurationEditText.setEnabled(true); + stopForwarder(); + } + } + + }); + + if (Forwarder.getInstance().isRunning()) { + forwarderSwitch.setText(Constants.ENABLED); + forwarderSwitch.setChecked(true); + } else { + forwarderSwitch.setText(Constants.DISABLED); + } + } + + private void startForwarder() { + //Forwarder forwarder = Forwarder.getInstance(); + Intent intent = new Intent(this, icn.forwarder.com.service.ForwarderAndroidService.class); + startService(intent); + } + + private void stopForwarder() { + Intent intent = new Intent(this, icn.forwarder.com.service.ForwarderAndroidService.class); + stopService(intent); + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + } +} diff --git a/MetisForwarderAndroid/app/src/main/java/icn/forwarder/com/service/ForwarderAndroidService.java b/MetisForwarderAndroid/app/src/main/java/icn/forwarder/com/service/ForwarderAndroidService.java new file mode 100644 index 00000000..95668a08 --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/java/icn/forwarder/com/service/ForwarderAndroidService.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2018 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package icn.forwarder.com.service; + +import android.app.Notification; +import android.app.NotificationChannel; +import android.app.NotificationManager; +import android.app.PendingIntent; +import android.app.Service; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.pm.PackageManager; +import android.os.Build; +import android.os.IBinder; +import android.util.Log; +import android.widget.EditText; + + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.Writer; + +import icn.forwarder.com.forwarderandroid.ForwarderAndroidActivity; +import icn.forwarder.com.supportlibrary.Forwarder; +import icn.forwarder.com.utility.Constants; +import icn.forwarder.com.utility.ResourcesEnumerator; + +public class ForwarderAndroidService extends Service { + private final static String TAG = "ForwarderService"; + + private static Thread sForwarderThread = null; + private EditText configurationEditText; + + public ForwarderAndroidService() { + } + + private String path; + + @Override + public IBinder onBind(Intent intent) { + return null; + } + + + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + + Forwarder forwarder = Forwarder.getInstance(); + if (!forwarder.isRunning()) { + Log.d(TAG, "Starting Forwarder"); + SharedPreferences sharedPreferences = getSharedPreferences(Constants.FORWARDER_PREFERENCES, MODE_PRIVATE); + String configuration = sharedPreferences.getString(ResourcesEnumerator.CONFIGURATION.key(), Constants.DEFAULT_CONFIGURATION); + String sourceIp = sharedPreferences.getString(ResourcesEnumerator.SOURCE_IP.key(), null); + String sourcePort = sharedPreferences.getString(ResourcesEnumerator.SOURCE_PORT.key(), null); + String nextHopIp = sharedPreferences.getString(ResourcesEnumerator.NEXT_HOP_IP.key(), null); + String nextHopPort = sharedPreferences.getString(ResourcesEnumerator.NEXT_HOP_PORT.key(), null); + String prefix = sharedPreferences.getString(ResourcesEnumerator.PREFIX.key(), null); + configuration = configuration.replace(Constants.SOURCE_IP, sourceIp); + configuration = configuration.replace(Constants.SOURCE_PORT, sourcePort); + configuration = configuration.replace(Constants.NEXT_HOP_IP, nextHopIp); + configuration = configuration.replace(Constants.NEXT_HOP_PORT, nextHopPort); + configuration = configuration.replace(Constants.PREFIX, prefix); + try { + String configurationDir = getPackageManager().getPackageInfo(getPackageName(), 0).applicationInfo.dataDir + + File.separator + Constants.CONFIGURATION_PATH; + File folder = new File(configurationDir); + if (!folder.exists()) { + folder.mkdirs(); + } + + writeToFile(configuration, configurationDir + File.separator + Constants.CONFIGURATION_FILE_NAME); + Log.d(TAG, configurationDir + File.separator + Constants.CONFIGURATION_FILE_NAME); + startForwarder(intent, configurationDir + File.separator + Constants.CONFIGURATION_FILE_NAME); + } catch (PackageManager.NameNotFoundException e) { + Log.w(TAG, "Error Package name not found ", e); + } + + + } else { + Log.d(TAG, "Forwarder already running."); + } + return Service.START_STICKY; + } + + + @Override + public void onDestroy() { + Forwarder forwarder = Forwarder.getInstance(); + Log.d(TAG, "Destroying Forwarder"); + if (forwarder.isRunning()) { + forwarder.stop(); + stopForeground(true); + } + super.onDestroy(); + } + + protected Runnable mForwarderRunner = new Runnable() { + + //private String path; + @Override + public void run() { + Forwarder forwarder = Forwarder.getInstance(); + forwarder.start(path); + } + + + }; + + private boolean writeToFile(String data, String path) { + Log.v(TAG, path + " " + data); + try (Writer writer = new BufferedWriter(new OutputStreamWriter( + new FileOutputStream(path), "utf-8"))) { + writer.write(data); + return true; + } catch (IOException e) { + Log.e(TAG, "File write failed: " + e.toString()); + return false; + } + } + + + private void startForwarder(Intent intent, String path) { + String NOTIFICATION_CHANNEL_ID = "12345"; + Notification.Builder notificationBuilder = null; + if (Build.VERSION.SDK_INT >= 26) { + notificationBuilder = + new Notification.Builder(this, NOTIFICATION_CHANNEL_ID); + } else { + notificationBuilder = new Notification.Builder(this); + } + + Intent notificationIntent = new Intent(this, ForwarderAndroidActivity.class); + PendingIntent activity = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); + + notificationBuilder.setContentTitle("ForwarderAndroid").setContentText("ForwarderAndroid").setOngoing(true).setContentIntent(activity); + Notification notification = notificationBuilder.build(); + + if (Build.VERSION.SDK_INT >= 26) { + NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, "ForwarderAndroid", NotificationManager.IMPORTANCE_DEFAULT); + channel.setDescription("ForwarderAndroid"); + NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + notificationManager.createNotificationChannel(channel); + + } + + startForeground(Constants.FOREGROUND_SERVICE, notification); + + + Forwarder forwarder = Forwarder.getInstance(); + if (!forwarder.isRunning()) { + this.path = path; + sForwarderThread = new Thread(mForwarderRunner, "ForwarderRunner"); + sForwarderThread.start(); + } + + + Log.e(TAG, "ForwarderAndroid starterd"); + + } +} diff --git a/MetisForwarderAndroid/app/src/main/java/icn/forwarder/com/supportlibrary/Forwarder.java b/MetisForwarderAndroid/app/src/main/java/icn/forwarder/com/supportlibrary/Forwarder.java new file mode 100644 index 00000000..117aa6de --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/java/icn/forwarder/com/supportlibrary/Forwarder.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2018 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package icn.forwarder.com.supportlibrary; + +public class Forwarder { + + private static Forwarder sInstance = null; + + static { + System.loadLibrary("forwarderWrap"); + } + + public static Forwarder getInstance() { + if (sInstance == null) { + sInstance = new Forwarder(); + } + return sInstance; + } + + private Forwarder() { + + } + + public native boolean isRunning(); + public native void start(String path); + public native void stop(); + +} diff --git a/MetisForwarderAndroid/app/src/main/java/icn/forwarder/com/utility/Constants.java b/MetisForwarderAndroid/app/src/main/java/icn/forwarder/com/utility/Constants.java new file mode 100644 index 00000000..abcfb70e --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/java/icn/forwarder/com/utility/Constants.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package icn.forwarder.com.utility; + +public class Constants { + public static final String DEFAULT_NEXT_HOP_IP = "137.194.54.121"; + public static final String DEFAULT_NEXT_HOP_PORT = "8080"; + public static final String DEFAULT_PREFIX = "ccnx:/systemx-cicn.enst.fr"; + public static final String ENABLED = "Enabled"; + public static final String DISABLED = "Disabled"; + public static final String FORWARDER_PREFERENCES = "forwarderPreferences"; + public static final String DEFAULT_SOURCE_INTERFACE = "eth0"; + public static final String DEFAULT_SOURCE_PORT = "1111"; + public static final String DEFAULT_CONFIGURATION = "add listener tcp local0 127.0.0.1 9695\n" + + "add listener udp remote0 %%source_ip%% %%source_port%%\n" + + "add connection udp conn0 %%next_hop_ip%% %%next_hop_port%% %%source_ip%% %%source_port%%\n" + + "add route conn0 %%prefix%% 1"; + public static final String SOURCE_IP = "%%source_ip%%"; + public static final String SOURCE_PORT = "%%source_port%%"; + public static final String NEXT_HOP_IP = "%%next_hop_ip%%"; + public static final String NEXT_HOP_PORT = "%%next_hop_port%%"; + public static final String PREFIX = "%%prefix%%"; + public static final String CONFIGURATION_PATH = "Configuration"; + public static final String CONFIGURATION_FILE_NAME = "forwarder.conf"; + public static final int FOREGROUND_SERVICE = 101; +} diff --git a/MetisForwarderAndroid/app/src/main/java/icn/forwarder/com/utility/ResourcesEnumerator.java b/MetisForwarderAndroid/app/src/main/java/icn/forwarder/com/utility/ResourcesEnumerator.java new file mode 100644 index 00000000..3d2409ea --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/java/icn/forwarder/com/utility/ResourcesEnumerator.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2018 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package icn.forwarder.com.utility; + +public enum ResourcesEnumerator { + SOURCE_IP("sourceIp"), + SOURCE_PORT("sourcePort"), + NEXT_HOP_IP("nextHopIp"), + NEXT_HOP_PORT("nextHopPort"), + CONFIGURATION("configuration"), + SOURCE_NETWORK_INTERFACE("sourceNetworkInterface"), + PREFIX("prefix"); + + private String key; + + ResourcesEnumerator(String key) { + this.key = key; + } + + public String key() { + return key; + } +} diff --git a/MetisForwarderAndroid/app/src/main/jni/forwarderWrap.c b/MetisForwarderAndroid/app/src/main/jni/forwarderWrap.c new file mode 100644 index 00000000..ab4de15e --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/jni/forwarderWrap.c @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2018 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <jni.h> +#include <unistd.h> +#include <stdio.h> +#include <android/log.h> +#include <stdbool.h> +#include <ccnx/forwarder/metis/core/metis_Forwarder.h> + +static bool _isRunning = false; +MetisForwarder *metis = NULL; + + +JNIEXPORT jboolean JNICALL +Java_icn_forwarder_com_supportlibrary_Forwarder_isRunning(JNIEnv *env, jobject instance) { + return _isRunning; +} + +JNIEXPORT void JNICALL +Java_icn_forwarder_com_supportlibrary_Forwarder_start(JNIEnv *env, jobject instance, + jstring path_) { + if (!_isRunning) { + __android_log_print(ANDROID_LOG_DEBUG, "HicnFwdWrap", "starting HicnFwd..."); + metis = metisForwarder_Create(NULL); + MetisConfiguration *configuration = metisForwarder_GetConfiguration(metis); + metisConfiguration_SetObjectStoreSize(configuration, 0); + metisConfiguration_StartCLI(configuration, 2001); + if (path_) { + const char *configFileName = (*env)->GetStringUTFChars(env, path_, 0); + metisForwarder_SetupFromConfigFile(metis, configFileName); + } else { + metisForwarder_SetupAllListeners(metis, PORT_NUMBER, NULL); + } + MetisDispatcher *dispatcher = metisForwarder_GetDispatcher(metis); + _isRunning = true; + metisDispatcher_Run(dispatcher); + } +} + +JNIEXPORT void JNICALL +Java_icn_forwarder_com_supportlibrary_Forwarder_stop(JNIEnv *env, jobject instance) { + if (_isRunning) { + __android_log_print(ANDROID_LOG_DEBUG, "MetisForwarderWrap", "stopping Metis..."); + metisDispatcher_Stop(metisForwarder_GetDispatcher(metis)); + sleep(2); + metisForwarder_Destroy(&metis); + _isRunning = false; + } +} diff --git a/MetisForwarderAndroid/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/MetisForwarderAndroid/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 00000000..c7bd21db --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:aapt="http://schemas.android.com/aapt" + android:width="108dp" + android:height="108dp" + android:viewportHeight="108" + android:viewportWidth="108"> + <path + android:fillType="evenOdd" + android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z" + android:strokeColor="#00000000" + android:strokeWidth="1"> + <aapt:attr name="android:fillColor"> + <gradient + android:endX="78.5885" + android:endY="90.9159" + android:startX="48.7653" + android:startY="61.0927" + android:type="linear"> + <item + android:color="#44000000" + android:offset="0.0" /> + <item + android:color="#00000000" + android:offset="1.0" /> + </gradient> + </aapt:attr> + </path> + <path + android:fillColor="#FFFFFF" + android:fillType="nonZero" + android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z" + android:strokeColor="#00000000" + android:strokeWidth="1" /> +</vector> diff --git a/MetisForwarderAndroid/app/src/main/res/drawable/border.xml b/MetisForwarderAndroid/app/src/main/res/drawable/border.xml new file mode 100644 index 00000000..c1f839b3 --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/drawable/border.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<shape xmlns:android="http://schemas.android.com/apk/res/android"> + <stroke + android:width="1dp" + android:color="#000000" /> + <solid + android:color="#00FFFFFF" + android:paddingLeft="10dp" + android:paddingTop="10dp"/> + + <padding + android:left="10dp" + android:top="10dp" + android:right="10dp" + android:bottom="10dp" /> + <corners + android:bottomRightRadius="15dp" + android:bottomLeftRadius="15dp" + android:topLeftRadius="15dp" + android:topRightRadius="15dp"/> +</shape>
\ No newline at end of file diff --git a/MetisForwarderAndroid/app/src/main/res/drawable/ic_cached_black_24px.xml b/MetisForwarderAndroid/app/src/main/res/drawable/ic_cached_black_24px.xml new file mode 100644 index 00000000..5b228f76 --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/drawable/ic_cached_black_24px.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> + <path + android:pathData="M19,8l-4,4h3c0,3.31 -2.69,6 -6,6 -1.01,0 -1.97,-0.25 -2.8,-0.7l-1.46,1.46C8.97,19.54 10.43,20 12,20c4.42,0 8,-3.58 8,-8h3l-4,-4zM6,12c0,-3.31 2.69,-6 6,-6 1.01,0 1.97,0.25 2.8,0.7l1.46,-1.46C15.03,4.46 13.57,4 12,4c-4.42,0 -8,3.58 -8,8H1l4,4 4,-4H6z" + android:fillColor="#000000"/> +</vector> diff --git a/MetisForwarderAndroid/app/src/main/res/drawable/ic_launcher_background.xml b/MetisForwarderAndroid/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 00000000..d5fccc53 --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ +<?xml version="1.0" encoding="utf-8"?> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="108dp" + android:height="108dp" + android:viewportHeight="108" + android:viewportWidth="108"> + <path + android:fillColor="#26A69A" + android:pathData="M0,0h108v108h-108z" /> + <path + android:fillColor="#00000000" + android:pathData="M9,0L9,108" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M19,0L19,108" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M29,0L29,108" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M39,0L39,108" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M49,0L49,108" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M59,0L59,108" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M69,0L69,108" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M79,0L79,108" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M89,0L89,108" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M99,0L99,108" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M0,9L108,9" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M0,19L108,19" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M0,29L108,29" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M0,39L108,39" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M0,49L108,49" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M0,59L108,59" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M0,69L108,69" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M0,79L108,79" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M0,89L108,89" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M0,99L108,99" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M19,29L89,29" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M19,39L89,39" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M19,49L89,49" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M19,59L89,59" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M19,69L89,69" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M19,79L89,79" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M29,19L29,89" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M39,19L39,89" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M49,19L49,89" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M59,19L59,89" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M69,19L69,89" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> + <path + android:fillColor="#00000000" + android:pathData="M79,19L79,89" + android:strokeColor="#33FFFFFF" + android:strokeWidth="0.8" /> +</vector> diff --git a/MetisForwarderAndroid/app/src/main/res/ic_cached_black_24px.svg b/MetisForwarderAndroid/app/src/main/res/ic_cached_black_24px.svg new file mode 100644 index 00000000..b08e815e --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/ic_cached_black_24px.svg @@ -0,0 +1,4 @@ +<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"> + <path d="M19 8l-4 4h3c0 3.31-2.69 6-6 6-1.01 0-1.97-.25-2.8-.7l-1.46 1.46C8.97 19.54 10.43 20 12 20c4.42 0 8-3.58 8-8h3l-4-4zM6 12c0-3.31 2.69-6 6-6 1.01 0 1.97.25 2.8.7l1.46-1.46C15.03 4.46 13.57 4 12 4c-4.42 0-8 3.58-8 8H1l4 4 4-4H6z"/> + <path d="M0 0h24v24H0z" fill="none"/> +</svg>
\ No newline at end of file diff --git a/MetisForwarderAndroid/app/src/main/res/layout/activity_forwarder_android.xml b/MetisForwarderAndroid/app/src/main/res/layout/activity_forwarder_android.xml new file mode 100644 index 00000000..650a9571 --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/layout/activity_forwarder_android.xml @@ -0,0 +1,258 @@ +<?xml version="1.0" encoding="utf-8"?> +<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context="icn.forwarder.com.forwarderandroid.ForwarderAndroidActivity"> + + <ScrollView + android:layout_width="fill_parent" + android:layout_height="fill_parent"> + + <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintHorizontal_bias="0.099" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.029999971"> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <TextView + android:id="@+id/sourceTextView" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Source" + android:textSize="30sp" + android:textStyle="bold" /> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_weight="0.25" + android:orientation="horizontal"> + + <TextView + android:id="@+id/sourceIpTextView" + android:layout_width="0dip" + android:layout_height="wrap_content" + android:layout_weight="20" + android:text="IP" + android:textAlignment="textEnd" + android:textSize="24sp" + android:textStyle="bold" /> + <LinearLayout + android:layout_width="0dip" + android:layout_weight="80" + android:layout_height="wrap_content" + android:orientation="horizontal"> + <Spinner + android:id="@+id/sourceIpSpinner" + android:layout_width="0dip" + android:layout_weight="20" + android:layout_height="match_parent" + /> + + <Button + android:id="@+id/sourceIpRefreshButton" + android:layout_width="50sp" + android:layout_height="50sp" + android:drawableLeft="@drawable/ic_cached_black_24px" /> + </LinearLayout> + + + + </LinearLayout> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_weight="0.25" + android:orientation="horizontal"> + + <TextView + android:id="@+id/sourcePortTextView" + android:layout_width="0dip" + android:layout_height="wrap_content" + android:layout_weight="20" + android:text="Port" + android:textAlignment="textEnd" + android:textSize="24sp" + android:textStyle="bold" /> + + <EditText + android:id="@+id/sourcePortEditText" + android:layout_width="0dip" + android:layout_height="wrap_content" + android:layout_weight="80" + android:ems="10" + android:inputType="number" + android:text="88888" + android:textSize="24sp" /> + + </LinearLayout> + </LinearLayout> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <TextView + android:id="@+id/nextHopTextView" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Next Hop" + android:textSize="30sp" + android:textStyle="bold" /> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_weight="0.25" + android:orientation="horizontal"> + + <TextView + android:id="@+id/destinationIpTextView" + android:layout_width="0dip" + android:layout_height="wrap_content" + android:layout_weight="20" + android:text="IP" + android:textAlignment="textEnd" + android:textSize="24sp" + android:textStyle="bold" /> + + <EditText + android:id="@+id/nextHopIpEditText" + android:layout_width="0dip" + android:layout_height="wrap_content" + android:layout_weight="80" + android:ems="10" + android:inputType="textUri" + android:text="8888:8888:8888:8888:8888:8888:8888:8888" + android:textSize="24sp" /> + </LinearLayout> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_weight="0.25" + android:orientation="horizontal"> + + <TextView + android:id="@+id/nextHopPortTextView" + android:layout_width="0dip" + android:layout_height="wrap_content" + android:layout_weight="20" + android:text="Port" + android:textAlignment="textEnd" + android:textSize="24sp" + android:textStyle="bold" /> + + <EditText + android:id="@+id/nextHopPortEditText" + android:layout_width="0dip" + android:layout_height="wrap_content" + android:layout_weight="80" + android:ems="10" + android:inputType="number" + android:text="88888" + android:textSize="24sp" /> + + + </LinearLayout> + + </LinearLayout> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <TextView + android:id="@+id/routeTextView" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Route" + android:textSize="30sp" + android:textStyle="bold" /> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="0.25" + android:orientation="horizontal"> + + <TextView + android:id="@+id/prefixTextView" + android:layout_width="0dip" + android:layout_height="wrap_content" + android:layout_weight="20" + android:text="Prefix" + android:textAlignment="textEnd" + android:textSize="24sp" + android:textStyle="bold" /> + + <EditText + android:id="@+id/prefixEditText" + android:layout_width="0dip" + android:layout_height="wrap_content" + android:layout_weight="80" + android:ems="10" + android:inputType="textUri" + android:text="8888:8888:8888:8888:8888:8888:8888:8888" + android:textSize="24sp" /> + </LinearLayout> + </LinearLayout> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <TextView + android:id="@+id/configurationTextView" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Configuration" + android:textSize="30sp" + android:textStyle="bold" /> + + <ScrollView + android:layout_width="fill_parent" + android:layout_height="200dp" + android:background="@drawable/border"> + + <EditText + android:id="@+id/configurationEditText" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:background="@android:color/transparent" + android:ems="10" + android:inputType="textMultiLine" + android:text="# Local listeners add listener tcp local0 127.0.0.1 9695 add listener udp local1 127.0.0.1 9695 # Remote face add listener udp remote0 %%source_ip%% %%source_port%% add connection udp conn0 %%destination_ip%% %%destination_port%% %%source_ip%% %%source_port%% # Route add route conn0 ccnx:/webserver 1# Local listeners add listener tcp local0 127.0.0.1 9695 add listener udp local1 127.0.0.1 9695 # Remote face add listener udp remote0 %%source_ip%% %%source_port%% add connection udp conn0 %%destination_ip%% %%destination_port%% %%source_ip%% %%source_port%% # Route add route conn0 ccnx:/webserver 1# Local listeners add listener tcp local0 127.0.0.1 9695 add listener udp local1 127.0.0.1 9695 # Remote face add listener udp remote0 %%source_ip%% %%source_port%% add connection udp conn0 %%destination_ip%% %%destination_port%% %%source_ip%% %%source_port%% # Route add route conn0 ccnx:/webserver 1# Local listeners add listener tcp local0 127.0.0.1 9695 add listener udp local1 127.0.0.1 9695 # Remote face add listener udp remote0 %%source_ip%% %%source_port%% add connection udp conn0 %%destination_ip%% %%destination_port%% %%source_ip%% %%source_port%% # Route add route conn0 ccnx:/webserver 1# Local listeners add listener tcp local0 127.0.0.1 9695 add listener udp local1 127.0.0.1 9695 # Remote face add listener udp remote0 %%source_ip%% %%source_port%% add connection udp conn0 %%destination_ip%% %%destination_port%% %%source_ip%% %%source_port%% # Route add route conn0 ccnx:/webserver 1" + app:layout_constraintVertical_bias="0.33999997" /> + </ScrollView> + + </LinearLayout> + + <Switch + android:id="@+id/forwarderSwitch" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:text="Disabled" + android:textSize="30sp" /> + + </LinearLayout> + </ScrollView> + +</android.support.constraint.ConstraintLayout> diff --git a/MetisForwarderAndroid/app/src/main/res/layout/spinner_layout.xml b/MetisForwarderAndroid/app/src/main/res/layout/spinner_layout.xml new file mode 100644 index 00000000..c73af27b --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/layout/spinner_layout.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<TextView + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textSize="24sp" + android:padding="5dp" + />
\ No newline at end of file diff --git a/MetisForwarderAndroid/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/MetisForwarderAndroid/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 00000000..036d09bc --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@color/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon>
\ No newline at end of file diff --git a/MetisForwarderAndroid/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/MetisForwarderAndroid/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 00000000..036d09bc --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@color/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon>
\ No newline at end of file diff --git a/MetisForwarderAndroid/app/src/main/res/mipmap-hdpi/ic_launcher.png b/MetisForwarderAndroid/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differnew file mode 100644 index 00000000..6ab8b2c6 --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/MetisForwarderAndroid/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/MetisForwarderAndroid/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png Binary files differnew file mode 100644 index 00000000..2d97d2fb --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png diff --git a/MetisForwarderAndroid/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/MetisForwarderAndroid/app/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differnew file mode 100644 index 00000000..211f018d --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/mipmap-hdpi/ic_launcher_round.png diff --git a/MetisForwarderAndroid/app/src/main/res/mipmap-mdpi/ic_launcher.png b/MetisForwarderAndroid/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differnew file mode 100644 index 00000000..988a9675 --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/MetisForwarderAndroid/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/MetisForwarderAndroid/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png Binary files differnew file mode 100644 index 00000000..85c34503 --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png diff --git a/MetisForwarderAndroid/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/MetisForwarderAndroid/app/src/main/res/mipmap-mdpi/ic_launcher_round.png Binary files differnew file mode 100644 index 00000000..4dfe5d85 --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/mipmap-mdpi/ic_launcher_round.png diff --git a/MetisForwarderAndroid/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/MetisForwarderAndroid/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differnew file mode 100644 index 00000000..10c00a27 --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/MetisForwarderAndroid/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/MetisForwarderAndroid/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png Binary files differnew file mode 100644 index 00000000..32a5ec25 --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png diff --git a/MetisForwarderAndroid/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/MetisForwarderAndroid/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png Binary files differnew file mode 100644 index 00000000..7934e70a --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png diff --git a/MetisForwarderAndroid/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/MetisForwarderAndroid/app/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differnew file mode 100644 index 00000000..631943ce --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/MetisForwarderAndroid/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/MetisForwarderAndroid/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png Binary files differnew file mode 100644 index 00000000..67886e23 --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png diff --git a/MetisForwarderAndroid/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/MetisForwarderAndroid/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png Binary files differnew file mode 100644 index 00000000..c409ed28 --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png diff --git a/MetisForwarderAndroid/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/MetisForwarderAndroid/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png Binary files differnew file mode 100644 index 00000000..6c8a206f --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/MetisForwarderAndroid/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/MetisForwarderAndroid/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png Binary files differnew file mode 100644 index 00000000..aa3c8401 --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png diff --git a/MetisForwarderAndroid/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/MetisForwarderAndroid/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png Binary files differnew file mode 100644 index 00000000..69c50e4f --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png diff --git a/MetisForwarderAndroid/app/src/main/res/values/colors.xml b/MetisForwarderAndroid/app/src/main/res/values/colors.xml new file mode 100644 index 00000000..3ab3e9cb --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <color name="colorPrimary">#3F51B5</color> + <color name="colorPrimaryDark">#303F9F</color> + <color name="colorAccent">#FF4081</color> +</resources> diff --git a/MetisForwarderAndroid/app/src/main/res/values/ic_launcher_background.xml b/MetisForwarderAndroid/app/src/main/res/values/ic_launcher_background.xml new file mode 100644 index 00000000..fb66f3a0 --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <color name="ic_launcher_background">#FEFEFE</color> +</resources>
\ No newline at end of file diff --git a/MetisForwarderAndroid/app/src/main/res/values/strings.xml b/MetisForwarderAndroid/app/src/main/res/values/strings.xml new file mode 100644 index 00000000..85af98c2 --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ +<resources> + <string name="app_name">ICN Metis</string> +</resources> diff --git a/MetisForwarderAndroid/app/src/main/res/values/styles.xml b/MetisForwarderAndroid/app/src/main/res/values/styles.xml new file mode 100644 index 00000000..5885930d --- /dev/null +++ b/MetisForwarderAndroid/app/src/main/res/values/styles.xml @@ -0,0 +1,11 @@ +<resources> + + <!-- Base application theme. --> + <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> + <!-- Customize your theme here. --> + <item name="colorPrimary">@color/colorPrimary</item> + <item name="colorPrimaryDark">@color/colorPrimaryDark</item> + <item name="colorAccent">@color/colorAccent</item> + </style> + +</resources> diff --git a/MetisForwarderAndroid/app/src/test/java/icn/forwarder/com/forwarderandroid/ExampleUnitTest.java b/MetisForwarderAndroid/app/src/test/java/icn/forwarder/com/forwarderandroid/ExampleUnitTest.java new file mode 100644 index 00000000..01352cb3 --- /dev/null +++ b/MetisForwarderAndroid/app/src/test/java/icn/forwarder/com/forwarderandroid/ExampleUnitTest.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2018 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package icn.forwarder.com.forwarderandroid; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() throws Exception { + assertEquals(4, 2 + 2); + } +} diff --git a/MetisForwarderAndroid/build.gradle b/MetisForwarderAndroid/build.gradle new file mode 100644 index 00000000..e6b32bc7 --- /dev/null +++ b/MetisForwarderAndroid/build.gradle @@ -0,0 +1,27 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + + repositories { + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.0.1' + + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/MetisForwarderAndroid/gradle.properties b/MetisForwarderAndroid/gradle.properties new file mode 100644 index 00000000..aac7c9b4 --- /dev/null +++ b/MetisForwarderAndroid/gradle.properties @@ -0,0 +1,17 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true diff --git a/MetisForwarderAndroid/gradle/wrapper/gradle-wrapper.jar b/MetisForwarderAndroid/gradle/wrapper/gradle-wrapper.jar Binary files differnew file mode 100644 index 00000000..13372aef --- /dev/null +++ b/MetisForwarderAndroid/gradle/wrapper/gradle-wrapper.jar diff --git a/MetisForwarderAndroid/gradle/wrapper/gradle-wrapper.properties b/MetisForwarderAndroid/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..fcf4d03b --- /dev/null +++ b/MetisForwarderAndroid/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Dec 13 11:41:14 CET 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip diff --git a/MetisForwarderAndroid/gradlew b/MetisForwarderAndroid/gradlew new file mode 100755 index 00000000..9d82f789 --- /dev/null +++ b/MetisForwarderAndroid/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/MetisForwarderAndroid/gradlew.bat b/MetisForwarderAndroid/gradlew.bat new file mode 100644 index 00000000..aec99730 --- /dev/null +++ b/MetisForwarderAndroid/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/MetisForwarderAndroid/settings.gradle b/MetisForwarderAndroid/settings.gradle new file mode 100644 index 00000000..e7b4def4 --- /dev/null +++ b/MetisForwarderAndroid/settings.gradle @@ -0,0 +1 @@ +include ':app' |