NewLionwang / dpkt

Automatically exported from code.google.com/p/dpkt
Other
0 stars 0 forks source link

please calculate the length of BGP-4 Attribute packets automatically #43

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The length of Attribute objects is not automatically calculated (the 'len' 
field'). Please calculate the length automatically when encoding a Attribute 
object.

As a workaround, I have to calculate the lengths manually, and to create the 
attribute objects in two steps, e.g.:

raw_attributes = [
  (0x40, dpkt.bgp.ORIGIN, dpkt.bgp.BGP.Update.Attribute.Origin(
      type=dpkt.bgp.ORIGIN_IGP)),
  ...
  ]

attributes = [dpkt.bgp.BGP.Update.Attribute(
                  flags=f, len=len(a), type=t, data=a)
              for f, t, a in raw_attributes]

This second step on the list of attribute objects could be avoided if Attribute 
calculated the 'len' attribute automatically when assigning the 'data' 
attribute, or when encoding the packet.

Original issue reported on code.google.com by lengletr...@googlemail.com on 5 Aug 2010 at 3:12

GoogleCodeExporter commented 8 years ago
There is the same problem with classes dpkt.bgp.BGP.Open.Parameter.Capability 
and dpkt.bgp.BGP.Open.Parameter: the 'len' field has to be calculated manually 
for objects of those classes.

Original comment by lengletr...@googlemail.com on 5 Aug 2010 at 3:17