|
@@ -342,27 +342,12 @@ int create_dhcp_request ( struct dhcp_packet *dhcppkt,
|
342
|
342
|
struct dhcp_settings {
|
343
|
343
|
/** Reference counter */
|
344
|
344
|
struct refcnt refcnt;
|
345
|
|
- /** Containing I/O buffer */
|
346
|
|
- struct io_buffer *iobuf;
|
347
|
345
|
/** DHCP packet */
|
348
|
346
|
struct dhcp_packet dhcppkt;
|
349
|
347
|
/** Setting interface */
|
350
|
348
|
struct settings settings;
|
351
|
349
|
};
|
352
|
350
|
|
353
|
|
-/**
|
354
|
|
- * Free DHCP settings block
|
355
|
|
- *
|
356
|
|
- * @v refcnt Reference counter
|
357
|
|
- */
|
358
|
|
-static void dhcpset_free ( struct refcnt *refcnt ) {
|
359
|
|
- struct dhcp_settings *dhcpset =
|
360
|
|
- container_of ( refcnt, struct dhcp_settings, refcnt );
|
361
|
|
-
|
362
|
|
- free_iob ( dhcpset->iobuf );
|
363
|
|
- free ( dhcpset );
|
364
|
|
-}
|
365
|
|
-
|
366
|
351
|
/**
|
367
|
352
|
* Decrement reference count on DHCP settings block
|
368
|
353
|
*
|
|
@@ -413,23 +398,22 @@ static struct settings_operations dhcpset_settings_operations = {
|
413
|
398
|
};
|
414
|
399
|
|
415
|
400
|
/**
|
416
|
|
- * Create DHCP setting block from I/O buffer
|
|
401
|
+ * Create DHCP setting block
|
417
|
402
|
*
|
418
|
|
- * @v iobuf I/O buffer
|
|
403
|
+ * @v dhcphdr DHCP packet
|
|
404
|
+ * @v len Length of DHCP packet
|
419
|
405
|
* @ret dhcpset DHCP settings block
|
420
|
|
- *
|
421
|
|
- * This function takes ownership of the I/O buffer. Future accesses
|
422
|
|
- * must be via the @c dhcpset data structure.
|
423
|
406
|
*/
|
424
|
|
-static struct dhcp_settings * dhcpset_create_iob ( struct io_buffer *iobuf ) {
|
|
407
|
+static struct dhcp_settings * dhcpset_create ( const struct dhcphdr *dhcphdr,
|
|
408
|
+ size_t len ) {
|
425
|
409
|
struct dhcp_settings *dhcpset;
|
|
410
|
+ void *data;
|
426
|
411
|
|
427
|
|
- dhcpset = zalloc ( sizeof ( *dhcpset ) );
|
|
412
|
+ dhcpset = zalloc ( sizeof ( *dhcpset ) + len );
|
428
|
413
|
if ( dhcpset ) {
|
429
|
|
- dhcpset->refcnt.free = dhcpset_free;
|
430
|
|
- dhcpset->iobuf = iobuf;
|
431
|
|
- dhcppkt_init ( &dhcpset->dhcppkt,
|
432
|
|
- iobuf->data, iob_len ( iobuf ) );
|
|
414
|
+ data = ( ( ( void * ) dhcpset ) + sizeof ( *dhcpset ) );
|
|
415
|
+ memcpy ( data, dhcphdr, len );
|
|
416
|
+ dhcppkt_init ( &dhcpset->dhcppkt, data, len );
|
433
|
417
|
settings_init ( &dhcpset->settings,
|
434
|
418
|
&dhcpset_settings_operations, &dhcpset->refcnt,
|
435
|
419
|
DHCP_SETTINGS_NAME );
|
|
@@ -632,9 +616,8 @@ static void dhcp_timer_expired ( struct retry_timer *timer, int fail ) {
|
632
|
616
|
* @v len Length of received data
|
633
|
617
|
* @ret rc Return status code
|
634
|
618
|
*/
|
635
|
|
-static int dhcp_deliver_iob ( struct xfer_interface *xfer,
|
636
|
|
- struct io_buffer *iobuf,
|
637
|
|
- struct xfer_metadata *meta __unused ) {
|
|
619
|
+static int dhcp_deliver_raw ( struct xfer_interface *xfer,
|
|
620
|
+ const void *data, size_t len ) {
|
638
|
621
|
struct dhcp_session *dhcp =
|
639
|
622
|
container_of ( xfer, struct dhcp_session, xfer );
|
640
|
623
|
struct dhcp_settings *response;
|
|
@@ -648,8 +631,8 @@ static int dhcp_deliver_iob ( struct xfer_interface *xfer,
|
648
|
631
|
uint8_t ignore_proxy = 0;
|
649
|
632
|
int rc;
|
650
|
633
|
|
651
|
|
- /* Convert packet into a DHCP-packet-in-iobuf */
|
652
|
|
- response = dhcpset_create_iob ( iobuf );
|
|
634
|
+ /* Convert packet into a DHCP settings block */
|
|
635
|
+ response = dhcpset_create ( data, len );
|
653
|
636
|
if ( ! response ) {
|
654
|
637
|
DBGC ( dhcp, "DHCP %p could not store DHCP packet\n", dhcp );
|
655
|
638
|
return -ENOMEM;
|
|
@@ -748,8 +731,8 @@ static struct xfer_interface_operations dhcp_xfer_operations = {
|
748
|
731
|
.vredirect = xfer_vopen,
|
749
|
732
|
.window = unlimited_xfer_window,
|
750
|
733
|
.alloc_iob = default_xfer_alloc_iob,
|
751
|
|
- .deliver_iob = dhcp_deliver_iob,
|
752
|
|
- .deliver_raw = xfer_deliver_as_iob,
|
|
734
|
+ .deliver_iob = xfer_deliver_as_raw,
|
|
735
|
+ .deliver_raw = dhcp_deliver_raw,
|
753
|
736
|
};
|
754
|
737
|
|
755
|
738
|
/****************************************************************************
|