Method: Rex::Socket::Comm::Local.create_ip

Defined in:
lib/rex/socket/comm/local.rb

.create_ip(param) ⇒ Object

Creates a raw IP socket using the supplied Parameter instance. Special-cased because of how different it is from UDP/TCP



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/rex/socket/comm/local.rb', line 95

def self.create_ip(param)
  self.instance.notify_before_socket_create(self, param)

  sock = ::Socket.open(::Socket::PF_INET, ::Socket::SOCK_RAW, ::Socket::IPPROTO_RAW)
  sock.setsockopt(::Socket::IPPROTO_IP, ::Socket::IP_HDRINCL, 1)

  # Configure broadcast support
  sock.setsockopt(::Socket::SOL_SOCKET, ::Socket::SO_BROADCAST, true)

  if (param.bare? == false)
    sock.extend(::Rex::Socket::Ip)
    sock.initsock(param)
  end

  self.instance.notify_socket_created(self, sock, param)

  sock
end