def desc_stats_in_handler(self, dpid, desc): lg.warn('############### desc_stats_in_handler ###############\n') self.dp_desc_stats[dpid] = desc ip = self.ctxt.get_switch_ip(dpid) self.dp_desc_stats[dpid]["ip"] = str(create_ipaddr(c_htonl(ip))) r.set('dp_desc_stats:' + str(dpid) + ':mfr_desc', self.dp_desc_stats[dpid]['mfr_desc']) r.set('dp_desc_stats:' + str(dpid) + ':hw_desc', self.dp_desc_stats[dpid]['hw_desc']) r.set('dp_desc_stats:' + str(dpid) + ':sw_desc', self.dp_desc_stats[dpid]['sw_desc']) r.set('dp_desc_stats:' + str(dpid) + ':serial_num', self.dp_desc_stats[dpid]['serial_num']) r.set('dp_desc_stats:' + str(dpid) + ':dp_desc', self.dp_desc_stats[dpid]['dp_desc']) print 'dp_desc_stats:' + str(dpid) + ':mrf_desc' print "dp_desc_stats[",dpid,"].mfr_desc = ", r.get('dp_desc_stats:' + str(dpid) + ':mfr_desc') print "dp_desc_stats[",dpid,"].hw_desc = ", r.get('dp_desc_stats:' + str(dpid) + ':hw_desc') print "dp_desc_stats[",dpid,"].sw_desc = ", r.get('dp_desc_stats:' + str(dpid) + ':sw_desc') print "dp_desc_stats[",dpid,"].serial_num= ", r.get('dp_desc_stats:' + str(dpid) + ':serial_num') print "dp_desc_stats[",dpid,"].dp_desc = ", r.get('dp_desc_stats:' + str(dpid) + ':dp_desc')
def desc_stats_in_handler(self, dpid, desc): self.dp_desc_stats[dpid] = desc ip = self.ctxt.get_switch_ip(dpid) self.dp_desc_stats[dpid]["ip"] = str(create_ipaddr(c_htonl(ip)))
def set_match(attrs): m = openflow.ofp_match() wildcards = 0 num_entries = 0 if attrs.has_key(core.IN_PORT): m.in_port = htons(attrs[core.IN_PORT]) num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_IN_PORT if attrs.has_key(core.DL_VLAN): m.dl_vlan = htons(attrs[core.DL_VLAN]) num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_DL_VLAN if attrs.has_key(core.DL_VLAN_PCP): m.dl_vlan_pcp = attrs[core.DL_VLAN_PCP] num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_DL_VLAN_PCP if attrs.has_key(core.DL_SRC): v = convert_to_eaddr(attrs[core.DL_SRC]) if v == None: print "invalid ethernet addr" return None m.set_dl_src(v.octet) num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_DL_SRC if attrs.has_key(core.DL_DST): v = convert_to_eaddr(attrs[core.DL_DST]) if v == None: print "invalid ethernet addr" return None m.set_dl_dst(v.octet) num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_DL_DST if attrs.has_key(core.DL_TYPE): m.dl_type = htons(attrs[core.DL_TYPE]) num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_DL_TYPE if attrs.has_key(core.NW_SRC): v = convert_to_ipaddr(attrs[core.NW_SRC]) if v == None: print "invalid ip addr" return None m.nw_src = v num_entries += 1 if attrs.has_key(core.NW_SRC_N_WILD): n_wild = attrs[core.NW_SRC_N_WILD] if n_wild > 31: wildcards |= openflow.OFPFW_NW_SRC_MASK elif n_wild >= 0: wildcards |= n_wild << openflow.OFPFW_NW_SRC_SHIFT else: print "invalid nw_src wildcard bit count", n_wild return None num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_NW_SRC_MASK if attrs.has_key(core.NW_DST): v = convert_to_ipaddr(attrs[core.NW_DST]) if v == None: print "invalid ip addr" return None m.nw_dst = v num_entries += 1 if attrs.has_key(core.NW_DST_N_WILD): n_wild = attrs[core.NW_DST_N_WILD] if n_wild > 31: wildcards |= openflow.OFPFW_NW_DST_MASK elif n_wild >= 0: wildcards |= n_wild << openflow.OFPFW_NW_DST_SHIFT else: print "invalid nw_dst wildcard bit count", n_wild return None num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_NW_DST_MASK if attrs.has_key(core.NW_PROTO): m.nw_proto = attrs[core.NW_PROTO] num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_NW_PROTO if attrs.has_key(core.NW_TOS): m.nw_tos = attrs[core.NW_TOS] num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_NW_TOS if attrs.has_key(core.TP_SRC): m.tp_src = htons(attrs[core.TP_SRC]) num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_TP_SRC if attrs.has_key(core.TP_DST): m.tp_dst = htons(attrs[core.TP_DST]) num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_TP_DST if num_entries != len(attrs.keys()): print "undefined flow attribute type in attrs", attrs return None m.wildcards = c_htonl(wildcards) return m
def set_match(attrs): m = openflow.ofp_match() wildcards = 0 num_entries = 0 if attrs.has_key(core.IN_PORT): m.in_port = htons(attrs[core.IN_PORT]) num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_IN_PORT if attrs.has_key(core.DL_VLAN): m.dl_vlan = htons(attrs[core.DL_VLAN]) num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_DL_VLAN if attrs.has_key(core.DL_VLAN_PCP): m.dl_vlan = htons(attrs[core.DL_VLAN_PCP]) num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_DL_VLAN_PCP if attrs.has_key(core.DL_SRC): v = convert_to_eaddr(attrs[core.DL_SRC]) if v == None: print 'invalid ethernet addr' return None m.set_dl_src(v.octet) num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_DL_SRC if attrs.has_key(core.DL_DST): v = convert_to_eaddr(attrs[core.DL_DST]) if v == None: print 'invalid ethernet addr' return None m.set_dl_dst(v.octet) num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_DL_DST if attrs.has_key(core.DL_TYPE): m.dl_type = htons(attrs[core.DL_TYPE]) num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_DL_TYPE if attrs.has_key(core.NW_SRC): v = convert_to_ipaddr(attrs[core.NW_SRC]) if v == None: print 'invalid ip addr' return None m.nw_src = v num_entries += 1 if attrs.has_key(core.NW_SRC_N_WILD): n_wild = attrs[core.NW_SRC_N_WILD] if n_wild > 31: wildcards |= openflow.OFPFW_NW_SRC_MASK elif n_wild >= 0: wildcards |= n_wild << openflow.OFPFW_NW_SRC_SHIFT else: print 'invalid nw_src wildcard bit count', n_wild return None num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_NW_SRC_MASK if attrs.has_key(core.NW_DST): v = convert_to_ipaddr(attrs[core.NW_DST]) if v == None: print 'invalid ip addr' return None m.nw_dst = v num_entries += 1 if attrs.has_key(core.NW_DST_N_WILD): n_wild = attrs[core.NW_DST_N_WILD] if n_wild > 31: wildcards |= openflow.OFPFW_NW_DST_MASK elif n_wild >= 0: wildcards |= n_wild << openflow.OFPFW_NW_DST_SHIFT else: print 'invalid nw_dst wildcard bit count', n_wild return None num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_NW_DST_MASK if attrs.has_key(core.NW_PROTO): m.nw_proto = attrs[core.NW_PROTO] num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_NW_PROTO if attrs.has_key(core.NW_TOS): m.nw_proto = attrs[core.NW_TOS] num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_NW_TOS if attrs.has_key(core.TP_SRC): m.tp_src = htons(attrs[core.TP_SRC]) num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_TP_SRC if attrs.has_key(core.TP_DST): m.tp_dst = htons(attrs[core.TP_DST]) num_entries += 1 else: wildcards = wildcards | openflow.OFPFW_TP_DST if num_entries != len(attrs.keys()): print 'undefined flow attribute type in attrs', attrs return None m.wildcards = c_htonl(wildcards) return m