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.testtool;
10 import java.util.List;
12 import org.opendaylight.protocol.pcep.PCEPSession;
13 import org.opendaylight.protocol.pcep.PCEPSessionListener;
14 import org.opendaylight.protocol.pcep.PCEPTerminationReason;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
19 import com.google.common.collect.Lists;
22 * Simple Session Listener that is notified about messages and changes in the session.
24 public class SimpleSessionListener implements PCEPSessionListener {
26 public List<Message> messages = Lists.newArrayList();
28 private static final Logger logger = LoggerFactory.getLogger(SimpleSessionListener.class);
30 public SimpleSessionListener() {
34 public void onMessage(final PCEPSession session, final Message message) {
35 logger.debug("Received message: {}", message);
36 this.messages.add(message);
40 public void onSessionUp(final PCEPSession session) {
41 logger.debug("Session up.");
42 // final List<ExplicitRouteSubobject> subs = new ArrayList<ExplicitRouteSubobject>();
43 // subs.add(new EROIPPrefixSubobject<Prefix<?>>(new IPv4Prefix(new IPv4Address(new byte[] { 10, 1, 1, 2 }), 32),
45 // subs.add(new EROIPPrefixSubobject<Prefix<?>>(new IPv4Prefix(new IPv4Address(new byte[] { 2, 2, 2, 2 }), 32),
47 // final CompositeInstantiationObject cpo = new CompositeInstantiationObject(new
48 // PCEPEndPointsObject<IPv4Address>(IPv4.FAMILY.addressForBytes(new byte[] {
49 // 1, 1, 1, 1 }), IPv4.FAMILY.addressForBytes(new byte[] { 2, 2, 2, 2 })), new PCEPLspaObject(0, 0, 0, (short)
50 // 0, (short) 0, false, false, false, false), new PCEPExplicitRouteObject(subs, false), null, null);
52 // session.sendMessage(new PCCreateMessage(Lists.newArrayList(cpo)));
56 public void onSessionDown(final PCEPSession session, final Exception e) {
57 logger.debug("Session down with cause : {} or exception: {}", e);
62 public void onSessionTerminated(final PCEPSession session, final PCEPTerminationReason cause) {
63 logger.debug("Session terminated. Cause : {}", cause.toString());