use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Notify in project bgpcep by opendaylight.
the class BGPSessionImplTest method testHandleOpenMsg.
@Test
public void testHandleOpenMsg() throws BGPDocumentedException {
this.bgpSession.handleMessage(this.classicOpen);
Assert.assertEquals(State.IDLE, this.bgpSession.getState());
Assert.assertEquals(1, this.receivedMsgs.size());
Assert.assertTrue(this.receivedMsgs.get(0) instanceof Notify);
final Notify error = (Notify) this.receivedMsgs.get(0);
Assert.assertEquals(BGPError.FSM_ERROR.getCode(), error.getErrorCode().shortValue());
Assert.assertEquals(BGPError.FSM_ERROR.getSubcode(), error.getErrorSubcode().shortValue());
Mockito.verify(this.speakerListener).close();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Notify in project bgpcep by opendaylight.
the class FSMTest method sendNotification.
@Test
public void sendNotification() {
this.clientSession.channelActive(null);
this.clientSession.handleMessage(this.classicOpen);
this.clientSession.handleMessage(new KeepaliveBuilder().build());
assertEquals(this.clientSession.getState(), BGPClientSessionNegotiator.State.FINISHED);
this.clientSession.handleMessage(new OpenBuilder().setMyAsNumber(30).setHoldTimer(3).setVersion(new ProtocolVersion((short) 4)).build());
assertEquals(3, this.receivedMsgs.size());
assertTrue(this.receivedMsgs.get(2) instanceof Notify);
final Notification m = this.receivedMsgs.get(2);
assertEquals(BGPError.FSM_ERROR.getCode(), ((Notify) m).getErrorCode().shortValue());
assertEquals(BGPError.FSM_ERROR.getSubcode(), ((Notify) m).getErrorSubcode().shortValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Notify in project bgpcep by opendaylight.
the class BGPSessionImpl method handleMessage.
/**
* Handles incoming message based on their type.
*
* @param msg incoming message
*/
synchronized void handleMessage(final Notification msg) {
if (this.state == State.IDLE) {
return;
}
try {
// Update last reception time
this.lastMessageReceivedAt = System.nanoTime();
if (msg instanceof Open) {
// Open messages should not be present here
this.terminate(new BGPDocumentedException(null, BGPError.FSM_ERROR));
} else if (msg instanceof Notify) {
final Notify notify = (Notify) msg;
// Notifications are handled internally
LOG.info("Session closed because Notification message received: {} / {}, data={}", notify.getErrorCode(), notify.getErrorSubcode(), notify.getData() != null ? ByteBufUtil.hexDump(notify.getData()) : null);
notifyTerminationReasonAndCloseWithoutMessage(notify.getErrorCode(), notify.getErrorSubcode());
} else if (msg instanceof Keepalive) {
// Keepalives are handled internally
LOG.trace("Received KeepAlive message.");
this.kaCounter++;
if (this.kaCounter >= 2) {
this.sync.kaReceived();
}
} else if (msg instanceof RouteRefresh) {
this.listener.onMessage(this, msg);
} else if (msg instanceof Update) {
this.listener.onMessage(this, msg);
this.sync.updReceived((Update) msg);
} else {
LOG.warn("Ignoring unhandled message: {}.", msg.getClass());
}
this.sessionState.messageReceived(msg);
} catch (final BGPDocumentedException e) {
this.terminate(e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Notify in project lispflowmapping by opendaylight.
the class MapNotifySerializationTest method deserialize__MultipleRecords.
@Test
public void deserialize__MultipleRecords() throws Exception {
// LISP(Type = 4 Map-Notify, I=1
// Record Counter: 4
// EID prefixes: 153.16.254.1 -- 152.16.254.1 -- 151.16.254.1 --
// 150.16.254.1
// Local RLOCs: 192.168.136.10 -- 192.168.136.11 -- 192.168.136.12 --
// 192.168.136.13
//
MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("40 00 00 " + // Record count
"04 " + "FF BB 00 00 00 00 00 00 00 01 00 14 87 c1 33 cd " + "d1 1e bc 80 fd 3e 71 11 81 17 40 74 26 25 44 bd " + // Record
"00 00 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " + // 1
"ff 00 00 05 00 01 c0 a8 88 0a " + // contd
"00 00 00 0a 01 20 10 00 00 00 00 01 98 10 fe 01 01 64 " + // 2
"ff 00 00 05 00 01 c0 a8 88 0b " + // contd
"00 00 00 0a 01 20 10 00 00 00 00 01 97 10 fe 01 01 64 " + // 3
"ff 00 00 05 00 01 c0 a8 88 0c " + // contd
"00 00 00 0a 01 20 10 00 00 00 00 01 96 10 fe 01 01 64 " + // 4
"ff 00 00 05 00 01 c0 a8 88 0d "));
assertEquals(4, mn.getMappingRecordItem().size());
assertEquals(LispAddressUtil.asIpv4PrefixBinaryEid("153.16.254.1/32"), mn.getMappingRecordItem().get(0).getMappingRecord().getEid());
assertEquals(LispAddressUtil.asIpv4PrefixBinaryEid("151.16.254.1/32"), mn.getMappingRecordItem().get(2).getMappingRecord().getEid());
assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.11"), mn.getMappingRecordItem().get(1).getMappingRecord().getLocatorRecord().get(0).getRloc());
assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.13"), mn.getMappingRecordItem().get(3).getMappingRecord().getLocatorRecord().get(0).getRloc());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Notify in project lispflowmapping by opendaylight.
the class MapNotifySerializationTest method deserialize__SHA256.
@Test
public void deserialize__SHA256() throws Exception {
// LISP(Type = 4 Map-Notify, I=0
// Record Counter: 1
// Nonce: (something)
// Key ID: 0x0002
// AuthDataLength: 32 Data:
// 70 30 d4 c6 10 44 0d 83 be 4d bf fd a9 8c 57 6d 68 a5 bf 32 11 c9 7b
// 58 c4 b9 9f 06 11 23 b9 38
// EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
// No-Action
// Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
// Priority/Weight: 1/100, Multicast Priority/Weight: 255/0
//
MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("40 00 00 01 FF BB " + "00 00 00 00 00 00 00 02 00 20 70 30 d4 c6 10 44 0d 83 be 4d bf fd a9 8c 57 6d 68 a5 bf 32 " + "11 c9 7b 58 c4 b9 9f 06 11 23 b9 38 00 00 " + "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " + "ff 00 00 05 00 01 c0 a8 88 0a"));
assertFalse(mn.isXtrSiteIdPresent());
assertEquals(1, mn.getMappingRecordItem().size());
assertEquals(0xFFBB000000000000L, mn.getNonce().longValue());
assertEquals(0x0002, mn.getKeyId().shortValue());
byte[] expectedAuthenticationData = { (byte) 0x70, (byte) 0x30, (byte) 0xd4, (byte) 0xc6, (byte) 0x10, (byte) 0x44, (byte) 0x0d, (byte) 0x83, (byte) 0xbe, (byte) 0x4d, (byte) 0xbf, (byte) 0xfd, (byte) 0xa9, (byte) 0x8c, (byte) 0x57, (byte) 0x6d, (byte) 0x68, (byte) 0xa5, (byte) 0xbf, (byte) 0x32, (byte) 0x11, (byte) 0xc9, (byte) 0x7b, (byte) 0x58, (byte) 0xc4, (byte) 0xb9, (byte) 0x9f, (byte) 0x06, (byte) 0x11, (byte) 0x23, (byte) 0xb9, (byte) 0x38 };
ArrayAssert.assertEquals(expectedAuthenticationData, mn.getAuthenticationData());
}
Aggregations