use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.server.config.Server in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method registerAddress.
/*
// This registers an IP with a MapRegister, then adds a password via the
// northbound REST API
// and checks that the password works
public void testPasswordExactMatch() throws Exception {
cleanUP();
String ipString = "10.0.0.1";
LispIpv4Address address = LispAddressUtil.asIPAfiAddress(ipString);
int mask = 32;
String pass = "pass";
URL url = createPutURL("key");
String jsonAuthData = createAuthKeyJSON(pass, address, mask);
LOG.trace("Sending this JSON to LISP server: \n" + jsonAuthData);
LOG.trace("Address: " + address);
byte[] expectedSha = new byte[] { (byte) 146, (byte) 234, (byte) 52, (byte) 247, (byte) 186, (byte) 232,
(byte) 31, (byte) 249, (byte) 87,
(byte) 73, (byte) 234, (byte) 54, (byte) 225, (byte) 160, (byte) 129, (byte) 251, (byte) 73, (byte) 53,
(byte) 196, (byte) 62 };
byte[] zeros = new byte[20];
callURL("PUT", "application/json", "text/plain", jsonAuthData, url);
// build a MapRegister
MapRegisterBuilder mapRegister = new MapRegisterBuilder();
mapRegister.setWantMapNotify(true);
mapRegister.setNonce((long) 8);
EidToLocatorRecordBuilder etlr = new EidToLocatorRecordBuilder();
etlr.setLispAddressContainer(LispAddressUtil.toContainer(address));
etlr.setMaskLength((short) mask);
etlr.setRecordTtl(254);
LocatorRecordBuilder record = new LocatorRecordBuilder();
record.setLispAddressContainer(LispAddressUtil.toContainer(locatorEid));
etlr.setLocatorRecord(new ArrayList<LocatorRecord>());
etlr.getLocatorRecord().add(record.build());
mapRegister.setMappingRecordItem(new ArrayList<MappingRecordItem>());
mapRegister.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(etlr.build()).build());
mapRegister.setKeyId((short) 1); // LispKeyIDEnum.SHA1.getKeyID()
mapRegister.setAuthenticationData(zeros);
sendMapRegister(mapRegister.build());
assertNoPacketReceived(3000);
mapRegister.setAuthenticationData(expectedSha);
sendMapRegister(mapRegister.build());
assertMapNotifyReceived();
}
public void testPasswordMaskMatch() throws Exception {
cleanUP();
LispIpv4Address addressInRange = LispAddressUtil.asIPAfiAddress("10.20.30.40");
LispIpv4Address addressOutOfRange = LispAddressUtil.asIPAfiAddress("20.40.30.40");
LispIpv4Address range = LispAddressUtil.asIPAfiAddress("10.20.30.0");
int mask = 32;
String pass = "pass";
URL url = createPutURL("key");
String jsonAuthData = createAuthKeyJSON(pass, range, 8);
callURL("PUT", "application/json", "text/plain", jsonAuthData, url);
// build a MapRegister
MapRegisterBuilder mapRegister = new MapRegisterBuilder();
mapRegister.setWantMapNotify(true);
mapRegister.setNonce((long) 8);
EidToLocatorRecordBuilder etlr = new EidToLocatorRecordBuilder();
etlr.setLispAddressContainer(LispAddressUtil.toContainer(addressInRange));
etlr.setMaskLength((short) mask);
etlr.setRecordTtl(254);
LocatorRecordBuilder record = new LocatorRecordBuilder();
record.setLispAddressContainer(LispAddressUtil.toContainer(locatorEid));
record.setLispAddressContainer(LispAddressUtil.toContainer(locatorEid));
etlr.setLocatorRecord(new ArrayList<LocatorRecord>());
etlr.getLocatorRecord().add(record.build());
mapRegister.setMappingRecordItem(new ArrayList<MappingRecordItem>());
mapRegister.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(etlr.build()).build());
mapRegister.setKeyId((short) 1); // LispKeyIDEnum.SHA1.getKeyID()
mapRegister
.setAuthenticationData(new byte[] { -15, -52, 38, -94, 125, -111, -68, -79, 68, 6, 101, 45, -1, 47, -4,
-67, -113, 104, -110, -71 });
sendMapRegister(mapRegister.build());
assertMapNotifyReceived();
etlr.setLispAddressContainer(LispAddressUtil.toContainer(addressOutOfRange));
mapRegister
.setAuthenticationData(new byte[] { -54, 68, -58, -91, -23, 22, -88, -31, 113, 39, 115, 78, -68, -123,
-71, -14, -99, 67, -23, -73 });
sendMapRegister(mapRegister.build());
assertNoPacketReceived(3000);
}
*/
// takes an address, packs it in a MapRegister and sends it
private void registerAddress(Eid eid) throws SocketTimeoutException {
mapService.addAuthenticationKey(eid, NULL_AUTH_KEY);
sleepForSeconds(1);
MapRegister mapRegister = MappingServiceIntegrationTestUtil.getDefaultMapRegisterBuilder(eid).build();
sendMapRegister(mapRegister);
MapNotify mapNotify = receiveMapNotify();
assertEquals(8, mapNotify.getNonce().longValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.server.config.Server in project bgpcep by opendaylight.
the class AbstractBGPDispatcherTest method createServer.
Channel createServer(final InetSocketAddress serverAddress) {
this.registry.addPeer(new IpAddressNoZone(new Ipv4AddressNoZone(serverAddress.getAddress().getHostAddress())), this.serverListener, createPreferences(serverAddress));
LoggerFactory.getLogger(AbstractBGPDispatcherTest.class).info("createServer");
final ChannelFuture future = this.serverDispatcher.createServer(serverAddress);
future.addListener(future1 -> Preconditions.checkArgument(future1.isSuccess(), "Unable to start bgp server on %s", future1.cause()));
waitFutureSuccess(future);
return future.channel();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.server.config.Server in project bgpcep by opendaylight.
the class BmpDeployerImpl method updateBmpMonitor.
@SuppressWarnings("checkstyle:IllegalCatch")
private synchronized void updateBmpMonitor(final BmpMonitorConfig bmpConfig) {
final MonitorId monitorId = bmpConfig.getMonitorId();
final BmpMonitoringStationImpl oldService = bmpMonitorServices.remove(monitorId);
try {
if (oldService != null) {
oldService.closeServiceInstance().get(TIMEOUT_NS, TimeUnit.NANOSECONDS);
oldService.close();
}
final Server server = bmpConfig.getServer();
final InetSocketAddress inetAddress = Ipv4Util.toInetSocketAddress(server.getBindingAddress(), server.getBindingPort());
final BmpMonitoringStationImpl monitor = new BmpMonitoringStationImpl(domDataBroker, dispatcher, extensions, codecTree, singletonProvider, monitorId, inetAddress, bmpConfig.nonnullMonitoredRouter().values());
bmpMonitorServices.put(monitorId, monitor);
} catch (final Exception e) {
LOG.error("Failed to create Bmp Monitor {}.", monitorId, e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.server.config.Server in project bgpcep by opendaylight.
the class AbstractTopologySessionListener method updatePccState.
synchronized void updatePccState(final PccSyncState pccSyncState) {
if (this.nodeState == null) {
LOG.info("Server Session Manager is closed.");
AbstractTopologySessionListener.this.session.close(TerminationReason.UNKNOWN);
return;
}
final MessageContext ctx = new MessageContext(this.nodeState.getChain().newWriteOnlyTransaction());
updatePccNode(ctx, new PathComputationClientBuilder().setStateSync(pccSyncState).build());
if (pccSyncState != PccSyncState.Synchronized) {
this.synced.set(false);
this.triggeredResyncInProcess = true;
}
// All set, commit the modifications
ctx.trans.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
LOG.trace("Pcc Internal state for session {} updated successfully", AbstractTopologySessionListener.this.session);
}
@Override
public void onFailure(final Throwable throwable) {
LOG.error("Failed to update Pcc internal state for session {}", AbstractTopologySessionListener.this.session, throwable);
AbstractTopologySessionListener.this.session.close(TerminationReason.UNKNOWN);
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.server.config.Server in project bgpcep by opendaylight.
the class PCEPTopologyProvider method enableRPCs.
private synchronized void enableRPCs(final SettableFuture<Empty> future, final ChannelFuture channelFuture) {
final var channelFailure = channelFuture.cause();
if (channelFailure != null) {
LOG.error("Topology Provider {} failed to initialize server channel", topologyId(), channelFailure);
disableManager(future);
return;
}
channel = channelFuture.channel();
// Register RPCs
final RpcProviderService rpcRegistry = dependencies.getRpcProviderRegistry();
elementReg = rpcRegistry.registerRpcImplementation(NetworkTopologyPcepService.class, new TopologyRPCs(manager), Set.of(instanceIdentifier));
networkReg = rpcRegistry.registerRpcImplementation(NetworkTopologyPcepProgrammingService.class, new TopologyProgramming(scheduler, manager), Set.of(instanceIdentifier));
// We are now completely initialized
LOG.info("PCEP Topology Provider {} enabled", topologyId());
finishOperation(future);
}
Aggregations