2 * Copyright (c) 2013 Cisco Systems, Inc. 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
8 package org.opendaylight.protocol.pcep.impl;
10 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
13 * Type identifier for {@link org.opendaylight.protocol.pcep.PCEPMessage PCEPMessage}
15 public enum PCEPMessageType {
16 OPEN(1), NOTIFICATION(5), KEEPALIVE(2), RESPONSE(4), REQUEST(3), ERROR(6), CLOSE(7), UPDATE_REQUEST(11), STATUS_REPORT(10),
17 // TODO: replace with actual values by IANA
18 XR_ADD_TUNNEL(8), XR_DELETE_TUNNEL(9), PCCREATE(12);
20 private final int identifier;
22 PCEPMessageType(final int identifier) {
23 this.identifier = identifier;
26 public int getIdentifier() {
27 return this.identifier;
30 public static PCEPMessageType getFromInt(final int type) throws PCEPDeserializerException {
32 for (final PCEPMessageType type_e : PCEPMessageType.values()) {
33 if (type_e.getIdentifier() == type) {
38 throw new PCEPDeserializerException("Unknown PCEPMessage Class identifier. Passed: " + type + "; Known: "
39 + PCEPMessageType.values() + ".");