I have implemented this code to handle ARP.. is it ok ? I am not sure about that.. need your comments please
a= packet.find('arp') if a: if a.prototype == arp.PROTO_TYPE_IP: if a.hwtype == arp.HW_TYPE_ETHERNET: if a.protosrc != 0: if a.protosrc in arp_tale: if a.hwsrc == True: Mac = EthAddr(a.hwsrc) arp_table[a.protosrc] = Mac: if a.opcode == arp.REQUEST: # Maybe we can answer if a.protodst in arp_table: r = arp() r.hwtype = a.hwtype r.prototype = a.prototype r.hwlen = a.hwlen r.protolen = a.protolen r.opcode = arp.REPLY r.hwdst = a.hwsrc r.protodst = a.protosrc r.protosrc = a.protodst Mac = arp_table[a.protodst] Mac = _dpid_to_mac(dpid) r.hwsrc = Mac e = ethernet(type=packet.type, src=_dpid_to_mac(dpid), dst=a.hwsrc) e.payload = r log.info("%s answering ARP for %s" % (dpid_to_str(dpid), str(r.protosrc))) msg = of.ofp_packet_out() msg.data = e.pack() msg.actions.append(of.ofp_action_output(port = of.OFPP_IN_PORT)) msg.in_port = inport event.connection.send(msg) else: msg = of.ofp_packet_out() msg.actions.append(of.ofp_action_output(port = of.OFPP_FLOOD)) msg.data = event.ofp event.connection.send(msg.pack()) Thanks Muhammad On Nov 13, 2013, at 12:56 PM, Murphy McCauley <murphy.mccau...@gmail.com> wrote: > Durga is spot on, but I'll throw in another couple things you might look at: > forwarding.l3_learning handles ARP > proto.arp_helper attempts to make it easier to work with ARP > > (Oh, and misc.arp_responder has moved to proto.arp_responder in newer > versions.) > > -- Murphy > > On Nov 13, 2013, at 2:06 AM, durga <c.vijaya.du...@gmail.com> wrote: > >> >> hello, >> Seems pox supports packet type as arp, can be found here (pox / pox / lib / >> packet / arp.py ), as well as may be you can get some help by refering to >> the below example. >> pox / pox / misc / arp_responder.py >> >> Cheers! >> Durga >> >> >> >> On Wed, Nov 13, 2013 at 8:35 PM, Muhammad Furqan Gagan >> <furqan.ga...@gmail.com> wrote: >> Hello, >> >> Any one know how to handle ARP request in controller? >> >> Thanks >> >> Muhammad >> >