本文整理汇总了Java中org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate.setAuthType方法的典型用法代码示例。如果您正苦于以下问题:Java LsUpdate.setAuthType方法的具体用法?Java LsUpdate.setAuthType怎么用?Java LsUpdate.setAuthType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate
的用法示例。
在下文中一共展示了LsUpdate.setAuthType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendLsa
import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate; //导入方法依赖的package包/类
/**
* Sends the LSA to destination address.
*
* @param lsa LSA instance to sent
* @param destination destination IP address
* @param ch netty channel instance
*/
public void sendLsa(LsaHeader lsa, Ip4Address destination, Channel ch) {
if (lsa == null) {
return;
}
LsUpdate responseLsUpdate = new LsUpdate();
// seting OSPF Header
responseLsUpdate.setOspfVer(OspfUtil.OSPF_VERSION);
responseLsUpdate.setOspftype(OspfPacketType.LSUPDATE.value());
responseLsUpdate.setRouterId(ospfArea.routerId());
responseLsUpdate.setAreaId(ospfArea.areaId());
responseLsUpdate.setAuthType(OspfUtil.NOT_ASSIGNED);
responseLsUpdate.setAuthentication(OspfUtil.NOT_ASSIGNED);
responseLsUpdate.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
responseLsUpdate.setChecksum(OspfUtil.NOT_ASSIGNED);
responseLsUpdate.setNumberOfLsa(1);
responseLsUpdate.addLsa(lsa);
//setting the destination.
responseLsUpdate.setDestinationIp(destination);
byte[] messageToWrite = getMessage(responseLsUpdate);
ch.write(messageToWrite);
}
示例2: testGetMessage4
import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate; //导入方法依赖的package包/类
/**
* Tests getMessage() method.
*/
@Test(expected = Exception.class)
public void testGetMessage4() throws Exception {
lsUpdate = new LsUpdate();
lsUpdate.setAuthType(1);
lsUpdate.setOspftype(3);
lsUpdate.setRouterId(Ip4Address.valueOf("10.226.165.164"));
lsUpdate.setAreaId(Ip4Address.valueOf("10.226.165.100"));
lsUpdate.setChecksum(201);
lsUpdate.setAuthentication(2);
lsUpdate.setOspfPacLength(48);
lsUpdate.setOspfVer(2);
ospfMessageWriter.getMessage(lsUpdate, 1, 1);
assertThat(ospfMessageWriter, is(notNullValue()));
}
示例3: testIsValidOspfCheckSum
import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate; //导入方法依赖的package包/类
/**
* Tests isValidOspfCheckSum() method.
*/
@Test
public void testIsValidOspfCheckSum() throws Exception {
hello = new HelloPacket();
hello.setOspfVer(2);
hello.setOspftype(1);
hello.setOspfPacLength(172);
hello.setRouterId(Ip4Address.valueOf("192.168.170.3"));
hello.setAreaId(Ip4Address.valueOf("0.0.0.1"));
hello.setChecksum(5537);
hello.setAuthType(0);
hello.setAuthentication(0);
validate = checksumCalculator.isValidOspfCheckSum(hello, ospfChecksumPos1, ospfChecksumPos2);
assertThat(validate, is(false));
lsack = new LsAcknowledge();
lsack.setOspfVer(2);
lsack.setOspftype(5);
lsack.setOspfPacLength(172);
lsack.setRouterId(Ip4Address.valueOf("192.168.170.3"));
lsack.setAreaId(Ip4Address.valueOf("0.0.0.1"));
lsack.setChecksum(37537);
lsack.setAuthType(0);
lsack.setAuthentication(0);
validate = checksumCalculator.isValidOspfCheckSum(lsack, ospfChecksumPos1, ospfChecksumPos2);
assertThat(validate, is(true));
message = new LsUpdate();
message.setOspfVer(2);
message.setOspftype(5);
message.setOspfPacLength(172);
message.setRouterId(Ip4Address.valueOf("192.168.170.3"));
message.setAreaId(Ip4Address.valueOf("0.0.0.1"));
message.setChecksum(37537);
message.setAuthType(0);
message.setAuthentication(0);
validate = checksumCalculator.isValidOspfCheckSum(message, ospfChecksumPos1, ospfChecksumPos2);
assertThat(validate, is(true));
message1 = new DdPacket();
message1.setOspfVer(2);
message1.setOspftype(5);
message1.setOspfPacLength(172);
message1.setRouterId(Ip4Address.valueOf("192.168.170.3"));
message1.setAreaId(Ip4Address.valueOf("0.0.0.1"));
message1.setChecksum(37537);
message1.setAuthType(0);
message1.setAuthentication(0);
validate = checksumCalculator.isValidOspfCheckSum(message1, ospfChecksumPos1, ospfChecksumPos2);
assertThat(validate, is(true));
message2 = new LsRequest();
message2.setOspfVer(2);
message2.setOspftype(5);
message2.setOspfPacLength(172);
message2.setRouterId(Ip4Address.valueOf("192.168.170.3"));
message2.setAreaId(Ip4Address.valueOf("0.0.0.1"));
message2.setChecksum(37537);
message2.setAuthType(0);
message2.setAuthentication(0);
validate = checksumCalculator.isValidOspfCheckSum(message2, ospfChecksumPos1, ospfChecksumPos2);
assertThat(validate, is(true));
}
示例4: processLsRequestMessage
import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate; //导入方法依赖的package包/类
/**
* Process the Ls Request message.
*
* @param ospfMessage OSPF message instance.
* @param ctx channel handler context instance.
* @throws Exception might throws exception
*/
void processLsRequestMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
log.debug("OspfChannelHandler::processLsRequestMessage...!!!");
Channel channel = ctx.getChannel();
LsRequest lsrPacket = (LsRequest) ospfMessage;
OspfNbr nbr = neighbouringRouter(lsrPacket.routerId().toString());
if (nbr.getState() == OspfNeighborState.EXCHANGE || nbr.getState() == OspfNeighborState.LOADING ||
nbr.getState() == OspfNeighborState.FULL) {
LsRequest reqMsg = (LsRequest) ospfMessage;
if (reqMsg.getLinkStateRequests().isEmpty()) {
log.debug("Received Link State Request Vector is Empty ");
return;
} else {
//Send the LsUpdate back
ListIterator<LsRequestPacket> listItr = reqMsg.getLinkStateRequests().listIterator();
while (listItr.hasNext()) {
LsUpdate lsupdate = new LsUpdate();
lsupdate.setOspfVer(OspfUtil.OSPF_VERSION);
lsupdate.setOspftype(OspfPacketType.LSUPDATE.value());
lsupdate.setRouterId(ospfArea.routerId());
lsupdate.setAreaId(ospfArea.areaId());
lsupdate.setAuthType(OspfUtil.NOT_ASSIGNED);
lsupdate.setAuthentication(OspfUtil.NOT_ASSIGNED);
lsupdate.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
lsupdate.setChecksum(OspfUtil.NOT_ASSIGNED);
//limit to mtu
int currentLength = OspfUtil.OSPF_HEADER_LENGTH + OspfUtil.FOUR_BYTES;
int maxSize = mtu() -
OspfUtil.LSA_HEADER_LENGTH; // subtract a normal IP header.
int noLsa = 0;
while (listItr.hasNext()) {
LsRequestPacket lsRequest = (LsRequestPacket) listItr.next();
// to verify length of the LSA
LsaWrapper wrapper = ospfArea.getLsa(lsRequest.lsType(), lsRequest.linkStateId(),
lsRequest.ownRouterId());
OspfLsa ospflsa = wrapper.ospfLsa();
if ((currentLength + ((LsaWrapperImpl) wrapper).lsaHeader().lsPacketLen()) >= maxSize) {
listItr.previous();
break;
}
if (ospflsa != null) {
lsupdate.addLsa(ospflsa);
noLsa++;
currentLength = currentLength + ((LsaWrapperImpl) wrapper).lsaHeader().lsPacketLen();
} else {
nbr.badLSReq(channel);
}
}
lsupdate.setNumberOfLsa(noLsa);
//set the destination
if (state() == OspfInterfaceState.DR ||
state() == OspfInterfaceState.BDR ||
state() == OspfInterfaceState.POINT2POINT) {
lsupdate.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
} else if (state() == OspfInterfaceState.DROTHER) {
lsupdate.setDestinationIp(OspfUtil.ALL_DROUTERS);
}
byte[] messageToWrite = getMessage(lsupdate);
ctx.getChannel().write(messageToWrite);
}
}
}
}
示例5: buildLsUpdate
import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate; //导入方法依赖的package包/类
/**
* Builds the LsUpdate for flooding.
*
* @param txList list contains LSAs
* @return list of LsUpdate instances
*/
private List buildLsUpdate(Map<String, OspfLsa> txList) {
List<LsUpdate> lsUpdateList = new ArrayList<>();
ListIterator itr = new ArrayList(txList.keySet()).listIterator();
while (itr.hasNext()) {
LsUpdate lsupdate = new LsUpdate();
// seting OSPF Header
lsupdate.setOspfVer(OspfUtil.OSPF_VERSION);
lsupdate.setOspftype(OspfPacketType.LSUPDATE.value());
lsupdate.setRouterId(ospfArea.routerId());
lsupdate.setAreaId(ospfArea.areaId());
lsupdate.setAuthType(OspfUtil.NOT_ASSIGNED);
lsupdate.setAuthentication(OspfUtil.NOT_ASSIGNED);
lsupdate.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
lsupdate.setChecksum(OspfUtil.NOT_ASSIGNED);
//limit to mtu
int currentLength = OspfUtil.OSPF_HEADER_LENGTH + OspfUtil.FOUR_BYTES;
int maxSize = ospfInterface.mtu() -
OspfUtil.LSA_HEADER_LENGTH; // subtract a normal IP header.
int noLsa = 0;
while (itr.hasNext()) {
String key = (String) itr.next();
OspfLsa lsa = txList.get(key);
if ((lsa.age() + OspfParameters.INFTRA_NS_DELAY) >= OspfParameters.MAXAGE) {
((LsaHeader) lsa.lsaHeader()).setAge(OspfParameters.MAXAGE);
} else {
((LsaHeader) lsa.lsaHeader()).setAge(lsa.age() + OspfParameters.INFTRA_NS_DELAY);
}
if ((currentLength + ((LsaHeader) lsa.lsaHeader()).lsPacketLen()) >= maxSize) {
itr.previous();
break;
}
log.debug("FloodingTimer::LSA Type::{}, Header: {}, LSA: {}", lsa.getOspfLsaType(),
lsa.lsaHeader(), lsa);
if (lsa != null) {
lsupdate.addLsa(lsa);
noLsa++;
currentLength = currentLength + ((LsaHeader) lsa.lsaHeader()).lsPacketLen();
}
log.debug("FloodingTimer::Removing key {}", key);
if (txList.equals(reTxList)) {
reTxList.remove(key);
pendingReTxList.put(key, lsa);
}
}
//set number of lsa's
lsupdate.setNumberOfLsa(noLsa);
lsUpdateList.add(lsupdate);
}
return lsUpdateList;
}
示例6: processLsRequestMessage
import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate; //导入方法依赖的package包/类
/**
* Process the Ls Request message.
*
* @param ospfMessage OSPF message instance.
* @param ctx channel handler context instance.
*/
void processLsRequestMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) {
log.debug("OspfChannelHandler::processLsRequestMessage...!!!");
Channel channel = ctx.getChannel();
LsRequest lsrPacket = (LsRequest) ospfMessage;
OspfNbr nbr = neighbouringRouter(lsrPacket.routerId().toString());
if (nbr.getState() == OspfNeighborState.EXCHANGE || nbr.getState() == OspfNeighborState.LOADING ||
nbr.getState() == OspfNeighborState.FULL) {
LsRequest reqMsg = (LsRequest) ospfMessage;
if (reqMsg.getLinkStateRequests().isEmpty()) {
log.debug("Received Link State Request Vector is Empty ");
return;
} else {
//Send the LsUpdate back
ListIterator<LsRequestPacket> listItr = reqMsg.getLinkStateRequests().listIterator();
while (listItr.hasNext()) {
LsUpdate lsupdate = new LsUpdate();
lsupdate.setOspfVer(OspfUtil.OSPF_VERSION);
lsupdate.setOspftype(OspfPacketType.LSUPDATE.value());
lsupdate.setRouterId(ospfArea.routerId());
lsupdate.setAreaId(ospfArea.areaId());
lsupdate.setAuthType(OspfUtil.NOT_ASSIGNED);
lsupdate.setAuthentication(OspfUtil.NOT_ASSIGNED);
lsupdate.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
lsupdate.setChecksum(OspfUtil.NOT_ASSIGNED);
//limit to mtu
int currentLength = OspfUtil.OSPF_HEADER_LENGTH + OspfUtil.FOUR_BYTES;
int maxSize = mtu() -
OspfUtil.LSA_HEADER_LENGTH; // subtract a normal IP header.
int noLsa = 0;
while (listItr.hasNext()) {
LsRequestPacket lsRequest = listItr.next();
// to verify length of the LSA
LsaWrapper wrapper = ospfArea.getLsa(lsRequest.lsType(), lsRequest.linkStateId(),
lsRequest.ownRouterId());
if (wrapper != null) {
OspfLsa ospflsa = wrapper.ospfLsa();
if ((currentLength + ((LsaWrapperImpl) wrapper).lsaHeader().lsPacketLen()) >= maxSize) {
listItr.previous();
break;
}
if (ospflsa != null) {
lsupdate.addLsa(ospflsa);
noLsa++;
currentLength = currentLength + ((LsaWrapperImpl) wrapper).lsaHeader().lsPacketLen();
} else {
nbr.badLSReq(channel);
}
}
}
lsupdate.setNumberOfLsa(noLsa);
//set the destination
if (state() == OspfInterfaceState.DR ||
state() == OspfInterfaceState.BDR ||
state() == OspfInterfaceState.POINT2POINT) {
lsupdate.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
} else if (state() == OspfInterfaceState.DROTHER) {
lsupdate.setDestinationIp(OspfUtil.ALL_DROUTERS);
}
byte[] messageToWrite = getMessage(lsupdate);
ctx.getChannel().write(messageToWrite);
}
}
}
}
示例7: buildLsUpdate
import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate; //导入方法依赖的package包/类
/**
* Builds the LsUpdate for flooding.
*
* @param txList list contains LSAs
* @return list of LsUpdate instances
*/
private List buildLsUpdate(Map<String, OspfLsa> txList) {
List<LsUpdate> lsUpdateList = new ArrayList<>();
ListIterator itr = new ArrayList(txList.keySet()).listIterator();
while (itr.hasNext()) {
LsUpdate lsupdate = new LsUpdate();
// seting OSPF Header
lsupdate.setOspfVer(OspfUtil.OSPF_VERSION);
lsupdate.setOspftype(OspfPacketType.LSUPDATE.value());
lsupdate.setRouterId(ospfArea.routerId());
lsupdate.setAreaId(ospfArea.areaId());
lsupdate.setAuthType(OspfUtil.NOT_ASSIGNED);
lsupdate.setAuthentication(OspfUtil.NOT_ASSIGNED);
lsupdate.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
lsupdate.setChecksum(OspfUtil.NOT_ASSIGNED);
//limit to mtu
int currentLength = OspfUtil.OSPF_HEADER_LENGTH + OspfUtil.FOUR_BYTES;
int maxSize = ospfInterface.mtu() -
OspfUtil.LSA_HEADER_LENGTH; // subtract a normal IP header.
int noLsa = 0;
while (itr.hasNext()) {
String key = (String) itr.next();
OspfLsa lsa = txList.get(key);
if (lsa != null) {
if ((lsa.age() + OspfParameters.INFTRA_NS_DELAY) >= OspfParameters.MAXAGE) {
((LsaHeader) lsa.lsaHeader()).setAge(OspfParameters.MAXAGE);
} else {
((LsaHeader) lsa.lsaHeader()).setAge(lsa.age() + OspfParameters.INFTRA_NS_DELAY);
}
if ((currentLength + ((LsaHeader) lsa.lsaHeader()).lsPacketLen()) >= maxSize) {
itr.previous();
break;
}
log.debug("FloodingTimer::LSA Type::{}, Header: {}, LSA: {}", lsa.getOspfLsaType(),
lsa.lsaHeader(), lsa);
lsupdate.addLsa(lsa);
noLsa++;
currentLength = currentLength + ((LsaHeader) lsa.lsaHeader()).lsPacketLen();
}
log.debug("FloodingTimer::Removing key {}", key);
if (txList.equals(reTxList)) {
reTxList.remove(key);
pendingReTxList.put(key, lsa);
}
}
//set number of lsa's
lsupdate.setNumberOfLsa(noLsa);
lsUpdateList.add(lsupdate);
}
return lsUpdateList;
}