> 2013/10/29 YAMAMOTO Takashi <[email protected]>
>
>> > Hi,
>> >
>> > I feel noisy that a packet jumps into the handler of EventOFPPacketIn
>> > indiscriminately. Theredore, I would like to filter of a packet in the
>> > handler be based on a certain rule.
>> >
>> > I consider the following API:
>> >
>> > @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
>> > @packet_in_filter(TypeFilter, {'types': [
>> > vlan.vlan,
>> > ipv4.ipv4,
>> > ]})
>> > def packet_in_handler(self, ev):
>> > # Only the packet (event) containing VLAN and IPv4 enters here.
>> >
>> > In this example, the filter based on the type contained in a packet is
>> > used. The algorithm of a filter can be changed by a class (Strategy
>> > pattern). It is possible that a user makes arbitrary filters besides it.
>> >
>> > How do you think?
>>
>> i like the idea but unsure about api details.
>>
>>
> The details of API which I consider are as follows. We make a class which
> extends PacketInFilterBase.
please define what will happen for packets truncated by a small
max_len/miss_send_len.
otherwise looks good to me. thanks.
>
> ------------------------------
> def packet_in_filter(cls, args=None):
> def _packet_in_filter(packet_in_handler):
> def __packet_in_filter(self, ev):
> if not hasattr(packet_in_handler, 'pkt_in_filter'):
> pkt_in_filter = cls(args)
> packet_in_handler.pkt_in_filter = pkt_in_filter
this block should be in the outer function i guess.
> pkt = packet.Packet(ev.msg.data)
> if not packet_in_handler.pkt_in_filter.filter(pkt):
> LOG.debug('The packet is discarded by %s: %s' % (cls, pkt))
> return
> return packet_in_handler(self, ev)
> return __packet_in_filter
> return _packet_in_filter
>
> class PacketInFilterBase(object):
> __metaclass__ = ABCMeta
>
> def __init__(self, args):
> self.args = args
>
> @abstractmethod
> def filter(self, pkt):
> pass
>
>
> class TypeFilter(PacketInFilterBase):
>
> def filter(self, pkt):
> accept_types = self.args.get('types') or []
the name accept_types seems confusing. how about required_types?
YAMAMOTO Takashi
> for accept_type in accept_types:
> if not pkt.get_protocol(accept_type):
> return False
> return True
>
> ------------------------------
>
>
>> YAMAMOTO Takashi
>>
>> >
>> > Thanks,
>> > Satoshi
>>
------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel