.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Net::DHCP::Packet 3pm" .TH Net::DHCP::Packet 3pm "2013-10-05" "perl v5.18.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Net::DHCP::Packet \- Object methods to create a DHCP packet. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Net::DHCP::Packet; \& \& my $p = Net::DHCP::Packet\->new( \& \*(AqChaddr\*(Aq => \*(Aq000BCDEF\*(Aq, \& \*(AqXid\*(Aq => 0x9F0FD, \& \*(AqCiaddr\*(Aq => \*(Aq0.0.0.0\*(Aq, \& \*(AqSiaddr\*(Aq => \*(Aq0.0.0.0\*(Aq, \& \*(AqHops\*(Aq => 0); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Represents a \s-1DHCP\s0 packet as specified in \s-1RFC 1533, RFC 2132.\s0 .SH "CONSTRUCTOR" .IX Header "CONSTRUCTOR" This module only provides basic constructor. For \*(L"easy\*(R" constructors, you can use the Net::DHCP::Session module. .IP "new( )" 4 .IX Item "new( )" .PD 0 .IP "new( \s-1BUFFER \s0)" 4 .IX Item "new( BUFFER )" .IP "new( \s-1ARG\s0 => \s-1VALUE, ARG\s0 => \s-1VALUE... \s0)" 4 .IX Item "new( ARG => VALUE, ARG => VALUE... )" .PD Creates an \f(CW\*(C`Net::DHCP::Packet\*(C'\fR object, which can be used to send or receive \&\s-1DHCP\s0 network packets. \s-1BOOTP\s0 is not supported. .Sp Without argument, a default empty packet is created. .Sp .Vb 1 \& $packet = Net::DHCP::Packet(); .Ve .Sp A \f(CW\*(C`BUFFER\*(C'\fR argument is interpreted as a binary buffer like one provided by the socket \f(CW\*(C`recv()\*(C'\fR function. if the packet is malformed, a fatal error is issued. .Sp .Vb 2 \& use IO::Socket::INET; \& use Net::DHCP::Packet; \& \& $sock = IO::Socket::INET\->new(LocalPort => 67, Proto => "udp", Broadcast => 1) \& or die "socket: $@"; \& \& while ($sock\->recv($newmsg, 1024)) { \& $packet = Net::DHCP::Packet\->new($newmsg); \& print $packet\->toString(); \& } .Ve .Sp To create a fresh new packet \f(CW\*(C`new()\*(C'\fR takes arguments as a key-value pairs : .Sp .Vb 2 \& ARGUMENT FIELD OCTETS DESCRIPTION \& \-\-\-\-\-\-\-\- \-\-\-\-\- \-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\- \& \& Op op 1 Message op code / message type. \& 1 = BOOTREQUEST, 2 = BOOTREPLY \& Htype htype 1 Hardware address type, see ARP section in "Assigned \& Numbers" RFC; e.g., \*(Aq1\*(Aq = 10mb ethernet. \& Hlen hlen 1 Hardware address length (e.g. \*(Aq6\*(Aq for 10mb \& ethernet). \& Hops hops 1 Client sets to zero, optionally used by relay agents \& when booting via a relay agent. \& Xid xid 4 Transaction ID, a random number chosen by the \& client, used by the client and server to associate \& messages and responses between a client and a \& server. \& Secs secs 2 Filled in by client, seconds elapsed since client \& began address acquisition or renewal process. \& Flags flags 2 Flags (see figure 2). \& Ciaddr ciaddr 4 Client IP address; only filled in if client is in \& BOUND, RENEW or REBINDING state and can respond \& to ARP requests. \& Yiaddr yiaddr 4 \*(Aqyour\*(Aq (client) IP address. \& Siaddr siaddr 4 IP address of next server to use in bootstrap; \& returned in DHCPOFFER, DHCPACK by server. \& Giaddr giaddr 4 Relay agent IP address, used in booting via a \& relay agent. \& Chaddr chaddr 16 Client hardware address. \& Sname sname 64 Optional server host name, null terminated string. \& File file 128 Boot file name, null terminated string; "generic" \& name or null in DHCPDISCOVER, fully qualified \& directory\-path name in DHCPOFFER. \& IsDhcp isDhcp 4 Controls whether the packet is BOOTP or DHCP. \& DHCP conatains the "magic cookie" of 4 bytes. \& 0x63 0x82 0x53 0x63. \& DHO_*code Optional parameters field. See the options \& documents for a list of defined options. \& See Net::DHCP::Constants. \& Padding padding * Optional padding at the end of the packet .Ve .Sp See below methods for values and syntax descrption. .Sp Note: \s-1DHCP\s0 options are created in the same order as key-value pairs. .SH "METHODS" .IX Header "METHODS" .SS "\s-1ATTRIBUTE METHODS\s0" .IX Subsection "ATTRIBUTE METHODS" .IP "comment( [\s-1STRING\s0] )" 4 .IX Item "comment( [STRING] )" Sets or gets the comment attribute (object meta-data only) .IP "op( [\s-1BYTE\s0] )" 4 .IX Item "op( [BYTE] )" Sets/gets the \fI\s-1BOOTP\s0 opcode\fR. .Sp Normal values are: .Sp .Vb 2 \& BOOTREQUEST() \& BOOTREPLY() .Ve .IP "htype( [\s-1BYTE\s0] )" 4 .IX Item "htype( [BYTE] )" Sets/gets the \fIhardware address type\fR. .Sp Common value is: \f(CW\*(C`HTYPE_ETHER()\*(C'\fR (1) = ethernet .IP "hlen ( [\s-1BYTE\s0] )" 4 .IX Item "hlen ( [BYTE] )" Sets/gets the \fIhardware address length\fR. Value must be between \f(CW0\fR and \f(CW16\fR. .Sp For most \s-1NIC\s0's, the \s-1MAC\s0 address has 6 bytes. .IP "hops ( [\s-1BYTE\s0] )" 4 .IX Item "hops ( [BYTE] )" Sets/gets the \fInumber of hops\fR. .Sp This field is incremented by each encountered \s-1DHCP\s0 relay agent. .IP "xid ( [\s-1INTEGER\s0] )" 4 .IX Item "xid ( [INTEGER] )" Sets/gets the 32 bits \fItransaction id\fR. .Sp This field should be a random value set by the \s-1DHCP\s0 client. .IP "secs ( [\s-1SHORT\s0] )" 4 .IX Item "secs ( [SHORT] )" Sets/gets the 16 bits \fIelapsed boot time\fR in seconds. .IP "flags ( [\s-1SHORT\s0] )" 4 .IX Item "flags ( [SHORT] )" Sets/gets the 16 bits \fIflags\fR. .Sp .Vb 1 \& 0x8000 = Broadcast reply requested. .Ve .IP "ciaddr ( [\s-1STRING\s0] )" 4 .IX Item "ciaddr ( [STRING] )" Sets/gets the \fIclient \s-1IP\s0 address\fR. .Sp \&\s-1IP\s0 address is only accepted as a string like '10.24.50.3'. .Sp Note: \s-1IP\s0 address is internally stored as a 4 bytes binary string. See \*(L"Special methods\*(R" below. .IP "yiaddr ( [\s-1STRING\s0] )" 4 .IX Item "yiaddr ( [STRING] )" Sets/gets the \fIyour \s-1IP\s0 address\fR. .Sp \&\s-1IP\s0 address is only accepted as a string like '10.24.50.3'. .Sp Note: \s-1IP\s0 address is internally stored as a 4 bytes binary string. See \*(L"Special methods\*(R" below. .IP "siaddr ( [\s-1STRING\s0] )" 4 .IX Item "siaddr ( [STRING] )" Sets/gets the \fInext server \s-1IP\s0 address\fR. .Sp \&\s-1IP\s0 address is only accepted as a string like '10.24.50.3'. .Sp Note: \s-1IP\s0 address is internally stored as a 4 bytes binary string. See \*(L"Special methods\*(R" below. .IP "giaddr ( [\s-1STRING\s0] )" 4 .IX Item "giaddr ( [STRING] )" Sets/gets the \fIrelay agent \s-1IP\s0 address\fR. .Sp \&\s-1IP\s0 address is only accepted as a string like '10.24.50.3'. .Sp Note: \s-1IP\s0 address is internally stored as a 4 bytes binary string. See \*(L"Special methods\*(R" below. .IP "chaddr ( [\s-1STRING\s0] )" 4 .IX Item "chaddr ( [STRING] )" Sets/gets the \fIclient hardware address\fR. Its length is given by the \f(CW\*(C`hlen\*(C'\fR attribute. .Sp Valude is formatted as an Hexadecimal string representation. .Sp .Vb 1 \& Example: "0010A706DFFF" for 6 bytes mac address. .Ve .Sp Note : internal format is packed bytes string. See \*(L"Special methods\*(R" below. .IP "sname ( [\s-1STRING\s0] )" 4 .IX Item "sname ( [STRING] )" Sets/gets the \*(L"server host name\*(R". Maximum size is 63 bytes. If greater a warning is issued. .IP "file ( [\s-1STRING\s0] )" 4 .IX Item "file ( [STRING] )" Sets/gets the \*(L"boot file name\*(R". Maximum size is 127 bytes. If greater a warning is issued. .IP "isDhcp ( [\s-1BOOLEAN\s0] )" 4 .IX Item "isDhcp ( [BOOLEAN] )" Sets/gets the \fI\s-1DHCP\s0 cookie\fR. Returns whether the cookie is valid or not, hence whether the packet is \s-1DHCP\s0 or \s-1BOOTP.\s0 .Sp Default value is \f(CW1\fR, valid \s-1DHCP\s0 cookie. .IP "padding ( [\s-1BYTES\s0] )" 4 .IX Item "padding ( [BYTES] )" Sets/gets the optional padding at the end of the \s-1DHCP\s0 packet, i.e. after \&\s-1DHCP\s0 options. .SS "\s-1DHCP OPTIONS METHODS\s0" .IX Subsection "DHCP OPTIONS METHODS" This section describes how to read or set \s-1DHCP\s0 options. Methods are given in two flavours : (i) text format with automatic type conversion, (ii) raw binary format. .PP Standard way of accessing options is through automatic type conversion, described in the \*(L"\s-1DHCP OPTION TYPES\*(R"\s0 section. Only a subset of types is supported, mainly those defined in rfc 2132. .PP Raw binary functions are provided for pure performance optimization, and for unsupported types manipulation. .IP "addOptionValue ( \s-1CODE, VALUE \s0)" 4 .IX Item "addOptionValue ( CODE, VALUE )" Adds a \s-1DHCP\s0 option field. Common code values are listed in \&\f(CW\*(C`Net::DHCP::Constants\*(C'\fR \f(CW\*(C`DHO_\*(C'\fR*. .Sp Values are automatically converted according to their data types, depending on their format as defined by \s-1RFC 2132.\s0 Please see \*(L"\s-1DHCP OPTION TYPES\*(R"\s0 for supported options and corresponding formats. .Sp If you nedd access to the raw binary values, please use \f(CW\*(C`addOptionRaw()\*(C'\fR. .Sp .Vb 3 \& $pac = Net::DHCP::Packet\->new(); \& $pac\->addOption(DHO_DHCP_MESSAGE_TYPE(), DHCPINFORM()); \& $pac\->addOption(DHO_NAME_SERVERS(), "10.0.0.1", "10.0.0.2")); .Ve .IP "addSubOptionValue ( \s-1CODE, SUBCODE, VALUE \s0)" 4 .IX Item "addSubOptionValue ( CODE, SUBCODE, VALUE )" Adds a \s-1DHCP\s0 sub-option field. Common code values are listed in \&\f(CW\*(C`Net::DHCP::Constants\*(C'\fR \f(CW\*(C`SUBOPTION_\*(C'\fR*. .Sp Values are automatically converted according to their data types, depending on their format as defined by \s-1RFC 2132.\s0 Please see \*(L"\s-1DHCP OPTION TYPES\*(R"\s0 for supported options and corresponding formats. .Sp If you nedd access to the raw binary values, please use \f(CW\*(C`addSubOptionRaw()\*(C'\fR. .Sp .Vb 4 \& $pac = Net::DHCP::Packet\->new(); \& # FIXME update exampls \& $pac\->addSubOption(DHO_DHCP_MESSAGE_TYPE(), DHCPINFORM()); \& $pac\->addSubOption(DHO_NAME_SERVERS(), "10.0.0.1", "10.0.0.2")); .Ve .IP "getOptionValue ( \s-1CODE \s0)" 4 .IX Item "getOptionValue ( CODE )" Returns the value of a \s-1DHCP\s0 option. .Sp Automatic type conversion is done according to their data types, as defined in \s-1RFC 2132.\s0 Please see \*(L"\s-1DHCP OPTION TYPES\*(R"\s0 for supported options and corresponding formats. .Sp If you nedd access to the raw binary values, please use \f(CW\*(C`getOptionRaw()\*(C'\fR. .Sp Return value is either a string or an array, depending on the context. .Sp .Vb 2 \& $ip = $pac\->getOptionValue(DHO_SUBNET_MASK()); \& $ips = $pac\->getOptionValue(DHO_NAME_SERVERS()); .Ve .IP "addOptionRaw ( \s-1CODE, VALUE \s0)" 4 .IX Item "addOptionRaw ( CODE, VALUE )" Adds a \s-1DHCP OPTION\s0 provided in packed binary format. Please see corresponding \s-1RFC\s0 for manual type conversion. .IP "addSubOptionRaw ( \s-1CODE, SUBCODE, VALUE \s0)" 4 .IX Item "addSubOptionRaw ( CODE, SUBCODE, VALUE )" Adds a \s-1DHCP\s0 SUB-OPTION provided in packed binary format. Please see corresponding \s-1RFC\s0 for manual type conversion. .IP "getOptionRaw ( \s-1CODE \s0)" 4 .IX Item "getOptionRaw ( CODE )" Gets a \s-1DHCP OPTION\s0 provided in packed binary format. Please see corresponding \s-1RFC\s0 for manual type conversion. .IP "getSubOptionRaw ( \s-1CODE, SUBCODE \s0)" 4 .IX Item "getSubOptionRaw ( CODE, SUBCODE )" Gets a \s-1DHCP\s0 SUB-OPTION provided in packed binary format. Please see corresponding \s-1RFC\s0 for manual type conversion. .IP "getSubOptionValue ()" 4 .IX Item "getSubOptionValue ()" This is an empty stub for now .IP "removeSubOption ()" 4 .IX Item "removeSubOption ()" This is an empty stub for now .IP "removeOption ( \s-1CODE \s0)" 4 .IX Item "removeOption ( CODE )" Remove option from option list. .IP "encodeRelayAgent ()" 4 .IX Item "encodeRelayAgent ()" These are half baked, but will encode the relay agent options in the future .IP "decodeRelayAgent ()" 4 .IX Item "decodeRelayAgent ()" These are half baked, but will decode the relay agent options in the future .IP "unpackRelayAgent ( \s-1HASH \s0)" 4 .IX Item "unpackRelayAgent ( HASH )" returns a human readable 'relay agent options', not to be confused with \&\f(CW\*(C`decodeRelayAgent\*(C'\fR .IP "\fIaddOption ( \s-1CODE, VALUE \s0)\fR" 4 .IX Item "addOption ( CODE, VALUE )" \&\fIRemoved as of version 0.60. Please use \f(CI\*(C`addOptionRaw()\*(C'\fI instead.\fR .IP "\fIgetOption ( \s-1CODE \s0)\fR" 4 .IX Item "getOption ( CODE )" \&\fIRemoved as of version 0.60. Please use \f(CI\*(C`getOptionRaw()\*(C'\fI instead.\fR .SS "\s-1DHCP OPTIONS TYPES\s0" .IX Subsection "DHCP OPTIONS TYPES" This section describes supported option types (cf. rfc 2132). .PP For unsupported data types, please use \f(CW\*(C`getOptionRaw()\*(C'\fR and \&\f(CW\*(C`addOptionRaw\*(C'\fR to manipulate binary format directly. .IP "dhcp message type" 4 .IX Item "dhcp message type" Only supported for \s-1DHO_DHCP_MESSAGE_TYPE \s0(053) option. Converts a integer to a single byte. .Sp Option code for 'dhcp message' format: .Sp .Vb 1 \& (053) DHO_DHCP_MESSAGE_TYPE .Ve .Sp Example: .Sp .Vb 1 \& $pac\->addOptionValue(DHO_DHCP_MESSAGE_TYPE(), DHCPINFORM()); .Ve .IP "string" 4 .IX Item "string" Pure string attribute, no type conversion. .Sp Option codes for 'string' format: .Sp .Vb 10 \& (012) DHO_HOST_NAME \& (014) DHO_MERIT_DUMP \& (015) DHO_DOMAIN_NAME \& (017) DHO_ROOT_PATH \& (018) DHO_EXTENSIONS_PATH \& (047) DHO_NETBIOS_SCOPE \& (056) DHO_DHCP_MESSAGE \& (060) DHO_VENDOR_CLASS_IDENTIFIER \& (062) DHO_NWIP_DOMAIN_NAME \& (064) DHO_NIS_DOMAIN \& (065) DHO_NIS_SERVER \& (066) DHO_TFTP_SERVER \& (067) DHO_BOOTFILE \& (086) DHO_NDS_TREE_NAME \& (098) DHO_USER_AUTHENTICATION_PROTOCOL .Ve .Sp Example: .Sp .Vb 1 \& $pac\->addOptionValue(DHO_TFTP_SERVER(), "foobar"); .Ve .IP "single ip address" 4 .IX Item "single ip address" Exactly one \s-1IP\s0 address, in dotted numerical format '192.168.1.1'. .Sp Option codes for 'single ip address' format: .Sp .Vb 7 \& (001) DHO_SUBNET_MASK \& (016) DHO_SWAP_SERVER \& (028) DHO_BROADCAST_ADDRESS \& (032) DHO_ROUTER_SOLICITATION_ADDRESS \& (050) DHO_DHCP_REQUESTED_ADDRESS \& (054) DHO_DHCP_SERVER_IDENTIFIER \& (118) DHO_SUBNET_SELECTION .Ve .Sp Example: .Sp .Vb 1 \& $pac\->addOptionValue(DHO_SUBNET_MASK(), "255.255.255.0"); .Ve .IP "multiple ip addresses" 4 .IX Item "multiple ip addresses" Any number of \s-1IP\s0 address, in dotted numerical format '192.168.1.1'. Empty value allowed. .Sp Option codes for 'multiple ip addresses' format: .Sp .Vb 10 \& (003) DHO_ROUTERS \& (004) DHO_TIME_SERVERS \& (005) DHO_NAME_SERVERS \& (006) DHO_DOMAIN_NAME_SERVERS \& (007) DHO_LOG_SERVERS \& (008) DHO_COOKIE_SERVERS \& (009) DHO_LPR_SERVERS \& (010) DHO_IMPRESS_SERVERS \& (011) DHO_RESOURCE_LOCATION_SERVERS \& (041) DHO_NIS_SERVERS \& (042) DHO_NTP_SERVERS \& (044) DHO_NETBIOS_NAME_SERVERS \& (045) DHO_NETBIOS_DD_SERVER \& (048) DHO_FONT_SERVERS \& (049) DHO_X_DISPLAY_MANAGER \& (068) DHO_MOBILE_IP_HOME_AGENT \& (069) DHO_SMTP_SERVER \& (070) DHO_POP3_SERVER \& (071) DHO_NNTP_SERVER \& (072) DHO_WWW_SERVER \& (073) DHO_FINGER_SERVER \& (074) DHO_IRC_SERVER \& (075) DHO_STREETTALK_SERVER \& (076) DHO_STDA_SERVER \& (085) DHO_NDS_SERVERS .Ve .Sp Example: .Sp .Vb 1 \& $pac\->addOptionValue(DHO_NAME_SERVERS(), "10.0.0.11 192.168.1.10"); .Ve .IP "pairs of ip addresses" 4 .IX Item "pairs of ip addresses" Even number of \s-1IP\s0 address, in dotted numerical format '192.168.1.1'. Empty value allowed. .Sp Option codes for 'pairs of ip address' format: .Sp .Vb 2 \& (021) DHO_POLICY_FILTER \& (033) DHO_STATIC_ROUTES .Ve .Sp Example: .Sp .Vb 1 \& $pac\->addOptionValue(DHO_STATIC_ROUTES(), "10.0.0.1 192.168.1.254"); .Ve .IP "byte, short and integer" 4 .IX Item "byte, short and integer" Numerical value in byte (8 bits), short (16 bits) or integer (32 bits) format. .Sp Option codes for 'byte (8)' format: .Sp .Vb 10 \& (019) DHO_IP_FORWARDING \& (020) DHO_NON_LOCAL_SOURCE_ROUTING \& (023) DHO_DEFAULT_IP_TTL \& (027) DHO_ALL_SUBNETS_LOCAL \& (029) DHO_PERFORM_MASK_DISCOVERY \& (030) DHO_MASK_SUPPLIER \& (031) DHO_ROUTER_DISCOVERY \& (034) DHO_TRAILER_ENCAPSULATION \& (036) DHO_IEEE802_3_ENCAPSULATION \& (037) DHO_DEFAULT_TCP_TTL \& (039) DHO_TCP_KEEPALIVE_GARBAGE \& (046) DHO_NETBIOS_NODE_TYPE \& (052) DHO_DHCP_OPTION_OVERLOAD \& (116) DHO_AUTO_CONFIGURE .Ve .Sp Option codes for 'short (16)' format: .Sp .Vb 4 \& (013) DHO_BOOT_SIZE \& (022) DHO_MAX_DGRAM_REASSEMBLY \& (026) DHO_INTERFACE_MTU \& (057) DHO_DHCP_MAX_MESSAGE_SIZE .Ve .Sp Option codes for 'integer (32)' format: .Sp .Vb 7 \& (002) DHO_TIME_OFFSET \& (024) DHO_PATH_MTU_AGING_TIMEOUT \& (035) DHO_ARP_CACHE_TIMEOUT \& (038) DHO_TCP_KEEPALIVE_INTERVAL \& (051) DHO_DHCP_LEASE_TIME \& (058) DHO_DHCP_RENEWAL_TIME \& (059) DHO_DHCP_REBINDING_TIME .Ve .Sp Examples: .Sp .Vb 3 \& $pac\->addOptionValue(DHO_DHCP_OPTION_OVERLOAD(), 3); \& $pac\->addOptionValue(DHO_INTERFACE_MTU(), 1500); \& $pac\->addOptionValue(DHO_DHCP_RENEWAL_TIME(), 24*60*60); .Ve .IP "multiple bytes, shorts" 4 .IX Item "multiple bytes, shorts" A list a bytes or shorts. .Sp Option codes for 'multiple bytes (8)' format: .Sp .Vb 1 \& (055) DHO_DHCP_PARAMETER_REQUEST_LIST .Ve .Sp Option codes for 'multiple shorts (16)' format: .Sp .Vb 2 \& (025) DHO_PATH_MTU_PLATEAU_TABLE \& (117) DHO_NAME_SERVICE_SEARCH .Ve .Sp Examples: .Sp .Vb 1 \& $pac\->addOptionValue(DHO_DHCP_PARAMETER_REQUEST_LIST(), "1 3 6 12 15 28 42 72"); .Ve .SS "\s-1SERIALIZATION METHODS\s0" .IX Subsection "SERIALIZATION METHODS" .IP "serialize ()" 4 .IX Item "serialize ()" Converts a Net::DHCP::Packet to a string, ready to put on the network. .IP "marshall ( \s-1BYTES \s0)" 4 .IX Item "marshall ( BYTES )" The inverse of serialize. Converts a string, presumably a received \s-1UDP\s0 packet, into a Net::DHCP::Packet. .Sp If the packet is malformed, a fatal error is produced. .SS "\s-1HELPER METHODS\s0" .IX Subsection "HELPER METHODS" .IP "toString ()" 4 .IX Item "toString ()" Returns a textual representation of the packet, for debugging. .IP "packinet ( \s-1STRING \s0)" 4 .IX Item "packinet ( STRING )" Transforms a \s-1IP\s0 address \*(L"xx.xx.xx.xx\*(R" into a packed 4 bytes string. .Sp These are simple never failing versions of inet_ntoa and inet_aton. .IP "packinets ( \s-1STRING \s0)" 4 .IX Item "packinets ( STRING )" Transforms a list of space delimited \s-1IP\s0 addresses into a packed bytes string. .IP "packinets_array( \s-1LIST \s0)" 4 .IX Item "packinets_array( LIST )" Transforms an array (list) of \s-1IP\s0 addresses into a packed bytes string. .IP "unpackinet ( \s-1STRING \s0)" 4 .IX Item "unpackinet ( STRING )" Transforms a packed bytes \s-1IP\s0 address into a \*(L"xx.xx.xx.xx\*(R" string. .IP "unpackinets ( \s-1STRING \s0)" 4 .IX Item "unpackinets ( STRING )" Transforms a packed bytes liste of \s-1IP\s0 addresses into a list of \&\*(L"xx.xx.xx.xx\*(R" space delimited string. .IP "unpackinets_array ( \s-1STRING \s0)" 4 .IX Item "unpackinets_array ( STRING )" Transforms a packed bytes liste of \s-1IP\s0 addresses into a array of \&\*(L"xx.xx.xx.xx\*(R" strings. .SS "\s-1SPECIAL METHODS\s0" .IX Subsection "SPECIAL METHODS" These methods are provided for performance tuning only. They give access to internal data representation , thus avoiding unnecessary type conversion. .IP "ciaddrRaw ( [\s-1STRING\s0])" 4 .IX Item "ciaddrRaw ( [STRING])" Sets/gets the \fIclient \s-1IP\s0 address\fR in packed 4 characters binary strings. .IP "yiaddrRaw ( [\s-1STRING\s0] )" 4 .IX Item "yiaddrRaw ( [STRING] )" Sets/gets the \fIyour \s-1IP\s0 address\fR in packed 4 characters binary strings. .IP "siaddrRaw ( [\s-1STRING\s0] )" 4 .IX Item "siaddrRaw ( [STRING] )" Sets/gets the \fInext server \s-1IP\s0 address\fR in packed 4 characters binary strings. .IP "giaddrRaw ( [\s-1STRING\s0] )" 4 .IX Item "giaddrRaw ( [STRING] )" Sets/gets the \fIrelay agent \s-1IP\s0 address\fR in packed 4 characters binary strings. .IP "chaddrRaw ( [\s-1STRING\s0] )" 4 .IX Item "chaddrRaw ( [STRING] )" Sets/gets the \fIclient hardware address\fR in packed binary string. Its length is given by the \f(CW\*(C`hlen\*(C'\fR attribute. .SH "EXAMPLES" .IX Header "EXAMPLES" Sending a simple \s-1DHCP\s0 packet: .PP .Vb 2 \& #!/usr/bin/perl \& # Simple DHCP client \- sending a broadcasted DHCP Discover request \& \& use IO::Socket::INET; \& use Net::DHCP::Packet; \& use Net::DHCP::Constants; \& \& # creat DHCP Packet \& $discover = Net::DHCP::Packet\->new( \& xid => int(rand(0xFFFFFFFF)), # random xid \& Flags => 0x8000, # ask for broadcast answer \& DHO_DHCP_MESSAGE_TYPE() => DHCPDISCOVER() \& ); \& \& # send packet \& $handle = IO::Socket::INET\->new(Proto => \*(Aqudp\*(Aq, \& Broadcast => 1, \& PeerPort => \*(Aq67\*(Aq, \& LocalPort => \*(Aq68\*(Aq, \& PeerAddr => \*(Aq255.255.255.255\*(Aq) \& or die "socket: $@"; # yes, it uses $@ here \& $handle\->send($discover\->serialize()) \& or die "Error sending broadcast inform:$!\en"; .Ve .PP Sniffing \s-1DHCP\s0 packets. .PP .Vb 2 \& #!/usr/bin/perl \& # Simple DHCP server \- listen to DHCP packets and print them \& \& use IO::Socket::INET; \& use Net::DHCP::Packet; \& $sock = IO::Socket::INET\->new(LocalPort => 67, Proto => "udp", Broadcast => 1) \& or die "socket: $@"; \& while ($sock\->recv($newmsg, 1024)) { \& $packet = Net::DHCP::Packet\->new($newmsg); \& print STDERR $packet\->toString(); \& } .Ve .PP Sending a \s-1LEASEQUERY \s0(provided by John A. Murphy). .PP .Vb 2 \& #!/usr/bin/perl \& # Simple DHCP client \- send a LeaseQuery (by IP) and receive the response \& \& use IO::Socket::INET; \& use Net::DHCP::Packet; \& use Net::DHCP::Constants; \& \& $usage = "usage: $0 DHCP_SERVER_IP DHCP_CLIENT_IP\en"; $ARGV[1] || die $usage; \& \& # create a socket \& $handle = IO::Socket::INET\->new(Proto => \*(Aqudp\*(Aq, \& Broadcast => 1, \& PeerPort => \*(Aq67\*(Aq, \& LocalPort => \*(Aq67\*(Aq, \& PeerAddr => $ARGV[0]) \& or die "socket: $@"; # yes, it uses $@ here \& \& # create DHCP Packet \& $inform = Net::DHCP::Packet\->new( \& op => BOOTREQUEST(), \& Htype => \*(Aq0\*(Aq, \& Hlen => \*(Aq0\*(Aq, \& Ciaddr => $ARGV[1], \& Giaddr => $handle\->sockhost(), \& Xid => int(rand(0xFFFFFFFF)), # random xid \& DHO_DHCP_MESSAGE_TYPE() => DHCPLEASEQUERY \& ); \& \& # send request \& $handle\->send($inform\->serialize()) or die "Error sending LeaseQuery: $!\en"; \& \& #receive response \& $handle\->recv($newmsg, 1024) or die; \& $packet = Net::DHCP::Packet\->new($newmsg); \& print $packet\->toString(); .Ve .PP A simple \s-1DHCP\s0 Server is provided in the \*(L"examples\*(R" directory. It is composed of \&\*(L"dhcpd.pl\*(R" a *very* simple server example, and \*(L"dhcpd_test.pl\*(R" a simple tester for this server. .SH "AUTHOR" .IX Header "AUTHOR" Dean Hamstead Previously Stephan Hadinger . Original version by F. van Dun. .SH "BUGS" .IX Header "BUGS" See .SH "COPYRIGHT" .IX Header "COPYRIGHT" This is free software. It can be distributed and/or modified under the same terms as Perl itself. .SH "SEE ALSO" .IX Header "SEE ALSO" Net::DHCP::Options, Net::DHCP::Constants.