Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How is network byte order handled. #33

Open
GoogleCodeExporter opened this issue May 5, 2015 · 0 comments
Open

How is network byte order handled. #33

GoogleCodeExporter opened this issue May 5, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant