add OpenHarmony 1.0 baseline

This commit is contained in:
wenjun
2020-09-08 10:21:39 +08:00
parent 94f5f466b4
commit 6df931fc98
736 changed files with 111817 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# 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. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "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 COPYRIGHT HOLDER OR
# CONTRIBUTORS 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.
include $(LITEOSTOPDIR)/config.mk
ifeq ($(LWIPDIR), )
$(error "LWIPDIR not defined")
endif
include $(LWIPDIR)/Filelists.mk
MODULE_NAME := lwip
LOCAL_INCLUDE := -I $(LITEOSTOPDIR)/net/lwip-2.1/enhancement/include
LOCAL_FLAGS := -D__LWIP__ -DLWIP_NOASSERT
LOCAL_FLAGS += $(LOCAL_INCLUDE)
LOCAL_SRCS := $(wildcard porting/src/*.c $(LWIPNOAPPSFILES))
LOCAL_SRCS += $(wildcard enhancement/src/*.c)
LOCAL_SRCS += $(wildcard $(LWIPDIR)/core/ipv4/dhcps.c)
LOCAL_SRCS := $(filter-out $(LWIPDIR)/core/ipv4/etharp.c, $(LOCAL_SRCS))
LOCAL_SRCS := $(filter-out $(LWIPDIR)/api/sockets.c, $(LOCAL_SRCS))
include $(MODULE)
+63
View File
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 COPYRIGHT HOLDER OR
* CONTRIBUTORS 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.
*/
#ifndef LWIP_API_SHELL_H
#define LWIP_API_SHELL_H
#include "arch/cc.h"
#include "lwip/opt.h"
#if defined (__cplusplus) && __cplusplus
extern "C" {
#endif
u32_t lwip_ifconfig(int argc, const char **argv);
u32_t lwip_arp(int argc, const char **argv);
u32_t osShellNetIfUp(int argc, const char **argv);
u32_t osShellNetIfDown(int argc, const char **argv);
u32_t osShellPing(int argc, const char **argv);
u32_t osShellTftp(int argc, const char **argv);
#if LWIP_SNTP
u32_t osShellNtpdate(int argc, const char **argv);
#endif
#if LWIP_DNS
u32_t osShellDns(int argc, const char **argv);
#endif /* LWIP_DNS */
u32_t osShellNetstat(int argc, const char **argv);
void netstat_internal(void *ctx);
#if defined (__cplusplus) && __cplusplus
}
#endif
#endif
+161
View File
@@ -0,0 +1,161 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 COPYRIGHT HOLDER OR
* CONTRIBUTORS 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.
*/
#ifndef LITEOS_A_FIXME_H
#define LITEOS_A_FIXME_H
#define LWIP_ENABLE_LOS_SHELL_CMD 1
#define LWIP_ENABLE_IP_CONFLICT_SIGNAL 0
#define PF_PKT_SUPPORT 1
#define NETCONN_PKT_RAW 0x80
#include "lwip/opt.h"
#if LWIP_ENABLE_LOS_SHELL_CMD
#define link_rx_drop cachehit
#define link_tx_drop cachehit
#define link_rx_overrun cachehit
#define link_tx_overrun cachehit
#define ip_rx_err cachehit
#define ip_tx_err cachehit
#define ip_rx_bytes cachehit
#define ip_tx_bytes cachehit
#define LWIP_STATIC static
#define SYS_ARCH_ERROR SYS_ARCH_TIMEOUT
#include "netif/etharp.h"
#include "lwip/netif.h"
#define LWIP_SHELL_CMD_PING_RETRY_TIMES 4
#define LWIP_SHELL_CMD_PING_TIMEOUT 2000
#define TRANSFER_MODE_BINARY 1
u32_t lwip_tftp_get_file_by_filename(u32_t ulHostAddr,
u16_t usTftpServPort,
u8_t ucTftpTransMode,
s8_t *szSrcFileName,
s8_t *szDestDirPath);
u32_t lwip_tftp_put_file_by_filename(u32_t ulHostAddr,
u16_t usTftpServPort,
u8_t cTftpTransMode,
s8_t *szSrcFileName,
s8_t *szDestDirPath);
#define ip_addr_set_val(dest, src) do { IP_SET_TYPE_VAL(*dest, IP_GET_TYPE(src)); if(IP_IS_V6_VAL(*(src))) { \
ip6_addr_set(ip_2_ip6(dest), ip_2_ip6(src)); } else { \
ip4_addr_set(ip_2_ip4(dest), ip_2_ip4(src)); }} while (0)
#define ip_addr_ismulticast_val(ipaddr) ((IP_IS_V6_VAL(*ipaddr)) ? \
ip6_addr_ismulticast(ip_2_ip6(ipaddr)) : \
ip4_addr_ismulticast(ip_2_ip4(ipaddr)))
#define ip_addr_isbroadcast_val(ipaddr, netif) ((IP_IS_V6_VAL(*ipaddr)) ? \
0 : \
ip4_addr_isbroadcast(ip_2_ip4(ipaddr), netif))
#define ip_addr_netcmp_val(addr1, addr2, mask) ((IP_IS_V6_VAL(*(addr1)) && IP_IS_V6_VAL(*(addr2))) ? \
0 : \
ip4_addr_netcmp(ip_2_ip4(addr1), ip_2_ip4(addr2), mask))
#if LWIP_DHCP
/*
* Close DHCP and set static network.
*
* @param netif a pre-allocated netif structure
*
* @return ERR_OK, or ERR_VAL if failed.
*/
err_t netif_dhcp_off(struct netif *netif);
#endif /* LWIP_DHCP */
#include "lwip/prot/dhcp.h"
err_t netif_do_rmv_ipv6_addr(struct netif *netif, void *arguments);
err_t netif_set_mtu(struct netif *netif, u16_t netif_mtu);
err_t netif_set_hwaddr(struct netif *netif, const unsigned char *hw_addr, int hw_len);
struct netif *netifapi_netif_find_by_name(const char *name);
/* 2 seconds period */
#define DUP_ARP_DETECT_TIME 2000
err_t etharp_update_arp_entry(struct netif *netif, const ip4_addr_t *ipaddr, struct eth_addr *ethaddr, u8_t flags);
err_t etharp_delete_arp_entry(struct netif *netif, ip4_addr_t *ipaddr);
#define LWIP_MAX_UDP_RAW_SEND_SIZE 65332
#define ip6_addr_isnone_val(ip6addr) (((ip6addr).addr[0] == 0xffffffffUL) && \
((ip6addr).addr[1] == 0xffffffffUL) && \
((ip6addr).addr[2] == 0xffffffffUL) && \
((ip6addr).addr[3] == 0xffffffffUL))
#define ip6_addr_isnone(ip6addr) (((ip6addr) == NULL) || ip6_addr_isnone_val(*(ip6addr)))
err_t lwip_dns_setserver(u8_t numdns, ip_addr_t *dnsserver);
err_t lwip_dns_getserver(u8_t numdns, ip_addr_t *dnsserver);
#define ipaddr_ntoa_unsafe(addr) ((IP_IS_V6_VAL(*addr)) ? ip6addr_ntoa(ip_2_ip6(addr)) : ip4addr_ntoa(ip_2_ip4(addr)))
#define SOF_BINDNONUNICAST 0x0800U /* socket has bind to a non unicast */
#if PF_PKT_SUPPORT
extern struct raw_pcb *pkt_raw_pcbs;
#endif
extern struct raw_pcb *raw_pcbs;
#ifdef ip6_addr_cmp
#undef ip6_addr_cmp
#define ip6_addr_cmp(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \
((addr1)->addr[1] == (addr2)->addr[1]) && \
((addr1)->addr[2] == (addr2)->addr[2]) && \
((addr1)->addr[3] == (addr2)->addr[3]))
#endif //ip6_addr_cmp
#define LWIP_EXT_POLL_SUPPORT LWIP_SOCKET_POLL
#endif //LWIP_ENABLE_LOS_SHELL_CMD
#endif //LITEOS_A_FIXME_H
+81
View File
@@ -0,0 +1,81 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 COPYRIGHT HOLDER OR
* CONTRIBUTORS 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.
*/
#ifndef LWIP_HDR_DHCPS_H
#define LWIP_HDR_DHCPS_H
#include "lwip/opt.h"
#include "lwip/prot/dhcp.h"
#if LWIP_DHCPS /* don't build if not configured for use in lwipopts.h */
#include "lwip/netif.h"
#include "lwip/udp.h"
#if defined (__cplusplus) && __cplusplus
extern "C" {
#endif
#ifndef LWIP_DHCPS_MAX_LEASE
#define LWIP_DHCPS_MAX_LEASE 30
#endif
#ifndef LWIP_DHCPS_LEASE_TIME
#define LWIP_DHCPS_LEASE_TIME ~0
#endif
/* Offer time in seconds */
#ifndef LWIP_DHCPS_OFFER_TIME
#define LWIP_DHCPS_OFFER_TIME 300
#endif
#ifndef LWIP_DHCPS_DECLINE_TIME
#define LWIP_DHCPS_DECLINE_TIME 500
#endif
err_t dhcps_start(struct netif *netif, const char *start_ip, u16_t ip_num);
void dhcps_stop(struct netif *netif);
void dhcp_common_option(struct dhcp_msg *msg_out, u8_t option_type, u8_t option_len, u16_t *options_out_len);
void dhcp_common_option_byte(struct dhcp_msg *msg_out, u8_t value, u16_t *options_out_len);
void dhcp_common_option_short(struct dhcp_msg *msg_out, u16_t value, u16_t *options_out_len);
void dhcp_common_option_long(struct dhcp_msg *msg_out, u32_t value, u16_t *options_out_len);
void dhcp_common_option_trailer(struct dhcp_msg *msg_out, u16_t *options_out_len);
#if LWIP_DHCP_BOOTP_FILE
err_t dhcps_parse_options(struct pbuf *p, char *boot_file_name);
#else
err_t dhcps_parse_options(struct pbuf *p);
#endif
#if defined (__cplusplus) && __cplusplus
}
#endif
#endif /* LWIP_DHCPS */
#endif /* LWIP_HDR_DHCPS_H */
+102
View File
@@ -0,0 +1,102 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 COPYRIGHT HOLDER OR
* CONTRIBUTORS 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.
*/
#ifndef LITEOS_A_DHCPS_FIXME_H
#define LITEOS_A_DHCPS_FIXME_H
#include "lwip/opt.h"
#if (LWIP_DHCP) && (LWIP_DHCPS)
#define LWIP_STATIC static
/* Option handling: options are parsed in dhcp_parse_reply
* and saved in an array where other functions can load them from.
* This might be moved into the struct dhcp (not necessarily since
* lwIP is single-threaded and the array is only used while in recv
* callback). */
enum dhcp_option_idx {
DHCP_OPTION_IDX_OVERLOAD = 0,
DHCP_OPTION_IDX_MSG_TYPE,
DHCP_OPTION_IDX_SERVER_ID,
DHCP_OPTION_IDX_LEASE_TIME,
DHCP_OPTION_IDX_T1,
DHCP_OPTION_IDX_T2,
DHCP_OPTION_IDX_SUBNET_MASK,
DHCP_OPTION_IDX_ROUTER,
#if LWIP_DHCP_PROVIDE_DNS_SERVERS
DHCP_OPTION_IDX_DNS_SERVER,
DHCP_OPTION_IDX_DNS_SERVER_LAST = DHCP_OPTION_IDX_DNS_SERVER + LWIP_DHCP_PROVIDE_DNS_SERVERS - 1,
#endif /* LWIP_DHCP_PROVIDE_DNS_SERVERS */
#if LWIP_DHCP_GET_NTP_SRV
DHCP_OPTION_IDX_NTP_SERVER,
DHCP_OPTION_IDX_NTP_SERVER_LAST = DHCP_OPTION_IDX_NTP_SERVER + LWIP_DHCP_MAX_NTP_SERVERS - 1,
#endif /* LWIP_DHCP_GET_NTP_SRV */
DHCP_OPTION_IDX_REQUESTED_IP,
DHCP_OPTION_IDX_MAX
};
#define DHCP_OPTION_ROUTER_SIZE 4
#define DHCP_OPTION_SUBNET_MASK_SIZE 4
#define DHCP_OPTION_LEASE_TIME_SIZE 4
#define DHCP_OPTION_SERVER_ID_LEN 4
#define DHCP_OPTION_T1_LEN 4
#define DHCP_OPTION_T2_LEN 4
#define DHCP_CLIENT_PORT 68
#define DHCP_SERVER_PORT 67
#define DHCP_BROADCAST_FLAG 0x8000
#define DHCP_MAX_MSG_LEN_MIN_REQUIRED 576
struct dyn_lease_addr {
u8_t cli_hwaddr[DHCP_CHADDR_LEN];
u32_t flags;
u32_t leasetime;
u32_t proposed_leasetime;
ip4_addr_t cli_addr;
};
struct dhcps {
struct udp_pcb *pcb;
struct dyn_lease_addr leasearr[LWIP_DHCPS_MAX_LEASE];
u8_t pcb_allocated;
u8_t lease_num;
struct netif *netif;
ip4_addr_t start_addr;
ip4_addr_t end_addr;
};
#endif // (LWIP_DHCP) && (LWIP_DHCPS)
#endif // LITEOS_A_DHCPS_FIXME_H
File diff suppressed because it is too large Load Diff
+410
View File
@@ -0,0 +1,410 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 COPYRIGHT HOLDER OR
* CONTRIBUTORS 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.
*/
#include "api_shell_fix.h"
#include <time.h>
#include <lwip/sys.h>
#include <lwip/snmp.h>
#include <lwip/etharp.h>
#include <lwip/netifapi.h>
#include <lwip/sockets.h>
#include <lwip/priv/api_msg.h>
#include "securec.h"
#define NETIFAPI_VAR_REF(name) API_VAR_REF(name)
#define NETIFAPI_VAR_DECLARE(name) API_VAR_DECLARE(struct netifapi_msg, name)
#define NETIFAPI_VAR_ALLOC(name) API_VAR_ALLOC(struct netifapi_msg, MEMP_NETIFAPI_MSG, name, ERR_MEM)
#define NETIFAPI_VAR_FREE(name) API_VAR_FREE(MEMP_NETIFAPI_MSG, name)
/**
*
*
* ################# FOR API_SHELL ONLY #################
*
*
*
*/
#if LWIP_ENABLE_LOS_SHELL_CMD
#if LWIP_DHCP
#include <lwip/dhcp.h>
/*
* Close DHCP and set static network.
*
* @param netif a pre-allocated netif structure
*
* @return ERR_OK, or ERR_VAL if failed.
*/
err_t netif_dhcp_off(struct netif *netif)
{
ip_addr_t old_ipaddr;
ip_addr_t old_netmask;
ip_addr_t old_gateway;
if (netif == NULL) {
return ERR_VAL;
}
old_ipaddr = netif->ip_addr;
old_netmask = netif->netmask;
old_gateway = netif->gw;
if (netif_dhcp_data(netif)) {
(void) dhcp_release(netif);
(void) dhcp_stop(netif);
(void) dhcp_cleanup(netif);
LWIP_DEBUGF(NETIF_DEBUG, ("DHCP is close;set static IP\n"));
}
ip_addr_set_val(&netif->ip_addr, &old_ipaddr);
ip_addr_set_val(&netif->netmask, &old_netmask);
ip_addr_set_val(&netif->gw, &old_gateway);
(void) netif_set_up(netif);
return ERR_OK;
}
#endif /* LWIP_DHCP */
#if LWIP_DHCPS
#include "dhcps.h"
static err_t netifapi_do_dhcps_start (struct tcpip_api_call_data *m)
{
/* cast through void* to silence alignment warnings.
* We know it works because the structs have been instantiated as struct netifapi_msg */
err_t ret;
struct netifapi_msg *msg = (struct netifapi_msg*)(void*)m;
ret = dhcps_start(msg->netif, msg->msg.dhcp_start_params.start_ip, msg->msg.dhcp_start_params.ip_num);
return ret;
}
err_t netifapi_dhcps_start(struct netif *netif, char *start_ip, u16_t ip_num)
{
err_t err;
NETIFAPI_VAR_DECLARE(msg);
LWIP_ERROR("netifapi_dhcps_start : invalid arguments", (netif != NULL), return ERR_VAL);
NETIFAPI_VAR_ALLOC(msg);
NETIFAPI_VAR_REF(msg).netif = netif;
NETIFAPI_VAR_REF(msg).msg.dhcp_start_params.start_ip = start_ip ;
NETIFAPI_VAR_REF(msg).msg.dhcp_start_params.ip_num = ip_num ;
err = tcpip_api_call(netifapi_do_dhcps_start, &API_VAR_REF(msg).call);
NETIFAPI_VAR_FREE(msg);
return err;
}
err_t netifapi_dhcps_stop(struct netif *netif)
{
LWIP_ERROR("netifapi_dhcps_stop : invalid arguments", (netif != NULL), return ERR_VAL);
return netifapi_netif_common(netif, dhcps_stop, NULL);
}
#endif /* LWIP_DHCPS */
/*
* This function is for making sure that accept() should not block indefinetely
* when removing IPv6 address used for accept() by using API[netifapi_netif_rmv_ip6_address].
*/
static void tcp_unlock_accept(ip6_addr_t *ipaddr)
{
// FIXME
}
static void netif_ip6_addr_setinvalid(struct netif *netif, const ip6_addr_t *addr6)
{
s8_t idx;
LWIP_ERROR("netif_ip6_addr_set : invalid arguments", (netif != NULL), return);
LWIP_ERROR("netif_ip6_addr_set : invalid arguments", (addr6 != NULL), return);
idx = netif_get_ip6_addr_match(netif, addr6);
if (idx < 0) {
return;
}
netif_ip6_addr_set_state(netif, idx, IP6_ADDR_INVALID);
return;
}
err_t netif_do_rmv_ipv6_addr(struct netif *netif, void *arguments)
{
ip_addr_t *ipaddr = (ip_addr_t *)arguments;
if (IP_IS_V6(ipaddr)) {
#if LWIP_TCP
tcp_unlock_accept(ip_2_ip6(ipaddr));
#endif
netif_ip6_addr_setinvalid(netif, ip_2_ip6(ipaddr));
}
return ERR_OK;
}
static err_t netif_do_rmv_ip6_address(struct tcpip_api_call_data *m)
{
/* cast through void* to silence alignment warnings.
* We know it works because the structs have been instantiated as struct netifapi_msg */
struct netifapi_msg *msg = (struct netifapi_msg *)(void *)m;
return netif_do_rmv_ipv6_addr(msg->netif, (void *)msg->msg.add.ipaddr);
}
void netifapi_netif_rmv_ip6_address(struct netif *netif, ip_addr_t *ipaddr)
{
err_t err;
if (netif == NULL) {
return;
}
NETIFAPI_VAR_DECLARE(msg);
NETIFAPI_VAR_ALLOC(msg);
NETIFAPI_VAR_REF(msg).netif = netif;
NETIFAPI_VAR_REF(msg).msg.add.ipaddr = (void *)ipaddr;
err = tcpip_api_call(netif_do_rmv_ip6_address, &API_VAR_REF(msg).call);
NETIFAPI_VAR_FREE(msg);
(void)err;
}
static struct netif *netif_find_by_name(const char *name)
{
struct netif *netif = NULL;
LWIP_ASSERT_CORE_LOCKED();
if (name == NULL) {
return NULL;
}
if (strcmp("lo", name) == 0) {
LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: found %c%c\n", name[0], name[1]));
return netif_find(name);
}
NETIF_FOREACH(netif) {
if (strcmp(netif->full_name, name) == 0) {
LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: found %c%c\n", name[0], name[1]));
return netif;
}
}
LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: didn't find %c%c\n", name[0], name[1]));
return NULL;
}
static err_t netifapi_do_find_by_name(struct tcpip_api_call_data *m)
{
/* cast through void* to silence alignment warnings.
* We know it works because the structs have been instantiated as struct netifapi_msg */
struct netifapi_msg *msg = (struct netifapi_msg *)(void *)m;
msg->netif = netif_find_by_name(msg->msg.ifs.name);
return ERR_OK;
}
struct netif *netifapi_netif_find_by_name(const char *name)
{
struct netif *netif = NULL;
NETIFAPI_VAR_DECLARE(msg);
NETIFAPI_VAR_ALLOC(msg);
NETIFAPI_VAR_REF(msg).netif = NULL;
#if LWIP_MPU_COMPATIBLE
if (strncpy_s(NETIFAPI_VAR_REF(msg).msg.ifs.name, NETIF_NAMESIZE, name, NETIF_NAMESIZE - 1)) {
NETIFAPI_VAR_FREE(msg);
return netif;
}
NETIFAPI_VAR_REF(msg).msg.ifs.name[NETIF_NAMESIZE - 1] = '\0';
#else
NETIFAPI_VAR_REF(msg).msg.ifs.name = (char *)name;
#endif /* LWIP_MPU_COMPATIBLE */
(void)tcpip_api_call(netifapi_do_find_by_name, &API_VAR_REF(msg).call);
netif = msg.netif;
NETIFAPI_VAR_FREE(msg);
return netif;
}
#define NETIF_MTU_MIN 1280
#ifndef IP_FRAG_MIN_MTU
#define IP_FRAG_MIN_MTU 68
#endif
err_t netif_set_mtu(struct netif *netif, u16_t netif_mtu)
{
/*
* As per RFC 791, "Every internet module must be able to forward a datagram of 68
* octets without further fragmentation. This is because an internet header
* may be up to 60 octets, and the minimum fragment is 8 octets."
*/
LWIP_ERROR("netif_set_mtu: invalid arguments", (netif != NULL), return ERR_VAL);
#if LWIP_IPV6
LWIP_ERROR("netif_set_mtu: invalid arguments", (netif_mtu >= NETIF_MTU_MIN) && (netif_mtu <= IP_FRAG_MAX_MTU),
return ERR_ARG);
#else
LWIP_ERROR("netif_set_mtu: invalid arguments", (netif_mtu >= IP_FRAG_MIN_MTU) && (netif_mtu <= IP_FRAG_MAX_MTU),
return ERR_ARG);
#endif
netif->mtu = netif_mtu;
#if LWIP_IPV6 && LWIP_ND6_ALLOW_RA_UPDATES
netif->mtu6 = netif_mtu;
#endif /* LWIP_IPV6 && LWIP_ND6_ALLOW_RA_UPDATES */
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif: MTU of interface %s is changed to %d\n",
netif_get_name(netif), netif->mtu));
return ERR_OK;
}
err_t netif_set_hwaddr(struct netif *netif, const unsigned char *hw_addr, int hw_len)
{
LWIP_ERROR("netif_set_hwaddr : invalid arguments", (netif != NULL), return ERR_VAL);
LWIP_ERROR("netif_set_hwaddr : invalid arguments", (hw_addr != NULL), return ERR_VAL);
LWIP_ERROR("netif_set_hwaddr: invalid arguments",
((unsigned int)hw_len == NETIF_MAX_HWADDR_LEN), return ERR_VAL);
if (netif->drv_set_hwaddr == NULL) {
return ERR_IF; // ERR_OPNOTSUPP;
}
if (netif->drv_set_hwaddr(netif, (u8_t *)hw_addr, hw_len) != ERR_OK) {
return ERR_VAL;
}
if (memcpy_s(netif->hwaddr, NETIF_MAX_HWADDR_LEN, hw_addr, hw_len) != EOK) {
LWIP_DEBUGF(NETIF_DEBUG, ("netif_set_hwaddr: memcpy_s error\n"));
return ERR_VAL;
}
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE,
("netif: HW address of interface %s set to %02X:%02X:%02X:%02X:%02X:%02X\n",
netif_get_name(netif),
netif->hwaddr[0], netif->hwaddr[1], netif->hwaddr[2],
netif->hwaddr[3], netif->hwaddr[4], netif->hwaddr[5]));
return ERR_OK;
}
err_t etharp_update_arp_entry(struct netif *netif, const ip4_addr_t *ipaddr, struct eth_addr *ethaddr, u8_t flags)
{
return 0;
}
err_t etharp_delete_arp_entry(struct netif *netif, ip4_addr_t *ipaddr)
{
return 0;
}
err_t lwip_dns_setserver(u8_t numdns, ip_addr_t *dnsserver)
{
return 0;
}
err_t lwip_dns_getserver(u8_t numdns, ip_addr_t *dnsserver)
{
return 0;
}
#if PF_PKT_SUPPORT
struct raw_pcb *pkt_raw_pcbs;
#endif
struct raw_pcb *raw_pcbs;
/******************************************************************/
#if LWIP_ENABLE_IP_CONFLICT_SIGNAL
u32_t is_ip_conflict_signal = 0;
sys_sem_t ip_conflict_detect;
#endif
u32_t is_dup_detect_initialized = 0;
sys_sem_t dup_addr_detect;
int lwip_sntp_start(int server_num, char **sntp_server, struct timeval *time)
{
return 0;
}
u32_t lwip_tftp_get_file_by_filename(u32_t ulHostAddr,
u16_t usTftpServPort,
u8_t ucTftpTransMode,
s8_t *szSrcFileName,
s8_t *szDestDirPath)
{
return 0;
}
u32_t lwip_tftp_put_file_by_filename(u32_t ulHostAddr,
u16_t usTftpServPort,
u8_t cTftpTransMode,
s8_t *szSrcFileName,
s8_t *szDestDirPath)
{
return 0;
}
const char *const tcp_state_str[] = {
"CLOSED",
"LISTEN",
"SYN_SENT",
"SYN_RCVD",
"ESTABLISHED",
"FIN_WAIT_1",
"FIN_WAIT_2",
"CLOSE_WAIT",
"CLOSING",
"LAST_ACK",
"TIME_WAIT"
};
volatile int tcpip_init_finish = 1; // needed by api_shell.c
#endif
+74
View File
@@ -0,0 +1,74 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 COPYRIGHT HOLDER OR
* CONTRIBUTORS 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.
*/
#ifndef _LWIP_PORTING_CC_H_
#define _LWIP_PORTING_CC_H_
#ifdef LITTLE_ENDIAN
#undef LITTLE_ENDIAN
#endif
#ifdef BIG_ENDIAN
#undef BIG_ENDIAN
#endif
#include <endian.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef htons
#define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS
#endif
#define SOCKLEN_T_DEFINED
#define SA_FAMILY_T_DEFINED
#define IN_PORT_T_DEFINED
#define LWIP_TIMEVAL_PRIVATE 0
#define LWIP_ERRNO_STDINCLUDE
#define LWIP_SOCKET_STDINCLUDE
/* Provide Thumb-2 routines for GCC to improve performance */
#if defined(TOOLCHAIN_GCC) && defined(__thumb2__)
#define LWIP_CHKSUM thumb2_checksum
u16_t thumb2_checksum(void* pData, int length);
#else
#define LWIP_CHKSUM_ALGORITHM 4
#endif
#define LWIP_RAND rand
#define LWIP_PLATFORM_DIAG(vars) dprintf vars
#define LWIP_PLATFORM_ASSERT(x) do { \
LWIP_PLATFORM_DIAG(("Assertion \"%s\" failed at line %d in %s\n", x, __LINE__, __FILE__)); \
abort(); \
} while (0)
#endif /* _LWIP_PORTING_CC_H_ */
+42
View File
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 COPYRIGHT HOLDER OR
* CONTRIBUTORS 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.
*/
#ifndef _LWIP_PORTING_PERF_H_
#define _LWIP_PORTING_PERF_H_
#if LWIP_PERF
#define PERF_START do {/* something to do */} while (0)
#define PERF_STOP(x) do {/* something to do */} while (0)
#endif
#endif /* _LWIP_PORTING_PERF_H_ */
+77
View File
@@ -0,0 +1,77 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 COPYRIGHT HOLDER OR
* CONTRIBUTORS 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.
*/
#ifndef _LWIP_PORTING_SYS_ARCH_H_
#define _LWIP_PORTING_SYS_ARCH_H_
#include <stdint.h>
#include "los_mux.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Mutex
*/
typedef LosMux sys_mutex_t;
/**
* Semaphore
*/
typedef uint32_t sys_sem_t;
/**
* MessageBox
*/
typedef uint32_t sys_mbox_t;
/**
* Protector
*/
typedef void *sys_prot_t;
/**
* Thread
*/
typedef uint32_t sys_thread_t;
#ifdef __cplusplus
}
#endif
#endif /* _LWIP_PORTING_SYS_ARCH_H_ */
+48
View File
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 COPYRIGHT HOLDER OR
* CONTRIBUTORS 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.
*/
#ifndef _LWIP_PORTING_DHCP_H_
#define _LWIP_PORTING_DHCP_H_
#include_next <lwip/dhcp.h>
#include <lwip/prot/dhcp.h> // For DHCP_STATE_BOUND, DHCP_DISCOVER etc. by `mac/common/mac_data.c'
#ifdef __cplusplus
extern "C" {
#endif
err_t dhcp_is_bound(struct netif *netif);
#ifdef __cplusplus
}
#endif
#endif /* _LWIP_PORTING_DHCP_H_ */
+61
View File
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 COPYRIGHT HOLDER OR
* CONTRIBUTORS 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.
*/
#ifndef _LWIP_PORTING_INET_H_
#define _LWIP_PORTING_INET_H_
#include <arpa/inet.h>
#include <netinet/in.h>
#include_next <lwip/inet.h>
#ifdef __LWIP__
#if LWIP_IPV4
#define inet_addr_from_ip4addr(target_inaddr, source_ipaddr) \
((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr))
#define inet_addr_to_ip4addr(target_ipaddr, source_inaddr) \
(ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr))
#endif /* LWIP_IPV4 */
#if LWIP_IPV6
#define inet6_addr_from_ip6addr(target_in6addr, source_ip6addr) \
{(target_in6addr)->s6_addr32[0] = (source_ip6addr)->addr[0]; \
(target_in6addr)->s6_addr32[1] = (source_ip6addr)->addr[1]; \
(target_in6addr)->s6_addr32[2] = (source_ip6addr)->addr[2]; \
(target_in6addr)->s6_addr32[3] = (source_ip6addr)->addr[3];}
#define inet6_addr_to_ip6addr(target_ip6addr, source_in6addr) \
{(target_ip6addr)->addr[0] = (source_in6addr)->s6_addr32[0]; \
(target_ip6addr)->addr[1] = (source_in6addr)->s6_addr32[1]; \
(target_ip6addr)->addr[2] = (source_in6addr)->s6_addr32[2]; \
(target_ip6addr)->addr[3] = (source_in6addr)->s6_addr32[3]; \
ip6_addr_clear_zone(target_ip6addr);}
#endif /* LWIP_IPV6 */
#endif /* __LWIP__ */
#endif /* _LWIP_PORTING_INET_H_ */
+221
View File
@@ -0,0 +1,221 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 COPYRIGHT HOLDER OR
* CONTRIBUTORS 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.
*/
#ifndef _LWIP_PORTING_LWIPOPTS_H_
#define _LWIP_PORTING_LWIPOPTS_H_
// lwIP debug options, comment the ones you don't want
#if LWIP_DEBUG
#define ETHARP_DEBUG LWIP_DBG_ON
#define NETIF_DEBUG LWIP_DBG_ON
#define PBUF_DEBUG LWIP_DBG_ON
#define API_LIB_DEBUG LWIP_DBG_ON
#define API_MSG_DEBUG LWIP_DBG_ON
#define SOCKETS_DEBUG LWIP_DBG_ON
#define ICMP_DEBUG LWIP_DBG_ON
#define IGMP_DEBUG LWIP_DBG_ON
#define INET_DEBUG LWIP_DBG_ON
#define IP_DEBUG LWIP_DBG_ON
#define DRIVERIF_DEBUG LWIP_DBG_ON
#define IP_REASS_DEBUG LWIP_DBG_ON
#define RAW_DEBUG LWIP_DBG_ON
#define MEM_DEBUG LWIP_DBG_ON
#define MEMP_DEBUG LWIP_DBG_ON
#define SYS_DEBUG LWIP_DBG_ON
#define TIMERS_DEBUG LWIP_DBG_ON
#define TCP_DEBUG LWIP_DBG_ON
#define TCP_ERR_DEBUG LWIP_DBG_ON
#define TCP_INPUT_DEBUG LWIP_DBG_ON
#define TCP_FR_DEBUG LWIP_DBG_ON
#define TCP_RTO_DEBUG LWIP_DBG_ON
#define TCP_CWND_DEBUG LWIP_DBG_ON
#define TCP_WND_DEBUG LWIP_DBG_ON
#define TCP_OUTPUT_DEBUG LWIP_DBG_ON
#define TCP_RST_DEBUG LWIP_DBG_ON
#define TCP_QLEN_DEBUG LWIP_DBG_ON
#define TCP_SACK_DEBUG LWIP_DBG_ON
#define TCP_TLP_DEBUG LWIP_DBG_ON
#define UDP_DEBUG LWIP_DBG_ON
#define TCPIP_DEBUG LWIP_DBG_ON
#define SLIP_DEBUG LWIP_DBG_ON
#define DHCP_DEBUG LWIP_DBG_ON
#define AUTOIP_DEBUG LWIP_DBG_ON
#define DNS_DEBUG LWIP_DBG_ON
#define TFTP_DEBUG LWIP_DBG_ON
#define SYS_ARCH_DEBUG LWIP_DBG_ON
#define SNTP_DEBUG LWIP_DBG_ON
#define IP6_DEBUG LWIP_DBG_ON
#define DHCP6_DEBUG LWIP_DBG_ON
#define DRV_STS_DEBUG LWIP_DBG_ON
#endif
// Options only in new opt.h
#define LWIP_SOCKET_SELECT 0
#define LWIP_SOCKET_POLL 1
// Options in old opt.h that differs from new opt.h
#define MEM_ALIGNMENT __SIZEOF_POINTER__
#define MEMP_NUM_NETDB 8
#define IP_REASS_MAXAGE 3
#define IP_SOF_BROADCAST 1
#define IP_SOF_BROADCAST_RECV 1
#define LWIP_MULTICAST_PING 1
#define LWIP_RAW 1
#define LWIP_DHCP_AUTOIP_COOP_TRIES 64
#define TCP_LISTEN_BACKLOG 1
#define TCP_DEFAULT_LISTEN_BACKLOG 16
#define LWIP_WND_SCALE 1
#define TCP_RCV_SCALE 7
#define LWIP_NETIF_HOSTNAME 1
#define LWIP_NETIF_TX_SINGLE_PBUF 1
#define LWIP_NETCONN_FULLDUPLEX 1 // Caution
#define LWIP_COMPAT_SOCKETS 2
#define LWIP_POSIX_SOCKETS_IO_NAMES 0
#define LWIP_TCP_KEEPALIVE 1
#define RECV_BUFSIZE_DEFAULT 65535
#define SO_REUSE_RXTOALL 1
#define LWIP_CHECKSUM_ON_COPY 1
#define LWIP_IPV6 1
#define LWIP_IPV6_NUM_ADDRESSES 5
#define LWIP_ND6_NUM_PREFIXES 10
#define LWIP_IPV6_DHCP6 1
#define LWIP_IPV6_DHCP6_STATEFUL 1
// Options in old lwipopts.h
#define ARP_QUEUEING 1
#define DEFAULT_ACCEPTMBOX_SIZE 32
#define DEFAULT_RAW_RECVMBOX_SIZE 128
#define DEFAULT_TCP_RECVMBOX_SIZE 128
#define DEFAULT_UDP_RECVMBOX_SIZE 128
#define ETHARP_SUPPORT_STATIC_ENTRIES 1
#define ETH_PAD_SIZE 2
#define IP_REASS_MAX_PBUFS (((65535) / (IP_FRAG_MAX_MTU - 20 - 8) + 1) * MEMP_NUM_REASSDATA)
#define LWIP_COMPAT_SOCKETS 2
#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_OFF
#define LWIP_DHCP 1
#define LWIP_DNS 1
#define LWIP_ETHERNET 1
#define LWIP_HAVE_LOOPIF 1
#define LWIP_IGMP 1
#define LWIP_NETIF_API 1
#define LWIP_NETIF_LINK_CALLBACK 1
#define LWIP_NETIF_LOOPBACK 1
#define LWIP_POSIX_SOCKETS_IO_NAMES 0
#define LWIP_RAW 1
#define LWIP_SOCKET_OFFSET CONFIG_NFILE_DESCRIPTORS
#define LWIP_SO_RCVBUF 1
#define LWIP_SO_RCVTIMEO 1
#define LWIP_SO_SNDTIMEO 1
#define LWIP_STATS_DISPLAY 1
#define MEM_LIBC_MALLOC 1
#define MEMP_NUM_ARP_QUEUE (65535 * LWIP_CONFIG_NUM_SOCKETS / (IP_FRAG_MAX_MTU - 20 - 8))
#define MEMP_NUM_NETBUF (65535 * 3 * LWIP_CONFIG_NUM_SOCKETS / (IP_FRAG_MAX_MTU - 20 - 8))
#define MEMP_NUM_NETCONN LWIP_CONFIG_NUM_SOCKETS
#define MEMP_NUM_PBUF LWIP_CONFIG_NUM_SOCKETS*2
#define MEMP_NUM_RAW_PCB LWIP_CONFIG_NUM_SOCKETS
#define MEMP_NUM_REASSDATA (IP_REASS_MAX_MEM_SIZE / 65535)
#define MEMP_NUM_TCPIP_MSG_API 64
#define MEMP_NUM_TCPIP_MSG_INPKT 512
#define MEMP_NUM_TCP_PCB LWIP_CONFIG_NUM_SOCKETS
#define MEMP_NUM_TCP_PCB_LISTEN LWIP_CONFIG_NUM_SOCKETS
#define MEMP_NUM_TCP_SEG (((TCP_SND_BUF * 3 / 2) + TCP_WND) * LWIP_CONFIG_NUM_SOCKETS / TCP_MSS)
#define MEMP_NUM_UDP_PCB LWIP_CONFIG_NUM_SOCKETS
#define MEM_SIZE (4*1024*1024) // (512*1024)
#define PBUF_POOL_BUFSIZE 1550
#define PBUF_POOL_SIZE 64
#define SO_REUSE 1
#define TCPIP_MBOX_SIZE 512
#define TCPIP_THREAD_PRIO 5
#define TCPIP_THREAD_STACKSIZE 0x6000
#define TCP_MAXRTX 64
#define TCP_MSS 1400
#define TCP_SND_BUF 65535
#define TCP_SND_QUEUELEN (8 * TCP_SND_BUF) / TCP_MSS
#define TCP_TTL 255
#define TCP_WND 32768
#define UDP_TTL 255
// Options in old lwipopts.h but kept in Defaults with new opt.h
#define IP_FORWARD 0
#define LWIP_DBG_TYPES_ON LWIP_DBG_ON
#define LWIP_ICMP 1
#define LWIP_NETCONN 1
#define LWIP_SOCKET 1
#define LWIP_STATS 1
#define LWIP_TCP 1
#define LWIP_UDP 1
#define NO_SYS 0
#define TCP_QUEUE_OOSEQ LWIP_TCP
// Change some options for lwIP 2.1.2
#undef TCP_MAXRTX
#define TCP_MAXRTX 12
#undef LWIP_COMPAT_SOCKETS
#define LWIP_COMPAT_SOCKETS 0
#define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL + (LWIP_IPV6 * LWIP_IPV6_DHCP6))
#undef DEFAULT_ACCEPTMBOX_SIZE
#define DEFAULT_ACCEPTMBOX_SIZE LWIP_CONFIG_NUM_SOCKETS
#undef TCP_MSS
#define TCP_MSS (IP_FRAG_MAX_MTU - 20 - 20)
#undef IP_SOF_BROADCAST_RECV
#define IP_SOF_BROADCAST_RECV 0
/**
* Defines whether to enable debugging for driver module.
*/
#ifndef DRIVERIF_DEBUG
#define DRIVERIF_DEBUG LWIP_DBG_OFF
#endif
// Options for old lwipopts.h
#define IP_FRAG_MAX_MTU 1500
#define LWIP_CONFIG_NUM_SOCKETS 128
#define IP_REASS_MAX_MEM_SIZE (MEM_SIZE / 4)
#define LWIP_DHCPS 1
#define LWIP_ENABLE_NET_CAPABILITY 1
#endif /* _LWIP_PORTING_LWIPOPTS_H_ */
+79
View File
@@ -0,0 +1,79 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 COPYRIGHT HOLDER OR
* CONTRIBUTORS 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.
*/
#ifndef _LWIP_PORTING_NETIF_H_
#define _LWIP_PORTING_NETIF_H_
#include <net/if.h> // For IFNAMSIZ/IF_NAMESIZE and `struct ifreq', by `lwip/netif.h' and `api/sockets.c'
#include <netinet/ip.h> // For IP_OFFMASK, by `core/ipv4/ip4_frag.c'
struct dhcps;
#define linkoutput linkoutput; \
void (*drv_send)(struct netif *netif, struct pbuf *p); \
u8_t (*drv_set_hwaddr)(struct netif *netif, u8_t *addr, u8_t len); \
void (*drv_config)(struct netif *netif, u32_t config_flags, u8_t setBit); \
struct dhcps *dhcps; \
char full_name[IFNAMSIZ]; \
u16_t link_layer_type
#include_next <lwip/netif.h>
#undef linkoutput
#include <lwip/etharp.h> // For ETHARP_HWADDR_LEN, by `hieth-sf src/interface.c' and `wal/wal_net.c'
#ifdef __cplusplus
extern "C" {
#endif
// redefine NETIF_NAMESIZE which was defined in netif.h
#undef NETIF_NAMESIZE
#define NETIF_NAMESIZE IFNAMSIZ
#define LOOPBACK_IF 0 // 772
#define ETHERNET_DRIVER_IF 1
#define WIFI_DRIVER_IF 801
err_t driverif_init(struct netif *netif);
void driverif_input(struct netif *netif, struct pbuf *p);
#ifndef __LWIP__
struct netif *netifapi_netif_find_by_name(const char *name);
#define PF_PKT_SUPPORT 1 // For netif->drv_config
#define netif_find(name) netifapi_netif_find_by_name(name)
#define netif_add(a, b, c, d) netif_add(a, b, c, d, (a)->state, driverif_init, tcpip_input)
#else /* __LWIP__ */
#define netif_get_name(netif) ((netif)->full_name)
#endif /* __LWIP__ */
#ifdef __cplusplus
}
#endif
#endif /* _LWIP_PORTING_NETIF_H_ */
+57
View File
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 COPYRIGHT HOLDER OR
* CONTRIBUTORS 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.
*/
#ifndef _LWIP_PORTING_NETIFAPI_H_
#define _LWIP_PORTING_NETIFAPI_H_
#include_next <lwip/netifapi.h>
#ifdef __cplusplus
extern "C" {
#endif
err_t netifapi_dhcps_start(struct netif *netif, char *start_ip, u16_t ip_num);
err_t netifapi_dhcps_stop(struct netif *netif);
#define netifapi_dhcp_cleanup(n) netifapi_netif_common(n, dhcp_cleanup, NULL)
#define netifapi_dhcp_is_bound(n) netifapi_netif_common(n, NULL, dhcp_is_bound)
void netifapi_netif_rmv_ip6_address(struct netif *netif, ip_addr_t *ipaddr);
#ifndef __LWIP__
#define netifapi_netif_add(a, b, c, d) netifapi_netif_add(a, b, c, d, (a)->state, driverif_init, tcpip_input)
#endif
#ifdef __cplusplus
}
#endif
#endif /* _LWIP_PORTING_NETIFAPI_H_ */
+57
View File
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 COPYRIGHT HOLDER OR
* CONTRIBUTORS 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.
*/
#ifndef _LWIP_PORTING_PBUF_H_
#define _LWIP_PORTING_PBUF_H_
#include_next <lwip/pbuf.h>
#ifdef __cplusplus
extern "C" {
#endif
struct pbuf_dma_info {
void *dma;
void *mac_header;
u16_t dma_len;
u16_t link_len;
};
#define pbuf_dma_ref(dma_info) // ERR_OK
#define pbuf_dma_free(dma_info)
#define dma_info payload
#ifdef __cplusplus
}
#endif
#endif /* _LWIP_PORTING_PBUF_H_ */
+47
View File
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 COPYRIGHT HOLDER OR
* CONTRIBUTORS 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.
*/
#ifndef _LWIP_PORTING_API_MSG_H_
#define _LWIP_PORTING_API_MSG_H_
#if LWIP_DHCPS
#define common common; \
struct { \
char *start_ip; \
u16_t ip_num; \
} dhcp_start_params
#else
#define common common
#endif
#include_next <lwip/priv/api_msg.h>
#undef common
#endif /* _LWIP_PORTING_API_MSG_H_ */
+41
View File
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 COPYRIGHT HOLDER OR
* CONTRIBUTORS 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.
*/
#ifndef _LWIP_PORTING_SOCKETS_PRIV_H_
#define _LWIP_PORTING_SOCKETS_PRIV_H_
#define select_waiting select_waiting; \
wait_queue_head_t wq; \
unsigned long s_refcount
#include_next <lwip/priv/sockets_priv.h>
#undef select_waiting
#endif /* _LWIP_PORTING_SOCKETS_PRIV_H_ */
+89
View File
@@ -0,0 +1,89 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 COPYRIGHT HOLDER OR
* CONTRIBUTORS 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.
*/
#ifndef _LWIP_PORTING_SOCKETS_H_
#define _LWIP_PORTING_SOCKETS_H_
#include <sys/socket.h>
#include <poll.h> // For poll_table
#include <netinet/tcp.h> // For TCP_NODELAY etc.
#include <netinet/in.h>
#include <sys/ioctl.h> // For FIONREAD etc.
#include <sys/select.h> // For FD_SET
#include <limits.h> // For IOV_MAX
#include_next <lwip/sockets.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __LWIP__
#if FD_SETSIZE < (LWIP_SOCKET_OFFSET + MEMP_NUM_NETCONN)
#error "external FD_SETSIZE too small for number of sockets"
#else
#define LWIP_SELECT_MAXNFDS FD_SETSIZE
#endif
#if IOV_MAX > 0xFFFF
#error "IOV_MAX larger than supported by LwIP"
#endif
#if LWIP_UDP && LWIP_UDPLITE
#define UDPLITE_SEND_CSCOV 0x01 /* sender checksum coverage */
#define UDPLITE_RECV_CSCOV 0x02 /* minimal receiver checksum coverage */
#endif
// For BSD 4.4 socket sa_len compatibility
#define DF_NADDR(addr) ip_addr_t naddr = addr
#define SA_LEN(addr, _) (IP_IS_V4_VAL(addr) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6))
#define sa_len sa_data[0] * 0 + SA_LEN(naddr, _)
#define sin_len sin_zero[0]
#define sin6_len sin6_addr.s6_addr[0]
// for sockets.c, TCP_KEEPALIVE is not supported currently
#define TCP_KEEPALIVE 0xFF
#define SIN_ZERO_LEN 8
#else
int closesocket(int sockfd);
#endif /* __LWIP__ */
int socks_poll(int sockfd, poll_table *wait);
int socks_ioctl(int sockfd, long cmd, void *argp);
int socks_close(int sockfd);
void socks_refer(int sockfd);
#ifdef __cplusplus
}
#endif
#endif /* _LWIP_PORTING_SOCKETS_H_ */
+38
View File
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 COPYRIGHT HOLDER OR
* CONTRIBUTORS 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.
*/
#ifndef __LITEOS_A_LWIPOPTS_H__
#define __LITEOS_A_LWIPOPTS_H__
// Just redirect
#include "lwip/lwipopts.h"
#endif //__LITEOS_A_LWIPOPTS_H__
+342
View File
@@ -0,0 +1,342 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 COPYRIGHT HOLDER OR
* CONTRIBUTORS 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.
*/
#include <lwip/sys.h>
#include <lwip/netif.h>
#include <lwip/snmp.h>
#include <lwip/etharp.h>
#include <lwip/sockets.h>
#include <lwip/snmp.h>
#include <lwip/etharp.h>
#include <lwip/ethip6.h>
#define LWIP_NETIF_HOSTNAME_DEFAULT "default"
#define LINK_SPEED_OF_YOUR_NETIF_IN_BPS 100000000 // 100Mbps
#define link_rx_drop cachehit
#define link_rx_overrun cachehit
#define NETIF_NAME_LEN 2
#define LWIP_STATIC static
#ifndef LWIP_NETIF_IFINDEX_MAX_EX
#define LWIP_NETIF_IFINDEX_MAX_EX 255
#endif
LWIP_STATIC void
driverif_init_ifname(struct netif *netif)
{
struct netif *tmpnetif = NULL;
const char *prefix = (netif->link_layer_type == WIFI_DRIVER_IF) ? "wlan" : "eth";
for (int i = 0; i < LWIP_NETIF_IFINDEX_MAX_EX; ++i) {
if (snprintf_s(netif->full_name, sizeof(netif->full_name), sizeof(netif->full_name) - 1,
"%s%d", prefix, i) < 0) {
break;
}
NETIF_FOREACH(tmpnetif) {
if (strcmp(tmpnetif->full_name, netif->full_name) == 0) {
break;
}
}
if (tmpnetif == NULL) {
return;
}
}
netif->full_name[0] = '\0';
}
/*
* This function should do the actual transmission of the packet. The packet is
* contained in the pbuf that is passed to the function. This pbuf
* might be chained.
*
* @param netif the lwip network interface structure for this driverif
* @param p the MAC packet to send (e.g. IP packet including MAC_addresses and type)
* @return ERR_OK if the packet could be sent
* an err_t value if the packet couldn't be sent
*
* @note Returning ERR_MEM here if a DMA queue of your MAC is full can lead to
* strange results. You might consider waiting for space in the DMA queue
* to become availale since the stack doesn't retry to send a packet
* dropped because of memory failure (except for the TCP timers).
*/
LWIP_STATIC err_t
driverif_output(struct netif *netif, struct pbuf *p)
{
LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_output : going to send packet pbuf 0x%p of length %"U16_F" through netif 0x%p\n", \
(void *)p, p->tot_len, (void *)netif));
#if PF_PKT_SUPPORT
if (all_pkt_raw_pcbs != NULL) {
p->flags = (u16_t)(p->flags & ~(PBUF_FLAG_LLMCAST | PBUF_FLAG_LLBCAST | PBUF_FLAG_HOST));
p->flags |= PBUF_FLAG_OUTGOING;
(void)raw_pkt_input(p, netif, NULL);
}
#endif
#if ETH_PAD_SIZE
(void)pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */
#endif
netif->drv_send(netif, p);
#if ETH_PAD_SIZE
(void)pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
#endif
MIB2_STATS_NETIF_ADD(netif, ifoutoctets, p->tot_len);
LINK_STATS_INC(link.xmit);
return ERR_OK;
}
/*
* This function should be called by network driver to pass the input packet to LwIP.
* Before calling this API, driver has to keep the packet in pbuf structure. Driver has to
* call pbuf_alloc() with type as PBUF_RAM to create pbuf structure. Then driver
* has to pass the pbuf structure to this API. This will add the pbuf into the TCPIP thread.
* Once this packet is processed by TCPIP thread, pbuf will be freed. Driver is not required to
* free the pbuf.
*
* @param netif the lwip network interface structure for this driverif
* @param p packet in pbuf structure format
*/
void
driverif_input(struct netif *netif, struct pbuf *p)
{
#if PF_PKT_SUPPORT
#if (DRIVERIF_DEBUG & LWIP_DBG_OFF)
u16_t ethhdr_type;
struct eth_hdr* ethhdr = NULL;
#endif
#else
u16_t ethhdr_type;
struct eth_hdr* ethhdr = NULL;
#endif
err_t ret = ERR_VAL;
LWIP_ERROR("driverif_input : invalid arguments", ((netif != NULL) && (p != NULL)), return);
LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_input : going to receive input packet. netif 0x%p, pbuf 0x%p, \
packet_length %"U16_F"\n", (void *)netif, (void *)p, p->tot_len));
/* points to packet payload, which starts with an Ethernet header */
MIB2_STATS_NETIF_ADD(netif, ifinoctets, p->tot_len);
if (p->len < SIZEOF_ETH_HDR) {
(void)pbuf_free(p);
LINK_STATS_INC(link.drop);
LINK_STATS_INC(link.link_rx_drop);
return;
}
#if PF_PKT_SUPPORT
#if (DRIVERIF_DEBUG & LWIP_DBG_OFF)
ethhdr = (struct eth_hdr *)p->payload;
ethhdr_type = ntohs(ethhdr->type);
LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_input : received packet of type %"U16_F" netif->input=%p\n", ethhdr_type, netif->input));
#endif
/* full packet send to tcpip_thread to process */
if (netif->input) {
ret = netif->input(p, netif);
}
if (ret != ERR_OK) {
LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_input: IP input error\n"));
(void)pbuf_free(p);
LINK_STATS_INC(link.drop);
LINK_STATS_INC(link.link_rx_drop);
if (ret == ERR_MEM) {
LINK_STATS_INC(link.link_rx_overrun);
}
} else {
LINK_STATS_INC(link.recv);
}
#else
ethhdr = (struct eth_hdr *)p->payload;
ethhdr_type = ntohs(ethhdr->type);
switch (ethhdr_type) {
/* IP or ARP packet? */
case ETHTYPE_IP:
case ETHTYPE_IPV6:
case ETHTYPE_ARP:
#if ETHARP_SUPPORT_VLAN
case ETHTYPE_VLAN:
#endif /* ETHARP_SUPPORT_VLAN */
LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_input : received packet of type %"U16_F"\n", ethhdr_type));
/* full packet send to tcpip_thread to process */
if (netif->input != NULL) {
ret = netif->input(p, netif);
}
if (ret != ERR_OK) {
LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_input: IP input error\n"));
(void)pbuf_free(p);
LINK_STATS_INC(link.drop);
LINK_STATS_INC(link.link_rx_drop);
if (ret == ERR_MEM) {
MIB2_STATS_NETIF_INC(netif, ifinoverruns);
LINK_STATS_INC(link.link_rx_overrun);
}
} else {
LINK_STATS_INC(link.recv);
}
break;
default:
LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_input : received packet is of unsupported type %"U16_F"\n", ethhdr_type));
(void)pbuf_free(p);
LINK_STATS_INC(link.drop);
LINK_STATS_INC(link.link_rx_drop);
break;
}
#endif
LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_input : received packet is processed\n"));
}
/*
* Should be called at the beginning of the program to set up the
* network interface. It calls the function low_level_init() to do the
* actual setup of the hardware.
*
* This function should be passed as a parameter to netif_add().
*
* @param netif the lwip network interface structure for this driverif
* @return ERR_OK if the loopif is initialized
* ERR_MEM on Allocation Failure
* any other err_t on error
*/
err_t
driverif_init(struct netif *netif)
{
u16_t link_layer_type;
err_t ret;
if (netif == NULL) {
return ERR_IF;
}
link_layer_type = netif->link_layer_type;
LWIP_ERROR("driverif_init : invalid link_layer_type in netif", \
((link_layer_type == ETHERNET_DRIVER_IF) || (link_layer_type == WIFI_DRIVER_IF)), \
return ERR_IF);
LWIP_ERROR("driverif_init : netif hardware length is greater than maximum supported", \
(netif->hwaddr_len <= NETIF_MAX_HWADDR_LEN), return ERR_IF);
LWIP_ERROR("driverif_init : drv_send is null", (netif->drv_send != NULL), return ERR_IF);
#if LWIP_NETIF_PROMISC
LWIP_ERROR("driverif_init : drv_config is null", (netif->drv_config != NULL), return ERR_IF);
#endif
#if LWIP_NETIF_HOSTNAME
/* Initialize interface hostname */
#if LOSCFG_NET_LWIP_SACK_2_0
if (strncpy_s(netif->hostname, NETIF_HOSTNAME_MAX_LEN,
LWIP_NETIF_HOSTNAME_DEFAULT, NETIF_HOSTNAME_MAX_LEN - 1) == EOK) {
netif->hostname[NETIF_HOSTNAME_MAX_LEN - 1] = '\0';
} else {
LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_init: hostname %s in invalid\n", LWIP_NETIF_HOSTNAME_DEFAULT));
netif->hostname[0] = '\0';
}
#else
netif->hostname = LWIP_NETIF_HOSTNAME_DEFAULT;
#endif
#endif /* LWIP_NETIF_HOSTNAME */
/*
* Initialize the snmp variables and counters inside the struct 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->output = etharp_output;
netif->linkoutput = driverif_output;
if (link_layer_type == ETHERNET_DRIVER_IF) {
ret = memcpy_s(netif->name, sizeof(netif->name), "et", NETIF_NAME_LEN);
} else {
ret = memcpy_s(netif->name, sizeof(netif->name), "wl", NETIF_NAME_LEN);
}
if (ret != EOK) {
#if LWIP_NETIF_HOSTNAME
#if LOSCFG_NET_LWIP_SACK_2_0
netif->hostname[0] = '\0';
#else
netif->hostname = NULL;
#endif
#endif
return ERR_IF;
}
/* init the netif's full name */
driverif_init_ifname(netif);
/* maximum transfer unit */
netif->mtu = IP_FRAG_MAX_MTU;
/* device capabilities */
/* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP |
#if DRIVER_STATUS_CHECK
NETIF_FLAG_DRIVER_RDY |
#endif
#if LWIP_IGMP
NETIF_FLAG_IGMP |
#endif
/**
@page RFC-2710 RFC-2710
@par Compliant Sections
Section 5. Node State Transition Diagram
@par Behavior Description
MLD messages are sent for multicast addresses whose scope is 2
(link-local), including Solicited-Node multicast addresses.\n
Behavior:Stack will send MLD6 report /Done to solicited node multicast address
if the LWIP_MLD6_ENABLE_MLD_ON_DAD is enabled. By default, this is disabled.
*/
/* Enable sending MLD report /done for solicited address during neighbour discovery */
#if LWIP_IPV6 && LWIP_IPV6_MLD
#if LWIP_MLD6_ENABLE_MLD_ON_DAD
NETIF_FLAG_MLD6 |
#endif /* LWIP_MLD6_ENABLE_MLD_ON_DAD */
#endif
NETIF_FLAG_LINK_UP;
#if DRIVER_STATUS_CHECK
netif->waketime = -1;
#endif /* DRIVER_STATUS_CHECK */
LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_init : Initialized netif 0x%p\n", (void *)netif));
return ERR_OK;
}
+46
View File
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 COPYRIGHT HOLDER OR
* CONTRIBUTORS 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.
*/
#include <lwip/netif.h>
#include <lwip/dhcp.h>
err_t dhcp_is_bound(struct netif *netif)
{
return (netif_dhcp_data(netif) ? (netif_dhcp_data(netif)->state == DHCP_STATE_BOUND) ? ERR_OK : ERR_INPROGRESS : ERR_ARG);
}
#if (LWIP_CHKSUM_ALGORITHM == 4) /* version #4, asm based */
#include "in_cksum.h"
u16_t lwip_standard_chksum(const void *dataptr, int len)
{
return ~(u16_t)(in_cksum(dataptr, len));
}
#endif
+1583
View File
File diff suppressed because it is too large Load Diff
+325
View File
@@ -0,0 +1,325 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 COPYRIGHT HOLDER OR
* CONTRIBUTORS 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.
*/
#include <arch/sys_arch.h>
#include <lwip/sys.h>
#include <lwip/debug.h>
#include <los_task.h>
#include <los_sys_pri.h>
#include <los_tick.h>
#include <los_queue.h>
#include <los_sem.h>
#include <los_mux.h>
#include <los_spinlock.h>
#if (LOSCFG_KERNEL_SMP == YES)
SPIN_LOCK_INIT(arch_protect_spin);
static u32_t lwprot_thread = LOS_ERRNO_TSK_ID_INVALID;
static int lwprot_count = 0;
#endif /* LOSCFG_KERNEL_SMP == YES */
/**
* Thread and System misc
*/
sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stackSize, int prio)
{
UINT32 taskID = LOS_ERRNO_TSK_ID_INVALID;
UINT32 ret;
TSK_INIT_PARAM_S task = {0};
/* Create host Task */
task.pfnTaskEntry = (TSK_ENTRY_FUNC)thread;
task.uwStackSize = stackSize;
task.pcName = (char *)name;
task.usTaskPrio = prio;
task.auwArgs[0] = (UINTPTR)arg;
task.uwResved = LOS_TASK_STATUS_DETACHED;
ret = LOS_TaskCreate(&taskID, &task);
if (ret != LOS_OK) {
LWIP_DEBUGF(SYS_DEBUG, ("sys_thread_new: LOS_TaskCreate error %u\n", ret));
return -1;
}
return taskID;
}
void sys_init(void)
{
/* set rand seed to make random sequence diff on every startup */
UINT32 seedhsb, seedlsb;
LOS_GetCpuCycle(&seedhsb, &seedlsb);
srand(seedlsb);
}
u32_t sys_now(void)
{
/* Lwip docs mentioned like wraparound is not a problem in this funtion */
return (u32_t)(((double)LOS_TickCountGet() * OS_SYS_MS_PER_SECOND) / LOSCFG_BASE_CORE_TICK_PER_SECOND);
}
/**
* Protector
*/
sys_prot_t sys_arch_protect(void)
{
#if (LOSCFG_KERNEL_SMP == YES)
/* Note that we are using spinlock instead of mutex for LiteOS-SMP here:
* 1. spinlock is more effective for short critical region protection.
* 2. this function is called only in task context, not in interrupt handler.
* so it's not needed to disable interrupt.
*/
if (lwprot_thread != LOS_CurTaskIDGet()) {
/* We are locking the spinlock where it has not been locked before
* or is being locked by another thread */
LOS_SpinLock(&arch_protect_spin);
lwprot_thread = LOS_CurTaskIDGet();
lwprot_count = 1;
} else {
/* It is already locked by THIS thread */
lwprot_count++;
}
#else
LOS_TaskLock();
#endif /* LOSCFG_KERNEL_SMP == YES */
return 0; /* return value is unused */
}
void sys_arch_unprotect(sys_prot_t pval)
{
LWIP_UNUSED_ARG(pval);
#if (LOSCFG_KERNEL_SMP == YES)
if (lwprot_thread == LOS_CurTaskIDGet()) {
lwprot_count--;
if (lwprot_count == 0) {
lwprot_thread = LOS_ERRNO_TSK_ID_INVALID;
LOS_SpinUnlock(&arch_protect_spin);
}
}
#else
LOS_TaskUnlock();
#endif /* LOSCFG_KERNEL_SMP == YES */
}
/**
* MessageBox
*/
err_t sys_mbox_new(sys_mbox_t *mbox, int size)
{
CHAR qName[] = "lwIP";
UINT32 ret = LOS_QueueCreate(qName, (UINT16)size, mbox, 0, sizeof(void*));
switch (ret) {
case LOS_OK:
return ERR_OK;
case LOS_ERRNO_QUEUE_CB_UNAVAILABLE:
case LOS_ERRNO_QUEUE_CREATE_NO_MEMORY:
return ERR_MEM;
default:
break;
}
LWIP_DEBUGF(SYS_DEBUG, ("%s: LOS_QueueCreate error %u\n", __FUNCTION__, ret));
return ERR_ARG;
}
void sys_mbox_post(sys_mbox_t *mbox, void *msg)
{
/* Caution: the second parameter is NOT &msg */
UINT32 ret = LOS_QueueWrite(*mbox, msg, sizeof(char *), LOS_WAIT_FOREVER);
if (ret != LOS_OK) {
LWIP_DEBUGF(SYS_DEBUG, ("%s: LOS_QueueWrite error %u\n", __FUNCTION__, ret));
}
}
err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg)
{
/* Caution: the second parameter is NOT &msg */
UINT32 ret = LOS_QueueWrite(*mbox, msg, sizeof(char *), 0);
switch (ret) {
case LOS_OK:
return ERR_OK;
case LOS_ERRNO_QUEUE_ISFULL:
return ERR_MEM;
default:
break;
}
LWIP_DEBUGF(SYS_DEBUG, ("%s: LOS_QueueWrite error %u\n", __FUNCTION__, ret));
return ERR_ARG;
}
err_t sys_mbox_trypost_fromisr(sys_mbox_t *mbox, void *msg);
u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeoutMs)
{
void *ignore = 0; /* if msg==NULL, the fetched msg should be dropped */
UINT64 tick = ((UINT64)timeoutMs * LOSCFG_BASE_CORE_TICK_PER_SECOND + OS_SYS_MS_PER_SECOND - 1) / OS_SYS_MS_PER_SECOND;
UINT32 ret = LOS_QueueRead(*mbox, msg ? msg : &ignore, sizeof(void*), tick ? (UINT32)tick : LOS_WAIT_FOREVER);
switch (ret) {
case LOS_OK:
return ERR_OK;
case LOS_ERRNO_QUEUE_ISEMPTY:
case LOS_ERRNO_QUEUE_TIMEOUT:
return SYS_ARCH_TIMEOUT;
default:
break;
}
LWIP_DEBUGF(SYS_DEBUG, ("%s: LOS_QueueRead error %u\n", __FUNCTION__, ret));
return SYS_ARCH_TIMEOUT; /* Errors should be treated as timeout */
}
u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg)
{
void *ignore = 0; /* if msg==NULL, the fetched msg should be dropped */
UINT32 ret = LOS_QueueRead(*mbox, msg ? msg : &ignore, sizeof(void*), 0);
switch (ret) {
case LOS_OK:
return ERR_OK;
case LOS_ERRNO_QUEUE_ISEMPTY:
return SYS_MBOX_EMPTY;
case LOS_ERRNO_QUEUE_TIMEOUT:
return SYS_ARCH_TIMEOUT;
default:
break;
}
LWIP_DEBUGF(SYS_DEBUG, ("%s: LOS_QueueRead error %u\n", __FUNCTION__, ret));
return SYS_MBOX_EMPTY; /* Errors should be treated as timeout */
}
void sys_mbox_free(sys_mbox_t *mbox)
{
(void)LOS_QueueDelete(*mbox);
}
int sys_mbox_valid(sys_mbox_t *mbox)
{
QUEUE_INFO_S queueInfo;
return LOS_OK == LOS_QueueInfoGet(*mbox, &queueInfo);
}
void sys_mbox_set_invalid(sys_mbox_t *mbox)
{
*mbox = LOSCFG_BASE_IPC_QUEUE_LIMIT;
}
/**
* Semaphore
*/
err_t sys_sem_new(sys_sem_t *sem, u8_t count)
{
UINT32 ret = LOS_SemCreate(count, sem);
if (ret != LOS_OK) {
return ERR_ARG;
}
return ERR_OK;
}
void sys_sem_signal(sys_sem_t *sem)
{
(void)LOS_SemPost(*sem);
}
u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeoutMs)
{
UINT64 tick = ((UINT64)timeoutMs * LOSCFG_BASE_CORE_TICK_PER_SECOND + OS_SYS_MS_PER_SECOND - 1) / OS_SYS_MS_PER_SECOND;
UINT32 ret = LOS_SemPend(*sem, tick ? (UINT32)tick : LOS_WAIT_FOREVER); // timeoutMs 0 means wait forever
switch (ret) {
case LOS_OK:
return ERR_OK;
case LOS_ERRNO_SEM_TIMEOUT:
return SYS_ARCH_TIMEOUT;
default:
break;
}
LWIP_DEBUGF(SYS_DEBUG, ("%s: LOS_SemPend error %u\n", __FUNCTION__, ret));
return SYS_ARCH_TIMEOUT; /* Errors should be treated as timeout */
}
void sys_sem_free(sys_sem_t *sem)
{
(void)LOS_SemDelete(*sem);
}
int sys_sem_valid(sys_sem_t *sem)
{
return *sem != LOSCFG_BASE_IPC_SEM_LIMIT;
}
void sys_sem_set_invalid(sys_sem_t *sem)
{
*sem = LOSCFG_BASE_IPC_SEM_LIMIT;
}
/**
* Mutex
*/
err_t sys_mutex_new(sys_mutex_t *mutex)
{
UINT32 ret = LOS_MuxInit(mutex, NULL);
if (ret != LOS_OK) {
return ERR_ARG;
}
return ERR_OK;
}
void sys_mutex_lock(sys_mutex_t *mutex)
{
(void)LOS_MuxLock(mutex, LOS_WAIT_FOREVER);
}
void sys_mutex_unlock(sys_mutex_t *mutex)
{
(void)LOS_MuxUnlock(mutex);
}
void sys_mutex_free(sys_mutex_t *mutex)
{
(void)LOS_MuxDestroy(mutex);
}
int sys_mutex_valid(sys_mutex_t *mutex)
{
return LOS_MuxIsValid(mutex);
}
void sys_mutex_set_invalid(sys_mutex_t *mutex)
{
(void)LOS_MuxDestroy(mutex);
}