X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fsamples%2Floadbalancer%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsamples%2Floadbalancer%2FLBUtil.java;h=aa195a34e9ceb9487291e4e9f020f8b1acec7244;hb=abf4ba1b0854fdd8b1a15c8c4481cf4b0bc93068;hp=c320250084150ddaac6f4337430b33eea8c9940f;hpb=e2f7aaa41e482815ca1d4495eb85c8653cd903ab;p=controller.git diff --git a/opendaylight/samples/loadbalancer/src/main/java/org/opendaylight/controller/samples/loadbalancer/LBUtil.java b/opendaylight/samples/loadbalancer/src/main/java/org/opendaylight/controller/samples/loadbalancer/LBUtil.java index c320250084..aa195a34e9 100644 --- a/opendaylight/samples/loadbalancer/src/main/java/org/opendaylight/controller/samples/loadbalancer/LBUtil.java +++ b/opendaylight/samples/loadbalancer/src/main/java/org/opendaylight/controller/samples/loadbalancer/LBUtil.java @@ -19,36 +19,36 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Class defines utilty methods that will be used by different components - * of the load balancer service + * Class defines utilty methods that will be used by different components + * of the load balancer service * */ public class LBUtil { - + private static final Logger lbuLogger = LoggerFactory.getLogger(LBUtil.class); - + public LBUtil(){} - + /** - * 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. + * 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(); @@ -56,47 +56,47 @@ public class LBUtil { 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; } - + /** * 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 + * @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; } } \ No newline at end of file