2 * Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include <gpxe/if_ether.h>
26 #include <gpxe/netdevice.h>
27 #include <gpxe/device.h>
28 #include <gpxe/xfer.h>
29 #include <gpxe/open.h>
31 #include <gpxe/retry.h>
32 #include <gpxe/tcpip.h>
34 #include <gpxe/uuid.h>
35 #include <gpxe/dhcp.h>
36 #include <gpxe/timer.h>
37 #include <gpxe/settings.h>
38 #include <gpxe/dhcp.h>
39 #include <gpxe/dhcpopts.h>
40 #include <gpxe/dhcppkt.h>
44 * Dynamic Host Configuration Protocol
49 * DHCP operation types
51 * This table maps from DHCP message types (i.e. values of the @c
52 * DHCP_MESSAGE_TYPE option) to values of the "op" field within a DHCP
55 static const uint8_t dhcp_op[] = {
56 [DHCPDISCOVER] = BOOTP_REQUEST,
57 [DHCPOFFER] = BOOTP_REPLY,
58 [DHCPREQUEST] = BOOTP_REQUEST,
59 [DHCPDECLINE] = BOOTP_REQUEST,
60 [DHCPACK] = BOOTP_REPLY,
61 [DHCPNAK] = BOOTP_REPLY,
62 [DHCPRELEASE] = BOOTP_REQUEST,
63 [DHCPINFORM] = BOOTP_REQUEST,
66 /** Raw option data for options common to all DHCP requests */
67 static uint8_t dhcp_request_options_data[] = {
68 DHCP_MAX_MESSAGE_SIZE, DHCP_WORD ( ETH_MAX_MTU ),
70 DHCP_STRING ( 'P', 'X', 'E', 'C', 'l', 'i', 'e', 'n', 't', ':',
71 'A', 'r', 'c', 'h', ':', '0', '0', '0', '0', '0', ':',
72 'U', 'N', 'D', 'I', ':', '0', '0', '2', '0', '0', '1' ),
73 DHCP_CLIENT_ARCHITECTURE, DHCP_WORD ( 0 ),
74 DHCP_CLIENT_NDI, DHCP_OPTION ( 1 /* UNDI */ , 2, 1 /* v2.1 */ ),
75 DHCP_PARAMETER_REQUEST_LIST,
76 DHCP_OPTION ( DHCP_SUBNET_MASK, DHCP_ROUTERS, DHCP_DNS_SERVERS,
77 DHCP_LOG_SERVERS, DHCP_HOST_NAME, DHCP_DOMAIN_NAME,
78 DHCP_ROOT_PATH, DHCP_VENDOR_ENCAP, DHCP_VENDOR_CLASS_ID,
79 DHCP_TFTP_SERVER_NAME, DHCP_BOOTFILE_NAME,
80 DHCP_EB_ENCAP, DHCP_ISCSI_INITIATOR_IQN ),
84 /** Options common to all DHCP requests */
85 static struct dhcp_options dhcp_request_options = {
86 .data = dhcp_request_options_data,
87 .max_len = sizeof ( dhcp_request_options_data ),
88 .len = sizeof ( dhcp_request_options_data ),
91 /** DHCP feature codes */
92 static uint8_t dhcp_features[0] __table_start ( uint8_t, dhcp_features );
93 static uint8_t dhcp_features_end[0] __table_end ( uint8_t, dhcp_features );
96 * Name a DHCP packet type
98 * @v msgtype DHCP message type
99 * @ret string DHCP mesasge type name
101 static inline const char * dhcp_msgtype_name ( unsigned int msgtype ) {
103 case 0: return "BOOTP"; /* Non-DHCP packet */
104 case DHCPDISCOVER: return "DHCPDISCOVER";
105 case DHCPOFFER: return "DHCPOFFER";
106 case DHCPREQUEST: return "DHCPREQUEST";
107 case DHCPDECLINE: return "DHCPDECLINE";
108 case DHCPACK: return "DHCPACK";
109 case DHCPNAK: return "DHCPNAK";
110 case DHCPRELEASE: return "DHCPRELEASE";
111 case DHCPINFORM: return "DHCPINFORM";
112 default: return "DHCP<invalid>";
117 * Calculate DHCP transaction ID for a network device
119 * @v netdev Network device
122 * Extract the least significant bits of the hardware address for use
123 * as the transaction ID.
125 static uint32_t dhcp_xid ( struct net_device *netdev ) {
128 memcpy ( &xid, ( netdev->ll_addr + netdev->ll_protocol->ll_addr_len
129 - sizeof ( xid ) ), sizeof ( xid ) );
134 * Create a DHCP packet
136 * @v dhcppkt DHCP packet structure to fill in
137 * @v netdev Network device
138 * @v msgtype DHCP message type
139 * @v options Initial options to include (or NULL)
140 * @v data Buffer for DHCP packet
141 * @v max_len Size of DHCP packet buffer
142 * @ret rc Return status code
144 * Creates a DHCP packet in the specified buffer, and fills out a @c
145 * dhcp_packet structure that can be passed to
146 * set_dhcp_packet_option() or copy_dhcp_packet_options().
148 static int create_dhcp_packet ( struct dhcp_packet *dhcppkt,
149 struct net_device *netdev, uint8_t msgtype,
150 struct dhcp_options *options,
151 void *data, size_t max_len ) {
152 struct dhcphdr *dhcphdr = data;
158 options_len = ( options ? options->len : 0 );
159 if ( max_len < ( sizeof ( *dhcphdr ) + options_len ) )
162 /* Initialise DHCP packet content */
163 memset ( dhcphdr, 0, max_len );
164 dhcphdr->xid = dhcp_xid ( netdev );
165 dhcphdr->magic = htonl ( DHCP_MAGIC_COOKIE );
166 dhcphdr->htype = ntohs ( netdev->ll_protocol->ll_proto );
167 dhcphdr->op = dhcp_op[msgtype];
168 /* If hardware length exceeds the chaddr field length, don't
169 * use the chaddr field. This is as per RFC4390.
171 hlen = netdev->ll_protocol->ll_addr_len;
172 if ( hlen > sizeof ( dhcphdr->chaddr ) ) {
174 dhcphdr->flags = htons ( BOOTP_FL_BROADCAST );
176 dhcphdr->hlen = hlen;
177 memcpy ( dhcphdr->chaddr, netdev->ll_addr, hlen );
178 memcpy ( dhcphdr->options, options->data, options_len );
180 /* Initialise DHCP packet structure and settings interface */
181 dhcppkt_init ( dhcppkt, NULL, data, max_len );
183 /* Set DHCP_MESSAGE_TYPE option */
184 if ( ( rc = store_setting ( &dhcppkt->settings, DHCP_MESSAGE_TYPE,
185 &msgtype, sizeof ( msgtype ) ) ) != 0 )
191 /** DHCP network device descriptor */
192 struct dhcp_netdev_desc {
199 } __attribute__ (( packed ));
201 /** DHCP client identifier */
202 struct dhcp_client_id {
203 /** Link-layer protocol */
205 /** Link-layer address */
206 uint8_t ll_addr[MAX_LL_ADDR_LEN];
207 } __attribute__ (( packed ));
209 /** DHCP client UUID */
210 struct dhcp_client_uuid {
211 /** Identifier type */
215 } __attribute__ (( packed ));
217 #define DHCP_CLIENT_UUID_TYPE 0
220 * Create DHCP request
222 * @v dhcppkt DHCP packet structure to fill in
223 * @v netdev Network device
224 * @v msgtype DHCP message type
225 * @v offer_settings Settings received in DHCPOFFER, or NULL
226 * @v data Buffer for DHCP packet
227 * @v max_len Size of DHCP packet buffer
228 * @ret rc Return status code
230 int create_dhcp_request ( struct dhcp_packet *dhcppkt,
231 struct net_device *netdev, int msgtype,
232 struct settings *offer_settings,
233 void *data, size_t max_len ) {
234 struct device_description *desc = &netdev->dev->desc;
235 struct dhcp_netdev_desc dhcp_desc;
236 struct dhcp_client_id client_id;
237 struct dhcp_client_uuid client_uuid;
238 size_t dhcp_features_len;
242 /* Create DHCP packet */
243 if ( ( rc = create_dhcp_packet ( dhcppkt, netdev, msgtype,
244 &dhcp_request_options, data,
246 DBG ( "DHCP could not create DHCP packet: %s\n",
251 /* Copy any required options from previous server repsonse */
252 if ( offer_settings ) {
253 if ( ( rc = copy_setting ( &dhcppkt->settings,
254 DHCP_SERVER_IDENTIFIER,
256 DHCP_SERVER_IDENTIFIER ) ) != 0 ) {
257 DBG ( "DHCP could not set server identifier "
258 "option: %s\n", strerror ( rc ) );
261 if ( ( rc = copy_setting ( &dhcppkt->settings,
262 DHCP_REQUESTED_ADDRESS,
264 DHCP_EB_YIADDR ) ) != 0 ) {
265 DBG ( "DHCP could not set requested address "
266 "option: %s\n", strerror ( rc ) );
271 /* Add options to identify the feature list */
272 dhcp_features_len = ( dhcp_features_end - dhcp_features );
273 if ( ( rc = store_setting ( &dhcppkt->settings, DHCP_EB_ENCAP,
274 dhcp_features, dhcp_features_len ) ) !=0 ){
275 DBG ( "DHCP could not set features list option: %s\n",
280 /* Add options to identify the network device */
281 dhcp_desc.type = desc->bus_type;
282 dhcp_desc.vendor = htons ( desc->vendor );
283 dhcp_desc.device = htons ( desc->device );
284 if ( ( rc = store_setting ( &dhcppkt->settings, DHCP_EB_BUS_ID,
285 &dhcp_desc, sizeof ( dhcp_desc ) ) ) !=0 ){
286 DBG ( "DHCP could not set bus ID option: %s\n",
291 /* Add DHCP client identifier. Required for Infiniband, and
292 * doesn't hurt other link layers.
294 client_id.ll_proto = ntohs ( netdev->ll_protocol->ll_proto );
295 ll_addr_len = netdev->ll_protocol->ll_addr_len;
296 assert ( ll_addr_len <= sizeof ( client_id.ll_addr ) );
297 memcpy ( client_id.ll_addr, netdev->ll_addr, ll_addr_len );
298 if ( ( rc = store_setting ( &dhcppkt->settings, DHCP_CLIENT_ID,
299 &client_id, ( ll_addr_len + 1 ) ) ) != 0 ){
300 DBG ( "DHCP could not set client ID: %s\n",
305 /* Add client UUID, if we have one. Required for PXE. */
306 client_uuid.type = DHCP_CLIENT_UUID_TYPE;
307 if ( ( rc = get_uuid ( &client_uuid.uuid ) ) == 0 ) {
308 if ( ( rc = store_setting ( &dhcppkt->settings,
309 DHCP_CLIENT_UUID, &client_uuid,
310 sizeof ( client_uuid ) ) ) != 0 ) {
311 DBG ( "DHCP could not set client UUID: %s\n",
321 * Create DHCP response
323 * @v dhcppkt DHCP packet structure to fill in
324 * @v netdev Network device
325 * @v msgtype DHCP message type
326 * @v settings Settings to include, or NULL
327 * @v data Buffer for DHCP packet
328 * @v max_len Size of DHCP packet buffer
329 * @ret rc Return status code
331 int create_dhcp_response ( struct dhcp_packet *dhcppkt,
332 struct net_device *netdev, int msgtype,
333 struct settings *settings,
334 void *data, size_t max_len ) {
337 /* Create packet and copy in options */
338 if ( ( rc = create_dhcp_packet ( dhcppkt, netdev, msgtype, NULL,
339 data, max_len ) ) != 0 )
341 if ( ( rc = copy_settings ( &dhcppkt->settings, settings ) ) != 0 )
347 /****************************************************************************
349 * DHCP packets contained in I/O buffers
353 /** A DHCP packet contained in an I/O buffer */
354 struct dhcp_iobuf_packet {
355 /** Reference counter */
356 struct refcnt refcnt;
358 struct dhcp_packet dhcppkt;
359 /** Containing I/O buffer */
360 struct io_buffer *iobuf;
364 * Free DHCP packet contained in an I/O buffer
366 * @v refcnt Reference counter
368 static void dhcpiob_free ( struct refcnt *refcnt ) {
369 struct dhcp_iobuf_packet *dhcpiob =
370 container_of ( refcnt, struct dhcp_iobuf_packet, refcnt );
372 free_iob ( dhcpiob->iobuf );
377 * Create DHCP packet from I/O buffer
379 * @v iobuf I/O buffer
380 * @ret dhcpiob DHCP packet contained in I/O buffer
382 * This function takes ownership of the I/O buffer. Future accesses
383 * must be via the @c dhcpiob data structure.
385 static struct dhcp_iobuf_packet * dhcpiob_create ( struct io_buffer *iobuf ) {
386 struct dhcp_iobuf_packet *dhcpiob;
388 dhcpiob = zalloc ( sizeof ( *dhcpiob ) );
390 dhcpiob->refcnt.free = dhcpiob_free;
391 dhcpiob->iobuf = iobuf;
392 dhcppkt_init ( &dhcpiob->dhcppkt, &dhcpiob->refcnt,
393 iobuf->data, iob_len ( iobuf ) );
398 static void dhcpiob_put ( struct dhcp_iobuf_packet *dhcpiob ) {
400 ref_put ( &dhcpiob->refcnt );
403 /****************************************************************************
405 * DHCP to UDP interface
409 /** A DHCP session */
410 struct dhcp_session {
411 /** Reference counter */
412 struct refcnt refcnt;
413 /** Job control interface */
414 struct job_interface job;
415 /** Data transfer interface */
416 struct xfer_interface xfer;
418 /** Network device being configured */
419 struct net_device *netdev;
421 /** State of the session
423 * This is a value for the @c DHCP_MESSAGE_TYPE option
424 * (e.g. @c DHCPDISCOVER).
427 /** Response obtained from DHCP server */
428 struct dhcp_iobuf_packet *response;
429 /** Response obtained from ProxyDHCP server */
430 struct dhcp_iobuf_packet *proxy_response;
431 /** Retransmission timer */
432 struct retry_timer timer;
433 /** Session start time (in ticks) */
440 * @v refcnt Reference counter
442 static void dhcp_free ( struct refcnt *refcnt ) {
443 struct dhcp_session *dhcp =
444 container_of ( refcnt, struct dhcp_session, refcnt );
446 netdev_put ( dhcp->netdev );
447 dhcpiob_put ( dhcp->response );
448 dhcpiob_put ( dhcp->proxy_response );
453 * Mark DHCP session as complete
455 * @v dhcp DHCP session
456 * @v rc Return status code
458 static void dhcp_finished ( struct dhcp_session *dhcp, int rc ) {
460 /* Block futher incoming messages */
461 job_nullify ( &dhcp->job );
462 xfer_nullify ( &dhcp->xfer );
464 /* Stop retry timer */
465 stop_timer ( &dhcp->timer );
467 /* Free resources and close interfaces */
468 xfer_close ( &dhcp->xfer, rc );
469 job_done ( &dhcp->job, rc );
473 * Register options received via DHCP
475 * @v dhcp DHCP session
476 * @ret rc Return status code
478 static int dhcp_register_settings ( struct dhcp_session *dhcp ) {
479 struct settings *settings;
480 struct settings *parent;
483 if ( dhcp->proxy_response ) {
484 settings = &dhcp->proxy_response->dhcppkt.settings;
485 if ( ( rc = register_settings ( settings, NULL ) ) != 0 )
489 settings = &dhcp->response->dhcppkt.settings;
490 parent = netdev_settings ( dhcp->netdev );
491 if ( ( rc = register_settings ( settings, parent ) ) != 0 )
497 /****************************************************************************
499 * Data transfer interface
504 * Transmit DHCP request
506 * @v dhcp DHCP session
507 * @ret rc Return status code
509 static int dhcp_send_request ( struct dhcp_session *dhcp ) {
510 struct xfer_metadata meta = {
511 .netdev = dhcp->netdev,
513 struct settings *offer_settings = NULL;
514 struct io_buffer *iobuf;
515 struct dhcp_packet dhcppkt;
518 DBGC ( dhcp, "DHCP %p transmitting %s\n",
519 dhcp, dhcp_msgtype_name ( dhcp->state ) );
521 assert ( ( dhcp->state == DHCPDISCOVER ) ||
522 ( dhcp->state == DHCPREQUEST ) );
524 /* Start retry timer. Do this first so that failures to
525 * transmit will be retried.
527 start_timer ( &dhcp->timer );
529 /* Allocate buffer for packet */
530 iobuf = xfer_alloc_iob ( &dhcp->xfer, DHCP_MIN_LEN );
534 /* Create DHCP packet in temporary buffer */
535 if ( dhcp->response )
536 offer_settings = &dhcp->response->dhcppkt.settings;
537 if ( ( rc = create_dhcp_request ( &dhcppkt, dhcp->netdev, dhcp->state,
538 offer_settings, iobuf->data,
539 iob_tailroom ( iobuf ) ) ) != 0 ) {
540 DBGC ( dhcp, "DHCP %p could not construct DHCP request: %s\n",
541 dhcp, strerror ( rc ) );
545 /* Transmit the packet */
546 iob_put ( iobuf, dhcppkt.len );
547 rc = xfer_deliver_iob_meta ( &dhcp->xfer, iobuf, &meta );
550 DBGC ( dhcp, "DHCP %p could not transmit UDP packet: %s\n",
551 dhcp, strerror ( rc ) );
561 * Handle DHCP retry timer expiry
563 * @v timer DHCP retry timer
564 * @v fail Failure indicator
566 static void dhcp_timer_expired ( struct retry_timer *timer, int fail ) {
567 struct dhcp_session *dhcp =
568 container_of ( timer, struct dhcp_session, timer );
571 dhcp_finished ( dhcp, -ETIMEDOUT );
573 dhcp_send_request ( dhcp );
580 * @v xfer Data transfer interface
581 * @v iobuf I/O buffer
582 * @v data Received data
583 * @v len Length of received data
584 * @ret rc Return status code
586 static int dhcp_deliver_iob ( struct xfer_interface *xfer,
587 struct io_buffer *iobuf,
588 struct xfer_metadata *meta __unused ) {
589 struct dhcp_session *dhcp =
590 container_of ( xfer, struct dhcp_session, xfer );
591 struct dhcp_iobuf_packet *response;
592 struct dhcp_iobuf_packet **store_response;
593 struct dhcphdr *dhcphdr;
594 struct settings *settings;
595 unsigned int msgtype;
596 unsigned long elapsed;
601 /* Convert packet into a DHCP-packet-in-iobuf */
602 response = dhcpiob_create ( iobuf );
604 DBGC ( dhcp, "DHCP %p could not store DHCP packet\n", dhcp );
607 dhcphdr = response->dhcppkt.dhcphdr;
608 settings = &response->dhcppkt.settings;
610 /* Check for matching transaction ID */
611 if ( dhcphdr->xid != dhcp_xid ( dhcp->netdev ) ) {
612 DBGC ( dhcp, "DHCP %p wrong transaction ID (wanted %08lx, "
613 "got %08lx)\n", dhcp, ntohl ( dhcphdr->xid ),
614 ntohl ( dhcp_xid ( dhcp->netdev ) ) );
618 /* Determine and verify message type */
619 is_proxy = ( dhcphdr->yiaddr.s_addr == 0 );
620 msgtype = fetch_uintz_setting ( settings, DHCP_MESSAGE_TYPE );
621 DBGC ( dhcp, "DHCP %p received %s%s\n", dhcp,
622 ( is_proxy ? "Proxy" : "" ), dhcp_msgtype_name ( msgtype ) );
623 if ( ( ( dhcp->state != DHCPDISCOVER ) || ( msgtype != DHCPOFFER ) ) &&
624 ( ( dhcp->state != DHCPREQUEST ) || ( msgtype != DHCPACK ) ) ) {
625 DBGC ( dhcp, "DHCP %p discarding %s while in %s state\n",
626 dhcp, dhcp_msgtype_name ( msgtype ),
627 dhcp_msgtype_name ( dhcp->state ) );
631 /* Update stored standard/ProxyDHCP options, if the new
632 * options have equal or higher priority than the
633 * currently-stored options.
635 store_response = ( is_proxy ? &dhcp->proxy_response : &dhcp->response);
636 if ( ( ! *store_response ) ||
637 ( fetch_uintz_setting ( settings, DHCP_EB_PRIORITY ) >=
638 fetch_uintz_setting ( &(*store_response)->dhcppkt.settings,
639 DHCP_EB_PRIORITY ) ) ) {
640 dhcpiob_put ( *store_response );
641 *store_response = response;
643 dhcpiob_put ( response );
646 /* If we don't yet have a standard DHCP response (i.e. one
647 * with an IP address), then just leave the timer running.
649 if ( ! dhcp->response )
652 /* Handle DHCP response */
653 ignore_proxy = fetch_uintz_setting ( &dhcp->response->dhcppkt.settings,
654 DHCP_EB_NO_PROXYDHCP );
655 switch ( dhcp->state ) {
657 /* If we have allowed sufficient time for ProxyDHCP
658 * reponses, then transition to making the DHCPREQUEST.
660 elapsed = ( currticks() - dhcp->start );
661 if ( ignore_proxy || ( elapsed > PROXYDHCP_WAIT_TIME ) ) {
662 stop_timer ( &dhcp->timer );
663 dhcp->state = DHCPREQUEST;
664 dhcp_send_request ( dhcp );
668 /* DHCP finished; register options and exit */
669 if ( ignore_proxy && dhcp->proxy_response ) {
670 dhcpiob_put ( dhcp->proxy_response );
671 dhcp->proxy_response = NULL;
673 if ( ( rc = dhcp_register_settings ( dhcp ) ) != 0 ) {
674 dhcp_finished ( dhcp, rc );
677 dhcp_finished ( dhcp, 0 );
687 dhcpiob_put ( response );
691 /** DHCP data transfer interface operations */
692 static struct xfer_interface_operations dhcp_xfer_operations = {
693 .close = ignore_xfer_close,
694 .vredirect = xfer_vopen,
695 .window = unlimited_xfer_window,
696 .alloc_iob = default_xfer_alloc_iob,
697 .deliver_iob = dhcp_deliver_iob,
698 .deliver_raw = xfer_deliver_as_iob,
701 /****************************************************************************
703 * Job control interface
708 * Handle kill() event received via job control interface
710 * @v job DHCP job control interface
712 static void dhcp_job_kill ( struct job_interface *job ) {
713 struct dhcp_session *dhcp =
714 container_of ( job, struct dhcp_session, job );
716 /* Terminate DHCP session */
717 dhcp_finished ( dhcp, -ECANCELED );
720 /** DHCP job control interface operations */
721 static struct job_interface_operations dhcp_job_operations = {
722 .done = ignore_job_done,
723 .kill = dhcp_job_kill,
724 .progress = ignore_job_progress,
727 /****************************************************************************
734 * Start DHCP on a network device
736 * @v job Job control interface
737 * @v netdev Network device
738 * @v register_options DHCP option block registration routine
739 * @ret rc Return status code
741 * Starts DHCP on the specified network device. If successful, the @c
742 * register_options() routine will be called with the acquired
745 int start_dhcp ( struct job_interface *job, struct net_device *netdev ) {
746 static struct sockaddr_in server = {
747 .sin_family = AF_INET,
748 .sin_addr.s_addr = INADDR_BROADCAST,
749 .sin_port = htons ( BOOTPS_PORT ),
751 static struct sockaddr_in client = {
752 .sin_family = AF_INET,
753 .sin_port = htons ( BOOTPC_PORT ),
755 struct dhcp_session *dhcp;
758 /* Allocate and initialise structure */
759 dhcp = zalloc ( sizeof ( *dhcp ) );
762 dhcp->refcnt.free = dhcp_free;
763 job_init ( &dhcp->job, &dhcp_job_operations, &dhcp->refcnt );
764 xfer_init ( &dhcp->xfer, &dhcp_xfer_operations, &dhcp->refcnt );
765 dhcp->netdev = netdev_get ( netdev );
766 dhcp->timer.expired = dhcp_timer_expired;
767 dhcp->state = DHCPDISCOVER;
768 dhcp->start = currticks();
770 /* Instantiate child objects and attach to our interfaces */
771 if ( ( rc = xfer_open_socket ( &dhcp->xfer, SOCK_DGRAM,
772 ( struct sockaddr * ) &server,
773 ( struct sockaddr * ) &client ) ) != 0 )
776 /* Start timer to initiate initial DHCPREQUEST */
777 start_timer_nodelay ( &dhcp->timer );
779 /* Attach parent interface, mortalise self, and return */
780 job_plug_plug ( &dhcp->job, job );
781 ref_put ( &dhcp->refcnt );
785 dhcp_finished ( dhcp, rc );
786 ref_put ( &dhcp->refcnt );