3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
10 package org.opendaylight.controller.protocol_plugin.openflow.internal;
12 import java.nio.ByteBuffer;
14 import org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension.V6Error;
15 import org.openflow.protocol.OFError;
16 import org.openflow.protocol.OFError.OFBadActionCode;
17 import org.openflow.protocol.OFError.OFBadRequestCode;
18 import org.openflow.protocol.OFError.OFErrorType;
19 import org.openflow.protocol.OFError.OFFlowModFailedCode;
20 import org.openflow.protocol.OFError.OFHelloFailedCode;
21 import org.openflow.protocol.OFError.OFPortModFailedCode;
22 import org.openflow.protocol.OFError.OFQueueOpFailedCode;
24 public final class Utils {
26 private Utils() { //prevent instantiation
27 throw new AssertionError();
29 static String getOFErrorString(OFError error) {
30 // Handle VENDOR extension errors here
31 if (error.getErrorType() == V6Error.NICIRA_VENDOR_ERRORTYPE) {
32 V6Error er = new V6Error(error);
33 byte[] b = error.getError();
34 ByteBuffer bb = ByteBuffer.allocate(b.length);
41 // Handle OF1.0 errors here
42 OFErrorType et = OFErrorType.values()[0xffff & error.getErrorType()];
43 String errorStr = "Error : " + et.toString();
45 case OFPET_HELLO_FAILED:
46 OFHelloFailedCode hfc = OFHelloFailedCode.values()[0xffff & error
48 errorStr += " " + hfc.toString();
50 case OFPET_BAD_REQUEST:
51 OFBadRequestCode brc = OFBadRequestCode.values()[0xffff & error
53 errorStr += " " + brc.toString();
55 case OFPET_BAD_ACTION:
56 OFBadActionCode bac = OFBadActionCode.values()[0xffff & error
58 errorStr += " " + bac.toString();
60 case OFPET_FLOW_MOD_FAILED:
61 OFFlowModFailedCode fmfc = OFFlowModFailedCode.values()[0xffff & error
63 errorStr += " " + fmfc.toString();
65 case OFPET_PORT_MOD_FAILED:
66 OFPortModFailedCode pmfc = OFPortModFailedCode.values()[0xffff & error
68 errorStr += " " + pmfc.toString();
70 case OFPET_QUEUE_OP_FAILED:
71 OFQueueOpFailedCode qofc = OFQueueOpFailedCode.values()[0xffff & error
73 errorStr += " " + qofc.toString();