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 abstract class Utils {
25 public static String getOFErrorString(OFError error) {
26 // Handle VENDOR extension errors here
27 if (error.getErrorType() == V6Error.NICIRA_VENDOR_ERRORTYPE) {
28 V6Error er = new V6Error(error);
29 byte[] b = error.getError();
30 ByteBuffer bb = ByteBuffer.allocate(b.length);
37 // Handle OF1.0 errors here
38 OFErrorType et = OFErrorType.values()[0xffff & error.getErrorType()];
39 String errorStr = "Error : " + et.toString();
41 case OFPET_HELLO_FAILED:
42 OFHelloFailedCode hfc = OFHelloFailedCode.values()[0xffff & error
44 errorStr += " " + hfc.toString();
46 case OFPET_BAD_REQUEST:
47 OFBadRequestCode brc = OFBadRequestCode.values()[0xffff & error
49 errorStr += " " + brc.toString();
51 case OFPET_BAD_ACTION:
52 OFBadActionCode bac = OFBadActionCode.values()[0xffff & error
54 errorStr += " " + bac.toString();
56 case OFPET_FLOW_MOD_FAILED:
57 OFFlowModFailedCode fmfc = OFFlowModFailedCode.values()[0xffff & error
59 errorStr += " " + fmfc.toString();
61 case OFPET_PORT_MOD_FAILED:
62 OFPortModFailedCode pmfc = OFPortModFailedCode.values()[0xffff & error
64 errorStr += " " + pmfc.toString();
66 case OFPET_QUEUE_OP_FAILED:
67 OFQueueOpFailedCode qofc = OFQueueOpFailedCode.values()[0xffff & error
69 errorStr += " " + qofc.toString();