I was using the socket method of the socket lib in python which looks like this:
socket.socket(family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None)
Now I have seen some means of using the method in order to filter ethernet packets, which looks like this:
import socket
ETH_P_ALL = 3
s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(ETH_P_ALL))
s.close()
I want to know where in the documentation it says that the proto parameter must be used in network endiannes ( big ). And why just the proto parameter and also not the rest of them. Why not this:
s = socket.socket(socket.htons(socket.AF_PACKET), socket.htons(socket.SOCK_RAW), socket.htons(ETH_P_ALL))
Thanks.
I want to know where in the documentation it says that the proto parameter must be used in network endiannes ( big )
From man 7 packet:
packet_socket = socket(AF_PACKET, int socket_type, int protocol);
... protocol is the IEEE 802.3 protocol number in network byte order. See the include file for a list of allowed protocols. When protocol is set to htons(ETH_P_ALL), then all protocols are received.