lwip/dhcp: add configure for enable vendor class identify option

Closes https://github.com/espressif/esp-idf/issues/6786
This commit is contained in:
Liu Han 2021-06-04 16:43:32 +08:00 committed by yuanjm
parent 2d3ec44011
commit 89873937eb
4 changed files with 31 additions and 42 deletions

View File

@ -79,6 +79,8 @@ typedef enum{
ESP_NETIF_REQUESTED_IP_ADDRESS = 50, /**< Request specific IP address */ ESP_NETIF_REQUESTED_IP_ADDRESS = 50, /**< Request specific IP address */
ESP_NETIF_IP_ADDRESS_LEASE_TIME = 51, /**< Request IP address lease time */ ESP_NETIF_IP_ADDRESS_LEASE_TIME = 51, /**< Request IP address lease time */
ESP_NETIF_IP_REQUEST_RETRY_TIME = 52, /**< Request IP address retry counter */ ESP_NETIF_IP_REQUEST_RETRY_TIME = 52, /**< Request IP address retry counter */
ESP_NETIF_VENDOR_CLASS_IDENTIFIER = 60, /**< Vendor Class Identifier of a DHCP client */
ESP_NETIF_VENDOR_SPECIFIC_INFO = 43, /**< Vendor Specific Information of a DHCP server */
} esp_netif_dhcp_option_id_t; } esp_netif_dhcp_option_id_t;
/** IP event declarations */ /** IP event declarations */

View File

@ -1,16 +1,8 @@
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD /*
// * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
// Licensed under the Apache License, Version 2.0 (the "License"); *
// you may not use this file except in compliance with the License. * SPDX-License-Identifier: Apache-2.0
// You may obtain a copy of the License at */
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <string.h> #include <string.h>
#include <lwip/ip_addr.h> #include <lwip/ip_addr.h>
@ -1889,9 +1881,12 @@ esp_err_t esp_netif_dhcpc_option(esp_netif_t *esp_netif, esp_netif_dhcp_option_m
*(uint8_t *)opt_val = dhcp->tries; *(uint8_t *)opt_val = dhcp->tries;
} }
break; break;
#if ESP_DHCP && !ESP_DHCP_DISABLE_VENDOR_CLASS_IDENTIFIER
case ESP_NETIF_VENDOR_SPECIFIC_INFO:
return dhcp_get_vendor_specific_information(opt_len, opt_val);
#endif
default: default:
return ESP_ERR_ESP_NETIF_INVALID_PARAMS; return ESP_ERR_ESP_NETIF_INVALID_PARAMS;
break;
} }
} else if (opt_op == ESP_NETIF_OP_SET) { } else if (opt_op == ESP_NETIF_OP_SET) {
if (esp_netif->dhcpc_status == ESP_NETIF_DHCP_STARTED) { if (esp_netif->dhcpc_status == ESP_NETIF_DHCP_STARTED) {
@ -1903,9 +1898,12 @@ esp_err_t esp_netif_dhcpc_option(esp_netif_t *esp_netif, esp_netif_dhcp_option_m
dhcp->tries = *(uint8_t *)opt_val; dhcp->tries = *(uint8_t *)opt_val;
} }
break; break;
#if ESP_DHCP && !ESP_DHCP_DISABLE_VENDOR_CLASS_IDENTIFIER
case ESP_NETIF_VENDOR_CLASS_IDENTIFIER:
return dhcp_set_vendor_class_identifier(opt_len, opt_val);
#endif
default: default:
return ESP_ERR_ESP_NETIF_INVALID_PARAMS; return ESP_ERR_ESP_NETIF_INVALID_PARAMS;
break;
} }
} else { } else {
return ESP_ERR_ESP_NETIF_INVALID_PARAMS; return ESP_ERR_ESP_NETIF_INVALID_PARAMS;

View File

@ -258,6 +258,13 @@ menu "LWIP"
in the DHCP packets as an option 61) in the DHCP packets as an option 61)
Set this option to "y" in order to exclude option 61 from DHCP packets. Set this option to "y" in order to exclude option 61 from DHCP packets.
config LWIP_DHCP_DISABLE_VENDOR_CLASS_ID
bool "DHCP: Disable Use of vendor class identification"
default y
help
This option could be used to disable DHCP client vendor class identification.
Set this option to "y" in order to exclude option 60 from DHCP packets.
config LWIP_DHCP_RESTORE_LAST_IP config LWIP_DHCP_RESTORE_LAST_IP
bool "DHCP: Restore last IP obtained from DHCP server" bool "DHCP: Restore last IP obtained from DHCP server"
default n default n

View File

@ -1,34 +1,11 @@
/* /*
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. * SPDX-FileCopyrightText: 2001-2003 Swedish Institute of Computer Science
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * SPDX-License-Identifier: BSD-3-Clause
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Simon Goldschmidt
* *
* SPDX-FileContributor: 2015-2021 Espressif Systems (Shanghai) CO LTD
*/ */
#ifndef __LWIPOPTS_H__ #ifndef __LWIPOPTS_H__
#define __LWIPOPTS_H__ #define __LWIPOPTS_H__
@ -272,6 +249,11 @@
*/ */
#define DHCP_OPTIONS_LEN CONFIG_LWIP_DHCP_OPTIONS_LEN #define DHCP_OPTIONS_LEN CONFIG_LWIP_DHCP_OPTIONS_LEN
/**
* LWIP_DHCP_DISABLE_VENDOR_CLASS_ID==1: Do not add option 60 (Vendor Class Identifier) to DHCP packets
*/
#define ESP_DHCP_DISABLE_VENDOR_CLASS_IDENTIFIER CONFIG_LWIP_DHCP_DISABLE_VENDOR_CLASS_ID
/* /*
------------------------------------ ------------------------------------
---------- AUTOIP options ---------- ---------- AUTOIP options ----------