scap1784 / dpkt

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

How is network byte order handled. #33

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hello, im creating an arp broadcast packet like this:

import dpkt
import socket
import binascii

def eth_aton(buffer):
        sp = buffer.split(':')
        buffer = ''.join(sp)
        return binascii.unhexlify(buffer)

arp = dpkt.arp.ARP()
arp.sha=eth_aton('00:24:8c:5b:11:ec')
arp.spa=socket.inet_aton('192.168.1.3')
arp.tha=eth_aton('00:00:00:00:00:00')  
arp.tpa=socket.inet_aton('192.168.1.4')
arp.op=dpkt.arp.ARP_OP_REQUEST  
eth=dpkt.ethernet.Ethernet()
eth.src=arp.sha       
eth.dst=eth_aton('ff:ff:ff:ff:ff:ff')           
eth.data=arp                      
eth.type=dpkt.ethernet.ETH_TYPE_ARP                      

And Im able to send the packet with a PF_PACKET RAW socket:

s = socket.socket(socket.PF_PACKET, socket.SOCK_RAW) 
s.bind((device, dpkt.ethernet.ETH_TYPE_ARP))
s.send(str(eth))            

Everyhting works great and Im able to get a reply, my question is How is
the network byte order handled? dpkt or the BSD socket handles it? I've
tried it in systems with different endiannesses and it works fine.

Original issue reported on code.google.com by rudebo...@gmail.com on 28 Mar 2010 at 10:18