socket.rawModule
RAW AF_PACKET socket operations.
This module provides a higher-level abstraction over the socket module.See also
Functions
| new (proto, ifindex) | Creates a raw packet socket bound to an EtherType and an interface. |
Functions in detail
- new (proto, ifindex)
-
Creates a raw packet socket bound to an EtherType and an interface.
It receives the frames of that EtherType, and sends a frame, which starts at the Ethernet
header, with
socket:send(frame, proto, ifindex), the EtherType in host byte order.Parameters
- proto (number) EtherType (defaults to ETH_P_ALL).
- ifindex (number) [optional] Interface index (defaults to listen all interfaces).
Returns
-
A new raw packet socket bound for proto and ifindex.
Raises
Error if socket.new() or socket.bind() fail; a socket whose bind fails is closed first.See also
Usage
local rx <close> = raw.new(0x0003) local tx <close> = raw.new(0x88cc, ifindex) tx:send(frame, 0x88cc, ifindex)