def send_arp_reply(reply_to, mac, src_mac=None, src_ip=None):
 arpp = reply_to.parsed.find('arp')
 mac = EthAddr(mac)
 if (src_mac is None):
  src_mac = reply_to.connection.eth_addr
 elif (src_mac is True):
  src_mac = reply_to.connection.ports[reply_to.port].hw_addr
 else:
  src_mac = EthAddr(src_mac)
 r = arp()
 r.opcode = r.REPLY
 r.hwdst = arpp.hwsrc
 r.protodst = arpp.protosrc
 r.hwsrc = EthAddr(src_mac)
 r.protosrc = (IPAddr('0.0.0.0') if (src_ip is None) else IPAddr(src_ip))
 e = ethernet(type=ethernet.ARP_TYPE, src=src_mac, dst=r.hwdst)
 e.payload = r
 msg = of.ofp_packet_out()
 msg.data = e.pack()
 msg.actions.append(of.ofp_action_output(port=reply_to.port))
 msg.in_port = of.OFPP_NONE
 reply_to.connection.send(msg)

def send_arp_reply ( reply_to , mac , src_mac = None , src_ip = None ) : arpp = reply_to . parsed . find ( 'arp' ) mac = EthAddr ( mac ) if ( src_mac is None ) : src_mac = reply_to . connection . eth_addr elif ( src_mac is True ) : src_mac = reply_to . connection . ports [ reply_to . port ] . hw_addr else : src_mac = EthAddr ( src_mac ) r = arp ( ) r . opcode = r . REPLY r . hwdst = arpp . hwsrc r . protodst = arpp . protosrc r . hwsrc = EthAddr ( src_mac ) r . protosrc = ( IPAddr ( '0.0.0.0' ) if ( src_ip is None ) else IPAddr ( src_ip ) ) e = ethernet ( type = ethernet . ARP_TYPE , src = src_mac , dst = r . hwdst ) e . payload = r msg = of . ofp_packet_out ( ) msg . data = e . pack ( ) msg . actions . append ( of . ofp_action_output ( port = reply_to . port ) ) msg . in_port = of . OFPP_NONE reply_to . connection . send ( msg )
send an arp reply .