ca56c5ec0cdc2781def68618b8e39a10b16ad129
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / translator / ErrorTranslator.java
1 /**
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.openflowplugin.openflow.md.core.translator;
9
10 import org.opendaylight.openflowplugin.openflow.md.core.ByteUtil;
11 import org.opendaylight.openflowplugin.openflow.md.core.IMDMessageTranslator;
12 import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
13 import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
16 import org.opendaylight.yangtools.yang.binding.DataObject;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19
20 /**
21  * @author mirehak
22  *
23  */
24 public class ErrorTranslator implements IMDMessageTranslator<OfHeader, DataObject> {
25
26     private static final Logger LOG = LoggerFactory
27             .getLogger(ErrorTranslator.class);
28     
29     @Override
30     public DataObject translate(SwitchConnectionDistinguisher cookie,
31             SessionContext sc, OfHeader msg) {
32         ErrorMessage errorMsg = (ErrorMessage) msg;
33         LOG.error("errorMessage arrived: type={}, code={}, data={} | [{}]", 
34                 errorMsg.getType(), errorMsg.getCode(),
35                 new String(errorMsg.getData()), ByteUtil.bytesToHexstring(errorMsg.getData(), " "));
36         //TODO:: add sal-error wrapper
37         return null;
38     }
39
40
41 }