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
29 if (error.getErrorType() == V6Error.NICIRA_VENDOR_ERRORTYPE) {
30 V6Error er = new V6Error(error);
31 byte[] b = error.getError();
32 ByteBuffer bb = ByteBuffer.allocate(b.length);
40 // Handle OF1.0 errors here
41 OFErrorType et = OFErrorType.values()[0xffff & error.getErrorType()];
42 String errorStr = "Error : " + et.toString();
44 case OFPET_HELLO_FAILED:
45 OFHelloFailedCode hfc = OFHelloFailedCode.values()[0xffff & error
47 errorStr += " " + hfc.toString();
49 case OFPET_BAD_REQUEST:
50 OFBadRequestCode brc = OFBadRequestCode.values()[0xffff & error
52 errorStr += " " + brc.toString();
54 case OFPET_BAD_ACTION:
55 OFBadActionCode bac = OFBadActionCode.values()[0xffff & error
57 errorStr += " " + bac.toString();
59 case OFPET_FLOW_MOD_FAILED:
60 OFFlowModFailedCode fmfc = OFFlowModFailedCode.values()[0xffff & error
62 errorStr += " " + fmfc.toString();
64 case OFPET_PORT_MOD_FAILED:
65 OFPortModFailedCode pmfc = OFPortModFailedCode.values()[0xffff & error
67 errorStr += " " + pmfc.toString();
69 case OFPET_QUEUE_OP_FAILED:
70 OFQueueOpFailedCode qofc = OFQueueOpFailedCode.values()[0xffff & error
72 errorStr += " " + qofc.toString();