16 package org.openkilda.floodlight.service;
27 import com.auth0.jwt.interfaces.DecodedJWT;
28 import com.google.common.collect.ImmutableSet;
29 import net.floodlightcontroller.core.FloodlightContext;
30 import net.floodlightcontroller.core.IFloodlightProviderService;
31 import net.floodlightcontroller.core.IOFSwitch;
32 import net.floodlightcontroller.core.internal.IOFSwitchService;
33 import net.floodlightcontroller.core.module.FloodlightModuleContext;
34 import net.floodlightcontroller.core.module.FloodlightModuleException;
35 import net.floodlightcontroller.core.module.IFloodlightService;
36 import net.floodlightcontroller.packet.Ethernet;
37 import org.projectfloodlight.openflow.protocol.OFMessage;
38 import org.projectfloodlight.openflow.protocol.OFType;
39 import org.slf4j.Logger;
40 import org.slf4j.LoggerFactory;
42 import java.util.LinkedList;
43 import java.util.ListIterator;
50 private final LinkedList<VerificationListenCommand> pendingRecipients =
new LinkedList<>();
59 synchronized (pendingRecipients) {
60 pendingRecipients.add(handler);
68 synchronized (pendingRecipients) {
69 pendingRecipients.remove(handler);
77 public void init(FloodlightModuleContext moduleContext)
throws FloodlightModuleException {
83 throw new FloodlightModuleException(String.format(
"Unable to initialize %s", getClass().
getName()), e);
86 switchUtils =
new SwitchUtils(moduleContext.getServiceImpl(IOFSwitchService.class));
91 public boolean handle(IOFSwitch sw, OFMessage packet, FloodlightContext context) {
92 Ethernet eth = IFloodlightProviderService.bcStore.get(context, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
97 if (payload == null) {
98 log.debug(
"packet xId: {} is not flow verification packet", packet.getXid());
102 DecodedJWT token = signature.verify(payload);
105 if (!
data.getDest().equals(sw.getId())) {
107 "Catch flow verification package on %s while target is %s", sw.getId(),
data.getDest()));
110 log.error(String.format(
"dpid:%s %s", sw.getId(), e));
114 boolean isHandled =
false;
115 synchronized (pendingRecipients) {
116 for (ListIterator<VerificationListenCommand> iter = pendingRecipients.listIterator(); iter.hasNext(); ) {
133 return ImmutableSet.of(
"PathVerificationService");
MacAddress dpIdToMac(final IOFSwitch sw)
static byte [] unwrapData(MacAddress targetL2Address, Ethernet packet)
void unsubscribe(VerificationListenCommand handler)
void activateSubscription(IFloodlightModuleContext moduleContext, OFType... desiredTypes)
static VerificationData of(DecodedJWT token)
boolean handle(IOFSwitch sw, OFMessage packet, FloodlightContext context)
DataSignature getSignature()
def command(payload, fields)
void init(FloodlightModuleContext moduleContext)
void subscribe(VerificationListenCommand handler)
Set< String > mustHandleBefore()