module Ethernet

Facade methods for the library.

See the inner classes for more advanced functionality.

Public Class Methods

devices() click to toggle source

Hash mapping Ethernet device names to their MAC addresses.

# File lib/ethernet.rb, line 6
def self.devices
  Hash[Ethernet::Devices.all.map { |dev| [dev, Ethernet::Devices.mac(dev)] }]
end
provision() click to toggle source

Allow non-root users to create low-level Ethernet sockets.

This is a security risk, because Ethernet sockets can be used to spy on all traffic on the machine’s network. This should not be called on production machines.

Returns true for success, false otherwise. If the call fails, it is most likely because it is not run by root / Administrator.

# File lib/ethernet.rb, line 27
def self.provision
  Ethernet::Provisioning.usermode_sockets
end
raw_socket(eth_device = nil, ether_type = nil) click to toggle source

A socket that sends and receives raw Ethernet frames.

Args:

eth_device:: device name for the Ethernet card, e.g. 'eth0'
ether_type:: only receive Ethernet frames with this protocol number
# File lib/ethernet.rb, line 36
def self.raw_socket(eth_device = nil, ether_type = nil)
  Ethernet::RawSocketFactory.socket eth_device, ether_type
end
socket(eth_device, ether_type) click to toggle source

Ethernet socket that abstracts away frames.

Args:

eth_device:: device name for the Ethernet card, e.g. 'eth0'
ether_type:: 2-byte Ethernet packet type number
# File lib/ethernet.rb, line 15
def self.socket(eth_device, ether_type)
  Ethernet::FrameSocket.new eth_device, ether_type
end