本文整理汇总了Java中org.opendaylight.controller.sal.utils.IPProtocols.getProtocolName方法的典型用法代码示例。如果您正苦于以下问题:Java IPProtocols.getProtocolName方法的具体用法?Java IPProtocols.getProtocolName怎么用?Java IPProtocols.getProtocolName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opendaylight.controller.sal.utils.IPProtocols
的用法示例。
在下文中一共展示了IPProtocols.getProtocolName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getClientFromPacket
import org.opendaylight.controller.sal.utils.IPProtocols; //导入方法依赖的package包/类
/**
* Extract the details of the source machine that sent this packet 'inPkt'
* @param inPkt Packet that is received by the controller
* @return Details of the source machine in Client object.
*/
public Client getClientFromPacket(IPv4 inPkt){
lbuLogger.info("Find client information from packet : {}",inPkt.toString());
String ip = NetUtils.getInetAddress(inPkt.getSourceAddress()).getHostAddress();
String protocol = IPProtocols.getProtocolName(inPkt.getProtocol());
lbuLogger.info("client ip {} and protocl {}",ip,protocol);
Packet tpFrame= inPkt.getPayload();
lbuLogger.info("Get protocol layer {}",tpFrame.toString());
short port = 0;
if(protocol.equals(IPProtocols.TCP.toString())){
TCP tcpFrame = (TCP)tpFrame;
port = tcpFrame.getSourcePort();
}else{
UDP udpFrame = (UDP)tpFrame;
port = udpFrame.getSourcePort();
}
lbuLogger.info("Found port {}",port);
Client source = new Client(ip, protocol,port);
lbuLogger.info("Client information : {}",source.toString());
return source;
}
示例2: getVIPFromPacket
import org.opendaylight.controller.sal.utils.IPProtocols; //导入方法依赖的package包/类
/**
* Extract the details of the destination machine where this packet 'inPkt' need
* to be delivered
* @param inPkt Packet that is received by controller for forwarding
* @return Details of the destination machine packet in VIP
*/
public VIP getVIPFromPacket(IPv4 inPkt){
lbuLogger.info("Find VIP information from packet : {}",inPkt.toString());
String ip = NetUtils.getInetAddress(inPkt.getDestinationAddress()).getHostAddress();
String protocol = IPProtocols.getProtocolName(inPkt.getProtocol());
Packet tpFrame= inPkt.getPayload();
short port = 0;
if(protocol.equals(IPProtocols.TCP.toString())){
TCP tcpFrame = (TCP)tpFrame;
port = tcpFrame.getDestinationPort();
}else{
UDP udpFrame = (UDP)tpFrame;
port = udpFrame.getDestinationPort();
}
VIP dest = new VIP(null,ip, protocol,port,null);
lbuLogger.info("VIP information : {}",dest.toString());
return dest;
}