use of org.onosproject.lisp.msg.types.lcaf.LispNatLcafAddress.NatAddressBuilder in project onos by opennetworkinglab.
the class LispMapServer method processInfoRequest.
/**
* Handles info-request message and replies with info-reply message.
*
* @param message info-request message
* @return info-reply message
*/
LispInfoReply processInfoRequest(LispMessage message) {
LispInfoRequest request = (LispInfoRequest) message;
if (!checkInfoRequestAuthData(request)) {
log.warn(INVALID_AUTHENTICATION_DATA_MSG, "Info-Request");
return null;
}
NatAddressBuilder natBuilder = new NatAddressBuilder();
try {
LispAfiAddress msAddress = new LispIpv4Address(valueOf(InetAddress.getLocalHost()));
natBuilder.withMsRlocAddress(msAddress);
natBuilder.withMsUdpPortNumber((short) INFO_REPLY_PORT);
// try to extract global ETR RLOC address from info-request
IpAddress globalRlocIp = valueOf(request.getSender().getAddress());
LispAfiAddress globalRlocAddress;
if (globalRlocIp.isIp4()) {
globalRlocAddress = new LispIpv4Address(globalRlocIp);
} else {
globalRlocAddress = new LispIpv6Address(globalRlocIp);
}
natBuilder.withGlobalEtrRlocAddress(globalRlocAddress);
natBuilder.withEtrUdpPortNumber((short) request.getSender().getPort());
natBuilder.withPrivateEtrRlocAddress(new LispNoAddress());
// TODO: need to specify RTR addresses
} catch (UnknownHostException e) {
log.warn(FAILED_TO_FORMULATE_NAT_MSG, e);
}
InfoReplyBuilder replyBuilder = new DefaultInfoReplyBuilder();
replyBuilder.withKeyId(request.getKeyId());
replyBuilder.withAuthDataLength(valueOf(authConfig.lispAuthKeyId()).getHashLength());
replyBuilder.withAuthKey(authConfig.lispAuthKey());
replyBuilder.withNonce(request.getNonce());
replyBuilder.withEidPrefix(request.getPrefix());
replyBuilder.withMaskLength(request.getMaskLength());
replyBuilder.withTtl(request.getTtl());
replyBuilder.withNatLcafAddress(natBuilder.build());
replyBuilder.withIsInfoReply(true);
LispInfoReply reply = replyBuilder.build();
reply.configSender(request.getSender());
return reply;
}
use of org.onosproject.lisp.msg.types.lcaf.LispNatLcafAddress.NatAddressBuilder in project onos by opennetworkinglab.
the class DefaultLispInfoReplyTest method testConstruction.
@Test
public void testConstruction() {
DefaultLispInfoReply reply = (DefaultLispInfoReply) reply1;
LispIpv4Address address = new LispIpv4Address(IpAddress.valueOf("192.168.1.4"));
short msUdpPortNumber1 = 80;
short etrUdpPortNumber1 = 100;
LispIpv4Address globalEtrRlocAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
LispIpv4Address msRlocAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.2"));
LispIpv4Address privateEtrRlocAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.3"));
LispNatLcafAddress natLcafAddress = new NatAddressBuilder().withLength((short) 0).withMsUdpPortNumber(msUdpPortNumber1).withEtrUdpPortNumber(etrUdpPortNumber1).withGlobalEtrRlocAddress(globalEtrRlocAddress1).withMsRlocAddress(msRlocAddress1).withPrivateEtrRlocAddress(privateEtrRlocAddress1).build();
assertThat(reply.isInfoReply(), is(true));
assertThat(reply.getNonce(), is(1L));
assertThat(reply.getKeyId(), is((short) 1));
assertThat(reply.getMaskLength(), is((byte) 1));
assertThat(reply.getPrefix(), is(address));
assertThat(reply.getNatLcafAddress(), is(natLcafAddress));
}
use of org.onosproject.lisp.msg.types.lcaf.LispNatLcafAddress.NatAddressBuilder in project onos by opennetworkinglab.
the class LispNatLcafAddressTest method setup.
@Before
public void setup() {
NatAddressBuilder builder1 = new NatAddressBuilder();
short msUdpPortNumber1 = 80;
short etrUdpPortNumber1 = 100;
LispIpv4Address globalEtrRlocAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
LispIpv4Address msRlocAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.2"));
LispIpv4Address privateEtrRlocAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.3"));
LispIpv4Address rtrRloc11 = new LispIpv4Address(IpAddress.valueOf("10.1.1.1"));
LispIpv4Address rtrRloc12 = new LispIpv4Address(IpAddress.valueOf("10.1.1.2"));
List<LispAfiAddress> rtrRlocs1 = ImmutableList.of(rtrRloc11, rtrRloc12);
address1 = builder1.withLength((short) 0).withMsUdpPortNumber(msUdpPortNumber1).withEtrUdpPortNumber(etrUdpPortNumber1).withGlobalEtrRlocAddress(globalEtrRlocAddress1).withMsRlocAddress(msRlocAddress1).withPrivateEtrRlocAddress(privateEtrRlocAddress1).withRtrRlocAddresses(rtrRlocs1).build();
NatAddressBuilder builder2 = new NatAddressBuilder();
sameAsAddress1 = builder2.withLength((short) 0).withMsUdpPortNumber(msUdpPortNumber1).withEtrUdpPortNumber(etrUdpPortNumber1).withGlobalEtrRlocAddress(globalEtrRlocAddress1).withMsRlocAddress(msRlocAddress1).withPrivateEtrRlocAddress(privateEtrRlocAddress1).withRtrRlocAddresses(rtrRlocs1).build();
NatAddressBuilder builder3 = new NatAddressBuilder();
short msUdpPortNumber2 = 81;
short etrUdpPortNumber2 = 101;
LispIpv4Address globalEtrRlocAddress2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.1"));
LispIpv4Address msRlocAddress2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.2"));
LispIpv4Address privateEtrRlocAddress2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.3"));
LispIpv4Address rtrRloc21 = new LispIpv4Address(IpAddress.valueOf("10.1.2.1"));
LispIpv4Address rtrRloc22 = new LispIpv4Address(IpAddress.valueOf("10.1.2.2"));
List<LispAfiAddress> rtrRlocs2 = ImmutableList.of(rtrRloc21, rtrRloc22);
address2 = builder3.withLength((short) 0).withMsUdpPortNumber(msUdpPortNumber2).withEtrUdpPortNumber(etrUdpPortNumber2).withGlobalEtrRlocAddress(globalEtrRlocAddress2).withMsRlocAddress(msRlocAddress2).withPrivateEtrRlocAddress(privateEtrRlocAddress2).withRtrRlocAddresses(rtrRlocs2).build();
}
use of org.onosproject.lisp.msg.types.lcaf.LispNatLcafAddress.NatAddressBuilder in project onos by opennetworkinglab.
the class DefaultLispInfoReplyTest method setup.
@Before
public void setup() {
InfoReplyBuilder builder1 = new DefaultInfoReplyBuilder();
short msUdpPortNumber1 = 80;
short etrUdpPortNumber1 = 100;
LispIpv4Address globalEtrRlocAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
LispIpv4Address msRlocAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.2"));
LispIpv4Address privateEtrRlocAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.3"));
LispIpv4Address address1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.4"));
LispNatLcafAddress natLcafAddress1 = new NatAddressBuilder().withLength((short) 0).withMsUdpPortNumber(msUdpPortNumber1).withEtrUdpPortNumber(etrUdpPortNumber1).withGlobalEtrRlocAddress(globalEtrRlocAddress1).withMsRlocAddress(msRlocAddress1).withPrivateEtrRlocAddress(privateEtrRlocAddress1).build();
reply1 = builder1.withNonce(1L).withKeyId((short) 1).withAuthKey(AUTH_KEY).withIsInfoReply(true).withMaskLength((byte) 1).withEidPrefix(address1).withNatLcafAddress(natLcafAddress1).build();
InfoReplyBuilder builder2 = new DefaultInfoReplyBuilder();
sameAsReply1 = builder2.withNonce(1L).withKeyId((short) 1).withAuthKey(AUTH_KEY).withIsInfoReply(true).withMaskLength((byte) 1).withEidPrefix(address1).withNatLcafAddress(natLcafAddress1).build();
InfoReplyBuilder builder3 = new DefaultInfoReplyBuilder();
short msUdpPortNumber2 = 81;
short etrUdpPortNumber2 = 101;
LispIpv4Address globalEtrRlocAddress2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.1"));
LispIpv4Address msRlocAddress2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.2"));
LispIpv4Address privateEtrRlocAddress2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.3"));
LispIpv4Address address2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.4"));
LispNatLcafAddress natLcafAddress2 = new NatAddressBuilder().withLength((short) 0).withMsUdpPortNumber(msUdpPortNumber2).withEtrUdpPortNumber(etrUdpPortNumber2).withGlobalEtrRlocAddress(globalEtrRlocAddress2).withMsRlocAddress(msRlocAddress2).withPrivateEtrRlocAddress(privateEtrRlocAddress2).build();
reply2 = builder3.withNonce(2L).withKeyId((short) 2).withAuthKey(AUTH_KEY).withIsInfoReply(true).withMaskLength((byte) 1).withEidPrefix(address2).withNatLcafAddress(natLcafAddress2).build();
}
Aggregations