mike01 / pypacker

:package: The fastest and simplest packet manipulation lib for Python
GNU General Public License v2.0
252 stars 46 forks source link

build new ip6/tcp packet #46

Closed shmir closed 6 years ago

shmir commented 6 years ago

I'm trying to build ip6/tcp packet as following:

from pypacker.layer12 import ethernet from pypacker.layer3 import ip6 from pypacker.layer4 import tcp

packet = ethernet.Ethernet() + ip6.IP6() + tcp.TCP()

packet.ip6 Output: IP6(v_fc_flow=60000000, dlen=0, nxt=0, hlim=0, src='\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', dst='\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', opts=[], handler=tcp) TCP(sport=DEAD, dport=0, seq=3735928559L, ack=0, off_x2=50, flags=2, win=FFFF, sum=0, urp=0, opts=[], bytes='')

packet.ip6.bin() Output: '`\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xad\x00\x00\xde\xad\xbe\xef\x00\x00\x00\x00P\x02\xff\xff\x00\x00\x00\x00'

It seems that the IPv6 header is empty, except for the header type (6, at the first byte). No payload length, no next header etc.

Is it a bug or am I missing something?

Thanks, Yoram

mike01 commented 6 years ago

The IPv6 header becomes what you put in + the updated values from the auto-update fields. I just had a look and the auto-update for dlen and nxt were missing..now added in the newest master commit.

shmir commented 6 years ago

Thanks, issue solved and merged to python 2.7 branch.