Merge branch 'feature/modify_lwip_port_according_to_lwip_2_0_3' into 'feature/update_lwip'

feat(lwip): Modify lwip port according to the lwip library update

See merge request sdk/ESP8266_RTOS_SDK!115
This commit is contained in:
Wu Jian Gang
2018-05-02 16:46:40 +08:00
6 changed files with 28 additions and 43 deletions

View File

@ -35,10 +35,9 @@ extern struct netif *esp_netif[2];
//static u8_t old_xid[4] = {0};
static const u32_t magic_cookie ICACHE_RODATA_ATTR STORE_ATTR = 0x63538263;
static struct udp_pcb* pcb_dhcps = NULL;
static struct ip_addr broadcast_dhcps;
static struct ip_addr server_address;
static struct ip_addr client_address;//added
static struct ip_addr client_address_plus;
static struct ip4_addr server_address;
static struct ip4_addr client_address;//added
static struct ip4_addr client_address_plus;
static struct dhcps_lease dhcps_lease;
//static bool dhcps_lease_flag = true;
@ -150,7 +149,7 @@ static u8_t* add_msg_type(u8_t* optptr, u8_t type)
///////////////////////////////////////////////////////////////////////////////////
static u8_t* add_offer_options(u8_t* optptr)
{
struct ip_addr ipadd;
struct ip4_addr ipadd;
ipadd.addr = *((u32_t*) &server_address);
@ -267,7 +266,7 @@ static u8_t* add_end(u8_t* optptr)
///////////////////////////////////////////////////////////////////////////////////
static void create_msg(struct dhcps_msg* m)
{
struct ip_addr client;
struct ip4_addr client;
client.addr = *((uint32_t*) &client_address);
@ -355,10 +354,10 @@ static void send_offer(struct dhcps_msg* m)
}
#if DHCPS_DEBUG
SendOffer_err_t = udp_sendto(pcb_dhcps, p, &broadcast_dhcps, DHCPS_CLIENT_PORT);
SendOffer_err_t = udp_sendto(pcb_dhcps, p, IP4_ADDR_BROADCAST, DHCPS_CLIENT_PORT);
os_printf("dhcps: send_offer>>udp_sendto result %x\n", SendOffer_err_t);
#else
udp_sendto(pcb_dhcps, p, &broadcast_dhcps, DHCPS_CLIENT_PORT);
udp_sendto(pcb_dhcps, p, IP4_ADDR_BROADCAST, DHCPS_CLIENT_PORT);
#endif
if (p->ref != 0) {
@ -431,10 +430,10 @@ static void send_nak(struct dhcps_msg* m)
}
#if DHCPS_DEBUG
SendNak_err_t = udp_sendto(pcb_dhcps, p, &broadcast_dhcps, DHCPS_CLIENT_PORT);
SendNak_err_t = udp_sendto(pcb_dhcps, p, IP4_ADDR_BROADCAST, DHCPS_CLIENT_PORT);
os_printf("dhcps: send_nak>>udp_sendto result %x\n", SendNak_err_t);
#else
udp_sendto(pcb_dhcps, p, &broadcast_dhcps, DHCPS_CLIENT_PORT);
udp_sendto(pcb_dhcps, p, IP4_ADDR_BROADCAST, DHCPS_CLIENT_PORT);
#endif
if (p->ref != 0) {
@ -508,10 +507,10 @@ static void send_ack(struct dhcps_msg* m)
}
#if DHCPS_DEBUG
SendAck_err_t = udp_sendto(pcb_dhcps, p, &broadcast_dhcps, DHCPS_CLIENT_PORT);
SendAck_err_t = udp_sendto(pcb_dhcps, p, IP4_ADDR_BROADCAST, DHCPS_CLIENT_PORT);
os_printf("dhcps: send_ack>>udp_sendto result %x\n", SendAck_err_t);
#else
udp_sendto(pcb_dhcps, p, &broadcast_dhcps, DHCPS_CLIENT_PORT);
udp_sendto(pcb_dhcps, p, IP4_ADDR_BROADCAST, DHCPS_CLIENT_PORT);
#endif
if (p->ref != 0) {
@ -533,7 +532,7 @@ static void send_ack(struct dhcps_msg* m)
///////////////////////////////////////////////////////////////////////////////////
static u8_t parse_options(u8_t* optptr, s16_t len)
{
struct ip_addr client;
struct ip4_addr client;
bool is_dhcp_parse_end = false;
struct dhcps_state s;
@ -663,14 +662,14 @@ static s16_t parse_msg(struct dhcps_msg* m, u16_t len)
/*
* <20><>¼<EFBFBD><C2BC><EFBFBD>ε<EFBFBD>xid<69>ţ<EFBFBD>ͬʱ<CDAC><CAB1><EFBFBD><EFBFBD><EFBFBD>IP<49><50><EFBFBD><EFBFBD>
*/
struct ip_addr addr_tmp;
struct ip4_addr addr_tmp;
// memcpy((char *)old_xid, (char *)m->xid, sizeof(m->xid));
// {
struct dhcps_pool* pdhcps_pool = NULL;
list_node* pnode = NULL;
list_node* pback_node = NULL;
struct ip_addr first_address;
struct ip4_addr first_address;
bool flag = false;
// POOL_START:
@ -747,7 +746,7 @@ static s16_t parse_msg(struct dhcps_msg* m, u16_t len)
POOL_CHECK:
if ((client_address.addr > dhcps_lease.end_ip.addr) || (ip_addr_isany(&client_address))) {
if ((client_address.addr > dhcps_lease.end_ip.addr) || (ip4_addr_isany(&client_address))) {
if (pnode != NULL) {
node_remove_from_list(&plist, pnode);
os_free(pnode);
@ -814,7 +813,7 @@ POOL_CHECK:
static void handle_dhcp(void* arg,
struct udp_pcb* pcb,
struct pbuf* p,
struct ip_addr* addr,
const ip_addr_t* addr,
u16_t port)
{
struct dhcps_msg* pmsg_dhcps = NULL;
@ -972,10 +971,8 @@ static void wifi_softap_init_dhcps_lease(u32_t ip)
///////////////////////////////////////////////////////////////////////////////////
void dhcps_start(struct ip_info* info)
{
struct netif* apnetif = esp_netif[0x01];
if (apnetif->dhcps_pcb != NULL) {
udp_remove(apnetif->dhcps_pcb);
if (pcb_dhcps != NULL) {
udp_remove(pcb_dhcps);
}
pcb_dhcps = udp_new();
@ -984,10 +981,6 @@ void dhcps_start(struct ip_info* info)
os_printf("dhcps_start(): could not obtain pcb\n");
}
apnetif->dhcps_pcb = pcb_dhcps;
IP4_ADDR(&broadcast_dhcps, 255, 255, 255, 255);
server_address = info->ip;
wifi_softap_init_dhcps_lease(server_address.addr);
client_address_plus.addr = dhcps_lease.start_ip.addr;
@ -1001,14 +994,12 @@ void dhcps_start(struct ip_info* info)
void dhcps_stop(void)
{
struct netif* apnetif = esp_netif[0x01];
udp_disconnect(pcb_dhcps);
// dhcps_lease_flag = true;
if (apnetif->dhcps_pcb != NULL) {
udp_remove(apnetif->dhcps_pcb);
apnetif->dhcps_pcb = NULL;
if (pcb_dhcps != NULL) {
udp_remove(pcb_dhcps);
pcb_dhcps = NULL;
}
//udp_remove(pcb_dhcps);

View File

@ -27,8 +27,8 @@ typedef struct dhcps_msg {
#ifndef LWIP_OPEN_SRC
struct dhcps_lease {
bool enable;
struct ip_addr start_ip;
struct ip_addr end_ip;
struct ip4_addr start_ip;
struct ip4_addr end_ip;
};
enum dhcps_offer_option {
@ -39,7 +39,7 @@ enum dhcps_offer_option {
#endif
struct dhcps_pool {
struct ip_addr ip;
struct ip4_addr ip;
u8_t mac[6];
u32_t lease_timer;
};

View File

@ -9,7 +9,7 @@
#define SNTP_TIME_H_
#include "lwip/opt.h"
#include "lwip/timers.h"
#include "lwip/timeouts.h"
#define SECSPERMIN 60L
#define MINSPERHOUR 60L

View File

@ -38,8 +38,7 @@
#define EFAULT 14
#define ERRNO
#define LWIP_PROVIDE_ERRNO
#define LWIP_ERRNO_INCLUDE "sys/errno.h"
#if (1)
#define BYTE_ORDER LITTLE_ENDIAN
@ -47,7 +46,6 @@
#define BYTE_ORDER BIG_ENDIAN
#endif
typedef unsigned long mem_ptr_t;
typedef int sys_prot_t;
#define S16_F "d"

View File

@ -346,7 +346,7 @@ sys_mutex_free(sys_mutex_t *pxMutex)
u32_t
sys_now(void)
{
return xTaskGetTickCount();
return xTaskGetTickCount() * portTICK_RATE_MS;
}
/*-----------------------------------------------------------------------------------*/

View File

@ -46,7 +46,7 @@ static void low_level_init(struct netif* netif)
/* device capabilities */
/* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP | NETIF_FLAG_UP;
#if LWIP_IGMP
netif->flags |= NETIF_FLAG_IGMP;
@ -289,7 +289,6 @@ int8_t ethernetif_init(struct netif* netif)
* The last argument should be replaced with your link speed, in units
* of bits per second.
*/
NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, LINK_SPEED_OF_YOUR_NETIF_IN_BPS);
netif->name[0] = IFNAME0;
netif->name[1] = IFNAME1;
@ -303,9 +302,6 @@ int8_t ethernetif_init(struct netif* netif)
#endif /* LWIP_IPV6 */
netif->linkoutput = low_level_output;
extern void wifi_station_dhcpc_event(void);
netif->dhcp_event = wifi_station_dhcpc_event;
/* initialize the hardware */
low_level_init(netif);