From 5d308865d0783d0cd70f7453c77980835ac5648e Mon Sep 17 00:00:00 2001 From: Angelo Mantellini Date: Wed, 21 Mar 2018 14:16:02 +0100 Subject: update android-sdk. Now it is possible to compile with clang Change-Id: I156aa48dd90467a2a7540eec11839c0111b13bd2 Signed-off-by: Angelo Mantellini --- .../forwarderandroid/ForwarderAndroidActivity.java | 241 +++++++++++++++++++++ .../com/service/ForwarderAndroidService.java | 177 +++++++++++++++ .../forwarder/com/supportlibrary/Forwarder.java | 41 ++++ .../java/icn/forwarder/com/utility/Constants.java | 39 ++++ .../forwarder/com/utility/ResourcesEnumerator.java | 36 +++ 5 files changed, 534 insertions(+) create mode 100644 MetisForwarderAndroid/app/src/main/java/icn/forwarder/com/forwarderandroid/ForwarderAndroidActivity.java create mode 100644 MetisForwarderAndroid/app/src/main/java/icn/forwarder/com/service/ForwarderAndroidService.java create mode 100644 MetisForwarderAndroid/app/src/main/java/icn/forwarder/com/supportlibrary/Forwarder.java create mode 100644 MetisForwarderAndroid/app/src/main/java/icn/forwarder/com/utility/Constants.java create mode 100644 MetisForwarderAndroid/app/src/main/java/icn/forwarder/com/utility/ResourcesEnumerator.java (limited to 'MetisForwarderAndroid/app/src/main/java/icn/forwarder') 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 sourceIpArrayList = new ArrayList(); + private List sourceNetworkInterfaceArrayList = new ArrayList<>(); + private HashMap addressesMap = new HashMap(); + 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 getLocalIpAddress() { + HashMap addressesMap = new HashMap(); + try { + for (Enumeration en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) { + NetworkInterface intf = en.nextElement(); + for (Enumeration 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 sourceIpSpinnerArrayAdapter = new ArrayAdapter(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 sourceIpComboArrayAdapter = new ArrayAdapter(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; + } +} -- cgit 1.2.3-korg