tuwien.auto.calimero.knxnetip.util.CRI Maven / Gradle / Ivy
Show all versions of calimero-core Show documentation
/*
Calimero 2 - A library for KNX network access
Copyright (c) 2006, 2011 B. Malinowsky
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.
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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under terms
of your choice, provided that you also meet, for each linked independent
module, the terms and conditions of the license of that module. An
independent module is a module which is not derived from or based on
this library. If you modify this library, you may extend this exception
to your version of the library, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from your
version.
*/
package tuwien.auto.calimero.knxnetip.util;
import tuwien.auto.calimero.exception.KNXFormatException;
/**
* Immutable container for a connection request information (CRI).
*
* The CRI structure is used for the additional information in a connection request.
* It is built up of host protocol independent data and host protocol dependent data, both
* optional. Refer to the available subtypes for more specific type information.
*
* For now, a plain CRI is returned for management connections, since this connection type
* doesn't require any additional host protocol data.
*
* Factory methods are provided for creation of CRI objects.
*
* @author B. Malinowsky
* @see tuwien.auto.calimero.knxnetip.servicetype.ConnectRequest
*/
public class CRI extends CRBase
{
/**
* Creates a new CRI out of a byte array.
*
*
* @param data byte array containing a CRI structure
* @param offset start offset of CRI in data
* @throws KNXFormatException if no CRI found or invalid structure
*/
protected CRI(final byte[] data, final int offset) throws KNXFormatException
{
super(data, offset);
}
/**
* Creates a new CRI for the given connection type.
*
* The array of optionalData
is not copied for internal storage. No
* additional checks regarding content are done.
*
* @param connectionType connection type the CRI is used for (e.g. tunnel connection)
* @param optionalData byte array containing optional host protocol independent and
* dependent data, this information is located starting at offset 2 in the CRI
* structure, optionalData.length
< 254
*/
protected CRI(final int connectionType, final byte[] optionalData)
{
super(connectionType, optionalData);
}
/**
* Creates a new CRI out of a byte array.
*
* If possible, a matching, more specific, CRI subtype is returned. Note, that CRIs
* for specific communication types might expect certain characteristics on
* data
(regarding contained data).
*
* @param data byte array containing the CRI structure
* @param offset start offset of CRI in data
* @return the new CRI object
* @throws KNXFormatException if no CRI found or invalid structure
*/
public static CRI createRequest(final byte[] data, final int offset) throws KNXFormatException
{
return (CRI) create(true, data, offset);
}
/**
* Creates a CRI for the given connection type.
*
* If possible, a matching, more specific, CRI subtype is returned. Note, that CRIs
* for specific communication types might expect certain characteristics on
* optionalData
(regarding length and/or content).
*
* @param connectionType connection type this CRI is used for, e.g., a tunneling
* connection
* @param optionalData byte array containing optional host protocol independent and
* dependent data, this information is located starting at offset 2 in the CRI
* structure, optionalData.length
< 254, may be null
* for no optional data
* @return the new CRI object
*/
public static CRI createRequest(final int connectionType, final byte[] optionalData)
{
return (CRI) create(true, connectionType, optionalData);
}
}