use of org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.Protocol in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method registerAndQuery__ApplicationData.
public void registerAndQuery__ApplicationData() throws SocketTimeoutException {
cleanUP();
String ipString = "1.2.3.4";
final Uint8 protocol = Uint8.ONE;
int ipTOs = 2;
final Uint16 localPortLow = Uint16.valueOf(3);
final Uint16 localPortHigh = Uint16.valueOf(4);
final Uint16 remotePortLow = Uint16.valueOf(4);
final Uint16 remotePortHigh = Uint16.valueOf(5);
ApplicationDataBuilder builder = new ApplicationDataBuilder();
builder.setIpTos(ipTOs);
builder.setProtocol(protocol);
builder.setLocalPortLow(new PortNumber(localPortLow));
builder.setLocalPortHigh(new PortNumber(localPortHigh));
builder.setRemotePortLow(new PortNumber(remotePortLow));
builder.setRemotePortHigh(new PortNumber(remotePortHigh));
builder.setAddress(new SimpleAddress(new IpAddress(new Ipv4Address(ipString))));
EidBuilder eb = new EidBuilder();
eb.setAddressType(ApplicationDataLcaf.class);
eb.setVirtualNetworkId(null);
eb.setAddress(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ApplicationDataBuilder().setApplicationData(builder.build()).build());
Eid addressToSend = eb.build();
MapReply reply = registerAddressAndQuery(addressToSend);
Eid receivedAddress = reply.getMappingRecordItem().get(0).getMappingRecord().getEid();
assertEquals(ApplicationDataLcaf.class, receivedAddress.getAddressType());
ApplicationData receivedApplicationDataAddress = (ApplicationData) receivedAddress.getAddress();
assertEquals(protocol, receivedApplicationDataAddress.getApplicationData().getProtocol());
assertEquals(ipTOs, receivedApplicationDataAddress.getApplicationData().getIpTos().intValue());
assertEquals(localPortLow, receivedApplicationDataAddress.getApplicationData().getLocalPortLow().getValue());
assertEquals(localPortHigh, receivedApplicationDataAddress.getApplicationData().getLocalPortHigh().getValue());
assertEquals(remotePortLow, receivedApplicationDataAddress.getApplicationData().getRemotePortLow().getValue());
assertEquals(remotePortHigh, receivedApplicationDataAddress.getApplicationData().getRemotePortHigh().getValue());
SimpleAddress ipAddressReceived = receivedApplicationDataAddress.getApplicationData().getAddress();
assertEquals(ipString, ipAddressReceived.getIpAddress().getIpv4Address().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.Protocol in project lispflowmapping by opendaylight.
the class ApplicationDataSerializerTest method serialize__Simple.
@Test
public void serialize__Simple() throws Exception {
ApplicationDataBuilder addressBuilder = new ApplicationDataBuilder().setIpTos(ByteUtil.getPartialInt(new byte[] { (byte) 0xAA, (byte) 0xBB, (byte) 0xCC })).setProtocol(Uint8.valueOf(0xDD)).setLocalPortLow(new PortNumber(Uint16.valueOf(0xA6A1))).setLocalPortHigh(new PortNumber(Uint16.valueOf(0xA6A2))).setRemotePortLow(new PortNumber(Uint16.valueOf(0xFFDD))).setRemotePortHigh(new PortNumber(Uint16.valueOf(0xFFDE))).setAddress(new SimpleAddress(new IpAddress(new Ipv4Address("17.34.51.68"))));
EidBuilder eb = new EidBuilder();
eb.setAddressType(ApplicationDataLcaf.class);
eb.setVirtualNetworkId(null);
eb.setAddress(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ApplicationDataBuilder().setApplicationData(addressBuilder.build()).build());
ByteBuffer buf = ByteBuffer.allocate(LispAddressSerializer.getInstance().getAddressSize(eb.build()));
LispAddressSerializer.getInstance().serialize(buf, eb.build());
ByteBuffer expectedBuf = hexToByteBuffer("40 03 00 00 " + //
"04 00 00 12 " + // IPTOS & protocol
"AA BB CC DD " + // local port range
"A6 A1 A6 A2 " + // remote port range
"FF DD FF DE " + // AFI=1, IP=0x11223344
"00 01 11 22 33 44");
ArrayAssert.assertEquals(expectedBuf.array(), buf.array());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.Protocol in project lispflowmapping by opendaylight.
the class ApplicationDataSerializerTest method deserialize__Ipv6.
@Test
public void deserialize__Ipv6() throws Exception {
Eid appAddress = LispAddressSerializer.getInstance().deserializeEid(hexToByteBuffer("40 03 00 00 " + "04 20 00 1E " + // IPTOS & protocol
"AA BB CC DD " + // local port range
"A6 A1 A6 A2 " + // remote port range
"FF DD FF DE " + "00 02 11 22 33 44 55 66 77 88 99 AA BB CC AA BB CC DD"), // AFI=2,
null);
// IPv6
assertEquals("1122:3344:5566:7788:99aa:bbcc:aabb:ccdd", ((ApplicationData) appAddress.getAddress()).getApplicationData().getAddress().stringValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.Protocol in project netconf by opendaylight.
the class NetconfConnectDeviceCommand method execute.
@Override
public Object execute() {
if (!NetconfCommandUtils.isIpValid(deviceIp) || !NetconfCommandUtils.isPortValid(devicePort)) {
return "Invalid IP:" + deviceIp + " or Port:" + devicePort + "Please enter a valid entry to proceed.";
}
final boolean isTcpOnly = connectionType.equals("true");
final boolean isSchemaless = schemaless.equals("true");
final NetconfNodeBuilder netconfNodeBuilder = new NetconfNodeBuilder();
netconfNodeBuilder.setHost(new Host(new IpAddress(new Ipv4Address(deviceIp)))).setPort(new PortNumber(Uint16.valueOf(Integer.decode(devicePort)))).setTcpOnly(isTcpOnly).setSchemaless(isSchemaless);
if (isTcpOnly || protocol.equalsIgnoreCase("ssh")) {
if (Strings.isNullOrEmpty(username) || Strings.isNullOrEmpty(password)) {
return "Empty Username:" + username + " or Password:" + password + ". In TCP or SSH mode, you must provide valid username and password.";
}
final Credentials credentials = new LoginPasswordBuilder().setPassword(password).setUsername(username).build();
netconfNodeBuilder.setCredentials(credentials);
if (!isTcpOnly) {
netconfNodeBuilder.setProtocol(new ProtocolBuilder().setName(Name.SSH).build());
}
} else if (protocol.equalsIgnoreCase("tls")) {
TlsCase tlsCase = null;
if (!Strings.isNullOrEmpty(excludedTlsVersions)) {
tlsCase = new TlsCaseBuilder().setTls(new TlsBuilder().setExcludedVersions(Arrays.asList(excludedTlsVersions.split(","))).build()).build();
}
netconfNodeBuilder.setProtocol(new ProtocolBuilder().setName(Name.TLS).setSpecification(tlsCase).build());
} else {
return "Invalid protocol: " + protocol + ". Only SSH and TLS are supported.";
}
service.connectDevice(netconfNodeBuilder.build(), deviceId);
final String message = "Netconf connector added succesfully";
return message;
}
Aggregations