Module: DHCP
- Defined in:
- lib/dhcp/client.rb,
lib/dhcp/dhcp.rb,
lib/dhcp/packet.rb,
lib/dhcp/server.rb,
lib/dhcp/options.rb,
lib/dhcp/version.rb
Overview
:nodoc:
Defined Under Namespace
Modules: Version Classes: Client, Opt, OptBool, OptData, OptDomain, OptFixedData, OptHexString, OptHost, OptIP, OptIPList, OptInt16, OptInt16List, OptInt32, OptInt8, OptInt8List, OptListData, OptListFixedData, OptRouteList, OptSInt32, OptStaticRoutes, OptSubList, Packet, Server, SubOpt, SubOptList, SubOptVSRInfo
Constant Summary collapse
- BOOTREQUEST =
BOOTP TYPES:
1
- BOOTREPLY =
2
- HTYPE =
HARDWARE TYPES: [htype code, hlen length]
{ :htype_10mb_ethernet => [ 1, 6 ] }
- DHCPDISCOVER =
DHCP MESSAGE TYPES:
1
- DHCPOFFER =
2
- DHCPREQUEST =
3
- DHCPDECLINE =
4
- DHCPACK =
5
- DHCPNAK =
6
- DHCPRELEASE =
7
- DHCPINFORM =
8
- DHCPFORCERENEW =
RFC 3203
9
- DHCPLEASEQUERY =
LEASEQUERY extensions:
10
- DHCPLEASEUNASSIGNED =
11
- DHCPLEASEUNKNOWN =
12
- DHCPLEASEACTIVE =
13
- MSG_STR_TO_TYPE =
Map message type string to integer type:
{ 'DHCPDISCOVER' => DHCPDISCOVER, 'DHCPOFFER' => DHCPOFFER, 'DHCPREQUEST' => DHCPREQUEST, 'DHCPDECLINE' => DHCPDECLINE, 'DHCPACK' => DHCPACK, 'DHCPNAK' => DHCPNAK, 'DHCPRELEASE' => DHCPRELEASE, 'DHCPINFORM' => DHCPINFORM, 'DHCPFORCERENEW' => DHCPFORCERENEW, 'DHCPLEASEQUERY' => DHCPLEASEQUERY, 'DHCPLEASEUNASSIGNED' => DHCPLEASEUNASSIGNED, 'DHCPLEASEUNKNOWN' => DHCPLEASEUNKNOWN, 'DHCPLEASEACTIVE' => DHCPLEASEACTIVE }
- MSG_TYPE_TO_STR =
Map message integer type to string:
MSG_STR_TO_TYPE.invert
- MSG_TYPE_TO_OP =
Map message type to correct packet operation (BOOTREQUEST/BOOTREPLY):
{ DHCPDISCOVER => BOOTREQUEST, DHCPOFFER => BOOTREPLY, DHCPREQUEST => BOOTREQUEST, DHCPDECLINE => BOOTREPLY, DHCPACK => BOOTREPLY, DHCPNAK => BOOTREPLY, DHCPRELEASE => BOOTREQUEST, DHCPINFORM => BOOTREQUEST, DHCPFORCERENEW => BOOTREPLY, DHCPLEASEQUERY => BOOTREQUEST, DHCPLEASEUNASSIGNED => BOOTREPLY, DHCPLEASEUNKNOWN => BOOTREPLY, DHCPLEASEACTIVE => BOOTREPLY }
- MAGIC =
DHCP MAGIC:
[99, 130, 83, 99].pack('C4')
- OPTIONS =
Options 0-18 and 254 are defined in RFC 1497 (BOOTP) TODO: Add in as yet unhandled options
{ :pad => [ 0, Opt ], ## Pad (RFC 2132) - Padding option :subnet_mask => [ 1, OptIP ], :time_offset => [ 2, OptSInt32 ], ## Offset from GMT (signed 32-bit integer seconds) :routers => [ 3, OptIPList ], ## Default gateway(s) :time_servers => [ 4, OptIPList ], :name_servers => [ 5, OptIPList ], ## IEN-116 name servers :dns_servers => [ 6, OptIPList ], ## DNS server(s) (RFC-1034/1025) :log_servers => [ 7, OptIPList ], ## Log server(s) (MIT-LCS UDP log servers) :cookie_servers => [ 8, OptIPList ], ## Cookie/Quote-of-the-day (RFC 865) server(s) :lpr_servers => [ 9, OptIPList ], ## LPR server(s) (RFC 1179) :impress_servers => [ 10, OptIPList ], ## Impress server(s) (in pref. order) :rlp_servers => [ 11, OptIPList ], ## RLP server(s) (RFC 887) :host_name => [ 12, OptHost ], ## May or may not be qualified with local domain name (RFC 1035) :boot_file_size => [ 13, OptInt16 ], ## Boot file size (number of 512-byte blocks as unsigned 16-bit integer) :merit_dump_file => [ 14, OptData ], ## File name client should dump core to :domain_name => [ 15, OptHost ], ## RFC 1034/1035 domain name :swap_server => [ 16, OptIP ], ## Swap server :root_path => [ 17, OptData ], ## Pathname to mount as root disk :extensions_path => [ 18, OptData ], ## TFTP-available file containing info to be interpreted the same way as 64-byte vendor-extension field in a BOOTP response with some exceptions (See RFC 1497) :ip_forwarding => [ 19, OptBool ], ## Host should enable/disable IP forwarding (0=disable/1=enable) :nonlocal_source_routing => [ 20, OptBool ], ## Enable/disable source routing :max_dgram_reassembly_size => [ 22, OptInt16 ], ## Maximum Datagram Reassembly Size (RFC 1533) - Min. value 576 :default_ttl => [ 23, OptInt8 ], ## Default IP Time-to-live (TTL) (RFC 1533) - Value in the range 1..255 inclusive :path_mtu_aging_timeout => [ 24, OptInt32 ], ## Path MTU Aging Timeout Option (RFC 2132) - Timeout to use when aging Path MTU values discovered according to RFC 1191 :path_mtu_plateau_table => [ 25, OptInt16List ], ## Path MTU Plateau Table Option (RFC 2132) - List of 16-bit unsigned integers ordered smallest to largest, minimum MTU value NOT smaller than 68, minimum of at least one list entry :interface_mtu => [ 26, OptInt16 ], ## Interface MTU (RFC 1533) - Minimum value 68 :all_subnets_are_local => [ 27, OptBool ], ## All Subnets Are Local (RFC 1533) - 0 = client should assume some subnets of directly connected net(s) may have smaller MTUs, 1 = all subnets share single MTU value :broadcast_address => [ 28, OptIP ], ## Broadcast Address (RFC 1533) - Client's broadcast IP on client's subnet :perform_mask_discovery => [ 29, OptBool ], ## Perform Mask Discovery (RFC 1533) - 0 = client should perform mask discovery, 1 = client should not :mask_supplier => [ 30, OptBool ], ## Mask Supplier (RFC 1533) - 0 = client should NOT respond to subnet mask requests using ICMP, 1 = client should respond :perform_router_discovery => [ 31, OptBool ], ## Perform Router Discover (RFC 1265) - 0 = client should NOT perform router discovery, 1 = client should :router_solicitation_address => [ 32, OptIP ], ## Router Solicitaion Address (RFC 1533) - IP address to which client transmits router solicitation requests :static_routes => [ 33, OptStaticRoutes ], ## Static Route (RFC 15333) - List of static routes client should install in routing cache, listed in descending order of priority (if multiple routes to same dest. are specified) - Use option 121 instead - Must NOT specify default route with this! (Illegal destination '0.0.0.0' for this option.) :arp_cache_timeout => [ 35, OptInt32 ], ## ARP Cache Timeout (RFC 1533) - Unsigned 32-bit integer timeout in seconds for ARP cache entries :ethernet_encapsulation => [ 36, OptBool ], ## Ethernet Encapsulation (RFC 1533) - = 0 = use ethernet v2 RFC 894 encapsulation, 1 = use 802.3 RFC 1042 encapsulation :tcp_default_ttl => [ 37, OptInt8 ], ## TCP Default TTL (RFC 1533) - Minimum value of 1 :tcp_keepalive_interval => [ 38, OptInt32 ], ## TCP Keepalive Interval (RFC 1533) - 0 = client should not generate keepalive messages unless requested by application - No. of seconds client should wait before sending keepalive messages on TCP connections :ntp_servers => [ 42, OptIPList ], :vendor_specific_information => [ 43, OptSubList ], :netbios_name_server => [ 44, OptIPList ], ## NetBIOS name server list :netbios_over_tcpip_node_type => [ 46, OptInt8 ], ## NetBIOS node type: 1=B-node, 2=P-node, 4=M-node, 8=H-node :netbios_over_tcpip_scope => [ 47, OptData ], ## NetBIOS scope :requested_ip_address => [ 50, OptIP ], ## Client's requested IP :ip_address_lease_time => [ 51, OptInt32 ], ## How long the lease lasts :option_overload => [ 52, OptInt8 ], ## Option Overload (RFC 2132) - 1, 2, or 3 == 'file' has options, 'sname' has options, both have options (RFC 2132) :dhcp_message_type => [ 53, OptInt8 ], ## One of the above-defined DHCP MESSAGE TYPEs :server_identifier => [ 54, OptIP ], ## How the client differentiates between DHCP servers :parameter_request_list => [ 55, OptInt8List ], ## List of options the CLIENT is requesting in response :message => [ 56, OptData ], ## Message in DHCPNAK or DHCPDECLINE saying why that response was sent :maximum_dhcp_message_size => [ 57, OptInt16 ], ## Maximum DHCP Message Size (RFD 2132) - Client tells server max. message size it will accept. Minimum allowed value is 576 octets. Do NOT include in DHCPDECLINE messages. On an ethernet with a 1500-byte MTU, subtracting 20 bytes for IP overhead and 8 for UDP overhead, the maximum packet size to use would be 1472 bytes. :vendor_class_identifier => [ 60, OptData ], ## For example, some MS boxes send "MSFT 98" or "MSFT 5.0" :client_identifier => [ 61, OptHexString ], ## Client's identifier (client picks ANYTHING) :netware_ip_domain_name => [ 62, OptData ], ## NetWare/IP Domain Name (RFC 2242) :netware_ip_information => [ 63, OptSubList ], ## NetWare/IP Information (RFC 2242) :nis_domain_name => [ 64, OptData ], ## Network Information Service+ Domain (RFC 2132) :nis_servers => [ 65, OptIPList ], ## Network Information Service+ Servers (RFC 2132) (one or more IPs) :tftp_server_name => [ 66, OptData ], ## TFTP Server Name (RFC 2132) - Used when the 'sname' field has been used for DHCP options (option 52 has value of 2 or 3) :bootfile_name => [ 67, OptData ], ## Bootfile Name (RFC 2132) - Used when the 'file' field has been used for DHCP options (option 52 has value of 1 or 3) :mobile_ip_home_agent => [ 68, OptIPList ], ## Mobile IP Home Agent (RFC 2132) list of IP addresses indicating mobile IP home agents available to the client in order of preference (zero or more IPs) :smtp_servers => [ 69, OptIPList ], :pop3_servers => [ 70, OptIPList ], :client_fqdn => [ 81, OptData ], ## Client's requested FQDN (DHCP server could use to update dynamic DNS) :relay_agent_information => [ 82, OptSubList ], ## VERY USEFUL with Cisco CMTS and Motorola Canopy :isns_servers => [ 83, OptData ], ## RFC 4184 Internet Storage Name Servers DHCP option (primary and backup) :authentication => [ 90, OptData ], ## RFC 3118 authentication option -- NOT IMPLEMENTED :client_last_transaction_time => [ 91, OptInt32 ], ## RFC 4388 leasequery option :associated_ip => [ 92, OptIPList ], ## RFC 4388 leasequery option :tz_posix => [ 100, OptData ], ## RFC 4833 timezone TZ-POSIX string (a POSIX time zone string like "MST7MDT6,M3.2.0/02:00,M11.1.0/02:00" which specifies an offset of 7 hours behind UTC during standard time, 6 during daylight time, with daylight beginning the 2nd Sunday in March at 2:00 AM local time and continuing until the 1st Sunday in November at 2:00 AM local time) :tz_database => [ 101, OptData ], ## RFC 4833 timezone TZ-Database string (the name of a time zone in a database, like "America/Denver") :classless_static_routes => [ 121, OptRouteList ], ## RFC 3442 classless static routes - obsoletes option 33 - Ignore opt. 33 if 121 is present - Should specify default routes using option 3 if this option is also present (can specify them in this option too) so if a client ignores 121, a default route will still be set up -- If client requests CLASSLESS STATIC ROUTES and either ROUTERS and/or STATIC ROUTES, ONLY respond with this option (see p. 6 RFC 3442) ## START SITE-SPECIFIC OPTIONS (128..254 inclusive): :ms_classless_static_routes => [ 249, OptRouteList ], ## Microsoft version of option 121 - does NOT ignore opt. 33 if present (differs from opt. 121) :site_local_auto_proxy_config => [ 252, OptData ], ## WPAD site-local proxy configuration ## END SITE-SPECIFIC OPTIONS :end => [ 255, Opt ] ## End (RFC 2132) Mark end of options in vendor field - subsequent bytes are pad options }
Class Method Summary collapse
-
.make_opt(opt, data = nil) ⇒ Object
Create a new DHCP option object based on the option number:.
-
.make_opt_name(name, data = nil) ⇒ Object
Create a new DHCP option object based on the symbolic name:.
Class Method Details
.make_opt(opt, data = nil) ⇒ Object
Create a new DHCP option object based on the option number:
644 645 646 647 648 649 |
# File 'lib/dhcp/options.rb', line 644 def self.make_opt(opt, data=nil) OPTIONS.each do |name, info| return info[1].new(info[0], name, data) if info[0] == opt end return nil end |
.make_opt_name(name, data = nil) ⇒ Object
Create a new DHCP option object based on the symbolic name:
638 639 640 641 |
# File 'lib/dhcp/options.rb', line 638 def self.make_opt_name(name, data=nil) raise "Unknown/unhandled option '#{name}'" unless OPTIONS.key?(name) OPTIONS[name][1].new(OPTIONS[name][0], name, data) end |