diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-15 00:34:04 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-15 00:34:04 +0200 |
commit | 40a327aeae87ab53f42a5669e8c16c4615fb09c7 (patch) | |
tree | ec117927bb14f8c5ad73246556efbfce00147163 | |
parent | 52c4b7ac3bbc216cc5fd40cf150517f36e7bb87a (diff) | |
download | busybox-w32-40a327aeae87ab53f42a5669e8c16c4615fb09c7.tar.gz busybox-w32-40a327aeae87ab53f42a5669e8c16c4615fb09c7.tar.bz2 busybox-w32-40a327aeae87ab53f42a5669e8c16c4615fb09c7.zip |
udhcpc: send client-id option in DHCPDECLINE
function old new delta
add_serverid_and_clientid_options - 46 +46
send_decline 88 83 -5
perform_release 200 159 -41
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 46/-46) Total: 0 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/udhcp/dhcpc.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 4e3d8ca5e..b80ea2f40 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -663,6 +663,24 @@ static void add_client_options(struct dhcp_packet *packet) | |||
663 | // ...add (DHCP_VENDOR, "udhcp "BB_VER) opt... | 663 | // ...add (DHCP_VENDOR, "udhcp "BB_VER) opt... |
664 | } | 664 | } |
665 | 665 | ||
666 | static void add_serverid_and_clientid_options(struct dhcp_packet *packet, uint32_t server) | ||
667 | { | ||
668 | struct option_set *ci; | ||
669 | |||
670 | udhcp_add_simple_option(packet, DHCP_SERVER_ID, server); | ||
671 | |||
672 | /* RFC 2131 section 2: | ||
673 | * If the client uses a 'client identifier' in one message, | ||
674 | * it MUST use that same identifier in all subsequent messages. | ||
675 | * section 3.1.6: | ||
676 | * If the client used a 'client identifier' when it obtained the lease, | ||
677 | * it MUST use the same 'client identifier' in the DHCPRELEASE message. | ||
678 | */ | ||
679 | ci = udhcp_find_option(client_data.options, DHCP_CLIENT_ID); | ||
680 | if (ci) | ||
681 | udhcp_add_binary_option(packet, ci->data); | ||
682 | } | ||
683 | |||
666 | /* RFC 2131 | 684 | /* RFC 2131 |
667 | * 4.4.4 Use of broadcast and unicast | 685 | * 4.4.4 Use of broadcast and unicast |
668 | * | 686 | * |
@@ -759,7 +777,7 @@ static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requeste | |||
759 | udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server); | 777 | udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server); |
760 | 778 | ||
761 | /* Add options: maxsize, | 779 | /* Add options: maxsize, |
762 | * "param req" option according to -O, and options specified with -x | 780 | * "param req" option according to -O, options specified with -x |
763 | */ | 781 | */ |
764 | add_client_options(&packet); | 782 | add_client_options(&packet); |
765 | 783 | ||
@@ -803,7 +821,7 @@ static NOINLINE int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr) | |||
803 | packet.ciaddr = ciaddr; | 821 | packet.ciaddr = ciaddr; |
804 | 822 | ||
805 | /* Add options: maxsize, | 823 | /* Add options: maxsize, |
806 | * "param req" option according to -O, and options specified with -x | 824 | * "param req" option according to -O, options specified with -x |
807 | */ | 825 | */ |
808 | add_client_options(&packet); | 826 | add_client_options(&packet); |
809 | 827 | ||
@@ -841,9 +859,7 @@ static NOINLINE int send_decline(/*uint32_t xid,*/ uint32_t server, uint32_t req | |||
841 | /* DHCPDECLINE uses "requested ip", not ciaddr, to store offered IP */ | 859 | /* DHCPDECLINE uses "requested ip", not ciaddr, to store offered IP */ |
842 | udhcp_add_simple_option(&packet, DHCP_REQUESTED_IP, requested); | 860 | udhcp_add_simple_option(&packet, DHCP_REQUESTED_IP, requested); |
843 | 861 | ||
844 | udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server); | 862 | add_serverid_and_clientid_options(&packet, server); |
845 | |||
846 | //TODO: add client-id opt? | ||
847 | 863 | ||
848 | bb_simple_info_msg("broadcasting decline"); | 864 | bb_simple_info_msg("broadcasting decline"); |
849 | return raw_bcast_from_client_data_ifindex(&packet, INADDR_ANY); | 865 | return raw_bcast_from_client_data_ifindex(&packet, INADDR_ANY); |
@@ -856,7 +872,6 @@ ALWAYS_INLINE /* one caller, help compiler to use this fact */ | |||
856 | int send_release(uint32_t server, uint32_t ciaddr) | 872 | int send_release(uint32_t server, uint32_t ciaddr) |
857 | { | 873 | { |
858 | struct dhcp_packet packet; | 874 | struct dhcp_packet packet; |
859 | struct option_set *ci; | ||
860 | 875 | ||
861 | /* Fill in: op, htype, hlen, cookie, chaddr, random xid fields, | 876 | /* Fill in: op, htype, hlen, cookie, chaddr, random xid fields, |
862 | * message type option: | 877 | * message type option: |
@@ -866,15 +881,7 @@ int send_release(uint32_t server, uint32_t ciaddr) | |||
866 | /* DHCPRELEASE uses ciaddr, not "requested ip", to store IP being released */ | 881 | /* DHCPRELEASE uses ciaddr, not "requested ip", to store IP being released */ |
867 | packet.ciaddr = ciaddr; | 882 | packet.ciaddr = ciaddr; |
868 | 883 | ||
869 | udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server); | 884 | add_serverid_and_clientid_options(&packet, server); |
870 | |||
871 | /* RFC 2131 section 3.1.6: | ||
872 | * If the client used a 'client identifier' when it obtained the lease, | ||
873 | * it MUST use the same 'client identifier' in the DHCPRELEASE message. | ||
874 | */ | ||
875 | ci = udhcp_find_option(client_data.options, DHCP_CLIENT_ID); | ||
876 | if (ci) | ||
877 | udhcp_add_binary_option(&packet, ci->data); | ||
878 | 885 | ||
879 | bb_info_msg("sending %s", "release"); | 886 | bb_info_msg("sending %s", "release"); |
880 | /* Note: normally we unicast here since "server" is not zero. | 887 | /* Note: normally we unicast here since "server" is not zero. |