[pox-dev] problem in lldp.py

Murphy McCauley murphy.mccauley at gmail.com
Sun Jul 7 12:33:50 PDT 2019


The constructor arguments are basically the same for all classes in the
packet library.

raw is used if you are parsing a raw packet that's held in a bytes/str
object.
prev is mostly used internally to build chains of packet headers.  That is,
since most packet headers are preceded by other packet headers, a packet's
.prev usually points to the preceding one.  But most of the time you don't
manually set it in the constructor; usually the right thing happens without
you having to worry about it.

If you're constructing a packet from scratch, you use keyword arguments.
This isn't that useful for LLDP packets.  It's more useful for things like
TCP packets.  It's more or less a shortcut so that you can do things like:
mypacket = foo(bar = 42)

Instead of:
mypacket = foo()
foo.bar = 42

LLDP packets don't really have many fields, though.  They're basically just
a list of TLVs.  So the more common way to use it is just to create an
empty LLDP header and append TLVs.  discovery does this, for example:
https://github.com/noxrepo/pox/blob/eel/pox/openflow/discovery.py#L189

-- Murphy

On Sun, Jul 7, 2019 at 6:01 AM AASIF MNIT <aasifmnit at gmail.com> wrote:

> The following is code from lldp.py, I am unable to get use of parameters
> used in methods, please help me.
>
>
> def __init__ (self, raw=None, prev=None, **kw):
>     packet_base.__init__(self)
>
>     self.prev = prev
>
>     self.next = None
>     self.tlvs = []
>
>     if raw is not None:
>       self.parse(raw)
>
>     self._init(kw)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.noxrepo.org/pipermail/pox-dev-noxrepo.org/attachments/20190707/cc57fa0d/attachment-0002.html>


More information about the pox-dev mailing list