]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Change calling conventions for cons_options so that DHCP client doesn't have to dummy...
authorTed Lemon <source@isc.org>
Tue, 18 Feb 1997 14:28:54 +0000 (14:28 +0000)
committerTed Lemon <source@isc.org>
Tue, 18 Feb 1997 14:28:54 +0000 (14:28 +0000)
bootp.c
common/options.c
dhcp.c
options.c
server/bootp.c
server/dhcp.c

diff --git a/bootp.c b/bootp.c
index d2855705160191ba70ce9963d924068496c88195..c98c45df9f6d4d3681500c6b6bcb94e43dfc7a1c 100644 (file)
--- a/bootp.c
+++ b/bootp.c
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: bootp.c,v 1.21 1996/12/31 02:00:33 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: bootp.c,v 1.22 1997/02/18 14:28:54 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -193,7 +193,8 @@ void bootp (packet)
        /* Pack the options into the buffer.   Unlike DHCP, we can't
           pack options into the filename and server name buffers. */
 
-       cons_options (packet, &outgoing, options, 0, 0);
+       outgoing.packet_length =
+               cons_options (packet, outgoing.raw, options, 0, 0);
        if (outgoing.packet_length < BOOTP_MIN_LEN)
                outgoing.packet_length = BOOTP_MIN_LEN;
 
index 53dd0224b18da308dc7a82e6d98a5ac52d6e527e..4f73c90041ce71182a7cc8f34f1b3c663c9fa2c4 100644 (file)
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: options.c,v 1.19 1996/09/11 05:52:18 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: options.c,v 1.20 1997/02/18 14:28:54 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #define DHCP_OPTION_DATA
@@ -155,9 +155,9 @@ void parse_option_buffer (packet, buffer, length)
    three seperate buffers if needed.  This allows us to cons up a set
    of vendor options using the same routine. */
 
-void cons_options (inpacket, outpacket, options, overload, terminate)
+int cons_options (inpacket, outpacket, options, overload, terminate)
        struct packet *inpacket;
-       struct packet *outpacket;
+       struct dhcp_packet *outpacket;
        struct tree_cache **options;
        int overload;   /* Overload flags that may be set. */
        int terminate;
@@ -168,6 +168,7 @@ void cons_options (inpacket, outpacket, options, overload, terminate)
        int main_buffer_size;
        int mainbufix, bufix;
        int option_size;
+       int length;
 
        /* If the client has provided a maximum DHCP message size,
           use that.   Otherwise, we use the default MTU size (576 bytes). */
@@ -225,7 +226,7 @@ void cons_options (inpacket, outpacket, options, overload, terminate)
                                     terminate);
 
        /* Put the cookie up front... */
-       memcpy (outpacket -> raw -> options, DHCP_OPTIONS_COOKIE, 4);
+       memcpy (outpacket -> options, DHCP_OPTIONS_COOKIE, 4);
        mainbufix = 4;
 
        /* If we're going to have to overload, store the overload
@@ -233,57 +234,57 @@ void cons_options (inpacket, outpacket, options, overload, terminate)
           whole thing in the packet's option buffer and leave it at
           that. */
        if (option_size <= main_buffer_size - mainbufix) {
-               memcpy (&outpacket -> raw -> options [mainbufix],
+               memcpy (&outpacket -> options [mainbufix],
                        buffer, option_size);
                mainbufix += option_size;
                if (mainbufix < main_buffer_size)
-                       outpacket -> raw -> options [mainbufix++]
+                       outpacket -> options [mainbufix++]
                                = DHO_END;
-               outpacket -> packet_length = DHCP_FIXED_NON_UDP + mainbufix;
+               length = DHCP_FIXED_NON_UDP + mainbufix;
        } else {
-               outpacket -> raw -> options [mainbufix++] =
+               outpacket -> options [mainbufix++] =
                        DHO_DHCP_OPTION_OVERLOAD;
-               outpacket -> raw -> options [mainbufix++] = 1;
+               outpacket -> options [mainbufix++] = 1;
                if (option_size > main_buffer_size - mainbufix + DHCP_FILE_LEN)
-                       outpacket -> raw -> options [mainbufix++] = 3;
+                       outpacket -> options [mainbufix++] = 3;
                else
-                       outpacket -> raw -> options [mainbufix++] = 1;
+                       outpacket -> options [mainbufix++] = 1;
 
-               memcpy (&outpacket -> raw -> options [mainbufix],
+               memcpy (&outpacket -> options [mainbufix],
                        buffer, main_buffer_size - mainbufix);
                bufix = main_buffer_size - mainbufix;
-               outpacket -> packet_length = DHCP_FIXED_NON_UDP + mainbufix;
+               length = DHCP_FIXED_NON_UDP + mainbufix;
                if (overload & 1) {
                        if (option_size - bufix <= DHCP_FILE_LEN) {
-                               memcpy (outpacket -> raw -> file,
+                               memcpy (outpacket -> file,
                                        &buffer [bufix], option_size - bufix);
                                mainbufix = option_size - bufix;
                                if (mainbufix < DHCP_FILE_LEN)
-                                       outpacket -> raw -> file [mainbufix++]
+                                       outpacket -> file [mainbufix++]
                                                = DHO_END;
                                while (mainbufix < DHCP_FILE_LEN)
-                                       outpacket -> raw -> file [mainbufix++]
+                                       outpacket -> file [mainbufix++]
                                                = DHO_PAD;
                        } else {
-                               memcpy (outpacket -> raw -> file,
+                               memcpy (outpacket -> file,
                                        &buffer [bufix], DHCP_FILE_LEN);
                                bufix += DHCP_FILE_LEN;
                        }
                }
                if ((overload & 2) && option_size < bufix) {
-                       memcpy (outpacket -> raw -> sname,
+                       memcpy (outpacket -> sname,
                                &buffer [bufix], option_size - bufix);
 
                        mainbufix = option_size - bufix;
                        if (mainbufix < DHCP_SNAME_LEN)
-                               outpacket -> raw -> file [mainbufix++]
+                               outpacket -> file [mainbufix++]
                                        = DHO_END;
                        while (mainbufix < DHCP_SNAME_LEN)
-                               outpacket -> raw -> file [mainbufix++]
+                               outpacket -> file [mainbufix++]
                                        = DHO_PAD;
                }
        }
-       return;
+       return length;
 }
 
 /* Store all the requested options into the requested buffer. */
diff --git a/dhcp.c b/dhcp.c
index 39e2969d8e028426b5949c16866715869b7d50c2..3be7e5f9ac57c8729157edf1e8cb0cbc885ca776 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: dhcp.c,v 1.36 1997/01/03 11:39:27 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: dhcp.c,v 1.37 1997/02/18 14:28:53 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -362,7 +362,8 @@ void nak_lease (packet, cip)
                (unsigned char *)0;
 
        /* Set up the option buffer... */
-       cons_options (packet, &outgoing, options, 0, 0);
+       outgoing.packet_length =
+               cons_options (packet, outgoing.raw, options, 0, 0);
 
 /*     memset (&raw.ciaddr, 0, sizeof raw.ciaddr);*/
        memcpy (&raw.siaddr, server_identifier.iabuf, 4);
@@ -416,7 +417,7 @@ void nak_lease (packet, cip)
           Otherwise, broadcast it on the local network. */
        if (raw.giaddr.s_addr) {
                to.sin_addr = raw.giaddr;
-               to.sin_port = server_port;
+               to.sin_port = local_port;
 
                if (outgoing.packet_length < BOOTP_MIN_LEN)
                        outgoing.packet_length = BOOTP_MIN_LEN;
@@ -812,9 +813,11 @@ void ack_lease (packet, lease, offer, when)
        if (packet -> options [DHO_HOST_NAME].data &&
            packet -> options [DHO_HOST_NAME].data
            [packet -> options [DHO_HOST_NAME].len - 1] == '\0')
-               cons_options (packet, &outgoing, options, bufs, 1);
+               outgoing.packet_length =
+                       cons_options (packet, outgoing.raw, options, bufs, 1);
        else
-               cons_options (packet, &outgoing, options, bufs, 0);
+               outgoing.packet_length =
+                       cons_options (packet, outgoing.raw, options, bufs, 0);
        if (!offer && outgoing.packet_length < BOOTP_MIN_LEN)
                outgoing.packet_length = BOOTP_MIN_LEN;
 
@@ -881,7 +884,7 @@ void ack_lease (packet, lease, offer, when)
        /* If this was gatewayed, send it back to the gateway... */
        if (raw.giaddr.s_addr) {
                to.sin_addr = raw.giaddr;
-               to.sin_port = server_port;
+               to.sin_port = local_port;
 
                if (outgoing.packet_length < BOOTP_MIN_LEN)
                        outgoing.packet_length = BOOTP_MIN_LEN;
@@ -901,7 +904,7 @@ void ack_lease (packet, lease, offer, when)
        } else if (raw.ciaddr.s_addr && offer == DHCPACK &&
                   !(raw.flags & htons (BOOTP_BROADCAST))) {
                to.sin_addr = packet -> raw -> ciaddr;
-               to.sin_port = htons (ntohs (server_port) + 1); /* XXX */
+               to.sin_port = remote_port; /* XXX */
 
 #ifdef USE_FALLBACK
                result = send_fallback (&fallback_interface,
@@ -915,7 +918,7 @@ void ack_lease (packet, lease, offer, when)
        /* Otherwise, broadcast it on the local network. */
        } else {
                to.sin_addr.s_addr = htonl (INADDR_BROADCAST);
-               to.sin_port = htons (ntohs (server_port) + 1); /* XXX */
+               to.sin_port = remote_port; /* XXX */
        }
 
 
index 53dd0224b18da308dc7a82e6d98a5ac52d6e527e..4f73c90041ce71182a7cc8f34f1b3c663c9fa2c4 100644 (file)
--- a/options.c
+++ b/options.c
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: options.c,v 1.19 1996/09/11 05:52:18 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: options.c,v 1.20 1997/02/18 14:28:54 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #define DHCP_OPTION_DATA
@@ -155,9 +155,9 @@ void parse_option_buffer (packet, buffer, length)
    three seperate buffers if needed.  This allows us to cons up a set
    of vendor options using the same routine. */
 
-void cons_options (inpacket, outpacket, options, overload, terminate)
+int cons_options (inpacket, outpacket, options, overload, terminate)
        struct packet *inpacket;
-       struct packet *outpacket;
+       struct dhcp_packet *outpacket;
        struct tree_cache **options;
        int overload;   /* Overload flags that may be set. */
        int terminate;
@@ -168,6 +168,7 @@ void cons_options (inpacket, outpacket, options, overload, terminate)
        int main_buffer_size;
        int mainbufix, bufix;
        int option_size;
+       int length;
 
        /* If the client has provided a maximum DHCP message size,
           use that.   Otherwise, we use the default MTU size (576 bytes). */
@@ -225,7 +226,7 @@ void cons_options (inpacket, outpacket, options, overload, terminate)
                                     terminate);
 
        /* Put the cookie up front... */
-       memcpy (outpacket -> raw -> options, DHCP_OPTIONS_COOKIE, 4);
+       memcpy (outpacket -> options, DHCP_OPTIONS_COOKIE, 4);
        mainbufix = 4;
 
        /* If we're going to have to overload, store the overload
@@ -233,57 +234,57 @@ void cons_options (inpacket, outpacket, options, overload, terminate)
           whole thing in the packet's option buffer and leave it at
           that. */
        if (option_size <= main_buffer_size - mainbufix) {
-               memcpy (&outpacket -> raw -> options [mainbufix],
+               memcpy (&outpacket -> options [mainbufix],
                        buffer, option_size);
                mainbufix += option_size;
                if (mainbufix < main_buffer_size)
-                       outpacket -> raw -> options [mainbufix++]
+                       outpacket -> options [mainbufix++]
                                = DHO_END;
-               outpacket -> packet_length = DHCP_FIXED_NON_UDP + mainbufix;
+               length = DHCP_FIXED_NON_UDP + mainbufix;
        } else {
-               outpacket -> raw -> options [mainbufix++] =
+               outpacket -> options [mainbufix++] =
                        DHO_DHCP_OPTION_OVERLOAD;
-               outpacket -> raw -> options [mainbufix++] = 1;
+               outpacket -> options [mainbufix++] = 1;
                if (option_size > main_buffer_size - mainbufix + DHCP_FILE_LEN)
-                       outpacket -> raw -> options [mainbufix++] = 3;
+                       outpacket -> options [mainbufix++] = 3;
                else
-                       outpacket -> raw -> options [mainbufix++] = 1;
+                       outpacket -> options [mainbufix++] = 1;
 
-               memcpy (&outpacket -> raw -> options [mainbufix],
+               memcpy (&outpacket -> options [mainbufix],
                        buffer, main_buffer_size - mainbufix);
                bufix = main_buffer_size - mainbufix;
-               outpacket -> packet_length = DHCP_FIXED_NON_UDP + mainbufix;
+               length = DHCP_FIXED_NON_UDP + mainbufix;
                if (overload & 1) {
                        if (option_size - bufix <= DHCP_FILE_LEN) {
-                               memcpy (outpacket -> raw -> file,
+                               memcpy (outpacket -> file,
                                        &buffer [bufix], option_size - bufix);
                                mainbufix = option_size - bufix;
                                if (mainbufix < DHCP_FILE_LEN)
-                                       outpacket -> raw -> file [mainbufix++]
+                                       outpacket -> file [mainbufix++]
                                                = DHO_END;
                                while (mainbufix < DHCP_FILE_LEN)
-                                       outpacket -> raw -> file [mainbufix++]
+                                       outpacket -> file [mainbufix++]
                                                = DHO_PAD;
                        } else {
-                               memcpy (outpacket -> raw -> file,
+                               memcpy (outpacket -> file,
                                        &buffer [bufix], DHCP_FILE_LEN);
                                bufix += DHCP_FILE_LEN;
                        }
                }
                if ((overload & 2) && option_size < bufix) {
-                       memcpy (outpacket -> raw -> sname,
+                       memcpy (outpacket -> sname,
                                &buffer [bufix], option_size - bufix);
 
                        mainbufix = option_size - bufix;
                        if (mainbufix < DHCP_SNAME_LEN)
-                               outpacket -> raw -> file [mainbufix++]
+                               outpacket -> file [mainbufix++]
                                        = DHO_END;
                        while (mainbufix < DHCP_SNAME_LEN)
-                               outpacket -> raw -> file [mainbufix++]
+                               outpacket -> file [mainbufix++]
                                        = DHO_PAD;
                }
        }
-       return;
+       return length;
 }
 
 /* Store all the requested options into the requested buffer. */
index d2855705160191ba70ce9963d924068496c88195..c98c45df9f6d4d3681500c6b6bcb94e43dfc7a1c 100644 (file)
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: bootp.c,v 1.21 1996/12/31 02:00:33 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: bootp.c,v 1.22 1997/02/18 14:28:54 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -193,7 +193,8 @@ void bootp (packet)
        /* Pack the options into the buffer.   Unlike DHCP, we can't
           pack options into the filename and server name buffers. */
 
-       cons_options (packet, &outgoing, options, 0, 0);
+       outgoing.packet_length =
+               cons_options (packet, outgoing.raw, options, 0, 0);
        if (outgoing.packet_length < BOOTP_MIN_LEN)
                outgoing.packet_length = BOOTP_MIN_LEN;
 
index 39e2969d8e028426b5949c16866715869b7d50c2..3be7e5f9ac57c8729157edf1e8cb0cbc885ca776 100644 (file)
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: dhcp.c,v 1.36 1997/01/03 11:39:27 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: dhcp.c,v 1.37 1997/02/18 14:28:53 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -362,7 +362,8 @@ void nak_lease (packet, cip)
                (unsigned char *)0;
 
        /* Set up the option buffer... */
-       cons_options (packet, &outgoing, options, 0, 0);
+       outgoing.packet_length =
+               cons_options (packet, outgoing.raw, options, 0, 0);
 
 /*     memset (&raw.ciaddr, 0, sizeof raw.ciaddr);*/
        memcpy (&raw.siaddr, server_identifier.iabuf, 4);
@@ -416,7 +417,7 @@ void nak_lease (packet, cip)
           Otherwise, broadcast it on the local network. */
        if (raw.giaddr.s_addr) {
                to.sin_addr = raw.giaddr;
-               to.sin_port = server_port;
+               to.sin_port = local_port;
 
                if (outgoing.packet_length < BOOTP_MIN_LEN)
                        outgoing.packet_length = BOOTP_MIN_LEN;
@@ -812,9 +813,11 @@ void ack_lease (packet, lease, offer, when)
        if (packet -> options [DHO_HOST_NAME].data &&
            packet -> options [DHO_HOST_NAME].data
            [packet -> options [DHO_HOST_NAME].len - 1] == '\0')
-               cons_options (packet, &outgoing, options, bufs, 1);
+               outgoing.packet_length =
+                       cons_options (packet, outgoing.raw, options, bufs, 1);
        else
-               cons_options (packet, &outgoing, options, bufs, 0);
+               outgoing.packet_length =
+                       cons_options (packet, outgoing.raw, options, bufs, 0);
        if (!offer && outgoing.packet_length < BOOTP_MIN_LEN)
                outgoing.packet_length = BOOTP_MIN_LEN;
 
@@ -881,7 +884,7 @@ void ack_lease (packet, lease, offer, when)
        /* If this was gatewayed, send it back to the gateway... */
        if (raw.giaddr.s_addr) {
                to.sin_addr = raw.giaddr;
-               to.sin_port = server_port;
+               to.sin_port = local_port;
 
                if (outgoing.packet_length < BOOTP_MIN_LEN)
                        outgoing.packet_length = BOOTP_MIN_LEN;
@@ -901,7 +904,7 @@ void ack_lease (packet, lease, offer, when)
        } else if (raw.ciaddr.s_addr && offer == DHCPACK &&
                   !(raw.flags & htons (BOOTP_BROADCAST))) {
                to.sin_addr = packet -> raw -> ciaddr;
-               to.sin_port = htons (ntohs (server_port) + 1); /* XXX */
+               to.sin_port = remote_port; /* XXX */
 
 #ifdef USE_FALLBACK
                result = send_fallback (&fallback_interface,
@@ -915,7 +918,7 @@ void ack_lease (packet, lease, offer, when)
        /* Otherwise, broadcast it on the local network. */
        } else {
                to.sin_addr.s_addr = htonl (INADDR_BROADCAST);
-               to.sin_port = htons (ntohs (server_port) + 1); /* XXX */
+               to.sin_port = remote_port; /* XXX */
        }