Thank you so much for your reply. Please see inline comments below:

On Sun, Aug 30, 2015 at 8:52 AM, FUJITA Tomonori <
[email protected]> wrote:

> Hi, thanks for the report!
>
> On Fri, 28 Aug 2015 16:52:41 -0400
> A Sydney <[email protected]> wrote:
>
> > ...
> >
> > 3. Action:
> >
> > I added the following two lines to the start of the dhcp class in the
> > dhcp.py file around line 135 (PS. These lines also exist in the option
> > class):
> >
> > _UNPACK_STR = '!B'
> > _MIN_LEN = struct.calcsize(_UNPACK_STR)
> > # existing code is below
> > _HLEN_UNPACK_STR = '!BBB'
> > _HLEN_UNPACK_LEN = struct.calcsize(_HLEN_UNPACK_STR)
>
> I think that the dhcp parser expects at least 236 bytes so _MIN_LEN
> should be 236. If _MIN_LEN is 1, then the parse could get 1 byte
> buffer (and then the parser crashes).
>

With your patch, I still get the following error:

File "/usr/local/lib/python2.7/site-packages/ryu/lib/packet/packet.py",
line 46, in __init__
    self._parser(parse_cls)
  File "/usr/local/lib/python2.7/site-packages/ryu/lib/packet/packet.py",
line 55, in _parser
    if proto:
  File
"/usr/local/lib/python2.7/site-packages/ryu/lib/packet/packet_base.py",
line 46, in __len__
    return self._MIN_LEN
AttributeError: 'dhcp' object has no attribute '_MIN_LEN'


However, when I set _MIN_LEN to 1 as follows (from ryu/lib/packet/dhcp.py),
I am successfully able to extract the dhcp header:

...
 _UNPACK_STR = '!B'
    _MIN_LEN = struct.calcsize(_UNPACK_STR)
# existing code below
    _HLEN_UNPACK_STR = '!BBB'
    _HLEN_UNPACK_LEN = struct.calcsize(_HLEN_UNPACK_STR)
...


So as I said before, it appears that "_MIN_LEN" is not set in the "dhcp"
class.

Questions:

1. Based on your reply, if "_MIN_LEN" is set to 1, the parser should crash.
However, that is not the case. In fact, I am able to obtain the dhcp header
just fine.

2. How do I set "_MIN_LEN" to 236?


REF:
Also note that since I've included your path, I now use the following to
obtain the dhcp header:

dhcp_pkt = pkt.get_protocol(dhcp.dhcp)

Output of dhcp_pkt: http://codepad.org/nAWgWrgi

-Ali
------------------------------------------------------------------------------
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to