本文整理汇总了Java中net.floodlightcontroller.packet.LLDPTLV类的典型用法代码示例。如果您正苦于以下问题:Java LLDPTLV类的具体用法?Java LLDPTLV怎么用?Java LLDPTLV使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LLDPTLV类属于net.floodlightcontroller.packet包,在下文中一共展示了LLDPTLV类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserialize
import net.floodlightcontroller.packet.LLDPTLV; //导入依赖的package包/类
public IPacket deserialize(byte[] data, int offset, int length) {
ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
LLDPTLV tlv;
do {
tlv = new LLDPTLV().deserialize(bb);
// if there was a failure to deserialize stop processing TLVs
if (tlv == null)
break;
switch (tlv.getType()) {
case 0x0:
// can throw this one away, its just an end delimiter
break;
case 0x1:
this.chassisId = tlv;
break;
case 0x2:
this.portId = tlv;
break;
case 0x3:
this.ttl = tlv;
break;
default:
this.optionalTLVList.add(tlv);
break;
}
} while (tlv.getType() != 0 && bb.hasRemaining());
return this;
}
示例2: toString
import net.floodlightcontroller.packet.LLDPTLV; //导入依赖的package包/类
@Override
public String toString() {
String str = "";
str += "chassisId=" + ((this.chassisId == null) ? "null" : this.chassisId.toString());
str += " portId=" + ((this.portId == null) ? "null" : this.portId.toString());
str += " ttl=" + ((this.ttl == null) ? "null" : this.ttl.toString());
str += " etherType=" + ethType.toString();
str += " optionalTlvList=[";
if (this.optionalTLVList != null) {
for (LLDPTLV l : optionalTLVList) str += l.toString() + ", ";
}
str += "]";
return str;
}
示例3: getPacket
import net.floodlightcontroller.packet.LLDPTLV; //导入依赖的package包/类
protected IPacket getPacket() {
UDP udp = new UDP()
.setDestinationPort(
TransportPort.of(PathVerificationService.VERIFICATION_PACKET_UDP_PORT))
.setSourcePort(
TransportPort.of(PathVerificationService.VERIFICATION_PACKET_UDP_PORT));
VerificationPacket verificationPacket = new VerificationPacket()
.setChassisId(new LLDPTLV().setType((byte) 1).setLength((short) 7)
.setValue(new byte[] {0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}))
.setPortId(new LLDPTLV().setType((byte) 2).setLength((short) 3)
.setValue(new byte[] {0x02, 0x00, 0x01}))
.setTtl(new LLDPTLV().setType((byte) 3).setLength((short) 2)
.setValue(new byte[] {0x00, 0x78}));
udp.setPayload(new Data(verificationPacket.serialize()));
IPv4 ip = new IPv4()
.setSourceAddress("192.168.0.1")
.setDestinationAddress(PathVerificationService.VERIFICATION_PACKET_IP_DST)
.setProtocol(IpProtocol.UDP);
Ethernet eth = new Ethernet()
.setDestinationMACAddress("AA:BB:CC:DD:EE:FF")
.setSourceMACAddress("11:22:33:44:55:66")
.setEtherType(EthType.IPv4);
eth.setPayload(ip);
ip.setPayload(udp);
return eth;
}
示例4: setControllerTLV
import net.floodlightcontroller.packet.LLDPTLV; //导入依赖的package包/类
protected void setControllerTLV() {
// Setting the controllerTLVValue based on current nano time,
// controller's IP address, and the network interface object hash
// the corresponding IP address.
final int prime = 7867;
byte[] controllerTLVValue = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }; // 8
// byte
// value.
ByteBuffer bb = ByteBuffer.allocate(10);
long result = System.nanoTime();
try{
// Use some data specific to the machine this controller is
// running on. In this case: the list of network interfaces
Enumeration<NetworkInterface> ifaces =
NetworkInterface.getNetworkInterfaces();
if (ifaces != null) {
result = result * prime + ifaces.hashCode();
}
} catch (SocketException e) {
log.warn("Could not get list of interfaces of local machine to " +
"encode in TLV: {}", e.toString());
}
// set the first 4 bits to 0.
result = result & (0x0fffffffffffffffL);
bb.putLong(result);
bb.rewind();
bb.get(controllerTLVValue, 0, 8);
this.controllerTLV = new LLDPTLV().setType((byte) 0x0c)
.setLength((short) controllerTLVValue.length)
.setValue(controllerTLVValue);
}
示例5: setControllerTLV
import net.floodlightcontroller.packet.LLDPTLV; //导入依赖的package包/类
protected void setControllerTLV() {
//Setting the controllerTLVValue based on current nano time,
//controller's IP address, and the network interface object hash
//the corresponding IP address.
final int prime = 7867;
InetAddress localIPAddress = null;
NetworkInterface localInterface = null;
byte[] controllerTLVValue = new byte[] {0, 0, 0, 0, 0, 0, 0, 0}; // 8 byte value.
ByteBuffer bb = ByteBuffer.allocate(10);
try{
localIPAddress = java.net.InetAddress.getLocalHost();
localInterface = NetworkInterface.getByInetAddress(localIPAddress);
} catch (Exception e) {
e.printStackTrace();
}
long result = System.nanoTime();
if (localIPAddress != null)
result = result * prime + IPv4.toIPv4Address(localIPAddress.getHostAddress());
if (localInterface != null)
result = result * prime + localInterface.hashCode();
// set the first 4 bits to 0.
result = result & (0x0fffffffffffffffL);
bb.putLong(result);
bb.rewind();
bb.get(controllerTLVValue, 0, 8);
this.controllerTLV = new LLDPTLV().setType((byte) 0x0c).setLength((short) controllerTLVValue.length).setValue(controllerTLVValue);
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:35,代码来源:LinkDiscoveryManager.java
示例6: generateMACTLV
import net.floodlightcontroller.packet.LLDPTLV; //导入依赖的package包/类
protected LLDPTLV generateMACTLV(byte[] macTLVValue){
if (macTLVValue == null){
log.error("Generate MAC TLV fails!");
return null;
}
LLDPTLV macTLV = new LLDPTLV().setType((byte) 0x0d)
.setLength((short)macTLVValue.length)
.setValue(macTLVValue);
return macTLV;
}
示例7: VerificationPacket
import net.floodlightcontroller.packet.LLDPTLV; //导入依赖的package包/类
public VerificationPacket() {
this.optionalTLVList = new ArrayList<LLDPTLV>();
}
示例8: getChassisId
import net.floodlightcontroller.packet.LLDPTLV; //导入依赖的package包/类
/**
* @return the chassisId
*/
public LLDPTLV getChassisId() {
return chassisId;
}
示例9: setChassisId
import net.floodlightcontroller.packet.LLDPTLV; //导入依赖的package包/类
/**
* @param chassisId the chassisId to set
*/
public VerificationPacket setChassisId(LLDPTLV chassisId) {
this.chassisId = chassisId;
return this;
}
示例10: getPortId
import net.floodlightcontroller.packet.LLDPTLV; //导入依赖的package包/类
/**
* @return the portId
*/
public LLDPTLV getPortId() {
return portId;
}
示例11: setPortId
import net.floodlightcontroller.packet.LLDPTLV; //导入依赖的package包/类
/**
* @param portId the portId to set
*/
public VerificationPacket setPortId(LLDPTLV portId) {
this.portId = portId;
return this;
}
示例12: getTtl
import net.floodlightcontroller.packet.LLDPTLV; //导入依赖的package包/类
/**
* @return the ttl
*/
public LLDPTLV getTtl() {
return ttl;
}
示例13: setTtl
import net.floodlightcontroller.packet.LLDPTLV; //导入依赖的package包/类
/**
* @param ttl the ttl to set
*/
public VerificationPacket setTtl(LLDPTLV ttl) {
this.ttl = ttl;
return this;
}
示例14: getOptionalTLVList
import net.floodlightcontroller.packet.LLDPTLV; //导入依赖的package包/类
/**
* @return the optionalTLVList
*/
public List<LLDPTLV> getOptionalTLVList() {
return optionalTLVList;
}
示例15: setOptionalTLVList
import net.floodlightcontroller.packet.LLDPTLV; //导入依赖的package包/类
/**
* @param optionalTLVList the optionalTLVList to set
*/
public VerificationPacket setOptionalTLVList(List<LLDPTLV> optionalTLVList) {
this.optionalTLVList = optionalTLVList;
return this;
}