android: Add measurement collector for Product Information
This commit is contained in:
@@ -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.Attribute;
|
||||||
import org.strongswan.android.logic.imc.attributes.AttributeType;
|
import org.strongswan.android.logic.imc.attributes.AttributeType;
|
||||||
import org.strongswan.android.logic.imc.collectors.Collector;
|
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 org.strongswan.android.logic.imc.collectors.StringVersionCollector;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -46,6 +47,9 @@ public class AndroidImc
|
|||||||
|
|
||||||
switch (attributeType)
|
switch (attributeType)
|
||||||
{
|
{
|
||||||
|
case IETF_PRODUCT_INFORMATION:
|
||||||
|
collector = new ProductInformationCollector();
|
||||||
|
break;
|
||||||
case IETF_STRING_VERSION:
|
case IETF_STRING_VERSION:
|
||||||
collector = new StringVersionCollector();
|
collector = new StringVersionCollector();
|
||||||
break;
|
break;
|
||||||
|
|||||||
+1
@@ -18,6 +18,7 @@ package org.strongswan.android.logic.imc.attributes;
|
|||||||
public enum PrivateEnterpriseNumber
|
public enum PrivateEnterpriseNumber
|
||||||
{
|
{
|
||||||
IETF(0x000000),
|
IETF(0x000000),
|
||||||
|
GOOGLE(0x002B79),
|
||||||
UNASSIGNED(0xfffffe),
|
UNASSIGNED(0xfffffe),
|
||||||
RESERVED(0xffffff);
|
RESERVED(0xffffff);
|
||||||
|
|
||||||
|
|||||||
+47
@@ -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 <http://www.fsf.org/copyleft/gpl.txt>.
|
||||||
|
*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
+30
@@ -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 <http://www.fsf.org/copyleft/gpl.txt>.
|
||||||
|
*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user