The reason why I need to look at the code is that I want to know how does
NOX handle the Datapath_join_event.
I know the gen_datapath_join_callback was invoked by function
register_for_datapath_join in core.py.

I am very interested in the architecture of NOX. I am eager to know how the
NOX works. Any information will be appreciated.
Thanks for advance.
hzy

2011/11/2 hzy <yyjianx...@gmail.com>

> Hi all:
> when I look at the code in nox/src/nox/lib/util.py written in python. I
> was confused about some codes there. Because I am newbie to python.
>
> def gen_datapath_join_callback(handler):
>>     def f(event):
>>         attrs = {}
>>         attrs[core.N_BUFFERS] = event.n_buffers
>>         attrs[core.N_TABLES] = event.n_tables
>>         attrs[core.CAPABILITES] = event.capabilities
>>         attrs[core.ACTIONS] = event.actions
>>         attrs[core.PORTS] = event.ports
>>         for i in range(0, len(attrs[core.PORTS])):
>>             port = attrs[core.PORTS][i]
>>             config = port['config']
>>             state = port['state']
>>             attrs[core.PORTS][i]['link']    = (state &
>> openflow.OFPPS_LINK_DOWN) == 0
>>             attrs[core.PORTS][i]['enabled'] = (config &
>> openflow.OFPPC_PORT_DOWN) == 0
>>             attrs[core.PORTS][i]['flood']   = (config &
>> openflow.OFPPC_NO_FLOOD)  == 0
>>
>>         ret = f.cb(event.datapath_id, attrs)
>>         if ret == None:
>>             return CONTINUE
>>         return ret
>>     f.cb = handler
>>     return f
>>
>
> Python can define a function in a function really confused me. I do not
> know how the function f(event) is invoked. and what the f.cb mean.
> Any ideas?
> Thanks forward.
> hzy
>
_______________________________________________
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev

Reply via email to