All event handlers in NOX *really* only get a single parameter -- an event 
object.
The trick is that when you use a helper to register for the event, such as 
self.register_for_packet_in(), it generates a new event handler function (with 
a single parameter), which then "breaks out" some of values from the event 
object and uses them as parameters to the multiple-parameter handler function 
you gave it.  The generation of this intermediate handler function happens in 
src/nox/lib/util.py in functions such as gen_packet_in_callback() (which has 
just been called from register_for_packet_in() in core.py).

Hope that helps.

-- Murphy

On Aug 18, 2011, at 9:31 PM, Chen Gao wrote:

> Dear All,
>  
> I’m confused about how do arguments for method callback in component come out.
>  
> For example, I register an event in install like 
> self.register_for_packet_in(packet_in_callback).
> Then, I can do some stuff corresponding to packet_in_event in 
> packet_in_callback method.
> My question is in the
>  
> def packet_in_callback(dpid, inport, reason, len, bufid, packet)
>  
> how do the arguments dpid, inport, reason, len, bufid, packet come out ?
>  
> I understand that according to registering different events, NOX would 
> generate corresponding parameters for using by corresponding callback method.
> Such as for packet_in_event, NOX generate dpid, inport, reason, len, bufid, 
> packet.
> For datapath_leave event, NOX only generate parameter dpid for callback 
> method uses.
>  
> Is my understanding right? If not, could someone explain how do these 
> arguments for callback method come out?
>  
> Thank you very much in advance.
>  
> Best regards,
> Chen
> _______________________________________________
> nox-dev mailing list
> nox-dev@noxrepo.org
> http://noxrepo.org/mailman/listinfo/nox-dev

_______________________________________________
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev

Reply via email to