def processevent(self, event): """Process event """ if (isinstance(event, ofevents.flow_removed)): duration = event.flowrm.duration_sec + (float(event.flowrm.duration_nsec)/1e9) if (event.flowrm.reason == pyof.OFPRR_IDLE_TIMEOUT): duration -= event.flowrm.idle_timeout i = [time.time(), event.flowrm.cookie, event.flowrm.priority, event.flowrm.reason, event.flowrm.idle_timeout, event.flowrm.match.in_port, pu.array2hex_str(event.flowrm.match.dl_src), pu.array2hex_str(event.flowrm.match.dl_dst), event.flowrm.match.dl_type, event.flowrm.match.dl_vlan, event.flowrm.match.dl_vlan_pcp, event.flowrm.match.nw_src, event.flowrm.match.nw_dst, event.flowrm.match.nw_proto, event.flowrm.match.nw_tos, event.flowrm.match.tp_src, event.flowrm.match.tp_dst, event.flowrm.duration_sec, event.flowrm.duration_nsec, duration, event.flowrm.packet_count, event.flowrm.byte_count] self.table.add_row(tuple(i)) return True
def processevent(self, event): """Process authentication event """ if (event.host == None): return True if (isinstance(event, owevent.authenticated)): output.dbg( pu.array2hex_str(event.host) + " is authenticated", self.__class__.__name__) mcutil.set(host_auth.get_key(event.host), event.openid, MAX_AUTH_TIMEOUT) elif (isinstance(event, owevent.unauthenticated)): output.dbg( pu.array2hex_str(event.host) + " is unauthenticated", self.__class__.__name__) mcutil.delete(host_auth.get_key(event.host)) mcutil.delete(host_auth.get_auth_key(event.host)) elif (isinstance(event, owevent.going_to_auth)): output.dbg( pu.array2hex_str(event.host) + " is going to authenticate", self.__class__.__name__) mcutil.set(host_auth.get_auth_key(event.host), event.server(), AUTH_TIMEOUT) return True
def get_name_key(host, domain_name): """Get key for domain name @param domain_name domain name """ return host_dns.HOST_DNS_DOMAIN_PREFIX+\ pu.array2hex_str(host)+"_"+domain_name
def processevent(self, event): """Process event """ if (isinstance(event, owevent.authenticated)): h = None if (event.host != None): h = pu.array2hex_str(event.host) i = [time.time(), "auth", event.datapathid, h, event.openid] output.dbg("Authentication of "+str(h)+" recorded"+\ " with ID "+event.openid, self.__class__.__name__) self.table.add_row(tuple(i)) elif (isinstance(event, owevent.unauthenticated)): h = None if (event.host != None): h = pu.array2hex_str(event.host) i = [time.time(), "unauth", event.datapathid, h, None] output.dbg("Unauthentication of "+str(h)+" recorded", self.__class__.__name__) self.table.add_row(tuple(i)) elif (isinstance(event, owevent.going_to_auth)): h = None if (event.host != None): h = pu.array2hex_str(event.host) i = [time.time(), "tryauth", event.datapathid, h, event.url] output.dbg("Attempt authentication of "+str(h)+" recorded", self.__class__.__name__) self.table.add_row(tuple(i)) return True
def processevent(self, event): """Process authentication event """ if (event.host == None): return True if (isinstance(event, owevent.authenticated)): output.dbg(pu.array2hex_str(event.host)+" is authenticated", self.__class__.__name__) mcutil.set(host_auth.get_key(event.host), event.openid, MAX_AUTH_TIMEOUT) elif (isinstance(event, owevent.unauthenticated)): output.dbg(pu.array2hex_str(event.host)+" is unauthenticated", self.__class__.__name__) mcutil.delete(host_auth.get_key(event.host)) mcutil.delete(host_auth.get_auth_key(event.host)) elif (isinstance(event, owevent.going_to_auth)): output.dbg(pu.array2hex_str(event.host)+" is going to authenticate", self.__class__.__name__) mcutil.set(host_auth.get_auth_key(event.host), event.server(), AUTH_TIMEOUT) return True
def get_auth_key(host): """Get server for host authentication key """ return pu.array2hex_str(host)+"_auth_server"
def get_key(host): """Get host authentication key """ return pu.array2hex_str(host)+"_authenticated"
def get_auth_key(host): """Get server for host authentication key """ return pu.array2hex_str(host) + "_auth_server"
def get_key(host): """Get host authentication key """ return pu.array2hex_str(host) + "_authenticated"