2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowjava.protocol.impl.core;
11 import io.netty.channel.ChannelHandlerContext;
12 import io.netty.handler.codec.MessageToMessageDecoder;
14 import java.util.List;
16 import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory;
17 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
18 import org.opendaylight.yangtools.yang.binding.DataObject;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
23 * Transforms OpenFlow Protocol messages to POJOs
24 * @author michal.polkorab
26 public class OFDecoder extends MessageToMessageDecoder<VersionMessageWrapper> {
28 private static final Logger LOGGER = LoggerFactory.getLogger(OFDecoder.class);
31 * Constructor of class
34 LOGGER.trace("Creating OF 1.3 Decoder");
38 protected void decode(ChannelHandlerContext ctx, VersionMessageWrapper msg,
39 List<Object> out) throws Exception {
40 if (LOGGER.isDebugEnabled()) {
41 LOGGER.debug("VersionMessageWrapper received");
42 LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(msg.getMessageBuffer()));
44 DataObject dataObject = null;
46 dataObject = DeserializationFactory.bufferToMessage(msg.getMessageBuffer(),
48 } catch(Exception e) {
49 LOGGER.error("Message deserialization failed");
50 LOGGER.error(e.getMessage(), e);
53 if (dataObject == null) {
54 LOGGER.warn("Translated POJO is null");
57 msg.getMessageBuffer().release();