From: Tobias Brunner Date: Fri, 26 Apr 2013 12:29:00 +0000 (+0200) Subject: android: Add measurement collector for Product Information X-Git-Tag: 5.1.0dr2~2^2~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d61172314b432be1c68d213dc666aacc5b6b386;p=thirdparty%2Fstrongswan.git android: Add measurement collector for Product Information --- diff --git a/src/frontends/android/src/org/strongswan/android/logic/imc/AndroidImc.java b/src/frontends/android/src/org/strongswan/android/logic/imc/AndroidImc.java index 2aec690138..828b99d6e6 100644 --- a/src/frontends/android/src/org/strongswan/android/logic/imc/AndroidImc.java +++ b/src/frontends/android/src/org/strongswan/android/logic/imc/AndroidImc.java @@ -18,6 +18,7 @@ package org.strongswan.android.logic.imc; import org.strongswan.android.logic.imc.attributes.Attribute; import org.strongswan.android.logic.imc.attributes.AttributeType; import org.strongswan.android.logic.imc.collectors.Collector; +import org.strongswan.android.logic.imc.collectors.ProductInformationCollector; import org.strongswan.android.logic.imc.collectors.StringVersionCollector; import android.content.Context; @@ -46,6 +47,9 @@ public class AndroidImc switch (attributeType) { + case IETF_PRODUCT_INFORMATION: + collector = new ProductInformationCollector(); + break; case IETF_STRING_VERSION: collector = new StringVersionCollector(); break; diff --git a/src/frontends/android/src/org/strongswan/android/logic/imc/attributes/PrivateEnterpriseNumber.java b/src/frontends/android/src/org/strongswan/android/logic/imc/attributes/PrivateEnterpriseNumber.java index f014d69a77..5af20a855b 100644 --- a/src/frontends/android/src/org/strongswan/android/logic/imc/attributes/PrivateEnterpriseNumber.java +++ b/src/frontends/android/src/org/strongswan/android/logic/imc/attributes/PrivateEnterpriseNumber.java @@ -18,6 +18,7 @@ package org.strongswan.android.logic.imc.attributes; public enum PrivateEnterpriseNumber { IETF(0x000000), + GOOGLE(0x002B79), UNASSIGNED(0xfffffe), RESERVED(0xffffff); diff --git a/src/frontends/android/src/org/strongswan/android/logic/imc/attributes/ProductInformationAttribute.java b/src/frontends/android/src/org/strongswan/android/logic/imc/attributes/ProductInformationAttribute.java new file mode 100644 index 0000000000..cace18d555 --- /dev/null +++ b/src/frontends/android/src/org/strongswan/android/logic/imc/attributes/ProductInformationAttribute.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2013 Tobias Brunner + * Copyright (C) 2012 Christoph Buehler + * Copyright (C) 2012 Patrick Loetscher + * Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +package org.strongswan.android.logic.imc.attributes; + +import org.strongswan.android.utils.BufferedByteWriter; + +/** + * PA-TNC Product Information attribute (see section 4.2.2 of RFC 5792) + * + * 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Product Vendor ID | Product ID | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Product ID | Product Name (Variable Length) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +public class ProductInformationAttribute implements Attribute +{ + private final String PRODUCT_NAME = "Android"; + private final short PRODUCT_ID = 0; + + @Override + public byte[] getEncoding() + { + BufferedByteWriter writer = new BufferedByteWriter(); + writer.put24(PrivateEnterpriseNumber.GOOGLE.getValue()); + writer.put16(PRODUCT_ID); + writer.put(PRODUCT_NAME.getBytes()); + return writer.toByteArray(); + } +} diff --git a/src/frontends/android/src/org/strongswan/android/logic/imc/collectors/ProductInformationCollector.java b/src/frontends/android/src/org/strongswan/android/logic/imc/collectors/ProductInformationCollector.java new file mode 100644 index 0000000000..c377e9041b --- /dev/null +++ b/src/frontends/android/src/org/strongswan/android/logic/imc/collectors/ProductInformationCollector.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2013 Tobias Brunner + * Copyright (C) 2012 Christoph Buehler + * Copyright (C) 2012 Patrick Loetscher + * Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +package org.strongswan.android.logic.imc.collectors; + +import org.strongswan.android.logic.imc.attributes.Attribute; +import org.strongswan.android.logic.imc.attributes.ProductInformationAttribute; + +public class ProductInformationCollector implements Collector +{ + @Override + public Attribute getMeasurement() + { /* this is currently hardcoded in the attribute */ + return new ProductInformationAttribute(); + } +}