├── .gitignore ├── README.md ├── pom.xml └── src ├── etc ├── license-header.txt └── license-tinyos.txt ├── main └── java │ └── de │ └── uniluebeck │ └── itm │ └── nettyprotocols │ ├── Base64DecoderFactory.java │ ├── Base64EncoderFactory.java │ ├── ChannelHandlerConfig.java │ ├── ChannelHandlerConfigList.java │ ├── CompatibleObjectDecoderFactory.java │ ├── CompatibleObjectEncoderFactory.java │ ├── DelimiterBasedFrameDecoderFactory.java │ ├── FixedLengthFrameDecoderFactory.java │ ├── HandlerFactory.java │ ├── HandlerFactoryMap.java │ ├── HandlerFactoryMapImpl.java │ ├── LengthFieldBasedFrameDecoderFactory.java │ ├── LengthFieldPrependerFactory.java │ ├── NamedChannelHandler.java │ ├── NamedChannelHandlerList.java │ ├── NettyProtocolsModule.java │ ├── NewlineDecoder.java │ ├── NewlineDecoderFactory.java │ ├── NewlineEncoder.java │ ├── NewlineEncoderFactory.java │ ├── ObjectDecoderFactory.java │ ├── ObjectEncoderFactory.java │ ├── StringDecoderFactory.java │ ├── StringEncoderFactory.java │ ├── ZlibDecoderFactory.java │ ├── ZlibEncoderFactory.java │ ├── contiki │ └── ContikiHandlerFactory.java │ ├── discard │ ├── DiscardHandler.java │ └── DiscardHandlerFactory.java │ ├── dlestxetx │ ├── DleStxEtxConstants.java │ ├── DleStxEtxFramingDecoder.java │ ├── DleStxEtxFramingDecoderFactory.java │ ├── DleStxEtxFramingEncoder.java │ ├── DleStxEtxFramingEncoderFactory.java │ └── DleStxEtxFramingFactory.java │ ├── isense │ ├── ISenseFactory.java │ ├── ISensePacket.java │ ├── ISensePacketDecoder.java │ ├── ISensePacketDecoderFactory.java │ ├── ISensePacketDownstreamDecoder.java │ ├── ISensePacketDownstreamDecoderFactory.java │ ├── ISensePacketEncoder.java │ ├── ISensePacketEncoderFactory.java │ ├── ISensePacketFactory.java │ ├── ISensePacketType.java │ ├── ISensePacketUpstreamEncoder.java │ ├── ISensePacketUpstreamEncoderFactory.java │ ├── iseraerial │ │ ├── ISerAerialConfirmPacket.java │ │ ├── ISerAerialIncomingPacket.java │ │ ├── ISerAerialOutgoingPacket.java │ │ ├── ISerAerialPacketDecoder.java │ │ ├── ISerAerialPacketDecoderFactory.java │ │ ├── ISerAerialPacketEncoder.java │ │ ├── ISerAerialPacketEncoderFactory.java │ │ ├── ISerAerialPacketFactory.java │ │ └── ISerAerialPacketSubType.java │ ├── ishellinterpreter │ │ ├── IShellInterpreterHandler.java │ │ ├── IShellInterpreterHandlerFactory.java │ │ ├── IShellInterpreterPacketTypes.java │ │ └── IShellInterpreterSetChannelMessage.java │ └── otap │ │ ├── ChipType.java │ │ ├── ISenseOtapAutomatedProgrammingHandler.java │ │ ├── ISenseOtapAutomatedProgrammingRequest.java │ │ ├── ISenseOtapAutomatedProgrammingRequestDownstreamDecoder.java │ │ ├── ISenseOtapAutomatedProgrammingRequestDownstreamEncoder.java │ │ ├── ISenseOtapChunk.java │ │ ├── ISenseOtapDevice.java │ │ ├── ISenseOtapFactory.java │ │ ├── ISenseOtapImage.java │ │ ├── ISenseOtapPacket.java │ │ ├── ISenseOtapPacketDecoder.java │ │ ├── ISenseOtapPacketDecoderSetAESKeyRequest.java │ │ ├── ISenseOtapPacketEncoder.java │ │ ├── ISenseOtapPacketEncoderSetAESKeyRequest.java │ │ ├── ISenseOtapPacketType.java │ │ ├── generatedmessages │ │ ├── MacroFabricSerializer.java │ │ ├── OtapInitReply.java │ │ ├── OtapInitRequest.java │ │ ├── OtapProgramReply.java │ │ ├── OtapProgramRequest.java │ │ ├── PresenceDetectReply.java │ │ └── PresenceDetectRequest.java │ │ ├── init │ │ ├── ISenseOtapInitHandler.java │ │ ├── ISenseOtapInitResult.java │ │ ├── ISenseOtapInitStartCommand.java │ │ └── ISenseOtapInitStopCommand.java │ │ ├── presencedetect │ │ ├── PresenceDetectControlStart.java │ │ ├── PresenceDetectControlStop.java │ │ ├── PresenceDetectHandler.java │ │ └── PresenceDetectStatus.java │ │ └── program │ │ ├── ISenseOtapProgramHandler.java │ │ ├── ISenseOtapProgramRequest.java │ │ ├── ISenseOtapProgramResult.java │ │ ├── ISenseOtapProgramResultUpstreamDecoder.java │ │ └── ISenseOtapProgramResultUpstreamEncoder.java │ ├── logging │ ├── LoggingHandler.java │ └── LoggingHandlerFactory.java │ ├── remoteuart │ ├── RUPFragment.java │ ├── RUPFragmentDecoder.java │ ├── RUPFragmentEncoder.java │ ├── RUPFragmentFactory.java │ ├── RUPFragmentImpl.java │ ├── RUPHelper.java │ ├── RUPPacket.java │ ├── RUPPacketDecoder.java │ ├── RUPPacketEncoder.java │ └── RUPPacketImpl.java │ ├── swap │ ├── SwapRequest.java │ ├── SwapRequestDecoder.java │ ├── SwapRequestEncoder.java │ ├── SwapResponse.java │ ├── SwapResponseDecoder.java │ ├── SwapResponseEncoder.java │ └── WiselibReturnValue.java │ ├── tinyos │ ├── HdlcTranslateConstants.java │ ├── HdlcTranslateDecoder.java │ ├── HdlcTranslateDecoderFactory.java │ ├── HdlcTranslateEncoder.java │ ├── HdlcTranslateEncoderFactory.java │ ├── HdlcTranslateFactory.java │ ├── TinyOsCrc.java │ ├── TinyOsFactory.java │ ├── TinyOsSerial.java │ ├── TinyOsSerialDecoder.java │ ├── TinyOsSerialDecoderFactory.java │ ├── TinyOsSerialEncoder.java │ ├── TinyOsSerialEncoderFactory.java │ └── TinyOsSerialFactory.java │ ├── tlspeerverification │ ├── Main.java │ ├── SecureChatKeyStore.java │ ├── TlsPeerVerificationHandler.java │ ├── TlsPeerVerificationKeyStore.java │ ├── TlsPeerVerificationSslContextFactory.java │ ├── TlsPeerVerificationTrustManager.java │ └── TlsPeerVerificationTrustManagerFactory.java │ ├── util │ ├── ChannelBufferTools.java │ ├── ConfirmPendingOrTimeoutHelper.java │ ├── DurationPlusUnit.java │ ├── HandlerFactoryPropertiesHelper.java │ ├── HandlerTools.java │ ├── HeaderAndJavaBeansXMLDecoderEncoder.java │ ├── HexStringIntegerMatcher.java │ ├── HexStringIntegerTransform.java │ ├── NettyStringUtils.java │ ├── OneToOneDownstreamDecoder.java │ ├── OneToOneUpstreamEncoder.java │ ├── PropertiesHelper.java │ └── StopAndWaitPacketSender.java │ └── wisebednodeapi │ ├── NodeAPIHandler.java │ └── packet │ ├── Command.java │ ├── CommandResponse.java │ ├── CommandType.java │ ├── Request.java │ ├── Response.java │ ├── TimeOutResponse.java │ ├── interaction │ ├── BinaryDataCommand.java │ ├── BinaryDataCommandResponse.java │ ├── BinaryDataRequest.java │ ├── BinaryDataResponse.java │ ├── BinaryMessageCommand.java │ ├── FlashProgramDataCommand.java │ ├── FlashProgramDataCommandResponse.java │ ├── FlashProgramDataRequest.java │ ├── FlashProgramDataResponse.java │ ├── FlashProgramMessageCommand.java │ ├── NodeOutputBinaryCommand.java │ ├── NodeOutputBinaryCommandResponse.java │ ├── NodeOutputBinaryRequest.java │ ├── NodeOutputBinaryResponse.java │ ├── NodeOutputTextCommand.java │ ├── NodeOutputTextCommandResponse.java │ ├── NodeOutputTextRequest.java │ ├── NodeOutputTextResponse.java │ ├── NodeOutputVirtualLinkCommand.java │ ├── NodeOutputVirtualLinkCommandResponse.java │ ├── NodeOutputVirtualLinkRequest.java │ ├── NodeOutputVirtualLinkResponse.java │ ├── TextDataCommand.java │ ├── TextDataCommandResponse.java │ ├── TextDataRequest.java │ ├── TextDataResponse.java │ ├── TextMessageCommand.java │ ├── VirtualLinkDataCommand.java │ ├── VirtualLinkDataCommandResponse.java │ ├── VirtualLinkDataRequest.java │ ├── VirtualLinkDataResponse.java │ └── VirtualLinkMessageCommand.java │ ├── linkcontrol │ ├── DestroyVirtualLinkCommand.java │ ├── DestroyVirtualLinkCommandResponse.java │ ├── DestroyVirtualLinkRequest.java │ ├── DestroyVirtualLinkResponse.java │ ├── DisablePhysicalLinkCommand.java │ ├── DisablePhysicalLinkCommandResponse.java │ ├── DisablePhysicalLinkRequest.java │ ├── DisablePhysicalLinkResponse.java │ ├── EnablePhysicalLinkCommand.java │ ├── EnablePhysicalLinkCommandResponse.java │ ├── EnablePhysicalLinkRequest.java │ ├── EnablePhysicalLinkResponse.java │ ├── SetVirtualLinkCommand.java │ ├── SetVirtualLinkCommandResponse.java │ ├── SetVirtualLinkRequest.java │ └── SetVirtualLinkResponse.java │ ├── networkdescription │ ├── GetNeighborhoodCommand.java │ ├── GetNeighborhoodCommandResponse.java │ ├── GetNeighborhoodRequest.java │ ├── GetNeighborhoodResponse.java │ ├── GetPropertyValueCommand.java │ ├── GetPropertyValueCommandResponse.java │ ├── GetPropertyValueRequest.java │ └── GetPropertyValueResponse.java │ └── nodecontrol │ ├── AreNodesAliveCommand.java │ ├── AreNodesAliveCommandResponse.java │ ├── AreNodesAliveRequest.java │ ├── AreNodesAliveResponse.java │ ├── DisableNodeCommand.java │ ├── DisableNodeCommandResponse.java │ ├── DisableNodeRequest.java │ ├── DisableNodeResponse.java │ ├── EnableNodeCommand.java │ ├── EnableNodeCommandResponse.java │ ├── EnableNodeRequest.java │ ├── EnableNodeResponse.java │ ├── GetVersionCommand.java │ ├── GetVersionCommandResponse.java │ ├── GetVersionRequest.java │ ├── GetVersionResponse.java │ ├── ResetNodeCommand.java │ ├── ResetNodeCommandResponse.java │ ├── ResetNodeRequest.java │ ├── ResetNodeResponse.java │ ├── SetStartTimeCommand.java │ ├── SetStartTimeCommandResponse.java │ ├── SetStartTimeRequest.java │ ├── SetStartTimeResponse.java │ ├── SetVirtualIDCommand.java │ ├── SetVirtualIDCommandResponse.java │ ├── SetVirtualIDRequest.java │ └── SetVirtualIDResponse.java └── test └── java └── de └── uniluebeck └── itm └── nettyprotocols ├── NewlineEncoderTest.java ├── dlestxetx ├── DleStxEtxFramingDecoderTest.java └── DleStxEtxFramingEncoderTest.java ├── isense └── otap │ ├── ISenseOtapAutomatedProgrammingRequestTest.java │ └── program │ └── ISenseOtapProgramResultTest.java ├── remoteuart ├── RUPFragmentDecoderTest.java ├── RUPFragmentEncoderTest.java ├── RUPPacketDecoderTest.java ├── RUPPacketDecoderTestBase.java └── RUPPacketEncoderTest.java ├── tinyos ├── HdlcTranslateDecoderTest.java ├── HdlcTranslateEncoderTest.java ├── TinyOsSerialDecoderTest.java ├── TinyOsSerialEncoderTest.java └── TinyOsSerialTestConstants.java ├── tlspeerverification ├── cacert.pem ├── client-signed-cert.pem └── howto-generate.txt ├── util └── ChannelBufferToolsTest.java └── wisebednodeapi └── NodeAPIHandlerTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .project 3 | .classpath 4 | .settings 5 | *.iml 6 | *.log 7 | *.ipr 8 | *.iws 9 | **/.classpath 10 | **/*.log 11 | **/target 12 | **/.project 13 | **/.settings 14 | **/*.iml 15 | **/*.ipr 16 | **/**/.classpath 17 | **/**/*.log 18 | **/*.iws 19 | **/**/target 20 | **/**/.project 21 | **/**/.settings 22 | **/**/*.iml 23 | **/**/*.ipr 24 | **/**/*.iws 25 | 26 | .idea 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Netty Protocols 2 | =============== 3 | 4 | Installation / Building 5 | ----------------------- 6 | No installation is required. To build Netty Protocols, you need Java 6 and 7 | Maven (http://maven.apache.org/). 8 | 9 | To build, run `mvn install`, this will build Netty Protocols and place the 10 | generated jar files in the various modules target/ subdirectories and in your 11 | local Maven repository. 12 | 13 | Usage 14 | ----- 15 | 16 | java -jar target/XXXXXX.jar --help 17 | 18 | LICENSE 19 | ---------------------------------------- 20 | This project is licenced under a BSD license. For details, see 21 | src/etc/license-header.txt 22 | 23 | -------------------------------------------------------------------------------- /src/etc/license-header.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010, Daniel Bimschas and Dennis Pfisterer, Institute of Telematics, University of Luebeck 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 5 | following conditions are met: 6 | 7 | - Redistributions of source code must retain the above copyright notice, this list of conditions and the following 8 | disclaimer. 9 | - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 10 | following disclaimer in the documentation and/or other materials provided with the distribution. 11 | - Neither the name of the University of Luebeck nor the names of its contributors may be used to endorse or promote 12 | products derived from this software without specific prior written permission. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 15 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 17 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 18 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 19 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 20 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | -------------------------------------------------------------------------------- /src/etc/license-tinyos.txt: -------------------------------------------------------------------------------- 1 | This implementation of the TinyOS serial protocol (SerialP) used in 2 | TinyOS uses the class net.tinyos.util.Crc distributed with TinyOS. 3 | Below is a copy of the license: 4 | 5 | /* Copyright (c) 2000-2003 The Regents of the University of California. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * - Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * - Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. 18 | * - Neither the name of the University of California nor the names of 19 | * its contributors may be used to endorse or promote products derived 20 | * from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 26 | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 27 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | * Copyright (c) 2002-2003 Intel Corporation 36 | * All rights reserved. 37 | * 38 | * This file is distributed under the terms in the attached INTEL-LICENSE 39 | * file. If you do not find these files, copies can be found by writing to 40 | * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 41 | * 94704. Attention: Intel License Inquiry. 42 | */ -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/Base64DecoderFactory.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols; 2 | 3 | import com.google.common.collect.HashMultimap; 4 | import com.google.common.collect.Multimap; 5 | import org.jboss.netty.handler.codec.base64.Base64Decoder; 6 | 7 | public class Base64DecoderFactory implements HandlerFactory { 8 | 9 | @Override 10 | public NamedChannelHandlerList create(final ChannelHandlerConfig config) throws Exception { 11 | return new NamedChannelHandlerList(new NamedChannelHandler(config.getInstanceName(), new Base64Decoder())); 12 | } 13 | 14 | @Override 15 | public Multimap getConfigurationOptions() { 16 | return HashMultimap.create(); 17 | } 18 | 19 | @Override 20 | public String getDescription() { 21 | return "Decodes a Base64-encoded ChannelBuffer or US-ASCII String into a ChannelBuffer. See" 22 | + "http://docs.jboss.org/netty/3.2/api/org/jboss/netty/handler/codec/base64/Base64Decoder.html."; 23 | } 24 | 25 | @Override 26 | public String getName() { 27 | return "base64-decoder"; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/Base64EncoderFactory.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols; 2 | 3 | import com.google.common.collect.HashMultimap; 4 | import com.google.common.collect.Multimap; 5 | import de.uniluebeck.itm.nettyprotocols.util.PropertiesHelper; 6 | import org.jboss.netty.handler.codec.base64.Base64Encoder; 7 | 8 | public class Base64EncoderFactory implements HandlerFactory { 9 | 10 | @Override 11 | public NamedChannelHandlerList create(final ChannelHandlerConfig config) throws Exception { 12 | 13 | Boolean breakLines = PropertiesHelper.getBooleanFromProperties(config.getProperties(), "breakLines"); 14 | 15 | Base64Encoder encoder; 16 | if (breakLines != null) { 17 | encoder = new Base64Encoder(breakLines); 18 | } else { 19 | encoder = new Base64Encoder(); 20 | } 21 | 22 | return new NamedChannelHandlerList(new NamedChannelHandler(config.getInstanceName(), encoder)); 23 | } 24 | 25 | @Override 26 | public Multimap getConfigurationOptions() { 27 | final HashMultimap configurationOptions = HashMultimap.create(); 28 | configurationOptions.put("breakLines", "(boolean)"); 29 | return configurationOptions; 30 | } 31 | 32 | @Override 33 | public String getDescription() { 34 | return "Encodes a ChannelBuffer into a Base64-encoded ChannelBuffer. See " 35 | + "http://docs.jboss.org/netty/3.2/api/org/jboss/netty/handler/codec/base64/Base64Encoder.html."; 36 | } 37 | 38 | @Override 39 | public String getName() { 40 | return "base64-encoder"; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/ChannelHandlerConfigList.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols; 2 | 3 | import com.google.common.collect.Multimap; 4 | 5 | import java.io.Serializable; 6 | import java.util.Collection; 7 | import java.util.LinkedList; 8 | 9 | public class ChannelHandlerConfigList extends LinkedList implements Serializable { 10 | 11 | public ChannelHandlerConfigList() { 12 | } 13 | 14 | public ChannelHandlerConfigList(final ChannelHandlerConfigList channelHandlerConfigs) { 15 | addAll(channelHandlerConfigs); 16 | } 17 | 18 | public ChannelHandlerConfigList(final Collection c) { 19 | super(c); 20 | } 21 | 22 | public ChannelHandlerConfigList(final ChannelHandlerConfig config, final ChannelHandlerConfig... moreConfigs) { 23 | add(config); 24 | for (ChannelHandlerConfig anotherConfig : moreConfigs) { 25 | add(anotherConfig); 26 | } 27 | } 28 | 29 | public boolean add(final String handlerName, final String instanceName, final Multimap properties) { 30 | return add(new ChannelHandlerConfig(handlerName, instanceName, properties)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/CompatibleObjectDecoderFactory.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols; 2 | 3 | import com.google.common.collect.HashMultimap; 4 | import com.google.common.collect.Multimap; 5 | import org.jboss.netty.handler.codec.serialization.CompatibleObjectDecoder; 6 | 7 | public class CompatibleObjectDecoderFactory implements HandlerFactory { 8 | 9 | private static final String RESET_INTERVAL = "resetInterval"; 10 | 11 | @Override 12 | public NamedChannelHandlerList create(final ChannelHandlerConfig config) throws Exception { 13 | return new NamedChannelHandlerList( 14 | new NamedChannelHandler(config.getInstanceName(), new CompatibleObjectDecoder()) 15 | ); 16 | } 17 | 18 | @Override 19 | public Multimap getConfigurationOptions() { 20 | return HashMultimap.create(); 21 | } 22 | 23 | @Override 24 | public String getDescription() { 25 | return "A decoder which deserializes the received ChannelBuffers into Java objects (interoperability version)." 26 | + "This decoder is interoperable with the standard Java object streams such as ObjectInputStream and" 27 | + "ObjectOutputStream. However, this decoder might perform worse than ObjectDecoder if the serialized " 28 | + "object is big and complex. Also, it does not limit the maximum size of the object, and consequently " 29 | + "your application might face the risk of DoS attack. Please use ObjectEncoder and ObjectDecoder if " 30 | + "you are not required to keep the interoperability with the standard object streams." 31 | + "Deprecated. This decoder has a known critical bug which fails to decode and raises a random " 32 | + "exception in some circumstances. Avoid to use it whenever you can. The only workaround is to " 33 | + "replace CompatibleObjectEncoder, CompatibleObjectDecoder, ObjectInputStream, and ObjectOutputStream " 34 | + "with ObjectEncoder, ObjectDecoder, ObjectEncoderOutputStream, and ObjectDecoderInputStream " 35 | + "respectively. This workaround requires both a client and a server to be modified. See" 36 | + "http://docs.jboss.org/netty/3.2/api/org/jboss/netty/handler/codec/serialization/CompatibleObjectDecoder.html."; 37 | } 38 | 39 | @Override 40 | public String getName() { 41 | return "compatible-object-decoder"; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/CompatibleObjectEncoderFactory.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols; 2 | 3 | import com.google.common.collect.HashMultimap; 4 | import com.google.common.collect.Multimap; 5 | import de.uniluebeck.itm.nettyprotocols.util.PropertiesHelper; 6 | import org.jboss.netty.channel.ChannelHandler; 7 | import org.jboss.netty.handler.codec.serialization.CompatibleObjectEncoder; 8 | 9 | public class CompatibleObjectEncoderFactory implements HandlerFactory { 10 | 11 | private static final String RESET_INTERVAL = "resetInterval"; 12 | 13 | @Override 14 | public NamedChannelHandlerList create(final ChannelHandlerConfig config) throws Exception { 15 | 16 | final Integer resetInterval = PropertiesHelper.getIntFromProperties(config.getProperties(), RESET_INTERVAL); 17 | 18 | final ChannelHandler encoder = resetInterval == null ? 19 | new CompatibleObjectEncoder() : 20 | new CompatibleObjectEncoder(resetInterval); 21 | 22 | return new NamedChannelHandlerList(new NamedChannelHandler(config.getInstanceName(), encoder)); 23 | } 24 | 25 | @Override 26 | public Multimap getConfigurationOptions() { 27 | final HashMultimap map = HashMultimap.create(); 28 | map.put(RESET_INTERVAL, "(int, optional, default=16) the number of objects between ObjectOutputStream.reset(). " 29 | + "0 will disable resetting the stream, but the remote peer will be at the risk of getting " 30 | + "OutOfMemoryError in the long term." 31 | ); 32 | return map; 33 | } 34 | 35 | @Override 36 | public String getDescription() { 37 | return "An encoder which serializes a Java object into a ChannelBuffer (interoperability version). This " 38 | + "encoder is interoperable with the standard Java object streams such as ObjectInputStream and " 39 | + "ObjectOutputStream. See " 40 | + "http://docs.jboss.org/netty/3.2/api/org/jboss/netty/handler/codec/serialization/CompatibleObjectEncoder.html."; 41 | } 42 | 43 | @Override 44 | public String getName() { 45 | return "compatible-object-encoder"; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/DelimiterBasedFrameDecoderFactory.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols; 2 | 3 | import com.google.common.collect.HashMultimap; 4 | import com.google.common.collect.Multimap; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | import org.jboss.netty.buffer.ChannelBuffers; 7 | import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; 8 | 9 | import java.nio.charset.Charset; 10 | 11 | public class DelimiterBasedFrameDecoderFactory implements HandlerFactory { 12 | 13 | private static final String MAX_FRAME_LENGTH = "maxFrameLength"; 14 | 15 | private static final String STRIP_DELIMITER = "stripDelimiter"; 16 | 17 | private static final String FRAME_DELIMITERS = "frameDelimiters"; 18 | 19 | @Override 20 | public NamedChannelHandlerList create(final ChannelHandlerConfig config) throws Exception { 21 | final int maxFrameLength = Integer.parseInt(config.getProperties().get(MAX_FRAME_LENGTH).iterator().next()); 22 | final boolean stripDelimiter = Boolean.parseBoolean(config.getProperties().get(STRIP_DELIMITER).iterator().next()); 23 | final ChannelBuffer frameDelimiters = ChannelBuffers.copiedBuffer( 24 | config.getProperties().get(FRAME_DELIMITERS).iterator().next().toCharArray(), 25 | Charset.defaultCharset() 26 | ); 27 | return new NamedChannelHandlerList( 28 | new NamedChannelHandler(config.getInstanceName(), 29 | new DelimiterBasedFrameDecoder(maxFrameLength, stripDelimiter, frameDelimiters) 30 | ) 31 | ); 32 | } 33 | 34 | @Override 35 | public Multimap getConfigurationOptions() { 36 | final HashMultimap map = HashMultimap.create(); 37 | map.put(MAX_FRAME_LENGTH, "(int) the maximum length of the decoded frame. A TooLongFrameException is thrown if the length of the frame exceeds this value."); 38 | map.put(STRIP_DELIMITER, "(boolean) whether the decoded frame should strip out the delimiter or not"); 39 | map.put(FRAME_DELIMITERS, "(String) the delimiter"); 40 | return map; 41 | } 42 | 43 | @Override 44 | public String getDescription() { 45 | return "A decoder that splits the received ChannelBuffers by one or more delimiters. It is particularly " 46 | + "useful for decoding the frames which ends with a delimiter such as NUL or newline characters. See " 47 | + "http://docs.jboss.org/netty/3.2/api/index.html?org/jboss/netty/handler/codec/frame/DelimiterBasedFrameDecoder.html."; 48 | } 49 | 50 | @Override 51 | public String getName() { 52 | return "delimiter-based-frame-decoder"; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/FixedLengthFrameDecoderFactory.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols; 2 | 3 | import com.google.common.collect.HashMultimap; 4 | import com.google.common.collect.Multimap; 5 | import org.jboss.netty.handler.codec.frame.FixedLengthFrameDecoder; 6 | 7 | public class FixedLengthFrameDecoderFactory implements HandlerFactory { 8 | 9 | @Override 10 | public NamedChannelHandlerList create(final ChannelHandlerConfig config) throws Exception { 11 | int frameLength = Integer.parseInt(config.getProperties().get("frameLength").iterator().next()); 12 | return new NamedChannelHandlerList( 13 | new NamedChannelHandler(config.getInstanceName(), new FixedLengthFrameDecoder(frameLength)) 14 | ); 15 | } 16 | 17 | @Override 18 | public Multimap getConfigurationOptions() { 19 | final HashMultimap map = HashMultimap.create(); 20 | map.put("frameLength", "(int) the number of bytes of an individual frame"); 21 | return map; 22 | } 23 | 24 | @Override 25 | public String getDescription() { 26 | return "A decoder that splits the received ChannelBuffers into a fixed number of bytes. See " 27 | + "http://docs.jboss.org/netty/3.2/api/org/jboss/netty/handler/codec/frame/FixedLengthFrameDecoder.html."; 28 | } 29 | 30 | @Override 31 | public String getName() { 32 | return "fixed-length-frame-decoder"; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/HandlerFactoryMap.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols; 2 | 3 | import java.util.Map; 4 | 5 | public interface HandlerFactoryMap extends Map { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/HandlerFactoryMapImpl.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols; 2 | 3 | import com.google.inject.Inject; 4 | 5 | import java.util.HashMap; 6 | import java.util.Set; 7 | 8 | class HandlerFactoryMapImpl extends HashMap implements HandlerFactoryMap { 9 | 10 | @Inject 11 | public HandlerFactoryMapImpl(final Set handlerFactories) { 12 | for (HandlerFactory handlerFactory : handlerFactories) { 13 | put(handlerFactory.getName(), handlerFactory); 14 | } 15 | } 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/LengthFieldPrependerFactory.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols; 2 | 3 | import com.google.common.collect.HashMultimap; 4 | import com.google.common.collect.Multimap; 5 | import de.uniluebeck.itm.nettyprotocols.util.PropertiesHelper; 6 | import org.jboss.netty.handler.codec.frame.LengthFieldPrepender; 7 | 8 | public class LengthFieldPrependerFactory implements HandlerFactory { 9 | 10 | private static final String LENGTH_FIELD_LENGTH = "lengthFieldLength"; 11 | 12 | private static final String LENGTH_INCLUDES_LENGTH_FIELD_LENGTH = "lengthIncludesLengthFieldLength"; 13 | 14 | @Override 15 | public NamedChannelHandlerList create(final ChannelHandlerConfig config) throws Exception { 16 | 17 | final Multimap properties = config.getProperties(); 18 | 19 | int lengthFieldLength = PropertiesHelper.getIntFromProperties(properties, LENGTH_FIELD_LENGTH); 20 | Boolean lengthIncludesLengthFieldLength = PropertiesHelper.getBooleanFromProperties( 21 | properties, 22 | LENGTH_INCLUDES_LENGTH_FIELD_LENGTH 23 | ); 24 | 25 | boolean optionalPropertiesProvided = lengthIncludesLengthFieldLength != null; 26 | 27 | LengthFieldPrepender prepender = optionalPropertiesProvided ? 28 | new LengthFieldPrepender(lengthFieldLength, lengthIncludesLengthFieldLength) : 29 | new LengthFieldPrepender(lengthFieldLength); 30 | 31 | return new NamedChannelHandlerList(new NamedChannelHandler(config.getInstanceName(), prepender)); 32 | } 33 | 34 | @Override 35 | public Multimap getConfigurationOptions() { 36 | final HashMultimap map = HashMultimap.create(); 37 | map.put(LENGTH_FIELD_LENGTH, 38 | "(int) the length of the prepended length field. Only 1, 2, 3, 4, and 8 are allowed." 39 | ); 40 | map.put(LENGTH_INCLUDES_LENGTH_FIELD_LENGTH, 41 | "(boolean, optional, default=false) if true, the length of the prepended length field is added to the " 42 | + "value of the prepended length field." 43 | ); 44 | return map; 45 | } 46 | 47 | @Override 48 | public String getDescription() { 49 | return "An encoder that prepends the length of the message. The length value is prepended as a binary form. " 50 | + "It is encoded in either big endian or little endian depending on the default ByteOrder of the " 51 | + "current ChannelBufferFactory. See " 52 | + "http://docs.jboss.org/netty/3.2/api/org/jboss/netty/handler/codec/frame/LengthFieldPrepender.html"; 53 | } 54 | 55 | @Override 56 | public String getName() { 57 | return "length-field-prepender"; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/NamedChannelHandler.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols; 2 | 3 | import org.jboss.netty.channel.ChannelHandler; 4 | 5 | import static com.google.common.base.Preconditions.checkNotNull; 6 | 7 | public class NamedChannelHandler { 8 | 9 | private final String instanceName; 10 | 11 | private final ChannelHandler channelHandler; 12 | 13 | public NamedChannelHandler(final String instanceName, final ChannelHandler channelHandler) { 14 | this.instanceName = checkNotNull(instanceName); 15 | this.channelHandler = checkNotNull(channelHandler); 16 | } 17 | 18 | public String getInstanceName() { 19 | return instanceName; 20 | } 21 | 22 | public ChannelHandler getChannelHandler() { 23 | return channelHandler; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/NamedChannelHandlerList.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols; 2 | 3 | import org.jboss.netty.channel.ChannelHandler; 4 | 5 | import java.util.Collection; 6 | import java.util.LinkedList; 7 | 8 | public class NamedChannelHandlerList extends LinkedList { 9 | 10 | public NamedChannelHandlerList() { 11 | } 12 | 13 | public NamedChannelHandlerList(final Collection c) { 14 | super(c); 15 | } 16 | 17 | public NamedChannelHandlerList(final NamedChannelHandlerList... lists) { 18 | for (NamedChannelHandlerList list : lists) { 19 | addAll(list); 20 | } 21 | } 22 | 23 | public NamedChannelHandlerList(final Iterable handlers) { 24 | for (NamedChannelHandler handler : handlers) { 25 | add(handler); 26 | } 27 | } 28 | 29 | public NamedChannelHandlerList(final NamedChannelHandler handler, final NamedChannelHandler... moreHandlers) { 30 | add(handler); 31 | for (NamedChannelHandler anotherHandler : moreHandlers) { 32 | add(anotherHandler); 33 | } 34 | } 35 | 36 | public boolean add(final String name, final ChannelHandler channelHandler) { 37 | return add(new NamedChannelHandler(name, channelHandler)); 38 | } 39 | 40 | public void add(NamedChannelHandlerList namedChannelHandlers) { 41 | addAll(namedChannelHandlers); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/NewlineDecoder.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols; 2 | 3 | import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; 4 | import org.jboss.netty.handler.codec.frame.Delimiters; 5 | 6 | public class NewlineDecoder extends DelimiterBasedFrameDecoder { 7 | 8 | public static final int DEFAULT_MAX_FRAME_LENGTH = 16*1000; 9 | 10 | public static final boolean DEFAULT_STRIP_NEWLINE = true; 11 | 12 | public NewlineDecoder() { 13 | this(null, null); 14 | } 15 | 16 | public NewlineDecoder(Integer maxFrameLength, Boolean stripNewline) { 17 | super( 18 | maxFrameLength != null ? maxFrameLength : DEFAULT_MAX_FRAME_LENGTH, 19 | stripNewline != null ? stripNewline : DEFAULT_STRIP_NEWLINE, 20 | Delimiters.lineDelimiter() 21 | ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/NewlineDecoderFactory.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols; 2 | 3 | import com.google.common.collect.HashMultimap; 4 | import com.google.common.collect.Multimap; 5 | import de.uniluebeck.itm.nettyprotocols.util.PropertiesHelper; 6 | 7 | public class NewlineDecoderFactory implements HandlerFactory { 8 | 9 | private static final String MAX_FRAME_LENGTH = "maxFrameLength"; 10 | 11 | private static final String STRIP_NEWLINE = "stripNewline"; 12 | 13 | @Override 14 | public NamedChannelHandlerList create(final ChannelHandlerConfig config) throws Exception { 15 | final Multimap properties = config.getProperties(); 16 | final Integer maxFrameLength = PropertiesHelper.getIntFromProperties(properties, MAX_FRAME_LENGTH); 17 | final Boolean stripNewline = PropertiesHelper.getBooleanFromProperties(properties, STRIP_NEWLINE); 18 | final NewlineDecoder decoder = new NewlineDecoder(maxFrameLength, stripNewline); 19 | return new NamedChannelHandlerList(new NamedChannelHandler(config.getInstanceName(), decoder)); 20 | } 21 | 22 | @Override 23 | public Multimap getConfigurationOptions() { 24 | final HashMultimap map = HashMultimap.create(); 25 | map.put(MAX_FRAME_LENGTH, "maximum length of a message (i.e. maximum amount of characters (=bytes) between " 26 | + "newline characters. If exceeded the data stream the message will be discarded with an error." 27 | ); 28 | map.put(STRIP_NEWLINE, 29 | "set to 'true' if newline characters should be stripped out of the stream, 'false' if not" 30 | ); 31 | return map; 32 | } 33 | 34 | @Override 35 | public String getDescription() { 36 | return "An encoder that splits up a byte stream at every newline character (\\r\\n or \\n, respectively). " 37 | + "Typically used for ASCII-based text protocols and in Shell-like interactive environments (such as in " 38 | + "Contiki)"; 39 | } 40 | 41 | @Override 42 | public String getName() { 43 | return "newline-decoder"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/NewlineEncoder.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols; 2 | 3 | import org.jboss.netty.buffer.ChannelBuffer; 4 | import org.jboss.netty.channel.Channel; 5 | import org.jboss.netty.channel.ChannelHandlerContext; 6 | import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; 7 | import org.jboss.netty.util.CharsetUtil; 8 | 9 | import static org.jboss.netty.buffer.ChannelBuffers.wrappedBuffer; 10 | 11 | public class NewlineEncoder extends OneToOneEncoder { 12 | 13 | @Override 14 | protected Object encode(final ChannelHandlerContext ctx, final Channel channel, final Object msg) 15 | throws Exception { 16 | if (msg instanceof String) { 17 | String bufString = (String) msg; 18 | if (bufString.endsWith("\n") || bufString.endsWith("\r\n")) { 19 | return bufString; 20 | } else { 21 | return bufString + '\n'; 22 | } 23 | } else if (msg instanceof ChannelBuffer) { 24 | final ChannelBuffer buf = (ChannelBuffer) msg; 25 | final String bufString = buf.toString(CharsetUtil.UTF_8); 26 | if (bufString.endsWith("\n") || bufString.endsWith("\r\n")) { 27 | return buf; 28 | } else { 29 | return wrappedBuffer(buf, wrappedBuffer(new byte[]{'\n'})); 30 | } 31 | } else { 32 | throw new IllegalArgumentException(); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/NewlineEncoderFactory.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols; 2 | 3 | import com.google.common.collect.HashMultimap; 4 | import com.google.common.collect.Multimap; 5 | 6 | public class NewlineEncoderFactory implements HandlerFactory { 7 | 8 | @Override 9 | public NamedChannelHandlerList create(final ChannelHandlerConfig config) throws Exception { 10 | return new NamedChannelHandlerList(new NamedChannelHandler(config.getInstanceName(), new NewlineEncoder())); 11 | } 12 | 13 | @Override 14 | public Multimap getConfigurationOptions() { 15 | return HashMultimap.create(); 16 | } 17 | 18 | @Override 19 | public String getDescription() { 20 | return "An encoder that adds a newline character (\\n) to every received packet if it is not already present " 21 | + "(\\r\\n or \\n). Typically used for ASCII-based text protocols and in Shell-like interactive " 22 | + "environments (such as in Contiki)."; 23 | } 24 | 25 | @Override 26 | public String getName() { 27 | return "newline-encoder"; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/ObjectDecoderFactory.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols; 2 | 3 | import com.google.common.collect.HashMultimap; 4 | import com.google.common.collect.Multimap; 5 | import de.uniluebeck.itm.nettyprotocols.util.PropertiesHelper; 6 | import org.jboss.netty.handler.codec.serialization.ObjectDecoder; 7 | 8 | public class ObjectDecoderFactory implements HandlerFactory { 9 | 10 | private static final String MAX_OBJECT_SIZE = "maxObjectSize"; 11 | 12 | @Override 13 | public NamedChannelHandlerList create(final ChannelHandlerConfig config) throws Exception { 14 | 15 | final Multimap properties = config.getProperties(); 16 | final Integer maxObjectSize = PropertiesHelper.getIntFromProperties(properties, MAX_OBJECT_SIZE); 17 | 18 | final ObjectDecoder decoder = maxObjectSize == null ? 19 | new ObjectDecoder() : 20 | new ObjectDecoder(maxObjectSize); 21 | 22 | return new NamedChannelHandlerList(new NamedChannelHandler(config.getInstanceName(), decoder)); 23 | } 24 | 25 | @Override 26 | public Multimap getConfigurationOptions() { 27 | final HashMultimap map = HashMultimap.create(); 28 | map.put(MAX_OBJECT_SIZE, "(int, optional, default=1048576) the maximum byte length of the serialized object. " 29 | + "if the length of the received object is greater than this value, StreamCorruptedException will be " 30 | + "raised." 31 | ); 32 | return map; 33 | } 34 | 35 | @Override 36 | public String getDescription() { 37 | return "A decoder which deserializes the received ChannelBuffers into Java objects. Please note that the " 38 | + "serialized form this decoder expects is not compatible with the standard ObjectOutputStream. " 39 | + "Please use ObjectEncoder or ObjectEncoderOutputStream to ensure the interoperability with this " 40 | + "decoder. See " 41 | + "http://docs.jboss.org/netty/3.2/api/org/jboss/netty/handler/codec/serialization/ObjectDecoder.html."; 42 | } 43 | 44 | @Override 45 | public String getName() { 46 | return "object-decoder"; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/ObjectEncoderFactory.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols; 2 | 3 | import com.google.common.collect.HashMultimap; 4 | import com.google.common.collect.Multimap; 5 | import de.uniluebeck.itm.nettyprotocols.util.PropertiesHelper; 6 | import org.jboss.netty.handler.codec.serialization.ObjectEncoder; 7 | 8 | public class ObjectEncoderFactory implements HandlerFactory { 9 | 10 | private static final String ESTIMATED_LENGTH = "estimatedLength"; 11 | 12 | @Override 13 | public NamedChannelHandlerList create(final ChannelHandlerConfig config) throws Exception { 14 | 15 | final Multimap properties = config.getProperties(); 16 | final Integer estimatedLength = PropertiesHelper.getIntFromProperties(properties, ESTIMATED_LENGTH); 17 | 18 | final ObjectEncoder encoder = estimatedLength == null ? 19 | new ObjectEncoder() : 20 | new ObjectEncoder(estimatedLength); 21 | 22 | return new NamedChannelHandlerList(new NamedChannelHandler(config.getInstanceName(), encoder)); 23 | } 24 | 25 | @Override 26 | public Multimap getConfigurationOptions() { 27 | final HashMultimap map = HashMultimap.create(); 28 | map.put(ESTIMATED_LENGTH, "(int, optional, default=512) the estimated byte length of the serialized form of an " 29 | + "object. If the length of the serialized form exceeds this value, the internal buffer will be " 30 | + "expanded automatically at the cost of memory bandwidth. If this value is too big, it will also " 31 | + "waste memory bandwidth. To avoid unnecessary memory copy or allocation cost, please specify the " 32 | + "properly estimated value." 33 | ); 34 | return map; 35 | } 36 | 37 | @Override 38 | public String getDescription() { 39 | return "An encoder which serializes a Java object into a ChannelBuffer. Please note that the serialized form " 40 | + "this encoder produces is not compatible with the standard ObjectInputStream. Please use " 41 | + "ObjectDecoder or ObjectDecoderInputStream to ensure the interoperability with this encoder.See " 42 | + "http://docs.jboss.org/netty/3.2/api/org/jboss/netty/handler/codec/serialization/ObjectEncoder.html."; 43 | } 44 | 45 | @Override 46 | public String getName() { 47 | return "object-encoder"; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/StringDecoderFactory.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols; 2 | 3 | import com.google.common.collect.HashMultimap; 4 | import com.google.common.collect.Multimap; 5 | import org.jboss.netty.handler.codec.string.StringDecoder; 6 | import org.jboss.netty.util.CharsetUtil; 7 | 8 | import java.nio.charset.Charset; 9 | 10 | public class StringDecoderFactory implements HandlerFactory { 11 | 12 | private static final String CHARSET_NAME = "charsetName"; 13 | 14 | @Override 15 | public NamedChannelHandlerList create(final ChannelHandlerConfig config) throws Exception { 16 | 17 | final Multimap properties = config.getProperties(); 18 | final String charsetName = properties.get(CHARSET_NAME).iterator().next(); 19 | 20 | final StringDecoder decoder = charsetName == null ? 21 | new StringDecoder(CharsetUtil.UTF_8) : 22 | new StringDecoder(Charset.forName(charsetName)); 23 | 24 | return new NamedChannelHandlerList(new NamedChannelHandler(config.getInstanceName(), decoder)); 25 | } 26 | 27 | @Override 28 | public Multimap getConfigurationOptions() { 29 | final HashMultimap map = HashMultimap.create(); 30 | map.put(CHARSET_NAME, "(int, optional, default=UTF-8) the character set to use (e.g. UTF-16, UTF-16BE, " 31 | + "UTF-16LE, UTF-8, ISO-8859-1, US-ASCII)" 32 | ); 33 | return map; 34 | } 35 | 36 | @Override 37 | public String getDescription() { 38 | return "Decodes a received ChannelBuffer into a String. Please note that this decoder must be used with a " 39 | + "proper FrameDecoder such as DelimiterBasedFrameDecoder if you are using a stream-based transport " 40 | + "such as TCP/IP. See " 41 | + "http://docs.jboss.org/netty/3.2/api/org/jboss/netty/handler/codec/string/StringDecoder.html."; 42 | } 43 | 44 | @Override 45 | public String getName() { 46 | return "string-decoder"; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/StringEncoderFactory.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols; 2 | 3 | import com.google.common.collect.HashMultimap; 4 | import com.google.common.collect.Multimap; 5 | import org.jboss.netty.handler.codec.string.StringEncoder; 6 | import org.jboss.netty.util.CharsetUtil; 7 | 8 | import java.nio.charset.Charset; 9 | 10 | public class StringEncoderFactory implements HandlerFactory { 11 | 12 | private static final String CHARSET_NAME = "charsetName"; 13 | 14 | @Override 15 | public NamedChannelHandlerList create(final ChannelHandlerConfig config) throws Exception { 16 | 17 | final Multimap properties = config.getProperties(); 18 | final String charsetName = properties.get(CHARSET_NAME).iterator().next(); 19 | 20 | final StringEncoder encoder = charsetName == null ? 21 | new StringEncoder(CharsetUtil.UTF_8) : 22 | new StringEncoder(Charset.forName(charsetName)); 23 | 24 | return new NamedChannelHandlerList(new NamedChannelHandler(config.getInstanceName(), encoder)); 25 | } 26 | 27 | @Override 28 | public Multimap getConfigurationOptions() { 29 | final HashMultimap map = HashMultimap.create(); 30 | map.put(CHARSET_NAME, "(int, optional, default=UTF-8) the character set to use (e.g. UTF-16, UTF-16BE, " 31 | + "UTF-16LE, UTF-8, ISO-8859-1, US-ASCII)" 32 | ); 33 | return map; 34 | } 35 | 36 | @Override 37 | public String getDescription() { 38 | return "Encodes the requested String into a ChannelBuffer. See " 39 | + "http://docs.jboss.org/netty/3.2/api/org/jboss/netty/handler/codec/string/StringEncoder.html."; 40 | } 41 | 42 | @Override 43 | public String getName() { 44 | return "string-encoder"; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/ZlibDecoderFactory.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols; 2 | 3 | import com.google.common.collect.HashMultimap; 4 | import com.google.common.collect.Multimap; 5 | import org.jboss.netty.handler.codec.compression.ZlibDecoder; 6 | 7 | public class ZlibDecoderFactory implements HandlerFactory { 8 | 9 | @Override 10 | public NamedChannelHandlerList create(final ChannelHandlerConfig config) throws Exception { 11 | return new NamedChannelHandlerList(new NamedChannelHandler(config.getInstanceName(), new ZlibDecoder())); 12 | } 13 | 14 | @Override 15 | public Multimap getConfigurationOptions() { 16 | return HashMultimap.create(); 17 | } 18 | 19 | @Override 20 | public String getDescription() { 21 | return "Decompresses a ChannelBuffer using the deflate algorithm. See " 22 | + "http://docs.jboss.org/netty/3.2/api/org/jboss/netty/handler/codec/compression/ZlibDecoder.html."; 23 | } 24 | 25 | @Override 26 | public String getName() { 27 | return "zlib-decoder"; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/ZlibEncoderFactory.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols; 2 | 3 | import com.google.common.collect.HashMultimap; 4 | import com.google.common.collect.Multimap; 5 | import org.jboss.netty.handler.codec.compression.ZlibEncoder; 6 | 7 | import static de.uniluebeck.itm.nettyprotocols.util.PropertiesHelper.getIntFromProperties; 8 | 9 | public class ZlibEncoderFactory implements HandlerFactory { 10 | 11 | private static final String COMPRESSION_LEVEL = "compressionLevel"; 12 | 13 | @Override 14 | public NamedChannelHandlerList create(final ChannelHandlerConfig config) throws Exception { 15 | 16 | final Integer compressionLevel = getIntFromProperties(config.getProperties(), COMPRESSION_LEVEL); 17 | 18 | final ZlibEncoder encoder = compressionLevel == null ? 19 | new ZlibEncoder() : 20 | new ZlibEncoder(compressionLevel); 21 | 22 | return new NamedChannelHandlerList(new NamedChannelHandler(config.getInstanceName(), encoder)); 23 | } 24 | 25 | @Override 26 | public Multimap getConfigurationOptions() { 27 | final HashMultimap map = HashMultimap.create(); 28 | map.put(COMPRESSION_LEVEL, "(int, optional, default=6) 1 yields the fastest compression and 9 yields the best " 29 | + "compression. 0 means no compression. The default compression level is 6." 30 | ); 31 | return map; 32 | } 33 | 34 | @Override 35 | public String getDescription() { 36 | return "Compresses a ChannelBuffer using the deflate algorithm. See " 37 | + "http://docs.jboss.org/netty/3.2/api/org/jboss/netty/handler/codec/compression/ZlibEncoder.html."; 38 | } 39 | 40 | @Override 41 | public String getName() { 42 | return "zlib-encoder"; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/contiki/ContikiHandlerFactory.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.contiki; 2 | 3 | import com.google.common.collect.HashMultimap; 4 | import com.google.common.collect.Multimap; 5 | import de.uniluebeck.itm.nettyprotocols.*; 6 | 7 | public class ContikiHandlerFactory implements HandlerFactory { 8 | 9 | @Override 10 | public NamedChannelHandlerList create(final ChannelHandlerConfig config) throws Exception { 11 | final NamedChannelHandlerList handlers = new NamedChannelHandlerList(); 12 | handlers.add(new NamedChannelHandler("contiki-newline-decoder", new NewlineDecoder())); 13 | handlers.add(new NamedChannelHandler("contiki-newline-encoder", new NewlineEncoder())); 14 | return handlers; 15 | } 16 | 17 | @Override 18 | public Multimap getConfigurationOptions() { 19 | return HashMultimap.create(); 20 | } 21 | 22 | @Override 23 | public String getDescription() { 24 | return "A protocol stack for serial communication with the Contiki operating system. Adds LF chars " 25 | + "(if necessary) when sending messages downstream towards the node (encoding), decodes the data stream " 26 | + "coming from the node by splitting it up on every LF (\\r\\n or \\n) character received. If a message " 27 | + "coming from the node contains more than " + NewlineDecoder.DEFAULT_MAX_FRAME_LENGTH + " characters " 28 | + "it will be discarded with an error."; 29 | } 30 | 31 | @Override 32 | public String getName() { 33 | return "contiki"; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/discard/DiscardHandler.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.discard; 2 | 3 | import org.jboss.netty.channel.ChannelHandlerContext; 4 | import org.jboss.netty.channel.MessageEvent; 5 | import org.jboss.netty.channel.SimpleChannelHandler; 6 | 7 | public class DiscardHandler extends SimpleChannelHandler { 8 | 9 | private final boolean discardUpstream; 10 | 11 | private final boolean discardDownstream; 12 | 13 | public DiscardHandler(boolean discardUpstream, boolean discardDownstream) { 14 | this.discardUpstream = discardUpstream; 15 | this.discardDownstream = discardDownstream; 16 | } 17 | 18 | @Override 19 | public void writeRequested(final ChannelHandlerContext ctx, final MessageEvent e) throws Exception { 20 | if (!discardDownstream) { 21 | super.writeRequested(ctx, e); 22 | } 23 | } 24 | 25 | @Override 26 | public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent e) throws Exception { 27 | if (!discardUpstream) { 28 | super.messageReceived(ctx, e); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/discard/DiscardHandlerFactory.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.discard; 2 | 3 | import com.google.common.collect.HashMultimap; 4 | import com.google.common.collect.Multimap; 5 | import de.uniluebeck.itm.nettyprotocols.ChannelHandlerConfig; 6 | import de.uniluebeck.itm.nettyprotocols.HandlerFactory; 7 | import de.uniluebeck.itm.nettyprotocols.NamedChannelHandler; 8 | import de.uniluebeck.itm.nettyprotocols.NamedChannelHandlerList; 9 | 10 | import static de.uniluebeck.itm.nettyprotocols.util.HandlerFactoryPropertiesHelper.getFirstValueOf; 11 | 12 | public class DiscardHandlerFactory implements HandlerFactory { 13 | 14 | private static final String KEY_DISCARD_UPSTREAM = "discardUpstream"; 15 | 16 | private static final String KEY_DISCARD_DOWNSTREAM = "discardDownstream"; 17 | 18 | @Override 19 | public NamedChannelHandlerList create(final ChannelHandlerConfig config) throws Exception { 20 | 21 | final boolean discardUpstream = getFirstValueOf(config.getProperties(), KEY_DISCARD_UPSTREAM, true); 22 | final boolean discardDownstream = getFirstValueOf(config.getProperties(), KEY_DISCARD_DOWNSTREAM, true); 23 | 24 | return new NamedChannelHandlerList(new NamedChannelHandler( 25 | config.getInstanceName(), 26 | new DiscardHandler(discardUpstream, discardDownstream) 27 | )); 28 | } 29 | 30 | @Override 31 | public Multimap getConfigurationOptions() { 32 | final HashMultimap map = HashMultimap.create(); 33 | map.put(KEY_DISCARD_UPSTREAM, "(optional, boolean, default=true) if true all upstream messages are discarded"); 34 | map.put(KEY_DISCARD_DOWNSTREAM, 35 | "(optional, boolean, default=true) if true all downstream messages are discarded" 36 | ); 37 | return map; 38 | } 39 | 40 | @Override 41 | public String getDescription() { 42 | return "Discards upstream and downstream messages"; 43 | } 44 | 45 | @Override 46 | public String getName() { 47 | return "discard"; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/dlestxetx/DleStxEtxConstants.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010, Daniel Bimschas and Dennis Pfisterer, Institute of Telematics, University of Luebeck 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 6 | * following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following 9 | * disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 11 | * following disclaimer in the documentation and/or other materials provided with the distribution. 12 | * - Neither the name of the University of Luebeck nor the names of its contributors may be used to endorse or promote 13 | * products derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 19 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 20 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | */ 23 | package de.uniluebeck.itm.nettyprotocols.dlestxetx; 24 | 25 | 26 | public class DleStxEtxConstants { 27 | 28 | public static final byte DLE = 0x10; 29 | 30 | public static final byte STX = 0x02; 31 | 32 | public static final byte ETX = 0x03; 33 | 34 | public static final byte[] DLE_STX = new byte[]{DLE, STX}; 35 | 36 | public static final byte[] DLE_ETX = new byte[]{DLE, ETX}; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/isense/ISensePacketDecoder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010, Daniel Bimschas and Dennis Pfisterer, Institute of Telematics, University of Luebeck 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 6 | * following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following 9 | * disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 11 | * following disclaimer in the documentation and/or other materials provided with the distribution. 12 | * - Neither the name of the University of Luebeck nor the names of its contributors may be used to endorse or promote 13 | * products derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 19 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 20 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | */ 23 | package de.uniluebeck.itm.nettyprotocols.isense; 24 | 25 | import org.jboss.netty.buffer.ChannelBuffer; 26 | import org.jboss.netty.channel.Channel; 27 | import org.jboss.netty.channel.ChannelHandlerContext; 28 | import org.jboss.netty.handler.codec.oneone.OneToOneDecoder; 29 | import org.slf4j.Logger; 30 | import org.slf4j.LoggerFactory; 31 | 32 | public class ISensePacketDecoder extends OneToOneDecoder { 33 | 34 | private final Logger log; 35 | 36 | public ISensePacketDecoder() { 37 | this(null); 38 | } 39 | 40 | public ISensePacketDecoder(String instanceName) { 41 | log = LoggerFactory.getLogger(instanceName != null ? instanceName : ISensePacketDecoder.class.getName()); 42 | } 43 | 44 | @Override 45 | protected Object decode(final ChannelHandlerContext ctx, final Channel channel, final Object msg) throws Exception { 46 | 47 | if (!(msg instanceof ChannelBuffer)) { 48 | return msg; 49 | } 50 | 51 | ChannelBuffer buffer = (ChannelBuffer) msg; 52 | ISensePacket iSensePacket = new ISensePacket(buffer); 53 | log.trace("Decoded ISensePacket: {}", iSensePacket); 54 | return iSensePacket; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/isense/ISensePacketEncoder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010, Daniel Bimschas and Dennis Pfisterer, Institute of Telematics, University of Luebeck 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 6 | * following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following 9 | * disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 11 | * following disclaimer in the documentation and/or other materials provided with the distribution. 12 | * - Neither the name of the University of Luebeck nor the names of its contributors may be used to endorse or promote 13 | * products derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 19 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 20 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | */ 23 | package de.uniluebeck.itm.nettyprotocols.isense; 24 | 25 | import org.jboss.netty.channel.Channel; 26 | import org.jboss.netty.channel.ChannelHandlerContext; 27 | import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; 28 | import org.slf4j.Logger; 29 | import org.slf4j.LoggerFactory; 30 | 31 | public class ISensePacketEncoder extends OneToOneEncoder { 32 | 33 | private final Logger log; 34 | 35 | public ISensePacketEncoder() { 36 | this(null); 37 | } 38 | 39 | public ISensePacketEncoder(String instanceName) { 40 | log = LoggerFactory.getLogger(instanceName != null ? instanceName : ISensePacketEncoder.class.getName()); 41 | } 42 | 43 | @Override 44 | protected Object encode(final ChannelHandlerContext ctx, final Channel channel, final Object msg) throws Exception { 45 | 46 | if (!(msg instanceof ISensePacket)) { 47 | return msg; 48 | } 49 | 50 | ISensePacket packet = (ISensePacket) msg; 51 | log.trace("Encoded ISensePacket: {}", packet); 52 | return packet.getBuffer(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/isense/ISensePacketUpstreamEncoder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010, Daniel Bimschas and Dennis Pfisterer, Institute of Telematics, University of Luebeck 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 6 | * following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following 9 | * disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 11 | * following disclaimer in the documentation and/or other materials provided with the distribution. 12 | * - Neither the name of the University of Luebeck nor the names of its contributors may be used to endorse or promote 13 | * products derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 19 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 20 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | */ 23 | package de.uniluebeck.itm.nettyprotocols.isense; 24 | 25 | import de.uniluebeck.itm.nettyprotocols.util.OneToOneUpstreamEncoder; 26 | import org.jboss.netty.channel.Channel; 27 | import org.jboss.netty.channel.ChannelHandlerContext; 28 | import org.slf4j.Logger; 29 | import org.slf4j.LoggerFactory; 30 | 31 | public class ISensePacketUpstreamEncoder extends OneToOneUpstreamEncoder { 32 | 33 | private final Logger log; 34 | 35 | public ISensePacketUpstreamEncoder() { 36 | this(null); 37 | } 38 | 39 | public ISensePacketUpstreamEncoder(String instanceName) { 40 | log = LoggerFactory 41 | .getLogger(instanceName != null ? instanceName : ISensePacketUpstreamEncoder.class.getName()); 42 | } 43 | 44 | @Override 45 | protected Object encode(final ChannelHandlerContext ctx, final Channel channel, final Object msg) throws Exception { 46 | 47 | if (!(msg instanceof ISensePacket)) { 48 | return msg; 49 | } 50 | 51 | ISensePacket packet = (ISensePacket) msg; 52 | log.trace("Encoded ISensePacket: {}", packet); 53 | return packet.getBuffer(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/isense/ishellinterpreter/IShellInterpreterSetChannelMessage.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010, Daniel Bimschas and Dennis Pfisterer, Institute of Telematics, University of Luebeck 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 6 | * following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following 9 | * disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 11 | * following disclaimer in the documentation and/or other materials provided with the distribution. 12 | * - Neither the name of the University of Luebeck nor the names of its contributors may be used to endorse or promote 13 | * products derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 19 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 20 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | */ 23 | package de.uniluebeck.itm.nettyprotocols.isense.ishellinterpreter; 24 | 25 | public class IShellInterpreterSetChannelMessage { 26 | 27 | private byte channel; 28 | 29 | public IShellInterpreterSetChannelMessage(byte channel) { 30 | this.channel = channel; 31 | } 32 | 33 | public byte getChannel() { 34 | return channel; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/isense/otap/ISenseOtapAutomatedProgrammingRequestDownstreamDecoder.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.isense.otap; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.util.HeaderAndJavaBeansXMLDecoderEncoder; 4 | import de.uniluebeck.itm.nettyprotocols.util.OneToOneDownstreamDecoder; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | import org.jboss.netty.channel.Channel; 7 | import org.jboss.netty.channel.ChannelHandlerContext; 8 | 9 | /** 10 | * This OneToOneEncoder "decodes" a byte array to an ISenseOtapAutomatedProgrammingRequest object. It is intended to be 11 | * used in a downstream filter pipeline which receives programming requests. The serialized object must contain the 12 | * String and then immediately afterwards the XML-serialized object (using 13 | * {@link java.beans.XMLEncoder}). 14 | */ 15 | public class ISenseOtapAutomatedProgrammingRequestDownstreamDecoder extends OneToOneDownstreamDecoder { 16 | 17 | @Override 18 | protected Object decode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { 19 | 20 | if (!(msg instanceof ChannelBuffer)) { 21 | return msg; 22 | } 23 | 24 | ISenseOtapAutomatedProgrammingRequest result = 25 | HeaderAndJavaBeansXMLDecoderEncoder.decode(ISenseOtapAutomatedProgrammingRequest.SERIALIZATION_HEADER, 26 | ISenseOtapAutomatedProgrammingRequest.class, (ChannelBuffer) msg 27 | ); 28 | 29 | return result != null ? result : msg; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/isense/otap/ISenseOtapAutomatedProgrammingRequestDownstreamEncoder.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.isense.otap; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.util.HeaderAndJavaBeansXMLDecoderEncoder; 4 | import org.jboss.netty.channel.Channel; 5 | import org.jboss.netty.channel.ChannelHandlerContext; 6 | import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; 7 | 8 | public class ISenseOtapAutomatedProgrammingRequestDownstreamEncoder extends OneToOneEncoder { 9 | 10 | @Override 11 | protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { 12 | if (!(msg instanceof ISenseOtapAutomatedProgrammingRequest)) { 13 | return msg; 14 | } 15 | 16 | return HeaderAndJavaBeansXMLDecoderEncoder.encode(ISenseOtapAutomatedProgrammingRequest.SERIALIZATION_HEADER, 17 | msg 18 | ); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/isense/otap/ISenseOtapPacketDecoderSetAESKeyRequest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.isense.otap; 2 | 3 | import com.coalesenses.tools.iSenseAes128BitKey; 4 | 5 | public class ISenseOtapPacketDecoderSetAESKeyRequest { 6 | 7 | private final iSenseAes128BitKey key; 8 | 9 | public ISenseOtapPacketDecoderSetAESKeyRequest(iSenseAes128BitKey key) { 10 | super(); 11 | this.key = key; 12 | } 13 | 14 | /** 15 | * @return the key 16 | */ 17 | public iSenseAes128BitKey getKey() { 18 | return key; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/isense/otap/ISenseOtapPacketEncoderSetAESKeyRequest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.isense.otap; 2 | 3 | import com.coalesenses.tools.iSenseAes128BitKey; 4 | 5 | public class ISenseOtapPacketEncoderSetAESKeyRequest { 6 | 7 | private final iSenseAes128BitKey key; 8 | 9 | public ISenseOtapPacketEncoderSetAESKeyRequest(iSenseAes128BitKey key) { 10 | super(); 11 | this.key = key; 12 | } 13 | 14 | /** 15 | * @return the key 16 | */ 17 | public iSenseAes128BitKey getKey() { 18 | return key; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/isense/otap/ISenseOtapPacketType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010, Daniel Bimschas and Dennis Pfisterer, Institute of Telematics, University of Luebeck 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 6 | * following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following 9 | * disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 11 | * following disclaimer in the documentation and/or other materials provided with the distribution. 12 | * - Neither the name of the University of Luebeck nor the names of its contributors may be used to endorse or promote 13 | * products derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 19 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 20 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | */ 23 | package de.uniluebeck.itm.nettyprotocols.isense.otap; 24 | 25 | public class ISenseOtapPacketType { 26 | 27 | /** 28 | * @see https://github.com/itm/testbed-runtime/blob/master/iwsn/wsn-device-drivers/src/main/java/de/uniluebeck/itm/wsn/devicedrivers/generic/ISenseOtapPacketType.java 29 | */ 30 | public static final byte OTAP = 0x6; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/isense/otap/generatedmessages/OtapInitReply.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010, Daniel Bimschas and Dennis Pfisterer, Institute of Telematics, University of Luebeck 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 6 | * following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following 9 | * disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 11 | * following disclaimer in the documentation and/or other materials provided with the distribution. 12 | * - Neither the name of the University of Luebeck nor the names of its contributors may be used to endorse or promote 13 | * products derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 19 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 20 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | */ 23 | package de.uniluebeck.itm.nettyprotocols.isense.otap.generatedmessages; 24 | 25 | /** 26 | * This class is representing a local complex type embedding in a top-level element. 27 | */ 28 | public class OtapInitReply { 29 | 30 | /** 31 | * Generated from local element 'device_id'. 32 | */ 33 | public int device_id; 34 | 35 | static int header_length = 2; 36 | 37 | /** 38 | * Check for object equality. 39 | * 40 | * @param o The other object. 41 | */ 42 | /*@Override 43 | public boolean equals(Object o) { 44 | if (!(o instanceof OtapInitReply)) { 45 | return false; 46 | } 47 | OtapInitReply other = (OtapInitReply)o; 48 | boolean equal = true; 49 | equal = equal && (this.device_id == other.device_id); 50 | return equal; 51 | } 52 | */ 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/isense/otap/generatedmessages/PresenceDetectRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010, Daniel Bimschas and Dennis Pfisterer, Institute of Telematics, University of Luebeck 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 6 | * following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following 9 | * disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 11 | * following disclaimer in the documentation and/or other materials provided with the distribution. 12 | * - Neither the name of the University of Luebeck nor the names of its contributors may be used to endorse or promote 13 | * products derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 19 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 20 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | */ 23 | package de.uniluebeck.itm.nettyprotocols.isense.otap.generatedmessages; 24 | 25 | public class PresenceDetectRequest { 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/isense/otap/init/ISenseOtapInitResult.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010, Daniel Bimschas and Dennis Pfisterer, Institute of Telematics, University of Luebeck 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 6 | * following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following 9 | * disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 11 | * following disclaimer in the documentation and/or other materials provided with the distribution. 12 | * - Neither the name of the University of Luebeck nor the names of its contributors may be used to endorse or promote 13 | * products derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 19 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 20 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | */ 23 | package de.uniluebeck.itm.nettyprotocols.isense.otap.init; 24 | 25 | import java.util.Set; 26 | 27 | public class ISenseOtapInitResult { 28 | 29 | private final ISenseOtapInitStartCommand otapInitStartCommand; 30 | 31 | private final Set initializedDevices; 32 | 33 | public ISenseOtapInitResult(ISenseOtapInitStartCommand otapInitStartCommand, Set initializedDevices) { 34 | this.otapInitStartCommand = otapInitStartCommand; 35 | this.initializedDevices = initializedDevices; 36 | } 37 | 38 | /** 39 | * @return the otapInitStartCommand 40 | */ 41 | public ISenseOtapInitStartCommand getOtapInitStartCommand() { 42 | return otapInitStartCommand; 43 | } 44 | 45 | /** 46 | * @return the initializedDevices 47 | */ 48 | public Set getInitializedDevices() { 49 | return initializedDevices; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/isense/otap/init/ISenseOtapInitStopCommand.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010, Daniel Bimschas and Dennis Pfisterer, Institute of Telematics, University of Luebeck 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 6 | * following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following 9 | * disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 11 | * following disclaimer in the documentation and/or other materials provided with the distribution. 12 | * - Neither the name of the University of Luebeck nor the names of its contributors may be used to endorse or promote 13 | * products derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 19 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 20 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | */ 23 | package de.uniluebeck.itm.nettyprotocols.isense.otap.init; 24 | 25 | public class ISenseOtapInitStopCommand { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/isense/otap/presencedetect/PresenceDetectControlStart.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010, Daniel Bimschas and Dennis Pfisterer, Institute of Telematics, University of Luebeck 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 6 | * following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following 9 | * disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 11 | * following disclaimer in the documentation and/or other materials provided with the distribution. 12 | * - Neither the name of the University of Luebeck nor the names of its contributors may be used to endorse or promote 13 | * products derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 19 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 20 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | */ 23 | package de.uniluebeck.itm.nettyprotocols.isense.otap.presencedetect; 24 | 25 | public class PresenceDetectControlStart { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/isense/otap/presencedetect/PresenceDetectControlStop.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010, Daniel Bimschas and Dennis Pfisterer, Institute of Telematics, University of Luebeck 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 6 | * following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following 9 | * disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 11 | * following disclaimer in the documentation and/or other materials provided with the distribution. 12 | * - Neither the name of the University of Luebeck nor the names of its contributors may be used to endorse or promote 13 | * products derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 19 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 20 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | */ 23 | package de.uniluebeck.itm.nettyprotocols.isense.otap.presencedetect; 24 | 25 | public class PresenceDetectControlStop { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/isense/otap/presencedetect/PresenceDetectStatus.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010, Daniel Bimschas and Dennis Pfisterer, Institute of Telematics, University of Luebeck 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 6 | * following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following 9 | * disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 11 | * following disclaimer in the documentation and/or other materials provided with the distribution. 12 | * - Neither the name of the University of Luebeck nor the names of its contributors may be used to endorse or promote 13 | * products derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 19 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 20 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | */ 23 | package de.uniluebeck.itm.nettyprotocols.isense.otap.presencedetect; 24 | 25 | import java.util.Set; 26 | 27 | public class PresenceDetectStatus { 28 | 29 | Set detectedDevices; 30 | 31 | public PresenceDetectStatus(Set detectedDevices) { 32 | super(); 33 | this.detectedDevices = detectedDevices; 34 | } 35 | 36 | /** 37 | * @return the detectedDevices 38 | */ 39 | public Set getDetectedDevices() { 40 | return detectedDevices; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/isense/otap/program/ISenseOtapProgramResultUpstreamDecoder.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.isense.otap.program; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.util.HeaderAndJavaBeansXMLDecoderEncoder; 4 | import org.jboss.netty.buffer.ChannelBuffer; 5 | import org.jboss.netty.channel.Channel; 6 | import org.jboss.netty.channel.ChannelHandlerContext; 7 | import org.jboss.netty.handler.codec.oneone.OneToOneDecoder; 8 | 9 | public class ISenseOtapProgramResultUpstreamDecoder extends OneToOneDecoder { 10 | 11 | @Override 12 | protected Object decode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { 13 | if (!(msg instanceof ChannelBuffer)) { 14 | return msg; 15 | } 16 | 17 | ISenseOtapProgramResult result = 18 | HeaderAndJavaBeansXMLDecoderEncoder.decode(ISenseOtapProgramResult.SERIALIZATION_HEADER, 19 | ISenseOtapProgramResult.class, (ChannelBuffer) msg 20 | ); 21 | 22 | return result != null ? result : msg; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/isense/otap/program/ISenseOtapProgramResultUpstreamEncoder.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.isense.otap.program; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.util.HeaderAndJavaBeansXMLDecoderEncoder; 4 | import de.uniluebeck.itm.nettyprotocols.util.OneToOneUpstreamEncoder; 5 | import org.jboss.netty.channel.Channel; 6 | import org.jboss.netty.channel.ChannelHandlerContext; 7 | 8 | public class ISenseOtapProgramResultUpstreamEncoder extends OneToOneUpstreamEncoder { 9 | 10 | @Override 11 | protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { 12 | if (!(msg instanceof ISenseOtapProgramResult)) { 13 | return msg; 14 | } 15 | 16 | return HeaderAndJavaBeansXMLDecoderEncoder.encode(ISenseOtapProgramResult.SERIALIZATION_HEADER, msg); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/remoteuart/RUPFragment.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010, Daniel Bimschas and Dennis Pfisterer, Institute of Telematics, University of Luebeck 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 6 | * following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following 9 | * disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 11 | * following disclaimer in the documentation and/or other materials provided with the distribution. 12 | * - Neither the name of the University of Luebeck nor the names of its contributors may be used to endorse or promote 13 | * products derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 19 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 20 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | */ 23 | package de.uniluebeck.itm.nettyprotocols.remoteuart; 24 | 25 | import org.jboss.netty.buffer.ChannelBuffer; 26 | 27 | /** 28 | * Interface that represents a Remote UART packet fragment. 29 | */ 30 | public interface RUPFragment extends RUPPacket { 31 | 32 | /** 33 | * Returns the packets sequence number. 34 | * 35 | * @return the packets sequence number 36 | */ 37 | byte getSequenceNumber(); 38 | 39 | /** 40 | * Returns the ChannelBuffer object backing the packet. Attention: This is the original ChannelBuffer, not a 41 | * copy. Any modifications to it will also reflect on this packet object instance. 42 | * 43 | * @return the ChannelBuffer object backing the packet 44 | */ 45 | ChannelBuffer getChannelBuffer(); 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/remoteuart/RUPFragmentEncoder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010, Daniel Bimschas and Dennis Pfisterer, Institute of Telematics, University of Luebeck 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 6 | * following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following 9 | * disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 11 | * following disclaimer in the documentation and/or other materials provided with the distribution. 12 | * - Neither the name of the University of Luebeck nor the names of its contributors may be used to endorse or promote 13 | * products derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 19 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 20 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | */ 23 | package de.uniluebeck.itm.nettyprotocols.remoteuart; 24 | 25 | import de.uniluebeck.itm.nettyprotocols.isense.ISensePacket; 26 | import de.uniluebeck.itm.nettyprotocols.isense.ISensePacketType; 27 | import org.jboss.netty.channel.Channel; 28 | import org.jboss.netty.channel.ChannelHandlerContext; 29 | import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; 30 | 31 | public class RUPFragmentEncoder extends OneToOneEncoder { 32 | 33 | public RUPFragmentEncoder() { 34 | } 35 | 36 | @Override 37 | protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { 38 | 39 | if (!(msg instanceof RUPFragment)) { 40 | return msg; 41 | } 42 | 43 | RUPFragment fragment = (RUPFragment) msg; 44 | return new ISensePacket(ISensePacketType.CUSTOM_IN_1, fragment.getChannelBuffer()); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/swap/SwapRequestDecoder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010, Daniel Bimschas and Dennis Pfisterer, Institute of Telematics, University of Luebeck 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 6 | * following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following 9 | * disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 11 | * following disclaimer in the documentation and/or other materials provided with the distribution. 12 | * - Neither the name of the University of Luebeck nor the names of its contributors may be used to endorse or promote 13 | * products derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 19 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 20 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | */ 23 | package de.uniluebeck.itm.nettyprotocols.swap; 24 | 25 | import de.uniluebeck.itm.nettyprotocols.remoteuart.RUPPacket; 26 | import org.jboss.netty.channel.Channel; 27 | import org.jboss.netty.channel.ChannelHandlerContext; 28 | import org.jboss.netty.handler.codec.oneone.OneToOneDecoder; 29 | 30 | public class SwapRequestDecoder extends OneToOneDecoder { 31 | 32 | public SwapRequestDecoder() { 33 | } 34 | 35 | @Override 36 | protected Object decode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { 37 | 38 | if (!(msg instanceof RUPPacket)) { 39 | return msg; 40 | } 41 | 42 | RUPPacket packet = (RUPPacket) msg; 43 | 44 | if (RUPPacket.Type.MESSAGE.getValue() != packet.getCmdType()) { 45 | return msg; 46 | } 47 | 48 | return SwapRequest.Factory.wrap(packet.getDestination(), packet.getSource(), packet.getPayload()); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/swap/SwapRequestEncoder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010, Daniel Bimschas and Dennis Pfisterer, Institute of Telematics, University of Luebeck 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 6 | * following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following 9 | * disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 11 | * following disclaimer in the documentation and/or other materials provided with the distribution. 12 | * - Neither the name of the University of Luebeck nor the names of its contributors may be used to endorse or promote 13 | * products derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 19 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 20 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | */ 23 | package de.uniluebeck.itm.nettyprotocols.swap; 24 | 25 | import de.uniluebeck.itm.nettyprotocols.remoteuart.RUPPacket; 26 | import de.uniluebeck.itm.nettyprotocols.remoteuart.RUPPacketImpl; 27 | import org.jboss.netty.channel.Channel; 28 | import org.jboss.netty.channel.ChannelHandlerContext; 29 | import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; 30 | 31 | public class SwapRequestEncoder extends OneToOneEncoder { 32 | 33 | public SwapRequestEncoder() { 34 | } 35 | 36 | @Override 37 | protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { 38 | 39 | if (!(msg instanceof SwapRequest)) { 40 | return msg; 41 | } 42 | 43 | SwapRequest request = (SwapRequest) msg; 44 | 45 | return new RUPPacketImpl( 46 | RUPPacket.Type.MESSAGE, 47 | request.getDestination(), 48 | request.getSource(), 49 | request.getBuffer() 50 | ); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/swap/SwapResponseEncoder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010, Daniel Bimschas and Dennis Pfisterer, Institute of Telematics, University of Luebeck 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 6 | * following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following 9 | * disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 11 | * following disclaimer in the documentation and/or other materials provided with the distribution. 12 | * - Neither the name of the University of Luebeck nor the names of its contributors may be used to endorse or promote 13 | * products derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 19 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 20 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | */ 23 | package de.uniluebeck.itm.nettyprotocols.swap; 24 | 25 | import de.uniluebeck.itm.nettyprotocols.remoteuart.RUPPacket; 26 | import de.uniluebeck.itm.nettyprotocols.remoteuart.RUPPacketImpl; 27 | import org.jboss.netty.channel.Channel; 28 | import org.jboss.netty.channel.ChannelHandlerContext; 29 | import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; 30 | 31 | public class SwapResponseEncoder extends OneToOneEncoder { 32 | 33 | public SwapResponseEncoder() { 34 | } 35 | 36 | @Override 37 | protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { 38 | 39 | if (!(msg instanceof SwapResponse)) { 40 | return msg; 41 | } 42 | 43 | SwapResponse response = (SwapResponse) msg; 44 | 45 | return new RUPPacketImpl( 46 | RUPPacket.Type.MESSAGE, 47 | response.getDestination(), 48 | response.getSource(), 49 | response.getBuffer() 50 | ); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/tinyos/HdlcTranslateConstants.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010, Daniel Bimschas and Dennis Pfisterer, Institute of Telematics, University of Luebeck 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 6 | * following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following 9 | * disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 11 | * following disclaimer in the documentation and/or other materials provided with the distribution. 12 | * - Neither the name of the University of Luebeck nor the names of its contributors may be used to endorse or promote 13 | * products derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 19 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 20 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | */ 23 | package de.uniluebeck.itm.nettyprotocols.tinyos; 24 | 25 | 26 | public class HdlcTranslateConstants { 27 | 28 | public static final byte FRAME_DELIMITER_BYTE = 0x7e; 29 | 30 | public static final byte[] FRAME_DELIMITER_BYTE_ARRAY = new byte[]{FRAME_DELIMITER_BYTE}; 31 | 32 | public static final byte ESCAPE_BYTE = 0x7d; 33 | 34 | public static final byte[] ESCAPE_BYTE_ARRAY = new byte[]{ESCAPE_BYTE}; 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/tinyos/TinyOsFactory.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.tinyos; 2 | 3 | import com.google.common.collect.HashMultimap; 4 | import com.google.common.collect.Multimap; 5 | import de.uniluebeck.itm.nettyprotocols.ChannelHandlerConfig; 6 | import de.uniluebeck.itm.nettyprotocols.HandlerFactory; 7 | import de.uniluebeck.itm.nettyprotocols.NamedChannelHandler; 8 | import de.uniluebeck.itm.nettyprotocols.NamedChannelHandlerList; 9 | 10 | public class TinyOsFactory implements HandlerFactory { 11 | 12 | @Override 13 | public NamedChannelHandlerList create(final ChannelHandlerConfig config) throws Exception { 14 | return new NamedChannelHandlerList( 15 | new NamedChannelHandler( 16 | config.getInstanceName() + "-tinyos-hdlctranslate-decoder", 17 | new HdlcTranslateDecoder(config.getInstanceName() + "-tinyos-hdlctranslate-decoder") 18 | ), 19 | new NamedChannelHandler( 20 | config.getInstanceName() + "-tinyos-hdlctranslate-encoder", 21 | new HdlcTranslateEncoder(config.getInstanceName() + "-tinyos-hdlctranslate-encoder") 22 | ), 23 | new NamedChannelHandler( 24 | config.getInstanceName() + "-tinyos-serial-decoder", 25 | new TinyOsSerialDecoder(config.getInstanceName() + "-tinyos-serial-decoder") 26 | ), 27 | new NamedChannelHandler( 28 | config.getInstanceName() + "-tinyos-serial-encoder", 29 | new TinyOsSerialEncoder(config.getInstanceName() + "-tinyos-serial-encoder") 30 | ) 31 | ); 32 | } 33 | 34 | @Override 35 | public Multimap getConfigurationOptions() { 36 | return HashMultimap.create(); 37 | } 38 | 39 | @Override 40 | public String getDescription() { 41 | return "Protocol stack consisting of tinyos-hdlctranslate and tinyos-serial protocols. For more details see http://www.tinyos.net/tinyos-2.x/doc/html/tep113.html"; 42 | } 43 | 44 | @Override 45 | public String getName() { 46 | return "tinyos"; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/tinyos/TinyOsSerial.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.tinyos; 2 | 3 | public abstract class TinyOsSerial { 4 | 5 | public static final int PROTO_PACKET_NOACK = 69; 6 | 7 | public static final int PROTO_PACKET_ACK = 68; 8 | 9 | public static final int PROTO_ACK = 67; 10 | 11 | public static final int TYPE_ACTIVE_MESSAGE = 0; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/tinyos/TinyOsSerialEncoder.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.tinyos; 2 | 3 | import org.jboss.netty.buffer.ChannelBuffer; 4 | import org.jboss.netty.buffer.ChannelBuffers; 5 | import org.jboss.netty.channel.Channel; 6 | import org.jboss.netty.channel.ChannelHandlerContext; 7 | import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | import static de.uniluebeck.itm.nettyprotocols.tinyos.TinyOsSerial.TYPE_ACTIVE_MESSAGE; 12 | 13 | public class TinyOsSerialEncoder extends OneToOneEncoder { 14 | 15 | private static final int PACKET_TYPE = 0x45 & 0xFF; 16 | 17 | private final Logger log; 18 | 19 | public TinyOsSerialEncoder() { 20 | this(null); 21 | } 22 | 23 | public TinyOsSerialEncoder(final String instanceName) { 24 | log = LoggerFactory.getLogger(instanceName != null ? instanceName : TinyOsSerialEncoder.class.getName()); 25 | } 26 | 27 | @Override 28 | protected Object encode(final ChannelHandlerContext ctx, final Channel channel, final Object msg) throws Exception { 29 | 30 | final ChannelBuffer decoded = (ChannelBuffer) msg; 31 | final int decodedLength = decoded.readableBytes(); 32 | final ChannelBuffer encoded = ChannelBuffers.buffer(decodedLength + 4); 33 | 34 | int crc = 0; 35 | 36 | encoded.writeByte(PACKET_TYPE); 37 | encoded.writeByte(TYPE_ACTIVE_MESSAGE); 38 | 39 | crc = TinyOsCrc.calcByte(crc, PACKET_TYPE); 40 | crc = TinyOsCrc.calcByte(crc, TYPE_ACTIVE_MESSAGE); 41 | 42 | byte currentByte; 43 | 44 | for (int i = 0; i < decodedLength; i++) { 45 | 46 | currentByte = decoded.readByte(); 47 | encoded.writeByte(currentByte); 48 | crc = TinyOsCrc.calcByte(crc, currentByte); 49 | } 50 | 51 | encoded.writeByte(crc & 0xFF); 52 | encoded.writeByte(crc >> 8); 53 | 54 | return encoded; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/tlspeerverification/TlsPeerVerificationHandler.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.tlspeerverification; 2 | 3 | import com.google.common.base.Preconditions; 4 | import org.jboss.netty.channel.*; 5 | import org.jboss.netty.handler.ssl.SslHandler; 6 | import org.slf4j.LoggerFactory; 7 | 8 | public class TlsPeerVerificationHandler extends SimpleChannelUpstreamHandler { 9 | 10 | private static final org.slf4j.Logger log = LoggerFactory.getLogger(TlsPeerVerificationHandler.class); 11 | 12 | public TlsPeerVerificationHandler() { 13 | } 14 | 15 | @Override 16 | public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { 17 | log.debug("Connected with {}, starting handshake", e.getChannel().getRemoteAddress()); 18 | 19 | // Get the SslHandler from the pipeline 20 | // which were added in SecureChatPipelineFactory. 21 | SslHandler sslHandler = ctx.getPipeline().get(SslHandler.class); 22 | Preconditions.checkNotNull(sslHandler, "No SSL handler in the current pipeline"); 23 | 24 | // Begin handshake 25 | sslHandler.handshake().addListener(new ChannelFutureListener() { 26 | 27 | @Override 28 | public void operationComplete(ChannelFuture future) throws Exception { 29 | if (future.isSuccess()) { 30 | log.debug("Handshake complete @ {} with remote {}", future.getChannel().getLocalAddress(), future 31 | .getChannel().getRemoteAddress() 32 | ); 33 | 34 | // future.getChannel().write("lkjlkjl"); 35 | } else { 36 | log.debug("Handshake failed @ {} with remote {} ({}): {}", new Object[]{ 37 | future.getChannel().getLocalAddress(), future 38 | .getChannel().getRemoteAddress(), future.getCause(), future.getCause().getMessage() 39 | } 40 | ); 41 | 42 | } 43 | } 44 | } 45 | ); 46 | 47 | super.channelConnected(ctx, e); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/tlspeerverification/TlsPeerVerificationSslContextFactory.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.tlspeerverification; 2 | 3 | import javax.net.ssl.KeyManagerFactory; 4 | import javax.net.ssl.SSLContext; 5 | import java.io.File; 6 | import java.io.IOException; 7 | import java.security.GeneralSecurityException; 8 | import java.security.KeyStore; 9 | import java.security.Security; 10 | import java.security.cert.CertificateException; 11 | 12 | public class TlsPeerVerificationSslContextFactory { 13 | 14 | private static final String PROTOCOL = "TLS"; 15 | 16 | public static SSLContext getContext(File rootCertificateAuthorityFile, File localCertificateFile, 17 | char[] certificatePassword, boolean clientMode) 18 | throws IOException, GeneralSecurityException { 19 | 20 | TlsPeerVerificationKeyStore keyStore = 21 | new TlsPeerVerificationKeyStore(rootCertificateAuthorityFile, localCertificateFile, certificatePassword 22 | ); 23 | 24 | return getContext(keyStore, certificatePassword, clientMode); 25 | 26 | } 27 | 28 | public static SSLContext getContext(TlsPeerVerificationKeyStore keyStore, char[] certificatePassword, 29 | boolean clientMode) 30 | throws CertificateException, GeneralSecurityException, IOException { 31 | 32 | String algorithm = Security.getProperty("ssl.KeyManagerFactory.algorithm"); 33 | 34 | if (algorithm == null) { 35 | algorithm = "SunX509"; 36 | } 37 | 38 | if (clientMode) { 39 | 40 | TlsPeerVerificationTrustManagerFactory trustManagerFactory = 41 | new TlsPeerVerificationTrustManagerFactory(null); 42 | 43 | SSLContext sslContext = SSLContext.getInstance(PROTOCOL); 44 | sslContext.init(null, trustManagerFactory.engineGetTrustManagers(), null); 45 | 46 | return sslContext; 47 | 48 | } else { 49 | KeyStore ks = KeyStore.getInstance("JKS"); 50 | ks.load(SecureChatKeyStore.asInputStream(), SecureChatKeyStore.getKeyStorePassword()); 51 | KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm); 52 | kmf.init(ks, SecureChatKeyStore.getCertificatePassword()); 53 | 54 | // Set up key manager factory to use our key store 55 | 56 | SSLContext sslContext = SSLContext.getInstance(PROTOCOL); 57 | sslContext.init(kmf.getKeyManagers(), null, null); 58 | // sslContext.init(kmf.getKeyManagers(), trustManagerFactory.engineGetTrustManagers(), null); 59 | return sslContext; 60 | } 61 | 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/tlspeerverification/TlsPeerVerificationTrustManager.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.tlspeerverification; 2 | 3 | import org.slf4j.LoggerFactory; 4 | 5 | import javax.net.ssl.X509TrustManager; 6 | import java.security.cert.CertificateException; 7 | import java.security.cert.X509Certificate; 8 | 9 | public class TlsPeerVerificationTrustManager implements X509TrustManager { 10 | 11 | private static final org.slf4j.Logger log = LoggerFactory.getLogger(TlsPeerVerificationTrustManager.class); 12 | 13 | private final TlsPeerVerificationKeyStore keyStore; 14 | 15 | public TlsPeerVerificationTrustManager(TlsPeerVerificationKeyStore keyStore) { 16 | super(); 17 | this.keyStore = keyStore; 18 | } 19 | 20 | @Override 21 | public X509Certificate[] getAcceptedIssuers() { 22 | return new X509Certificate[]{}; //TODO: keyStore.getRootCertificateAuthority() 23 | } 24 | 25 | @Override 26 | public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { 27 | log.debug("Checking client trust"); 28 | //TODO 29 | //throw new CertificateException("Untrusted :-)"); 30 | } 31 | 32 | @Override 33 | public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { 34 | log.debug("Checking server trust"); 35 | //TODO 36 | //throw new CertificateException("Untrusted :-)"); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/tlspeerverification/TlsPeerVerificationTrustManagerFactory.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.tlspeerverification; 2 | 3 | import org.slf4j.LoggerFactory; 4 | 5 | import javax.net.ssl.ManagerFactoryParameters; 6 | import javax.net.ssl.TrustManager; 7 | import javax.net.ssl.TrustManagerFactorySpi; 8 | import java.security.InvalidAlgorithmParameterException; 9 | import java.security.KeyStore; 10 | import java.security.KeyStoreException; 11 | 12 | public class TlsPeerVerificationTrustManagerFactory extends TrustManagerFactorySpi { 13 | 14 | private static final org.slf4j.Logger log = LoggerFactory.getLogger(TlsPeerVerificationTrustManagerFactory.class); 15 | 16 | private final TlsPeerVerificationTrustManager trustManager; 17 | 18 | public TlsPeerVerificationTrustManagerFactory(TlsPeerVerificationTrustManager trustManager) { 19 | super(); 20 | this.trustManager = trustManager; 21 | } 22 | 23 | @Override 24 | protected TrustManager[] engineGetTrustManagers() { 25 | log.debug("Returning custom trust manager"); 26 | return new TrustManager[]{trustManager}; 27 | } 28 | 29 | @Override 30 | protected void engineInit(KeyStore arg0) throws KeyStoreException { 31 | // Nothing to do 32 | } 33 | 34 | @Override 35 | protected void engineInit(ManagerFactoryParameters arg0) throws InvalidAlgorithmParameterException { 36 | // Nothing to do 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/util/ChannelBufferTools.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.util; 2 | 3 | import de.uniluebeck.itm.util.StringUtils; 4 | import org.jboss.netty.buffer.ChannelBuffer; 5 | 6 | @SuppressWarnings("unused") 7 | public abstract class ChannelBufferTools { 8 | 9 | /** 10 | * Uses {@link ChannelBuffer#getBytes(int, byte[], int, int)} to copy the buffers contents to a byte array. 11 | * 12 | * @param buffer 13 | * the buffer to copy from 14 | * 15 | * @return a new byte array instance 16 | */ 17 | public static byte[] getToByteArray(final ChannelBuffer buffer) { 18 | byte[] bytes = new byte[buffer.readableBytes()]; 19 | buffer.getBytes(buffer.readerIndex(), bytes, 0, buffer.readableBytes()); 20 | return bytes; 21 | } 22 | 23 | /** 24 | * Uses {@link ChannelBuffer#readBytes(byte[])} to copy the buffers contents to a byte array. 25 | * 26 | * @param buffer 27 | * the buffer to copy from 28 | * 29 | * @return a new byte array instance 30 | */ 31 | public static byte[] readToByteArray(final ChannelBuffer buffer) { 32 | byte[] bytes = new byte[buffer.readableBytes()]; 33 | buffer.readBytes(bytes); 34 | return bytes; 35 | } 36 | 37 | /** 38 | * Same as calling {@code toPrintableString(buffer, Integer.MAX_VALUE)}. 39 | * 40 | * @param buffer 41 | * the buffer to convert 42 | * 43 | * @return a printable String 44 | */ 45 | public static String toPrintableString(final ChannelBuffer buffer) { 46 | return toPrintableString(buffer, Integer.MAX_VALUE); 47 | } 48 | 49 | /** 50 | * Returns a printable (ASCII) String by constructing a new String of maximum length {@code maxLength} and calling 51 | * {@link StringUtils#replaceNonPrintableAsciiCharacters(String)} on it. 52 | * 53 | * @param buffer 54 | * the buffer to convert 55 | * @param maxLength 56 | * the maximum length of the input String for {@link StringUtils#replaceNonPrintableAsciiCharacters(String)} 57 | * 58 | * @return a printable String 59 | */ 60 | public static String toPrintableString(final ChannelBuffer buffer, int maxLength) { 61 | int actualLength = buffer.readableBytes() < maxLength ? buffer.readableBytes() : maxLength; 62 | final byte[] bytes = new byte[actualLength]; 63 | buffer.getBytes(buffer.readerIndex(), bytes, 0, actualLength); 64 | return StringUtils.replaceNonPrintableAsciiCharacters(new String(bytes)); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/util/HandlerFactoryPropertiesHelper.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.util; 2 | 3 | import com.google.common.collect.Multimap; 4 | 5 | import java.util.concurrent.TimeUnit; 6 | 7 | public class HandlerFactoryPropertiesHelper { 8 | 9 | public static String getFirstValueOf(Multimap properties, String name, String defaultValue) { 10 | if (properties.containsKey(name)) { 11 | return properties.get(name).iterator().next(); 12 | } else { 13 | return defaultValue; 14 | } 15 | } 16 | 17 | public static long getFirstValueOf(Multimap properties, String name, long defaultValue) { 18 | return Long.parseLong(getFirstValueOf(properties, name, "" + defaultValue)); 19 | } 20 | 21 | public static int getFirstValueOf(Multimap properties, String name, int defaultValue) { 22 | return Integer.parseInt(getFirstValueOf(properties, name, "" + defaultValue)); 23 | } 24 | 25 | public static short getFirstValueOf(Multimap properties, String name, short defaultValue) { 26 | return Short.parseShort(getFirstValueOf(properties, name, "" + defaultValue)); 27 | } 28 | 29 | public static TimeUnit getFirstValueOf(Multimap properties, String name, TimeUnit defaultValue) { 30 | return TimeUnit.valueOf(getFirstValueOf(properties, name, defaultValue.toString())); 31 | } 32 | 33 | public static boolean getFirstValueOf(final Multimap properties, final String name, 34 | final boolean defaultValue) { 35 | return Boolean.parseBoolean(getFirstValueOf(properties, name, "" + defaultValue)); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/util/HeaderAndJavaBeansXMLDecoderEncoder.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.util; 2 | 3 | import org.jboss.netty.buffer.ChannelBuffer; 4 | import org.jboss.netty.buffer.ChannelBuffers; 5 | import org.simpleframework.xml.Serializer; 6 | import org.simpleframework.xml.core.Persister; 7 | 8 | import java.io.ByteArrayInputStream; 9 | import java.io.ByteArrayOutputStream; 10 | import java.util.Arrays; 11 | 12 | 13 | public abstract class HeaderAndJavaBeansXMLDecoderEncoder { 14 | 15 | @SuppressWarnings("unchecked") 16 | public static T decode(String expectedHeader, Class expectedClass, ChannelBuffer buffer) { 17 | buffer.markReaderIndex(); 18 | 19 | byte[] requestBytes = getWithoutHeader(expectedHeader, buffer); 20 | 21 | if (requestBytes == null) { 22 | buffer.resetReaderIndex(); 23 | return null; 24 | } 25 | 26 | try { 27 | 28 | ByteArrayInputStream bufferInputStream = new ByteArrayInputStream(requestBytes); 29 | Serializer serializer = new Persister(); 30 | return serializer.read(expectedClass, bufferInputStream); 31 | 32 | } catch (Exception e) { 33 | buffer.resetReaderIndex(); 34 | return null; 35 | } 36 | 37 | } 38 | 39 | public static ChannelBuffer encode(String serializationHeader, Object object) { 40 | 41 | final ByteArrayOutputStream out = new ByteArrayOutputStream(); 42 | 43 | try { 44 | 45 | out.write(serializationHeader.getBytes()); 46 | 47 | Serializer serializer = new Persister(); 48 | serializer.write(object, out); 49 | 50 | return ChannelBuffers.wrappedBuffer(out.toByteArray()); 51 | 52 | } catch (Exception e) { 53 | throw new RuntimeException(e); 54 | } 55 | 56 | } 57 | 58 | 59 | /** 60 | * Extracts the XML bytes from the received object by removing the {@link this#header} SERIALIZATION_HEADER string. 61 | * Checks if the received message is a ChannelBuffer, has a minimal length and contains {@link this#header} prefix. 62 | * If not, null is returned. 63 | * 64 | * @param msg 65 | * The received object 66 | * 67 | * @return The bytes containing the request as serialized XML or null if the request could not be parsed. 68 | */ 69 | private static byte[] getWithoutHeader(String headerString, ChannelBuffer msg) { 70 | if (msg.readableBytes() <= headerString.length()) { 71 | return null; 72 | } 73 | 74 | byte[] byteArray = ChannelBufferTools.readToByteArray(msg); 75 | 76 | String receivedHeader = new String(byteArray, 0, headerString.length()); 77 | 78 | if (!headerString.equals(receivedHeader)) { 79 | return null; 80 | } 81 | 82 | byteArray = Arrays.copyOfRange(byteArray, headerString.length(), byteArray.length); 83 | return byteArray; 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/util/HexStringIntegerMatcher.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.util; 2 | 3 | import org.simpleframework.xml.transform.Matcher; 4 | import org.simpleframework.xml.transform.Transform; 5 | 6 | public class HexStringIntegerMatcher implements Matcher { 7 | 8 | @Override 9 | public Transform match(final Class type) throws Exception { 10 | if (type.equals(Integer.class)) { 11 | return new HexStringIntegerTransform(); 12 | } 13 | return null; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/util/HexStringIntegerTransform.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.util; 2 | 3 | import de.uniluebeck.itm.util.StringUtils; 4 | import org.simpleframework.xml.transform.Transform; 5 | 6 | public class HexStringIntegerTransform implements Transform { 7 | 8 | @Override 9 | public Integer read(final String value) throws Exception { 10 | return (int) StringUtils.fromStringToLong(value.trim()); 11 | } 12 | 13 | @Override 14 | public String write(final Integer value) throws Exception { 15 | return StringUtils.toHexString(value).trim(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/util/OneToOneDownstreamDecoder.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.util; 2 | 3 | import org.jboss.netty.channel.Channel; 4 | import org.jboss.netty.channel.ChannelHandlerContext; 5 | import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; 6 | 7 | public abstract class OneToOneDownstreamDecoder extends OneToOneEncoder { 8 | 9 | protected abstract Object decode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception; 10 | 11 | @Override 12 | protected final Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { 13 | return decode(ctx, channel, msg); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/util/OneToOneUpstreamEncoder.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.util; 2 | 3 | import org.jboss.netty.channel.Channel; 4 | import org.jboss.netty.channel.ChannelHandlerContext; 5 | import org.jboss.netty.handler.codec.oneone.OneToOneDecoder; 6 | 7 | public abstract class OneToOneUpstreamEncoder extends OneToOneDecoder { 8 | 9 | @Override 10 | protected final Object decode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { 11 | return encode(ctx, channel, msg); 12 | } 13 | 14 | protected abstract Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/util/PropertiesHelper.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.util; 2 | 3 | import com.google.common.collect.Multimap; 4 | 5 | import java.util.Iterator; 6 | 7 | public class PropertiesHelper { 8 | 9 | public static Integer getIntFromProperties(final Multimap properties, final String key) { 10 | 11 | final Iterator iterator = properties.get(key).iterator(); 12 | if (iterator.hasNext()) { 13 | String value = iterator.next(); 14 | return value == null ? null : Integer.parseInt(value); 15 | } 16 | return null; 17 | } 18 | 19 | public static Boolean getBooleanFromProperties(final Multimap properties, 20 | final String key) { 21 | 22 | final Iterator iterator = properties.get(key).iterator(); 23 | if (iterator.hasNext()) { 24 | String value = iterator.next(); 25 | return value == null ? null : Boolean.parseBoolean(value); 26 | } 27 | return null; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/Command.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet; 2 | 3 | import org.jboss.netty.buffer.ChannelBuffer; 4 | import org.jboss.netty.buffer.ChannelBuffers; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 09.06.11 10 | * Time: 13:27 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public abstract class Command { 14 | 15 | protected ChannelBuffer buffer; 16 | 17 | public Command(byte commandType, byte requestID, ChannelBuffer payload) { 18 | buffer = ChannelBuffers.dynamicBuffer(); 19 | buffer.writeByte(commandType); 20 | buffer.writeByte(requestID); 21 | buffer.writeBytes(payload); 22 | } 23 | 24 | public abstract ChannelBuffer getBuffer(); 25 | 26 | public int getCommandType() { 27 | return this.buffer.getByte(0); 28 | } 29 | 30 | public int getRequestID() { 31 | return this.buffer.getByte(1); 32 | } 33 | 34 | public ChannelBuffer getPayload() { 35 | return this.buffer.slice(2, this.buffer.readableBytes() - 2); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/CommandResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet; 2 | 3 | import org.jboss.netty.buffer.ChannelBuffer; 4 | import org.jboss.netty.buffer.ChannelBuffers; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 29.06.11 10 | * Time: 15:32 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public abstract class CommandResponse { 14 | 15 | protected ChannelBuffer buffer; 16 | 17 | public CommandResponse(byte commandType, byte requestID, byte result, ChannelBuffer payload) { 18 | buffer = ChannelBuffers.dynamicBuffer(); 19 | buffer.writeByte(commandType); 20 | buffer.writeByte(requestID); 21 | buffer.writeByte(result); 22 | buffer.writeBytes(payload); 23 | } 24 | 25 | public ChannelBuffer getBuffer() { 26 | return this.buffer; 27 | } 28 | 29 | public byte getCommandType() { 30 | return buffer.getByte(0); 31 | } 32 | 33 | public byte getRequestID() { 34 | return buffer.getByte(1); 35 | } 36 | 37 | public byte getResult() { 38 | return buffer.getByte(2); 39 | } 40 | 41 | public ChannelBuffer getPayload() { 42 | return buffer.slice(3, buffer.readableBytes() - 3); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/CommandType.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet; 2 | 3 | /** 4 | * Created by IntelliJ IDEA. 5 | * User: nrohwedder 6 | * Date: 29.06.11 7 | * Time: 17:01 8 | * To change this template use File | Settings | File Templates. 9 | */ 10 | public class CommandType { 11 | 12 | public class Interaction { 13 | 14 | public final static byte TEXT_DATA = 10; 15 | 16 | public final static byte VIRTUAL_LINK_DATA = 11; 17 | 18 | public final static byte BINARY_DATA = 12; 19 | 20 | public final static byte FLASH_PROGRAM_DATA = 13; 21 | 22 | public final static byte NODE_OUTPUT_TEXT = 50; 23 | 24 | public final static byte NODE_OUTPUT_BINARY = 51; 25 | 26 | public final static byte NODE_OUTPUT_VIRTUAL_LINK = 52; 27 | } 28 | 29 | public class NodeControl { 30 | 31 | public final static byte ENABLE_NODE = 20; 32 | 33 | public final static byte DISABLE_NODE = 21; 34 | 35 | public final static byte RESET_NODE = 22; 36 | 37 | public final static byte SET_START_TIME = 23; 38 | 39 | public final static byte SET_VIRTUAL_ID = 24; 40 | 41 | public final static byte ARE_NODES_ALIVE = 25; 42 | 43 | public final static byte GET_VERSION = 26; 44 | } 45 | 46 | public class LinkControl { 47 | 48 | public final static byte SET_VIRTUAL_LINK = 30; 49 | 50 | public final static byte DESTROY_VIRTUAL_LINK = 31; 51 | 52 | public final static byte ENABLE_PHYSICAL_LINK = 32; 53 | 54 | public final static byte DISABLE_PHYSICAL_LINK = 33; 55 | } 56 | 57 | public class NetworkDescription { 58 | 59 | public final static byte GET_PROPERTY_VALUE = 40; 60 | 61 | public final static byte GET_NEIGHBORHOOD = 41; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/Request.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet; 2 | 3 | /** 4 | * Created by IntelliJ IDEA. User: bimschas Date: 08.06.11 Time: 16:05 TODO change 5 | */ 6 | public abstract class Request { 7 | 8 | private final byte commandType; 9 | 10 | private final byte requestID; 11 | 12 | private final byte[] payload; 13 | 14 | public Request(final byte commandType, final byte requestID, final byte[] payload) { 15 | this.commandType = commandType; 16 | this.requestID = requestID; 17 | this.payload = payload; 18 | } 19 | 20 | public byte getRequestID() { 21 | return requestID; 22 | } 23 | 24 | public byte getCommandType() { 25 | return this.commandType; 26 | } 27 | 28 | public byte[] getPayload() { 29 | return payload; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/Response.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet; 2 | 3 | /** 4 | * Created by IntelliJ IDEA. 5 | * User: nrohwedder 6 | * Date: 09.06.11 7 | * Time: 13:25 8 | * To change this template use File | Settings | File Templates. 9 | */ 10 | public abstract class Response { 11 | 12 | final protected Request request; 13 | 14 | public Response(final Request request) { 15 | this.request = request; 16 | } 17 | 18 | public Request getRequest() { 19 | return this.request; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/TimeOutResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet; 2 | 3 | /** 4 | * Created by IntelliJ IDEA. 5 | * User: nrohwedder 6 | * Date: 10.06.11 7 | * Time: 12:18 8 | * To change this template use File | Settings | File Templates. 9 | */ 10 | public class TimeOutResponse extends Response { 11 | 12 | public TimeOutResponse(final Request request) { 13 | super(request); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/BinaryDataCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import org.jboss.netty.buffer.ChannelBuffer; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 04.07.11 10 | * Time: 10:37 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class BinaryDataCommand extends BinaryMessageCommand { 14 | 15 | public BinaryDataCommand(byte requestID, byte len, ChannelBuffer payload) { 16 | super(CommandType.Interaction.BINARY_DATA, requestID, len, payload); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/BinaryDataCommandResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandResponse; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 04.07.11 11 | * Time: 10:33 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class BinaryDataCommandResponse extends CommandResponse { 15 | 16 | public BinaryDataCommandResponse(byte requestID, byte result, ChannelBuffer payload) { 17 | super(CommandType.Interaction.BINARY_DATA, requestID, result, payload); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/BinaryDataRequest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Request; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 04.07.11 10 | * Time: 10:16 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class BinaryDataRequest extends Request { 14 | 15 | private final byte len; 16 | 17 | public BinaryDataRequest(final byte requestID, final byte len, final byte[] payload) { 18 | super(CommandType.Interaction.BINARY_DATA, requestID, payload); 19 | this.len = len; 20 | } 21 | 22 | public byte getLen() { 23 | return this.len; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/BinaryDataResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Response; 4 | 5 | /** 6 | * Created by IntelliJ IDEA. 7 | * User: nrohwedder 8 | * Date: 04.07.11 9 | * Time: 10:43 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class BinaryDataResponse extends Response { 13 | 14 | public BinaryDataResponse(final BinaryDataRequest request) { 15 | super(request); 16 | } 17 | 18 | public byte getLen() { 19 | return ((BinaryDataRequest) request).getLen(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/BinaryMessageCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Command; 4 | import org.jboss.netty.buffer.ChannelBuffer; 5 | import org.jboss.netty.buffer.ChannelBuffers; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 04.07.11 11 | * Time: 15:31 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public abstract class BinaryMessageCommand extends Command { 15 | 16 | private ChannelBuffer buffer; 17 | 18 | public BinaryMessageCommand(byte commandType, byte requestID, byte len, ChannelBuffer payload) { 19 | super(commandType, requestID, payload); 20 | this.buffer = ChannelBuffers.buffer(1); 21 | this.buffer.writeByte(len); 22 | 23 | } 24 | 25 | public byte getLen() { 26 | return this.buffer.getByte(0); 27 | } 28 | 29 | @Override 30 | public ChannelBuffer getBuffer() { 31 | return ChannelBuffers.wrappedBuffer(super.buffer, this.buffer); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/FlashProgramDataCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import org.jboss.netty.buffer.ChannelBuffer; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 04.07.11 10 | * Time: 12:01 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class FlashProgramDataCommand extends FlashProgramMessageCommand { 14 | 15 | public FlashProgramDataCommand(byte requestID, byte len, ChannelBuffer payload) { 16 | super(CommandType.Interaction.FLASH_PROGRAM_DATA, requestID, len, payload); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/FlashProgramDataCommandResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandResponse; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 04.07.11 11 | * Time: 11:59 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class FlashProgramDataCommandResponse extends CommandResponse { 15 | 16 | public FlashProgramDataCommandResponse(byte requestID, byte result, ChannelBuffer payload) { 17 | super(CommandType.Interaction.FLASH_PROGRAM_DATA, requestID, result, payload); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/FlashProgramDataRequest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Request; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 04.07.11 10 | * Time: 11:56 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class FlashProgramDataRequest extends Request { 14 | 15 | private final byte len; 16 | 17 | public FlashProgramDataRequest(final byte requestID, final byte len, final byte[] payload) { 18 | super(CommandType.Interaction.FLASH_PROGRAM_DATA, requestID, payload); 19 | this.len = len; 20 | } 21 | 22 | public byte getLen() { 23 | return len; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/FlashProgramDataResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Response; 4 | 5 | /** 6 | * Created by IntelliJ IDEA. 7 | * User: nrohwedder 8 | * Date: 04.07.11 9 | * Time: 13:13 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class FlashProgramDataResponse extends Response { 13 | 14 | public FlashProgramDataResponse(final FlashProgramDataRequest request) { 15 | super(request); 16 | } 17 | 18 | public byte getLen() { 19 | return ((FlashProgramDataRequest) request).getLen(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/FlashProgramMessageCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Command; 4 | import org.jboss.netty.buffer.ChannelBuffer; 5 | import org.jboss.netty.buffer.ChannelBuffers; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 04.07.11 11 | * Time: 15:39 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public abstract class FlashProgramMessageCommand extends Command { 15 | 16 | private ChannelBuffer buffer; 17 | 18 | public FlashProgramMessageCommand(byte commandType, byte requestID, byte len, ChannelBuffer payload) { 19 | super(commandType, requestID, payload); 20 | this.buffer = ChannelBuffers.buffer(1); 21 | this.buffer.writeByte(len); 22 | } 23 | 24 | public byte getLen() { 25 | return this.buffer.getByte(0); 26 | } 27 | 28 | @Override 29 | public ChannelBuffer getBuffer() { 30 | return ChannelBuffers.wrappedBuffer(super.buffer, this.buffer); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/NodeOutputBinaryCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import org.jboss.netty.buffer.ChannelBuffer; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 04.07.11 10 | * Time: 13:36 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class NodeOutputBinaryCommand extends BinaryMessageCommand { 14 | 15 | public NodeOutputBinaryCommand(byte requestID, byte len, ChannelBuffer payload) { 16 | super(CommandType.Interaction.NODE_OUTPUT_BINARY, requestID, len, payload); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/NodeOutputBinaryCommandResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandResponse; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 04.07.11 11 | * Time: 13:32 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class NodeOutputBinaryCommandResponse extends CommandResponse { 15 | 16 | public NodeOutputBinaryCommandResponse(byte requestID, byte result, ChannelBuffer payload) { 17 | super(CommandType.Interaction.NODE_OUTPUT_BINARY, requestID, result, payload); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/NodeOutputBinaryRequest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Request; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 04.07.11 10 | * Time: 13:30 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class NodeOutputBinaryRequest extends Request { 14 | 15 | private final byte len; 16 | 17 | public NodeOutputBinaryRequest(final byte requestID, final byte len, final byte[] payload) { 18 | super(CommandType.Interaction.NODE_OUTPUT_BINARY, requestID, payload); 19 | this.len = len; 20 | } 21 | 22 | public byte getLen() { 23 | return len; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/NodeOutputBinaryResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Response; 4 | 5 | /** 6 | * Created by IntelliJ IDEA. 7 | * User: nrohwedder 8 | * Date: 04.07.11 9 | * Time: 13:40 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class NodeOutputBinaryResponse extends Response { 13 | 14 | public NodeOutputBinaryResponse(final NodeOutputBinaryRequest request) { 15 | super(request); 16 | } 17 | 18 | public byte getLen() { 19 | return ((NodeOutputBinaryRequest) request).getLen(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/NodeOutputTextCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import org.jboss.netty.buffer.ChannelBuffer; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 04.07.11 10 | * Time: 13:22 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class NodeOutputTextCommand extends TextMessageCommand { 14 | 15 | public NodeOutputTextCommand(byte requestID, byte messageLevel, ChannelBuffer payload) { 16 | super(CommandType.Interaction.NODE_OUTPUT_TEXT, requestID, messageLevel, payload); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/NodeOutputTextCommandResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandResponse; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 04.07.11 11 | * Time: 13:20 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class NodeOutputTextCommandResponse extends CommandResponse { 15 | 16 | public NodeOutputTextCommandResponse(byte requestID, byte result, ChannelBuffer payload) { 17 | super(CommandType.Interaction.NODE_OUTPUT_TEXT, requestID, result, payload); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/NodeOutputTextRequest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Request; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 04.07.11 10 | * Time: 13:17 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class NodeOutputTextRequest extends Request { 14 | 15 | private final byte messageLevel; 16 | 17 | public NodeOutputTextRequest(final byte requestID, final byte messageLevel, final byte[] payload) { 18 | super(CommandType.Interaction.NODE_OUTPUT_TEXT, requestID, payload); 19 | this.messageLevel = messageLevel; 20 | 21 | } 22 | 23 | public byte getMessageLevel() { 24 | return messageLevel; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/NodeOutputTextResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Response; 4 | 5 | /** 6 | * Created by IntelliJ IDEA. 7 | * User: nrohwedder 8 | * Date: 04.07.11 9 | * Time: 13:26 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class NodeOutputTextResponse extends Response { 13 | 14 | public NodeOutputTextResponse(final NodeOutputTextRequest request) { 15 | super(request); 16 | } 17 | 18 | public byte getMessageLevel() { 19 | return ((NodeOutputTextRequest) request).getMessageLevel(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/NodeOutputVirtualLinkCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import org.jboss.netty.buffer.ChannelBuffer; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 04.07.11 10 | * Time: 13:51 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class NodeOutputVirtualLinkCommand extends VirtualLinkMessageCommand { 14 | 15 | public NodeOutputVirtualLinkCommand(byte requestID, byte rssi, byte lqi, byte len, long dest, long source, 16 | ChannelBuffer payload) { 17 | super(CommandType.Interaction.NODE_OUTPUT_VIRTUAL_LINK, requestID, rssi, lqi, len, dest, source, payload); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/NodeOutputVirtualLinkCommandResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandResponse; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 04.07.11 11 | * Time: 13:49 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class NodeOutputVirtualLinkCommandResponse extends CommandResponse { 15 | 16 | public NodeOutputVirtualLinkCommandResponse(byte requestID, byte result, ChannelBuffer payload) { 17 | super(CommandType.Interaction.NODE_OUTPUT_VIRTUAL_LINK, requestID, result, payload); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/NodeOutputVirtualLinkRequest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Request; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 04.07.11 10 | * Time: 13:44 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class NodeOutputVirtualLinkRequest extends Request { 14 | 15 | private final byte rssi; 16 | 17 | private final byte lqi; 18 | 19 | private final byte len; 20 | 21 | private final long dest; 22 | 23 | private final long source; 24 | 25 | public NodeOutputVirtualLinkRequest(final byte requestID, final byte rssi, final byte lqi, final byte len, 26 | final long dest, final long source, byte[] payload) { 27 | super(CommandType.Interaction.NODE_OUTPUT_VIRTUAL_LINK, requestID, payload); 28 | this.rssi = rssi; 29 | this.lqi = lqi; 30 | this.len = len; 31 | this.dest = dest; 32 | this.source = source; 33 | } 34 | 35 | public byte getRssi() { 36 | return rssi; 37 | } 38 | 39 | public byte getLqi() { 40 | return lqi; 41 | } 42 | 43 | public byte getLen() { 44 | return len; 45 | } 46 | 47 | public long getDest() { 48 | return dest; 49 | } 50 | 51 | public long getSource() { 52 | return source; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/NodeOutputVirtualLinkResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Response; 4 | 5 | /** 6 | * Created by IntelliJ IDEA. 7 | * User: nrohwedder 8 | * Date: 04.07.11 9 | * Time: 13:59 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class NodeOutputVirtualLinkResponse extends Response { 13 | 14 | public NodeOutputVirtualLinkResponse(final NodeOutputVirtualLinkRequest request) { 15 | super(request); 16 | } 17 | 18 | public byte getRssi() { 19 | return ((NodeOutputVirtualLinkRequest) request).getRssi(); 20 | } 21 | 22 | public byte getLqi() { 23 | return ((NodeOutputVirtualLinkRequest) request).getLqi(); 24 | } 25 | 26 | public byte getLen() { 27 | return ((NodeOutputVirtualLinkRequest) request).getLen(); 28 | } 29 | 30 | public long getDest() { 31 | return ((NodeOutputVirtualLinkRequest) request).getDest(); 32 | } 33 | 34 | public long getSource() { 35 | return ((NodeOutputVirtualLinkRequest) request).getSource(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/TextDataCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import org.jboss.netty.buffer.ChannelBuffer; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 01.07.11 10 | * Time: 12:12 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class TextDataCommand extends TextMessageCommand { 14 | 15 | public TextDataCommand(byte requestID, byte messageLevel, ChannelBuffer text) { 16 | super(CommandType.Interaction.TEXT_DATA, requestID, messageLevel, text); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/TextDataCommandResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandResponse; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 01.07.11 11 | * Time: 12:09 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class TextDataCommandResponse extends CommandResponse { 15 | 16 | public TextDataCommandResponse(byte requestID, byte result, ChannelBuffer payload) { 17 | super(CommandType.Interaction.TEXT_DATA, requestID, result, payload); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/TextDataRequest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Request; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 01.07.11 10 | * Time: 12:01 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class TextDataRequest extends Request { 14 | 15 | private final byte messageLevel; 16 | 17 | public TextDataRequest(final byte requestID, final byte messageLevel, final byte[] payload) { 18 | super(CommandType.Interaction.TEXT_DATA, requestID, payload); 19 | this.messageLevel = messageLevel; 20 | } 21 | 22 | public byte getMessageLevel() { 23 | return messageLevel; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/TextDataResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Response; 4 | 5 | /** 6 | * Created by IntelliJ IDEA. 7 | * User: nrohwedder 8 | * Date: 01.07.11 9 | * Time: 12:20 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class TextDataResponse extends Response { 13 | 14 | public TextDataResponse(final TextDataRequest request) { 15 | super(request); 16 | } 17 | 18 | public byte getMessageLevel() { 19 | return ((TextDataRequest) request).getMessageLevel(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/TextMessageCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Command; 4 | import org.jboss.netty.buffer.ChannelBuffer; 5 | import org.jboss.netty.buffer.ChannelBuffers; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 04.07.11 11 | * Time: 15:26 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public abstract class TextMessageCommand extends Command { 15 | 16 | private ChannelBuffer buffer; 17 | 18 | public TextMessageCommand(byte commandType, byte requestID, byte messageLevel, ChannelBuffer text) { 19 | super(commandType, requestID, text); 20 | this.buffer = ChannelBuffers.buffer(1); 21 | this.buffer.writeByte(messageLevel); 22 | } 23 | 24 | public byte getMessageLevel() { 25 | return this.buffer.getByte(0); 26 | } 27 | 28 | @Override 29 | public ChannelBuffer getBuffer() { 30 | return ChannelBuffers.wrappedBuffer(super.buffer, this.buffer); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/VirtualLinkDataCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import org.jboss.netty.buffer.ChannelBuffer; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 01.07.11 10 | * Time: 12:40 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class VirtualLinkDataCommand extends VirtualLinkMessageCommand { 14 | 15 | public VirtualLinkDataCommand(byte requestID, byte rssi, byte lqi, byte len, long dest, long source, 16 | ChannelBuffer payload) { 17 | super(CommandType.Interaction.VIRTUAL_LINK_DATA, requestID, rssi, lqi, len, dest, source, payload); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/VirtualLinkDataCommandResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandResponse; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 01.07.11 11 | * Time: 12:37 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class VirtualLinkDataCommandResponse extends CommandResponse { 15 | 16 | public VirtualLinkDataCommandResponse(byte requestID, byte result, ChannelBuffer payload) { 17 | super(CommandType.Interaction.VIRTUAL_LINK_DATA, requestID, result, payload); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/VirtualLinkDataRequest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Request; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 01.07.11 10 | * Time: 12:29 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class VirtualLinkDataRequest extends Request { 14 | 15 | private final byte rssi; 16 | 17 | private final byte lqi; 18 | 19 | private final byte len; 20 | 21 | private final long dest; 22 | 23 | private final long source; 24 | 25 | public VirtualLinkDataRequest(final byte requestID, final byte rssi, final byte lqi, final byte len, 26 | final long dest, final long source, final byte[] payload) { 27 | super(CommandType.Interaction.VIRTUAL_LINK_DATA, requestID, payload); 28 | this.rssi = rssi; 29 | this.lqi = lqi; 30 | this.len = len; 31 | this.dest = dest; 32 | this.source = source; 33 | } 34 | 35 | public byte getRssi() { 36 | return rssi; 37 | } 38 | 39 | public byte getLqi() { 40 | return lqi; 41 | } 42 | 43 | public byte getLen() { 44 | return len; 45 | } 46 | 47 | public long getDest() { 48 | return dest; 49 | } 50 | 51 | public long getSource() { 52 | return source; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/VirtualLinkDataResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Response; 4 | 5 | /** 6 | * Created by IntelliJ IDEA. 7 | * User: nrohwedder 8 | * Date: 04.07.11 9 | * Time: 10:08 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class VirtualLinkDataResponse extends Response { 13 | 14 | public VirtualLinkDataResponse(final VirtualLinkDataRequest request) { 15 | super(request); 16 | } 17 | 18 | public byte getRssi() { 19 | return ((VirtualLinkDataRequest) request).getRssi(); 20 | } 21 | 22 | public byte getLqi() { 23 | return ((VirtualLinkDataRequest) request).getLqi(); 24 | } 25 | 26 | public byte getLen() { 27 | return ((VirtualLinkDataRequest) request).getLen(); 28 | } 29 | 30 | public long getDest() { 31 | return ((VirtualLinkDataRequest) request).getDest(); 32 | } 33 | 34 | public long getSource() { 35 | return ((VirtualLinkDataRequest) request).getSource(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/interaction/VirtualLinkMessageCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.interaction; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Command; 4 | import org.jboss.netty.buffer.ChannelBuffer; 5 | import org.jboss.netty.buffer.ChannelBuffers; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 04.07.11 11 | * Time: 15:35 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public abstract class VirtualLinkMessageCommand extends Command { 15 | 16 | private ChannelBuffer buffer; 17 | 18 | public VirtualLinkMessageCommand(byte commandType, byte requestID, byte rssi, byte lqi, byte len, long dest, 19 | long source, ChannelBuffer payload) { 20 | super(commandType, requestID, payload); 21 | this.buffer = ChannelBuffers.buffer(19); 22 | this.buffer.writeByte(rssi); 23 | this.buffer.writeByte(lqi); 24 | this.buffer.writeByte(len); 25 | this.buffer.writeLong(dest); 26 | this.buffer.writeLong(source); 27 | } 28 | 29 | public byte getRssi() { 30 | return this.buffer.getByte(0); 31 | } 32 | 33 | public byte getLqi() { 34 | return this.buffer.getByte(1); 35 | } 36 | 37 | public byte getLen() { 38 | return this.buffer.getByte(2); 39 | } 40 | 41 | public long getDest() { 42 | return this.buffer.getLong(3); 43 | } 44 | 45 | public long getSource() { 46 | return this.buffer.getLong(11); 47 | } 48 | 49 | @Override 50 | public ChannelBuffer getBuffer() { 51 | return ChannelBuffers.wrappedBuffer(super.buffer, this.buffer); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/linkcontrol/DestroyVirtualLinkCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.linkcontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Command; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | import org.jboss.netty.buffer.ChannelBuffers; 7 | 8 | /** 9 | * Created by IntelliJ IDEA. 10 | * User: nrohwedder 11 | * Date: 29.06.11 12 | * Time: 17:05 13 | * To change this template use File | Settings | File Templates. 14 | */ 15 | public class DestroyVirtualLinkCommand extends Command { 16 | 17 | private ChannelBuffer buffer; 18 | 19 | public DestroyVirtualLinkCommand(byte requestID, ChannelBuffer payload, long destinationNode) { 20 | super(CommandType.LinkControl.DESTROY_VIRTUAL_LINK, requestID, payload); 21 | this.buffer = ChannelBuffers.buffer(8); 22 | this.buffer.writeLong(destinationNode); 23 | } 24 | 25 | public long getDestinationNode() { 26 | return this.buffer.getLong(0); 27 | } 28 | 29 | public ChannelBuffer getBuffer() { 30 | return ChannelBuffers.wrappedBuffer(super.buffer, this.buffer); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/linkcontrol/DestroyVirtualLinkCommandResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.linkcontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandResponse; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 29.06.11 11 | * Time: 17:29 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class DestroyVirtualLinkCommandResponse extends CommandResponse { 15 | 16 | public DestroyVirtualLinkCommandResponse(byte requestID, byte result, ChannelBuffer payload) { 17 | super(CommandType.LinkControl.DESTROY_VIRTUAL_LINK, requestID, result, payload); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/linkcontrol/DestroyVirtualLinkRequest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.linkcontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Request; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 29.06.11 10 | * Time: 17:23 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class DestroyVirtualLinkRequest extends Request { 14 | 15 | private final long destinationNode; 16 | 17 | public DestroyVirtualLinkRequest(final byte requestID, final byte payload[], final long destinationNode) { 18 | super(CommandType.LinkControl.DESTROY_VIRTUAL_LINK, requestID, payload); 19 | this.destinationNode = destinationNode; 20 | } 21 | 22 | public long getDestinationNode() { 23 | return destinationNode; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/linkcontrol/DestroyVirtualLinkResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.linkcontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Response; 4 | 5 | /** 6 | * Created by IntelliJ IDEA. 7 | * User: nrohwedder 8 | * Date: 29.06.11 9 | * Time: 17:48 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class DestroyVirtualLinkResponse extends Response { 13 | 14 | public DestroyVirtualLinkResponse(final DestroyVirtualLinkRequest request) { 15 | super(request); 16 | } 17 | 18 | public long getDestinationNode() { 19 | return ((DestroyVirtualLinkRequest) request).getDestinationNode(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/linkcontrol/DisablePhysicalLinkCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.linkcontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Command; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | import org.jboss.netty.buffer.ChannelBuffers; 7 | 8 | /** 9 | * Created by IntelliJ IDEA. 10 | * User: nrohwedder 11 | * Date: 30.06.11 12 | * Time: 10:39 13 | * To change this template use File | Settings | File Templates. 14 | */ 15 | public class DisablePhysicalLinkCommand extends Command { 16 | 17 | private ChannelBuffer buffer; 18 | 19 | public DisablePhysicalLinkCommand(byte requestID, ChannelBuffer payload, long nodeB) { 20 | super(CommandType.LinkControl.DISABLE_PHYSICAL_LINK, requestID, payload); 21 | this.buffer = ChannelBuffers.buffer(8); 22 | this.buffer.writeLong(nodeB); 23 | } 24 | 25 | @Override 26 | public ChannelBuffer getBuffer() { 27 | return ChannelBuffers.wrappedBuffer(super.buffer, this.buffer); 28 | } 29 | 30 | public long getNodeB() { 31 | return this.buffer.getLong(0); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/linkcontrol/DisablePhysicalLinkCommandResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.linkcontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandResponse; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 30.06.11 11 | * Time: 10:35 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class DisablePhysicalLinkCommandResponse extends CommandResponse { 15 | 16 | public DisablePhysicalLinkCommandResponse(byte requestID, byte result, ChannelBuffer payload) { 17 | super(CommandType.LinkControl.DISABLE_PHYSICAL_LINK, requestID, result, payload); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/linkcontrol/DisablePhysicalLinkRequest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.linkcontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Request; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 30.06.11 10 | * Time: 10:24 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class DisablePhysicalLinkRequest extends Request { 14 | 15 | private final long nodeB; 16 | 17 | public DisablePhysicalLinkRequest(final byte requestID, final byte[] payload, final long nodeB) { 18 | super(CommandType.LinkControl.DISABLE_PHYSICAL_LINK, requestID, payload); 19 | this.nodeB = nodeB; 20 | } 21 | 22 | public long getNodeB() { 23 | return this.nodeB; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/linkcontrol/DisablePhysicalLinkResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.linkcontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Response; 4 | 5 | /** 6 | * Created by IntelliJ IDEA. 7 | * User: nrohwedder 8 | * Date: 30.06.11 9 | * Time: 10:46 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class DisablePhysicalLinkResponse extends Response { 13 | 14 | public DisablePhysicalLinkResponse(final DisablePhysicalLinkRequest request) { 15 | super(request); 16 | } 17 | 18 | public long getNodeB() { 19 | return ((DisablePhysicalLinkRequest) request).getNodeB(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/linkcontrol/EnablePhysicalLinkCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.linkcontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Command; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | import org.jboss.netty.buffer.ChannelBuffers; 7 | 8 | /** 9 | * Created by IntelliJ IDEA. 10 | * User: nrohwedder 11 | * Date: 29.06.11 12 | * Time: 19:47 13 | * To change this template use File | Settings | File Templates. 14 | */ 15 | public class EnablePhysicalLinkCommand extends Command { 16 | 17 | private ChannelBuffer buffer; 18 | 19 | public EnablePhysicalLinkCommand(byte requestID, ChannelBuffer payload, long nodeB) { 20 | super(CommandType.LinkControl.ENABLE_PHYSICAL_LINK, requestID, payload); 21 | buffer = ChannelBuffers.buffer(8); 22 | buffer.writeLong(nodeB); 23 | } 24 | 25 | public long getNodeB() { 26 | return buffer.getLong(0); 27 | } 28 | 29 | public ChannelBuffer getBuffer() { 30 | return ChannelBuffers.wrappedBuffer(super.buffer, this.buffer); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/linkcontrol/EnablePhysicalLinkCommandResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.linkcontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandResponse; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 29.06.11 11 | * Time: 19:43 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class EnablePhysicalLinkCommandResponse extends CommandResponse { 15 | 16 | public EnablePhysicalLinkCommandResponse(byte requestID, byte result, ChannelBuffer payload) { 17 | super(CommandType.LinkControl.ENABLE_PHYSICAL_LINK, requestID, result, payload); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/linkcontrol/EnablePhysicalLinkRequest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.linkcontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Request; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 29.06.11 10 | * Time: 19:36 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class EnablePhysicalLinkRequest extends Request { 14 | 15 | private final long nodeB; 16 | 17 | public EnablePhysicalLinkRequest(final byte requestID, final byte[] payload, final long nodeB) { 18 | super(CommandType.LinkControl.ENABLE_PHYSICAL_LINK, requestID, payload); 19 | this.nodeB = nodeB; 20 | } 21 | 22 | public long getNodeB() { 23 | return nodeB; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/linkcontrol/EnablePhysicalLinkResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.linkcontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Response; 4 | 5 | /** 6 | * Created by IntelliJ IDEA. 7 | * User: nrohwedder 8 | * Date: 29.06.11 9 | * Time: 19:42 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class EnablePhysicalLinkResponse extends Response { 13 | 14 | public EnablePhysicalLinkResponse(final EnablePhysicalLinkRequest request) { 15 | super(request); 16 | } 17 | 18 | public long getNodeB() { 19 | return ((EnablePhysicalLinkRequest) request).getNodeB(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/linkcontrol/SetVirtualLinkCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.linkcontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Command; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | import org.jboss.netty.buffer.ChannelBuffers; 7 | 8 | /** 9 | * Created by IntelliJ IDEA. 10 | * User: nrohwedder 11 | * Date: 29.06.11 12 | * Time: 16:55 13 | * To change this template use File | Settings | File Templates. 14 | */ 15 | public class SetVirtualLinkCommand extends Command { 16 | 17 | private ChannelBuffer buffer; 18 | 19 | public SetVirtualLinkCommand(byte requestID, ChannelBuffer payload, long destinationNode) { 20 | super(CommandType.LinkControl.SET_VIRTUAL_LINK, requestID, payload); 21 | buffer = ChannelBuffers.buffer(8); 22 | buffer.writeLong(destinationNode); 23 | } 24 | 25 | public long getDestinationNode() { 26 | return this.buffer.getLong(0); 27 | } 28 | 29 | public ChannelBuffer getBuffer() { 30 | return ChannelBuffers.wrappedBuffer(super.buffer, this.buffer); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/linkcontrol/SetVirtualLinkCommandResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.linkcontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandResponse; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 29.06.11 11 | * Time: 16:55 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class SetVirtualLinkCommandResponse extends CommandResponse { 15 | 16 | public SetVirtualLinkCommandResponse(byte requestID, byte result, ChannelBuffer payload) { 17 | super(CommandType.LinkControl.SET_VIRTUAL_LINK, requestID, result, payload); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/linkcontrol/SetVirtualLinkRequest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.linkcontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Request; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. User: bimschas Date: 08.06.11 Time: 15:19 TODO change 8 | */ 9 | public class SetVirtualLinkRequest extends Request { 10 | 11 | private final long destinationNode; 12 | 13 | public SetVirtualLinkRequest(final byte requestID, final byte payload[], final long destinationNode) { 14 | super(CommandType.LinkControl.SET_VIRTUAL_LINK, requestID, payload); 15 | this.destinationNode = destinationNode; 16 | } 17 | 18 | public long getDestinationNode() { 19 | return destinationNode; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/linkcontrol/SetVirtualLinkResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.linkcontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Response; 4 | 5 | /** 6 | * Created by IntelliJ IDEA. 7 | * User: nrohwedder 8 | * Date: 09.06.11 9 | * Time: 13:24 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class SetVirtualLinkResponse extends Response { 13 | 14 | public SetVirtualLinkResponse(final SetVirtualLinkRequest setVirtualLinkRequest) { 15 | super(setVirtualLinkRequest); 16 | } 17 | 18 | public long getDestinationNode() { 19 | return ((SetVirtualLinkRequest) request).getDestinationNode(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/networkdescription/GetNeighborhoodCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.networkdescription; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Command; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 01.07.11 11 | * Time: 10:55 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class GetNeighborhoodCommand extends Command { 15 | 16 | public GetNeighborhoodCommand(byte requestID, ChannelBuffer payload) { 17 | super(CommandType.NetworkDescription.GET_NEIGHBORHOOD, requestID, payload); 18 | } 19 | 20 | @Override 21 | public ChannelBuffer getBuffer() { 22 | return super.buffer; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/networkdescription/GetNeighborhoodCommandResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.networkdescription; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandResponse; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 01.07.11 11 | * Time: 10:34 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class GetNeighborhoodCommandResponse extends CommandResponse { 15 | 16 | public GetNeighborhoodCommandResponse(byte requestID, byte result, ChannelBuffer payload) { 17 | super(CommandType.NetworkDescription.GET_NEIGHBORHOOD, requestID, result, payload); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/networkdescription/GetNeighborhoodRequest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.networkdescription; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Request; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 01.07.11 10 | * Time: 10:31 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class GetNeighborhoodRequest extends Request { 14 | 15 | public GetNeighborhoodRequest(final byte requestID, final byte[] payload) { 16 | super(CommandType.NetworkDescription.GET_NEIGHBORHOOD, requestID, payload); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/networkdescription/GetNeighborhoodResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.networkdescription; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Response; 4 | 5 | /** 6 | * Created by IntelliJ IDEA. 7 | * User: nrohwedder 8 | * Date: 01.07.11 9 | * Time: 11:02 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class GetNeighborhoodResponse extends Response { 13 | 14 | public GetNeighborhoodResponse(final GetNeighborhoodRequest request) { 15 | super(request); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/networkdescription/GetPropertyValueCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.networkdescription; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Command; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | import org.jboss.netty.buffer.ChannelBuffers; 7 | 8 | /** 9 | * Created by IntelliJ IDEA. 10 | * User: nrohwedder 11 | * Date: 01.07.11 12 | * Time: 10:37 13 | * To change this template use File | Settings | File Templates. 14 | */ 15 | public class GetPropertyValueCommand extends Command { 16 | 17 | private ChannelBuffer buffer; 18 | 19 | public GetPropertyValueCommand(byte requestID, ChannelBuffer payload, byte property) { 20 | super(CommandType.NetworkDescription.GET_PROPERTY_VALUE, requestID, payload); 21 | this.buffer = ChannelBuffers.buffer(1); 22 | this.buffer.writeByte(property); 23 | } 24 | 25 | public byte getProperty() { 26 | return this.buffer.getByte(0); 27 | } 28 | 29 | @Override 30 | public ChannelBuffer getBuffer() { 31 | return ChannelBuffers.wrappedBuffer(super.buffer, this.buffer); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/networkdescription/GetPropertyValueCommandResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.networkdescription; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandResponse; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 01.07.11 11 | * Time: 10:29 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class GetPropertyValueCommandResponse extends CommandResponse { 15 | 16 | public GetPropertyValueCommandResponse(byte requestID, byte result, ChannelBuffer payload) { 17 | super(CommandType.NetworkDescription.GET_PROPERTY_VALUE, requestID, result, payload); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/networkdescription/GetPropertyValueRequest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.networkdescription; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Request; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 01.07.11 10 | * Time: 10:08 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class GetPropertyValueRequest extends Request { 14 | 15 | private final byte property; 16 | 17 | public GetPropertyValueRequest(final byte requestID, final byte[] payload, final byte property) { 18 | super(CommandType.NetworkDescription.GET_PROPERTY_VALUE, requestID, payload); 19 | this.property = property; 20 | } 21 | 22 | public byte getProperty() { 23 | return property; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/networkdescription/GetPropertyValueResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.networkdescription; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Response; 4 | 5 | /** 6 | * Created by IntelliJ IDEA. 7 | * User: nrohwedder 8 | * Date: 01.07.11 9 | * Time: 10:58 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class GetPropertyValueResponse extends Response { 13 | 14 | public GetPropertyValueResponse(final GetPropertyValueRequest request) { 15 | super(request); 16 | } 17 | 18 | public byte getProperty() { 19 | return ((GetPropertyValueRequest) request).getProperty(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/AreNodesAliveCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Command; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 30.06.11 11 | * Time: 18:04 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class AreNodesAliveCommand extends Command { 15 | 16 | public AreNodesAliveCommand(byte requestID, ChannelBuffer payload) { 17 | super(CommandType.NodeControl.ARE_NODES_ALIVE, requestID, payload); 18 | } 19 | 20 | @Override 21 | public ChannelBuffer getBuffer() { 22 | return super.buffer; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/AreNodesAliveCommandResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandResponse; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 30.06.11 11 | * Time: 17:04 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class AreNodesAliveCommandResponse extends CommandResponse { 15 | 16 | public AreNodesAliveCommandResponse(byte requestID, byte result, ChannelBuffer payload) { 17 | super(CommandType.NodeControl.ARE_NODES_ALIVE, requestID, result, payload); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/AreNodesAliveRequest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Request; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 30.06.11 10 | * Time: 16:55 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class AreNodesAliveRequest extends Request { 14 | 15 | public AreNodesAliveRequest(final byte requestID, final byte[] payload) { 16 | super(CommandType.NodeControl.ARE_NODES_ALIVE, requestID, payload); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/AreNodesAliveResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Response; 4 | 5 | /** 6 | * Created by IntelliJ IDEA. 7 | * User: nrohwedder 8 | * Date: 30.06.11 9 | * Time: 18:39 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class AreNodesAliveResponse extends Response { 13 | 14 | public AreNodesAliveResponse(final AreNodesAliveRequest request) { 15 | super(request); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/DisableNodeCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Command; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 30.06.11 11 | * Time: 17:07 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class DisableNodeCommand extends Command { 15 | 16 | public DisableNodeCommand(byte requestID, ChannelBuffer payload) { 17 | super(CommandType.NodeControl.DISABLE_NODE, requestID, payload); 18 | } 19 | 20 | @Override 21 | public ChannelBuffer getBuffer() { 22 | return super.buffer; //To change body of implemented methods use File | Settings | File Templates. 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/DisableNodeCommandResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandResponse; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 30.06.11 11 | * Time: 16:41 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class DisableNodeCommandResponse extends CommandResponse { 15 | 16 | public DisableNodeCommandResponse(byte requestID, byte result, ChannelBuffer payload) { 17 | super(CommandType.NodeControl.DISABLE_NODE, requestID, result, payload); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/DisableNodeRequest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Request; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 30.06.11 10 | * Time: 16:39 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class DisableNodeRequest extends Request { 14 | 15 | public DisableNodeRequest(final byte requestID, final byte[] payload) { 16 | super(CommandType.NodeControl.DISABLE_NODE, requestID, payload); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/DisableNodeResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Response; 4 | 5 | /** 6 | * Created by IntelliJ IDEA. 7 | * User: nrohwedder 8 | * Date: 30.06.11 9 | * Time: 18:13 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class DisableNodeResponse extends Response { 13 | 14 | public DisableNodeResponse(final DisableNodeRequest request) { 15 | super(request); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/EnableNodeCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Command; 5 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 6 | import org.jboss.netty.buffer.ChannelBuffer; 7 | 8 | /** 9 | * Created by IntelliJ IDEA. 10 | * User: nrohwedder 11 | * Date: 30.06.11 12 | * Time: 15:28 13 | * To change this template use File | Settings | File Templates. 14 | */ 15 | public class EnableNodeCommand extends Command { 16 | 17 | public EnableNodeCommand(byte requestID, ChannelBuffer payload) { 18 | super(CommandType.NodeControl.ENABLE_NODE, requestID, payload); 19 | } 20 | 21 | @Override 22 | public ChannelBuffer getBuffer() { 23 | return super.buffer; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/EnableNodeCommandResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandResponse; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 30.06.11 11 | * Time: 15:06 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class EnableNodeCommandResponse extends CommandResponse { 15 | 16 | public EnableNodeCommandResponse(byte requestID, byte result, ChannelBuffer payload) { 17 | super(CommandType.NodeControl.ENABLE_NODE, requestID, result, payload); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/EnableNodeRequest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Request; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 30.06.11 10 | * Time: 15:04 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class EnableNodeRequest extends Request { 14 | 15 | public EnableNodeRequest(final byte requestID, final byte[] payload) { 16 | super(CommandType.NodeControl.ENABLE_NODE, requestID, payload); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/EnableNodeResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Response; 4 | 5 | /** 6 | * Created by IntelliJ IDEA. 7 | * User: nrohwedder 8 | * Date: 30.06.11 9 | * Time: 16:25 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class EnableNodeResponse extends Response { 13 | 14 | public EnableNodeResponse(final EnableNodeRequest request) { 15 | super(request); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/GetVersionCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Command; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 30.06.11 11 | * Time: 18:07 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class GetVersionCommand extends Command { 15 | 16 | public GetVersionCommand(byte requestID, ChannelBuffer payload) { 17 | super(CommandType.NodeControl.GET_VERSION, requestID, payload); 18 | } 19 | 20 | @Override 21 | public ChannelBuffer getBuffer() { 22 | return super.buffer; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/GetVersionCommandResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandResponse; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 30.06.11 11 | * Time: 17:05 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class GetVersionCommandResponse extends CommandResponse { 15 | 16 | public GetVersionCommandResponse(byte requestID, byte result, ChannelBuffer payload) { 17 | super(CommandType.NodeControl.GET_VERSION, requestID, result, payload); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/GetVersionRequest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Request; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 30.06.11 10 | * Time: 16:56 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class GetVersionRequest extends Request { 14 | 15 | public GetVersionRequest(final byte requestID, final byte[] payload) { 16 | super(CommandType.NodeControl.GET_VERSION, requestID, payload); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/GetVersionResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Response; 4 | 5 | /** 6 | * Created by IntelliJ IDEA. 7 | * User: nrohwedder 8 | * Date: 30.06.11 9 | * Time: 18:42 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class GetVersionResponse extends Response { 13 | 14 | public GetVersionResponse(final GetVersionRequest request) { 15 | super(request); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/ResetNodeCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Command; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | import org.jboss.netty.buffer.ChannelBuffers; 7 | 8 | /** 9 | * Created by IntelliJ IDEA. 10 | * User: nrohwedder 11 | * Date: 30.06.11 12 | * Time: 17:09 13 | * To change this template use File | Settings | File Templates. 14 | */ 15 | public class ResetNodeCommand extends Command { 16 | 17 | private ChannelBuffer buffer; 18 | 19 | public ResetNodeCommand(byte requestID, ChannelBuffer payload, short time) { 20 | super(CommandType.NodeControl.RESET_NODE, requestID, payload); 21 | this.buffer = ChannelBuffers.buffer(2); 22 | this.buffer.writeShort(time); 23 | } 24 | 25 | public short getTime() { 26 | return this.buffer.getShort(0); 27 | } 28 | 29 | @Override 30 | public ChannelBuffer getBuffer() { 31 | return ChannelBuffers.wrappedBuffer(super.buffer, this.buffer); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/ResetNodeCommandResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandResponse; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 30.06.11 11 | * Time: 16:47 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class ResetNodeCommandResponse extends CommandResponse { 15 | 16 | public ResetNodeCommandResponse(byte requestID, byte result, ChannelBuffer payload) { 17 | super(CommandType.NodeControl.RESET_NODE, requestID, result, payload); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/ResetNodeRequest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Request; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 30.06.11 10 | * Time: 16:43 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class ResetNodeRequest extends Request { 14 | 15 | private final short time; 16 | 17 | public ResetNodeRequest(final byte requestID, final byte[] payload, final short time) { 18 | super(CommandType.NodeControl.RESET_NODE, requestID, payload); 19 | this.time = time; 20 | } 21 | 22 | public short getTime() { 23 | return time; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/ResetNodeResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Response; 4 | 5 | /** 6 | * Created by IntelliJ IDEA. 7 | * User: nrohwedder 8 | * Date: 30.06.11 9 | * Time: 18:17 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class ResetNodeResponse extends Response { 13 | 14 | public ResetNodeResponse(final ResetNodeRequest request) { 15 | super(request); 16 | } 17 | 18 | public short getTime() { 19 | return ((ResetNodeRequest) request).getTime(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/SetStartTimeCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Command; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | import org.jboss.netty.buffer.ChannelBuffers; 7 | 8 | /** 9 | * Created by IntelliJ IDEA. 10 | * User: nrohwedder 11 | * Date: 30.06.11 12 | * Time: 17:22 13 | * To change this template use File | Settings | File Templates. 14 | */ 15 | public class SetStartTimeCommand extends Command { 16 | 17 | private ChannelBuffer buffer; 18 | 19 | public SetStartTimeCommand(byte requestID, ChannelBuffer payload, short time) { 20 | super(CommandType.NodeControl.SET_START_TIME, requestID, payload); 21 | this.buffer = ChannelBuffers.buffer(2); 22 | this.buffer.writeShort(time); 23 | } 24 | 25 | public short getTime() { 26 | return this.buffer.getShort(0); 27 | } 28 | 29 | @Override 30 | public ChannelBuffer getBuffer() { 31 | return ChannelBuffers.wrappedBuffer(super.buffer, this.buffer); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/SetStartTimeCommandResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandResponse; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 30.06.11 11 | * Time: 16:51 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class SetStartTimeCommandResponse extends CommandResponse { 15 | 16 | public SetStartTimeCommandResponse(byte requestID, byte result, ChannelBuffer payload) { 17 | super(CommandType.NodeControl.SET_START_TIME, requestID, result, payload); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/SetStartTimeRequest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Request; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 30.06.11 10 | * Time: 16:49 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class SetStartTimeRequest extends Request { 14 | 15 | private final short time; 16 | 17 | public SetStartTimeRequest(final byte requestID, final byte[] payload, final short time) { 18 | super(CommandType.NodeControl.SET_START_TIME, requestID, payload); 19 | this.time = time; 20 | 21 | } 22 | 23 | public short getTime() { 24 | return time; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/SetStartTimeResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Response; 4 | 5 | /** 6 | * Created by IntelliJ IDEA. 7 | * User: nrohwedder 8 | * Date: 30.06.11 9 | * Time: 18:24 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class SetStartTimeResponse extends Response { 13 | 14 | public SetStartTimeResponse(final SetStartTimeRequest request) { 15 | super(request); 16 | } 17 | 18 | public short getTime() { 19 | return ((SetStartTimeRequest) request).getTime(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/SetVirtualIDCommand.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Command; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | import org.jboss.netty.buffer.ChannelBuffers; 7 | 8 | /** 9 | * Created by IntelliJ IDEA. 10 | * User: nrohwedder 11 | * Date: 30.06.11 12 | * Time: 17:28 13 | * To change this template use File | Settings | File Templates. 14 | */ 15 | public class SetVirtualIDCommand extends Command { 16 | 17 | private ChannelBuffer buffer; 18 | 19 | public SetVirtualIDCommand(byte requestID, ChannelBuffer payload, long virtualNodeId) { 20 | super(CommandType.NodeControl.SET_VIRTUAL_ID, requestID, payload); 21 | this.buffer = ChannelBuffers.buffer(8); 22 | this.buffer.writeLong(virtualNodeId); 23 | } 24 | 25 | public long getVirtualNodeId() { 26 | return this.buffer.getLong(0); 27 | } 28 | 29 | @Override 30 | public ChannelBuffer getBuffer() { 31 | return ChannelBuffers.wrappedBuffer(super.buffer, this.buffer); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/SetVirtualIDCommandResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandResponse; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 5 | import org.jboss.netty.buffer.ChannelBuffer; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: nrohwedder 10 | * Date: 30.06.11 11 | * Time: 17:00 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class SetVirtualIDCommandResponse extends CommandResponse { 15 | 16 | public SetVirtualIDCommandResponse(byte requestID, byte result, ChannelBuffer payload) { 17 | super(CommandType.NodeControl.SET_VIRTUAL_ID, requestID, result, payload); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/SetVirtualIDRequest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.CommandType; 4 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Request; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: nrohwedder 9 | * Date: 30.06.11 10 | * Time: 16:53 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class SetVirtualIDRequest extends Request { 14 | 15 | private final long virtualNodeId; 16 | 17 | public SetVirtualIDRequest(final byte requestID, final byte[] payload, final long virtualNodeId) { 18 | super(CommandType.NodeControl.SET_VIRTUAL_ID, requestID, payload); 19 | this.virtualNodeId = virtualNodeId; 20 | } 21 | 22 | public long getVirtualNodeId() { 23 | return virtualNodeId; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/uniluebeck/itm/nettyprotocols/wisebednodeapi/packet/nodecontrol/SetVirtualIDResponse.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.nodecontrol; 2 | 3 | import de.uniluebeck.itm.nettyprotocols.wisebednodeapi.packet.Response; 4 | 5 | /** 6 | * Created by IntelliJ IDEA. 7 | * User: nrohwedder 8 | * Date: 30.06.11 9 | * Time: 18:33 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class SetVirtualIDResponse extends Response { 13 | 14 | public SetVirtualIDResponse(final SetVirtualIDRequest request) { 15 | super(request); 16 | } 17 | 18 | public long getVirtualNodeId() { 19 | return ((SetVirtualIDRequest) request).getVirtualNodeId(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/test/java/de/uniluebeck/itm/nettyprotocols/NewlineEncoderTest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols; 2 | 3 | import org.jboss.netty.buffer.ChannelBuffer; 4 | import org.jboss.netty.channel.Channel; 5 | import org.jboss.netty.channel.ChannelHandlerContext; 6 | import org.jboss.netty.util.CharsetUtil; 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | import org.mockito.Mock; 11 | import org.mockito.runners.MockitoJUnitRunner; 12 | 13 | import static org.jboss.netty.buffer.ChannelBuffers.wrappedBuffer; 14 | import static org.junit.Assert.assertEquals; 15 | import static org.junit.Assert.assertTrue; 16 | 17 | @RunWith(MockitoJUnitRunner.class) 18 | public class NewlineEncoderTest { 19 | 20 | @Mock 21 | private ChannelHandlerContext ctx; 22 | 23 | @Mock 24 | private Channel channel; 25 | 26 | private NewlineEncoder encoder; 27 | 28 | @Before 29 | public void setUp() throws Exception { 30 | encoder = new NewlineEncoder(); 31 | } 32 | 33 | @Test 34 | public void testIfNewlineAppendedToString() throws Exception { 35 | assertEquals("hello\n", encoder.encode(ctx, channel, "hello")); 36 | } 37 | 38 | @Test 39 | public void testIfNewlineNotAppendedIfAlreadyContainedLF() throws Exception { 40 | String encoded = (String) encoder.encode(ctx, channel, "hello\n"); 41 | assertTrue(encoded.indexOf("\n") == encoded.lastIndexOf("\n")); 42 | } 43 | 44 | @Test 45 | public void testIfNewlineNotAppendedIfAlreadyContainedCRLF() throws Exception { 46 | String encoded = (String) encoder.encode(ctx, channel, "hello\r\n"); 47 | assertTrue(encoded.indexOf("\r\n") == encoded.lastIndexOf("\r\n")); 48 | } 49 | 50 | @Test 51 | public void testIfNewlineNotAppendedIfAlreadyContainedInChannelBufferLF() throws Exception { 52 | ChannelBuffer encodedBuf = (ChannelBuffer) encoder.encode(ctx, channel, wrappedBuffer("hello\n".getBytes())); 53 | String encoded = encodedBuf.toString(CharsetUtil.UTF_8); 54 | assertTrue(encoded.indexOf("\n") == encoded.lastIndexOf("\n")); 55 | } 56 | 57 | @Test 58 | public void testIfNewlineNotAppendedIfAlreadyContainedInChannelBufferCRLF() throws Exception { 59 | ChannelBuffer encodedBuf = (ChannelBuffer) encoder.encode(ctx, channel, wrappedBuffer("hello\n".getBytes())); 60 | String encoded = encodedBuf.toString(CharsetUtil.UTF_8); 61 | assertTrue(encoded.indexOf("\r\n") == encoded.lastIndexOf("\r\n")); 62 | } 63 | 64 | @Test 65 | public void testIfNewlineAppendedToChannelBuffer() throws Exception { 66 | ChannelBuffer encoded = (ChannelBuffer) encoder.encode(ctx, channel, wrappedBuffer("hello".getBytes())); 67 | assertTrue(encoded.toString(CharsetUtil.UTF_8).endsWith("\n")); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/test/java/de/uniluebeck/itm/nettyprotocols/dlestxetx/DleStxEtxFramingEncoderTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010, Daniel Bimschas and Dennis Pfisterer, Institute of Telematics, University of Luebeck 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 6 | * following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following 9 | * disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 11 | * following disclaimer in the documentation and/or other materials provided with the distribution. 12 | * - Neither the name of the University of Luebeck nor the names of its contributors may be used to endorse or promote 13 | * products derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 19 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 20 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | */ 23 | package de.uniluebeck.itm.nettyprotocols.dlestxetx; 24 | 25 | import com.google.common.primitives.Bytes; 26 | import org.jboss.netty.buffer.ChannelBuffer; 27 | import org.jboss.netty.buffer.ChannelBuffers; 28 | import org.jboss.netty.handler.codec.embedder.EncoderEmbedder; 29 | import org.junit.Assert; 30 | import org.junit.Test; 31 | 32 | public class DleStxEtxFramingEncoderTest { 33 | 34 | @Test 35 | public void testEncoding() { 36 | 37 | byte[] payloadBytes = "hello, world".getBytes(); 38 | 39 | EncoderEmbedder embedder = new EncoderEmbedder(new DleStxEtxFramingEncoder()); 40 | embedder.offer(ChannelBuffers.wrappedBuffer(payloadBytes)); 41 | 42 | ChannelBuffer encodedBuffer = embedder.poll(); 43 | byte[] encodedBytes = new byte[encodedBuffer.readableBytes()]; 44 | encodedBuffer.readBytes(encodedBytes); 45 | 46 | Assert.assertArrayEquals(Bytes.concat(DleStxEtxConstants.DLE_STX, payloadBytes, DleStxEtxConstants.DLE_ETX), 47 | encodedBytes 48 | ); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/test/java/de/uniluebeck/itm/nettyprotocols/isense/otap/ISenseOtapAutomatedProgrammingRequestTest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.isense.otap; 2 | 3 | 4 | import com.coalesenses.tools.iSenseAes128BitKey; 5 | import com.google.common.collect.Sets; 6 | import org.junit.Test; 7 | import org.simpleframework.xml.Serializer; 8 | import org.simpleframework.xml.core.Persister; 9 | 10 | import java.io.ByteArrayInputStream; 11 | import java.io.ByteArrayOutputStream; 12 | 13 | import static org.junit.Assert.assertEquals; 14 | 15 | public class ISenseOtapAutomatedProgrammingRequestTest { 16 | 17 | @Test 18 | public void testSerializationDeserialization() throws Exception { 19 | 20 | Serializer serializer = new Persister(); 21 | 22 | ISenseOtapAutomatedProgrammingRequest request = 23 | new ISenseOtapAutomatedProgrammingRequest( 24 | Sets.newHashSet(1, 2, 3), 25 | new byte[]{ 26 | 1, 2, 3 27 | } 28 | ); 29 | request.setAesKeyFromISenseAes128BitKey( 30 | new iSenseAes128BitKey(new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}) 31 | ); 32 | request.setMaxRerequests((short) 1); 33 | request.setOtapInitTimeout(2); 34 | request.setPresenceDetectTimeout(3); 35 | request.setProgrammingTimeout(4); 36 | request.setTimeoutMultiplier((short) 5); 37 | 38 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 39 | serializer.write(request, outputStream); 40 | 41 | ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); 42 | ISenseOtapAutomatedProgrammingRequest requestRead = serializer.read( 43 | ISenseOtapAutomatedProgrammingRequest.class, 44 | inputStream 45 | ); 46 | 47 | assertEquals(request, requestRead); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/de/uniluebeck/itm/nettyprotocols/isense/otap/program/ISenseOtapProgramResultTest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.isense.otap.program; 2 | 3 | import org.junit.Test; 4 | import org.simpleframework.xml.Serializer; 5 | import org.simpleframework.xml.core.Persister; 6 | 7 | import java.io.ByteArrayInputStream; 8 | import java.io.ByteArrayOutputStream; 9 | 10 | import static com.google.common.collect.Sets.newHashSet; 11 | import static org.junit.Assert.assertEquals; 12 | 13 | public class ISenseOtapProgramResultTest { 14 | 15 | @Test 16 | public void testSerializationDeserialization() throws Exception { 17 | 18 | Serializer serializer = new Persister(); 19 | 20 | ISenseOtapProgramResult result = new ISenseOtapProgramResult(newHashSet(1,2,3)); 21 | result.addDoneDevice(1); 22 | result.addFailedDevice(2); 23 | result.addFailedDevice(3); 24 | 25 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 26 | serializer.write(result, outputStream); 27 | 28 | ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); 29 | final ISenseOtapProgramResult resultRead = serializer.read(ISenseOtapProgramResult.class, inputStream); 30 | 31 | assertEquals(result, resultRead); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/de/uniluebeck/itm/nettyprotocols/tinyos/TinyOsSerialEncoderTest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.tinyos; 2 | 3 | import org.junit.After; 4 | import org.junit.Before; 5 | import org.junit.Test; 6 | 7 | import static org.junit.Assert.assertEquals; 8 | 9 | public class TinyOsSerialEncoderTest implements TinyOsSerialTestConstants { 10 | 11 | private TinyOsSerialEncoder encoderTinyOs; 12 | 13 | @Before 14 | public void setUp() throws Exception { 15 | encoderTinyOs = new TinyOsSerialEncoder(); 16 | } 17 | 18 | @After 19 | public void tearDown() throws Exception { 20 | encoderTinyOs = null; 21 | } 22 | 23 | @Test 24 | public void testPacket1() throws Exception { 25 | assertEquals(ENCODED_PACKET_1, encoderTinyOs.encode(null, null, DECODED_PACKET_1)); 26 | } 27 | 28 | @Test 29 | public void testPacket2() throws Exception { 30 | assertEquals(ENCODED_PACKET_2, encoderTinyOs.encode(null, null, DECODED_PACKET_2)); 31 | } 32 | 33 | @Test 34 | public void testPacket3() throws Exception { 35 | assertEquals(ENCODED_PACKET_3, encoderTinyOs.encode(null, null, DECODED_PACKET_3)); 36 | } 37 | 38 | @Test 39 | public void testPacket4() throws Exception { 40 | assertEquals(ENCODED_PACKET_4, encoderTinyOs.encode(null, null, DECODED_PACKET_4)); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/de/uniluebeck/itm/nettyprotocols/tlspeerverification/cacert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDljCCAv+gAwIBAgIJAJW1GhqQN62TMA0GCSqGSIb3DQEBBQUAMIGPMQswCQYD 3 | VQQGEwJERTELMAkGA1UECBMCU0gxEDAOBgNVBAcTB0x1ZWJlY2sxFDASBgNVBAoT 4 | C1VuaSBMdWViZWNrMQwwCgYDVQQLEwNJVE0xETAPBgNVBAMTCENoZWZrb2NoMSow 5 | KAYJKoZIhvcNAQkBFhtjaGVma29jaEBpdG0udW5pLWx1ZWJlY2suZGUwHhcNMTEw 6 | NTEwMTIyNjU0WhcNMjEwNTA3MTIyNjU0WjCBjzELMAkGA1UEBhMCREUxCzAJBgNV 7 | BAgTAlNIMRAwDgYDVQQHEwdMdWViZWNrMRQwEgYDVQQKEwtVbmkgTHVlYmVjazEM 8 | MAoGA1UECxMDSVRNMREwDwYDVQQDEwhDaGVma29jaDEqMCgGCSqGSIb3DQEJARYb 9 | Y2hlZmtvY2hAaXRtLnVuaS1sdWViZWNrLmRlMIGfMA0GCSqGSIb3DQEBAQUAA4GN 10 | ADCBiQKBgQDjinisFaKhYdC6C6gjCJw7NJ0s9XhC0aUI4Qbg1/kiHgu41jW/MyGD 11 | W7jKRgcfRBnfP49dkJf3jZeFvTnM+wHjZGQH12CKVbUl35bSjemjIixTTFai5tji 12 | JorrKdNthb3Xg9ZXFzsx3yQOMtQ3VZecyGkh0B1CQ0mIkGpISVw60QIDAQABo4H3 13 | MIH0MB0GA1UdDgQWBBRNmaxTf1NSoM7VSKLJ6dcUCCoT8jCBxAYDVR0jBIG8MIG5 14 | gBRNmaxTf1NSoM7VSKLJ6dcUCCoT8qGBlaSBkjCBjzELMAkGA1UEBhMCREUxCzAJ 15 | BgNVBAgTAlNIMRAwDgYDVQQHEwdMdWViZWNrMRQwEgYDVQQKEwtVbmkgTHVlYmVj 16 | azEMMAoGA1UECxMDSVRNMREwDwYDVQQDEwhDaGVma29jaDEqMCgGCSqGSIb3DQEJ 17 | ARYbY2hlZmtvY2hAaXRtLnVuaS1sdWViZWNrLmRlggkAlbUaGpA3rZMwDAYDVR0T 18 | BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQC2zajUYwPRWx0DzUvoCc0xolTWCLoC 19 | 6jcVDqicIdQweG3DCXFoMMdUGyMJTve9IwUExkuAe4vwxXaQ1QJ6+T+6DAgdb21g 20 | h8eJ+FALJjHiUh2pj5lwqA3vgBIh0ZiyTcfUk9gF+IJBSOs4xOCEJ/4v/ZNSFapD 21 | W20rvoTea8wpLA== 22 | -----END CERTIFICATE----- 23 | -------------------------------------------------------------------------------- /src/test/java/de/uniluebeck/itm/nettyprotocols/tlspeerverification/client-signed-cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIC/zCCAmigAwIBAgICEAAwDQYJKoZIhvcNAQEFBQAwgY8xCzAJBgNVBAYTAkRF 3 | MQswCQYDVQQIEwJTSDEQMA4GA1UEBxMHTHVlYmVjazEUMBIGA1UEChMLVW5pIEx1 4 | ZWJlY2sxDDAKBgNVBAsTA0lUTTERMA8GA1UEAxMIQ2hlZmtvY2gxKjAoBgkqhkiG 5 | 9w0BCQEWG2NoZWZrb2NoQGl0bS51bmktbHVlYmVjay5kZTAeFw0xMTA1MTAxMjQ2 6 | MjZaFw0xMjA1MDkxMjQ2MjZaMH0xCzAJBgNVBAYTAkRFMQswCQYDVQQIEwJTSDEU 7 | MBIGA1UEChMLVW5pIEx1ZWJlY2sxDDAKBgNVBAsTA0lUTTERMA8GA1UEAxMIQ2hl 8 | ZmtvY2gxKjAoBgkqhkiG9w0BCQEWG2NoZWZrb2NoQGl0bS51bmktbHVlYmVjay5k 9 | ZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEApeJBHXliDH1PiVVT+rifmUeq 10 | VgXsChXcR6tiO7flmMNLPKtxefUH4j0AqqOzPiqcy/Z6DR7QO/4kynfUl43Su9ef 11 | oFxL9t/SGVpB8M6aw3jmeSFwEv4U/G8D+17YFolPiNmV2HBtbLkftL456F/n5isq 12 | ++tzq8++dF492zlgnK8CAwEAAaN7MHkwCQYDVR0TBAIwADAsBglghkgBhvhCAQ0E 13 | HxYdT3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFG8lCJrn 14 | cb7vH3nYnKiya7jFOumIMB8GA1UdIwQYMBaAFE2ZrFN/U1KgztVIosnp1xQIKhPy 15 | MA0GCSqGSIb3DQEBBQUAA4GBAKjq0J8jE0miEtabVx3PvEbEKu04Gq0PWxPr/hC5 16 | I7o8Ih38XHZXsSrQxg5sIbW12w4a9ZB1M7AnG9tlkt1GSrSx6RKax4Iz3zznCQJj 17 | /jsikxMP+WIhGLIic5J8DpygNTfdt0nLeFUVKBVTPvn9SpgfBe+7u/X0f13xCNk8 18 | B1I3 19 | -----END CERTIFICATE----- 20 | -------------------------------------------------------------------------------- /src/test/java/de/uniluebeck/itm/nettyprotocols/tlspeerverification/howto-generate.txt: -------------------------------------------------------------------------------- 1 | cd demoCA 2 | 3 | #Create CA 4 | openssl req -new -x509 -days 3650 -extensions v3_ca -keyout private/cakey.pem -out cacert.pem -config ../openssl.cnf 5 | 6 | touch demoCA/index.txt 7 | echo 1000 > demoCA/serial 8 | 9 | # Create a private key 10 | openssl req -new -x509 -days 3650 -extensions v3_ca -keyout private/cakey.pem -out cacert.pem -config ../openssl.cnf 11 | 12 | #Create unsigned certificate 13 | openssl req -new -x509 -key priv-client-key.pem -out client-unsigned-cert.pem 14 | 15 | #Create CSR 16 | cat client-unsigned-cert.pem priv-client-key.pem | openssl x509 -x509toreq -signkey priv-client-key.pem -out client-certreq.csr 17 | 18 | cd .. 19 | 20 | #Sign the CSR using the CA private key and its certificate 21 | openssl ca -config openssl.cnf -cert demoCA/cacert.pem -keyfile demoCA/private/cakey.pem -in demoCA/client-certreq.csr -out demoCA/client-signed-cert.pem 22 | 23 | #Result is in /demoCA/newcerts/ -------------------------------------------------------------------------------- /src/test/java/de/uniluebeck/itm/nettyprotocols/util/ChannelBufferToolsTest.java: -------------------------------------------------------------------------------- 1 | package de.uniluebeck.itm.nettyprotocols.util; 2 | 3 | import org.jboss.netty.buffer.ChannelBuffers; 4 | import org.junit.Test; 5 | 6 | import static de.uniluebeck.itm.nettyprotocols.util.ChannelBufferTools.toPrintableString; 7 | import static org.junit.Assert.assertEquals; 8 | 9 | public class ChannelBufferToolsTest { 10 | 11 | @Test 12 | public void testToPrintableStringWithEmptyBuffer() throws Exception { 13 | 14 | final String expected = ""; 15 | final String actual = toPrintableString(ChannelBuffers.buffer(0), 10); 16 | 17 | assertEquals(expected, actual); 18 | } 19 | 20 | @Test 21 | public void testToPrintableStringWithBufferSmallerThanMaxLength() throws Exception { 22 | 23 | final String expected = "0123456789"; 24 | final String actual = toPrintableString( 25 | ChannelBuffers.copiedBuffer(expected.getBytes()), 26 | expected.getBytes().length + 1 27 | ); 28 | 29 | assertEquals(expected, actual); 30 | } 31 | 32 | @Test 33 | public void testToPrintableStringWithBufferLargerThanMaxLength() throws Exception { 34 | 35 | final String original = "0123456789"; 36 | final String expected = "012345"; 37 | final String actual = toPrintableString( 38 | ChannelBuffers.copiedBuffer(original.getBytes()), 39 | expected.getBytes().length 40 | ); 41 | 42 | assertEquals(expected, actual); 43 | 44 | } 45 | } 46 | --------------------------------------------------------------------------------