mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
lwip: Add client's MAC addr to dhcp server cb
* Extended storage for staipassigned events to pass client's MAC address. * Added client's MAC to dhcp server callback * Posting the staipassigned events with clients IP and MAC address
This commit is contained in:
parent
ef5cfb217c
commit
e3d71c984a
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -136,6 +136,7 @@ typedef struct {
|
|||||||
/** Event structure for IP_EVENT_AP_STAIPASSIGNED event */
|
/** Event structure for IP_EVENT_AP_STAIPASSIGNED event */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
esp_ip4_addr_t ip; /*!< IP address which was assigned to the station */
|
esp_ip4_addr_t ip; /*!< IP address which was assigned to the station */
|
||||||
|
uint8_t mac[6]; /*!< MAC address of the connected client */
|
||||||
} ip_event_ap_staipassigned_t;
|
} ip_event_ap_staipassigned_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -764,14 +764,14 @@ esp_err_t esp_netif_recv_hook_detach(esp_netif_t *esp_netif)
|
|||||||
#endif // CONFIG_ESP_NETIF_L2_TAP
|
#endif // CONFIG_ESP_NETIF_L2_TAP
|
||||||
|
|
||||||
#if ESP_DHCPS
|
#if ESP_DHCPS
|
||||||
static void esp_netif_dhcps_cb(u8_t client_ip[4])
|
static void esp_netif_dhcps_cb(uint8_t ip[4], uint8_t mac[6])
|
||||||
{
|
{
|
||||||
ESP_LOGI(TAG, "DHCP server assigned IP to a station, IP is: %d.%d.%d.%d",
|
ip_event_ap_staipassigned_t evt = { 0 };
|
||||||
client_ip[0], client_ip[1], client_ip[2], client_ip[3]);
|
memcpy((char *)&evt.ip.addr, (char *)ip, sizeof(evt.ip.addr));
|
||||||
ip_event_ap_staipassigned_t evt;
|
memcpy((char *)&evt.mac, mac, sizeof(evt.mac));
|
||||||
|
ESP_LOGI(TAG, "DHCP server assigned IP to a station, IP is: " IPSTR, IP2STR(&evt.ip));
|
||||||
|
ESP_LOGD(TAG, "Client's MAC: %x:%x:%x:%x:%x:%x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||||
|
|
||||||
memset(&evt, 0, sizeof(ip_event_ap_staipassigned_t));
|
|
||||||
memcpy((char *)&evt.ip.addr, (char *)client_ip, sizeof(evt.ip.addr));
|
|
||||||
int ret = esp_event_send_internal(IP_EVENT, IP_EVENT_AP_STAIPASSIGNED, &evt, sizeof(evt), 0);
|
int ret = esp_event_send_internal(IP_EVENT, IP_EVENT_AP_STAIPASSIGNED, &evt, sizeof(evt), 0);
|
||||||
if (ESP_OK != ret) {
|
if (ESP_OK != ret) {
|
||||||
ESP_LOGE(TAG, "dhcps cb: failed to post IP_EVENT_AP_STAIPASSIGNED (%x)", ret);
|
ESP_LOGE(TAG, "dhcps cb: failed to post IP_EVENT_AP_STAIPASSIGNED (%x)", ret);
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2015-2022 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 "esp_common.h"
|
//#include "esp_common.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -690,7 +682,7 @@ static void send_ack(struct dhcps_msg *m, u16_t len)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (SendAck_err_t == ERR_OK) {
|
if (SendAck_err_t == ERR_OK) {
|
||||||
dhcps_cb(m->yiaddr);
|
dhcps_cb(m->yiaddr, m->chaddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->ref != 0) {
|
if (p->ref != 0) {
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2015-2022 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.
|
|
||||||
#ifndef __DHCPS_H__
|
#ifndef __DHCPS_H__
|
||||||
#define __DHCPS_H__
|
#define __DHCPS_H__
|
||||||
|
|
||||||
@ -74,7 +66,7 @@ typedef struct {
|
|||||||
dhcps_lease_t dhcps_poll;
|
dhcps_lease_t dhcps_poll;
|
||||||
} dhcps_options_t;
|
} dhcps_options_t;
|
||||||
|
|
||||||
typedef void (*dhcps_cb_t)(u8_t client_ip[4]);
|
typedef void (*dhcps_cb_t)(u8_t client_ip[4], u8_t client_mac[6]);
|
||||||
|
|
||||||
static inline bool dhcps_router_enabled (dhcps_offer_t offer)
|
static inline bool dhcps_router_enabled (dhcps_offer_t offer)
|
||||||
{
|
{
|
||||||
|
@ -1224,11 +1224,9 @@ components/linux/include/sys/queue.h
|
|||||||
components/log/esp_log_private.h
|
components/log/esp_log_private.h
|
||||||
components/log/host_test/log_test/main/log_test.cpp
|
components/log/host_test/log_test/main/log_test.cpp
|
||||||
components/log/log_linux.c
|
components/log/log_linux.c
|
||||||
components/lwip/apps/dhcpserver/dhcpserver.c
|
|
||||||
components/lwip/apps/ping/esp_ping.c
|
components/lwip/apps/ping/esp_ping.c
|
||||||
components/lwip/apps/ping/ping.c
|
components/lwip/apps/ping/ping.c
|
||||||
components/lwip/apps/sntp/sntp.c
|
components/lwip/apps/sntp/sntp.c
|
||||||
components/lwip/include/apps/dhcpserver/dhcpserver.h
|
|
||||||
components/lwip/include/apps/dhcpserver/dhcpserver_options.h
|
components/lwip/include/apps/dhcpserver/dhcpserver_options.h
|
||||||
components/lwip/include/apps/esp_ping.h
|
components/lwip/include/apps/esp_ping.h
|
||||||
components/lwip/include/apps/ping/ping.h
|
components/lwip/include/apps/ping/ping.h
|
||||||
|
Loading…
Reference in New Issue
Block a user