use of org.onosproject.lisp.msg.types.LispAfiAddress 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.LispAfiAddress in project onos by opennetworkinglab.
the class LispMapServer method sendSmrMessage.
/**
* Sends SMR (Solicit Map Request) to their subscribers.
*
* @param eidRecord the updated EID
*/
private void sendSmrMessage(LispEidRecord eidRecord) {
RequestBuilder builder = new DefaultRequestBuilder();
LispAfiAddress msAddress = null;
try {
msAddress = new LispIpv4Address(IpAddress.valueOf(InetAddress.getLocalHost()));
} catch (UnknownHostException e) {
log.warn("Source EID is not found, {}", e.getMessage());
}
LispMapRequest msg = builder.withIsSmr(true).withIsSmrInvoked(true).withIsProbe(false).withIsPitr(false).withIsAuthoritative(false).withIsMapDataPresent(false).withSourceEid(msAddress).withEidRecords(ImmutableList.of(eidRecord)).build();
LispRouterFactory routerFactory = LispRouterFactory.getInstance();
Collection<LispRouter> routers = routerFactory.getRouters();
routers.forEach(router -> {
if (isInEidRecordRange(eidRecord, router.getEidRecords())) {
router.sendMessage(msg);
}
});
}
use of org.onosproject.lisp.msg.types.LispAfiAddress in project onos by opennetworkinglab.
the class DefaultLispGenericLocator method deserialize.
/**
* Deserializes LispGenericLocator message portion.
*
* @param byteBuf byte buffer
* @return LispGenericLocator
* @throws LispParseError LISP message parse error
* @throws LispReaderException LISP message reader exception
*/
public static LispGenericLocator deserialize(ByteBuf byteBuf) throws LispParseError, LispReaderException {
// priority -> 8 bits
byte priority = (byte) byteBuf.readUnsignedByte();
// weight -> 8 bits
byte weight = (byte) byteBuf.readUnsignedByte();
// multi-cast priority -> 8 bits
byte multicastPriority = (byte) byteBuf.readUnsignedByte();
// multi-cast weight -> 8 bits
byte multicastWeight = (byte) byteBuf.readUnsignedByte();
// let's skip unused flags
byteBuf.skipBytes(SKIP_UNUSED_FLAG_LENGTH);
byte flags = byteBuf.readByte();
// local locator flag -> 1 bit
boolean localLocator = ByteOperator.getBit(flags, LOCAL_LOCATOR_INDEX);
// rloc probe flag -> 1 bit
boolean rlocProbed = ByteOperator.getBit(flags, RLOC_PROBED_INDEX);
// routed flag -> 1 bit
boolean routed = ByteOperator.getBit(flags, ROUTED_INDEX);
LispAfiAddress address = new LispAfiAddress.AfiAddressReader().readFrom(byteBuf);
return new DefaultLispGenericLocator(priority, weight, multicastPriority, multicastWeight, localLocator, rlocProbed, routed, address);
}
use of org.onosproject.lisp.msg.types.LispAfiAddress in project onos by opennetworkinglab.
the class DefaultLispInfo method deserialize.
public static LispInfo deserialize(ByteBuf byteBuf) throws LispParseError, LispReaderException {
if (byteBuf.readerIndex() != 0) {
return null;
}
// infoReply -> 1 bit
boolean infoReplyFlag = ByteOperator.getBit(byteBuf.readByte(), INFO_REPLY_INDEX);
// let's skip the reserved field
byteBuf.skipBytes(RESERVED_SKIP_LENGTH_1);
// nonce -> 64 bits
long nonce = byteBuf.readLong();
// keyId -> 16 bits
short keyId = byteBuf.readShort();
// authenticationDataLength -> 16 bits
short authLength = byteBuf.readShort();
// authData -> depends on the authenticationDataLength
byte[] authData = new byte[authLength];
byteBuf.readBytes(authData);
// ttl -> 32 bits
int ttl = byteBuf.readInt();
// let's skip the reserved field
byteBuf.skipBytes(RESERVED_SKIP_LENGTH_2);
// mask length -> 8 bits
short maskLength = byteBuf.readUnsignedByte();
LispAfiAddress prefix = new LispAfiAddress.AfiAddressReader().readFrom(byteBuf);
return new DefaultLispInfo(infoReplyFlag, nonce, keyId, authLength, authData, ttl, (byte) maskLength, prefix);
}
use of org.onosproject.lisp.msg.types.LispAfiAddress in project onos by opennetworkinglab.
the class LispAppDataLcafAddressTest method setup.
@Before
public void setup() {
AppDataAddressBuilder builder1 = new AppDataAddressBuilder();
LispAfiAddress ipv4Address1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
address1 = builder1.withProtocol((byte) 0x01).withIpTos((short) 10).withLocalPortLow((short) 1).withLocalPortHigh((short) 255).withRemotePortLow((short) 2).withRemotePortHigh((short) 254).withAddress(ipv4Address1).build();
AppDataAddressBuilder builder2 = new AppDataAddressBuilder();
sameAsAddress1 = builder2.withProtocol((byte) 0x01).withIpTos((short) 10).withLocalPortLow((short) 1).withLocalPortHigh((short) 255).withRemotePortLow((short) 2).withRemotePortHigh((short) 254).withAddress(ipv4Address1).build();
AppDataAddressBuilder builder3 = new AppDataAddressBuilder();
LispAfiAddress ipv4Address2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.1"));
address2 = builder3.withProtocol((byte) 0x02).withIpTos((short) 20).withLocalPortLow((short) 1).withLocalPortHigh((short) 255).withRemotePortLow((short) 2).withRemotePortHigh((short) 254).withAddress(ipv4Address2).build();
}
Aggregations