Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
8122da71
K
Kernel Liteos A
项目概览
OpenHarmony
/
Kernel Liteos A
1 年多 前同步成功
通知
460
Star
414
Fork
55
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel Liteos A
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8122da71
编写于
9月 30, 2020
作者:
O
openharmony_ci
提交者:
Gitee
9月 30, 2020
浏览文件
操作
浏览文件
下载
差异文件
!11 修复tftp功能,重构部分lwIP移植代码
Merge pull request !11 from Caoruihong/caoruihong_20200924094756
上级
f9b7df63
4f55f678
变更
18
展开全部
隐藏空白更改
内联
并排
Showing
18 changed file
with
3218 addition
and
398 deletion
+3218
-398
net/lwip-2.1/Makefile
net/lwip-2.1/Makefile
+1
-1
net/lwip-2.1/enhancement/include/dhcps_fix.h
net/lwip-2.1/enhancement/include/dhcps_fix.h
+0
-102
net/lwip-2.1/enhancement/include/lwip/api_shell.h
net/lwip-2.1/enhancement/include/lwip/api_shell.h
+3
-5
net/lwip-2.1/enhancement/include/lwip/dhcps.h
net/lwip-2.1/enhancement/include/lwip/dhcps.h
+0
-10
net/lwip-2.1/enhancement/include/lwip/fixme.h
net/lwip-2.1/enhancement/include/lwip/fixme.h
+44
-83
net/lwip-2.1/enhancement/include/lwip/tftpc.h
net/lwip-2.1/enhancement/include/lwip/tftpc.h
+310
-0
net/lwip-2.1/enhancement/src/api_shell.c
net/lwip-2.1/enhancement/src/api_shell.c
+6
-3
net/lwip-2.1/enhancement/src/dhcps.c
net/lwip-2.1/enhancement/src/dhcps.c
+983
-0
net/lwip-2.1/enhancement/src/fixme.c
net/lwip-2.1/enhancement/src/fixme.c
+60
-75
net/lwip-2.1/enhancement/src/tftpc.c
net/lwip-2.1/enhancement/src/tftpc.c
+1726
-0
net/lwip-2.1/porting/include/lwip/dhcp.h
net/lwip-2.1/porting/include/lwip/dhcp.h
+19
-0
net/lwip-2.1/porting/include/lwip/lwipopts.h
net/lwip-2.1/porting/include/lwip/lwipopts.h
+4
-0
net/lwip-2.1/porting/include/lwip/netif.h
net/lwip-2.1/porting/include/lwip/netif.h
+10
-5
net/lwip-2.1/porting/include/lwip/netifapi.h
net/lwip-2.1/porting/include/lwip/netifapi.h
+1
-0
net/lwip-2.1/porting/src/driverif.c
net/lwip-2.1/porting/src/driverif.c
+28
-52
net/lwip-2.1/porting/src/fixme.c
net/lwip-2.1/porting/src/fixme.c
+0
-46
net/lwip-2.1/porting/src/sockets.c
net/lwip-2.1/porting/src/sockets.c
+6
-8
net/lwip-2.1/porting/src/sys_arch.c
net/lwip-2.1/porting/src/sys_arch.c
+17
-8
未找到文件。
net/lwip-2.1/Makefile
浏览文件 @
8122da71
...
...
@@ -44,7 +44,7 @@ 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/dhcp.c,
$(LOCAL_SRCS)
)
LOCAL_SRCS
:=
$(
filter-out
$(LWIPDIR)
/core/ipv4/etharp.c,
$(LOCAL_SRCS)
)
LOCAL_SRCS
:=
$(
filter-out
$(LWIPDIR)
/api/sockets.c,
$(LOCAL_SRCS)
)
...
...
net/lwip-2.1/enhancement/include/dhcps_fix.h
已删除
100755 → 0
浏览文件 @
f9b7df63
/*
* 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
net/lwip-2.1/enhancement/include/api_shell.h
→
net/lwip-2.1/enhancement/include/
lwip/
api_shell.h
浏览文件 @
8122da71
...
...
@@ -29,8 +29,8 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef LWIP_API_SHELL_H
#define LWIP_API_SHELL_H
#ifndef LWIP_
HDR_
API_SHELL_H
#define LWIP_
HDR_
API_SHELL_H
#include "arch/cc.h"
#include "lwip/opt.h"
...
...
@@ -58,6 +58,4 @@ void netstat_internal(void *ctx);
}
#endif
#endif
#endif
/* LWIP_HDR_API_SHELL_H */
net/lwip-2.1/enhancement/include/dhcps.h
→
net/lwip-2.1/enhancement/include/
lwip/
dhcps.h
浏览文件 @
8122da71
...
...
@@ -63,16 +63,6 @@ extern "C" {
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
}
...
...
net/lwip-2.1/enhancement/include/
api_shell_fix
.h
→
net/lwip-2.1/enhancement/include/
lwip/fixme
.h
浏览文件 @
8122da71
...
...
@@ -29,17 +29,12 @@
* 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
#ifndef LWIP_HDR_FIXME_H
#define LWIP_HDR_FIXME_H
#include "lwip/opt.h"
#i
f LWIP_ENABLE_LOS_SHELL_CMD
#include "netif/etharp.h"
#i
nclude "lwip/netif.h"
#define link_rx_drop cachehit
#define link_tx_drop cachehit
...
...
@@ -51,61 +46,56 @@
#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 DUP_ARP_DETECT_TIME 2000
/* 2 seconds period */
#define SOF_BINDNONUNICAST 0x0800U
/* socket has bind to a non unicast */
#define NETCONN_PKT_RAW 0x80
#define SYS_ARCH_ERROR SYS_ARCH_TIMEOUT
#define LWIP_SHELL_CMD_PING_RETRY_TIMES 4
#define LWIP_ENABLE_LOS_SHELL_CMD LOSCFG_SHELL
#define LWIP_SHELL_CMD_PING_RETRY_TIMES 4
#define LWIP_SHELL_CMD_PING_TIMEOUT 2000
#define LWIP_MAX_UDP_RAW_SEND_SIZE 65332
#define LWIP_EXT_POLL_SUPPORT LWIP_SOCKET_POLL
#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_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)))
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))
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))
0 : \
ip4_addr_netcmp(ip_2_ip4(addr1), ip_2_ip4(addr2), mask))
#if LWIP_DHCP
#define ip6_addr_isnone_val(ip6addr) (((ip6addr).addr[0] == 0xffffffffUL) && \
((ip6addr).addr[1] == 0xffffffffUL) && \
((ip6addr).addr[2] == 0xffffffffUL) && \
((ip6addr).addr[3] == 0xffffffffUL))
/*
* 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
);
#define ip6_addr_isnone(ip6addr) (((ip6addr) == NULL) || ip6_addr_isnone_val(*(ip6addr)))
#define ipaddr_ntoa_unsafe(addr) ((IP_IS_V6_VAL(*addr)) ? ip6addr_ntoa(ip_2_ip6(addr)) : ip4addr_ntoa(ip_2_ip4(addr)))
#endif
/* LWIP_DHCP */
#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
#include "lwip/prot/dhcp.h"
err_t
netif_dhcp_off
(
struct
netif
*
netif
);
err_t
netif_do_rmv_ipv6_addr
(
struct
netif
*
netif
,
void
*
arguments
);
...
...
@@ -113,49 +103,20 @@ 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
#if LWIP_RAW
extern
struct
raw_pcb
*
raw_pcbs
;
#endif
#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
#endif
/* LWIP_HDR_FIXME_H */
net/lwip-2.1/enhancement/include/lwip/tftpc.h
0 → 100644
浏览文件 @
8122da71
/*
* 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_TFTPC_H
#define LWIP_HDR_TFTPC_H
#include "lwip/opt.h"
#include "lwip/sockets.h"
#if LWIP_TFTP
/* don't build if not configured for use in lwipopts.h */
#if defined (__cplusplus) && __cplusplus
extern
"C"
{
#endif
#define TFTP_NULL_UINT32 ((u32_t)0xffffffffUL)
#define TFTP_NULL_INT32 -1
/** @cond liteos
* @defgroup TFTP_Interfaces
* @ingroup Enums
* * This section contains the TFTP enums.
*/
/**
*
* This Enum is used to specify the transfer mode of the file to be handled by TFTP client.
*/
typedef
enum
tagTFTPC_TransferMode
{
TRANSFER_MODE_ASCII
=
0
,
/**< Indicates that the mode of transfer is ASCII. */
TRANSFER_MODE_BINARY
,
/**< Indicates that the mode of transfer is Binary */
TRANSFER_MODE_BUTT
/**< Indicates invalid transfer mode.*/
}
TFTPC_TRANSFER_MODE_E
;
/**
* This Enum is used to specify the transfer mode to be handled by TFTP client
* This Enum indicates the TFTP client transfer mode of the file
*/
typedef
enum
tagTFTPC_ErrCode
{
TFTPC_SOCKET_FAILURE
=
1
,
/**< Error while creating UDP socket. */
TFTPC_BIND_FAILURE
=
2
,
/**< Error while binding to the UDP socket. */
TFTPC_SELECT_ERROR
=
3
,
/**< Error returned by select() system call. */
TFTPC_RECVFROM_ERROR
=
4
,
/**< Error while receiving data from the peer. */
TFTPC_SENDTO_ERROR
=
5
,
/**< Error while sending data to the peer. */
TFTPC_FILE_NOT_FOUND
=
6
,
/**< Requested file is not found. */
/**< This is the error sent by the server when host name cannot be resolved. */
TFTPC_CANNOT_RESOLVE_HOSTNAME
=
7
,
TFTPC_INVALID_PARAVALUE
=
8
,
/**< Input parameters passed to TFTP interfaces are invalid. */
/**< Error detected in TFTP packet or the error received from the TFTP server. */
TFTPC_PROTO_ERROR
=
9
,
/**< Error during packet synchronization while sending or unexpected packet is received. */
TFTPC_SYNC_FAILURE
=
10
,
/**< File size limit crossed, Max block can be 0xFFFF, each block containing 512 bytes. */
TFTPC_FILE_TOO_BIG
=
11
,
TFTPC_SRC_FILENAME_LENGTH_ERROR
=
12
,
/**< File name length greater than 256. */
TFTPC_IP_NOT_WITHIN_RANGE
=
13
,
/**< Host name IP is not valid. */
TFTPC_ACCESS_ERROR
=
14
,
/**< TFTP server returned file access error. */
/**< TFTP server returned error signifying that the DISK is full to write. */
TFTPC_DISK_FULL
=
15
,
TFTPC_FILE_EXISTS
=
16
,
/**< TFTP server returned error signifying that the file exists. */
/**< tftp_put_file_by_filename returned error signifying that the source file name do not exist. */
TFTPC_FILE_NOT_EXIST
=
17
,
TFTPC_MEMALLOC_ERROR
=
18
,
/**< Memory allocation failed in TFTP client. */
TFTPC_FILEOPEN_ERROR
=
19
,
/**< File open failed. */
TFTPC_FILEREAD_ERROR
=
20
,
/**< File read error. */
TFTPC_FILECREATE_ERROR
=
21
,
/**< File create error. */
TFTPC_FILEWRITE_ERROR
=
22
,
/**< File write error. */
TFTPC_TIMEOUT_ERROR
=
23
,
/**< Max time expired while waiting for file to be received. */
/**< Error when the received packet is less than 4 bytes (error length) or greater than 512 bytes. */
TFTPC_PKT_SIZE_ERROR
=
24
,
TFTPC_ERROR_NOT_DEFINED
=
25
,
/**< Returned by TFTP server for protocol user error. */
TFTPC_DEST_PATH_LENGTH_ERROR
=
26
,
/**< If the destination file path length is greater than 256. */
TFTPC_UNKNOWN_TRANSFER_ID
=
27
,
/**< Returned by TFTP server for undefined transfer ID. */
/**< IOCTL function failed at TFTP client while setting the socket to non-block. */
TFTPC_IOCTLSOCKET_FAILURE
=
28
,
TFTPC_MEMCPY_FAILURE
=
29
/**< TFTP memcpy failure. */
}
TFTPC_ERR_CODE_E
;
typedef
enum
tagTFTPC_OpCode
{
TFTPC_OP_RRQ
=
1
,
/* read request */
TFTPC_OP_WRQ
,
/* write request */
TFTPC_OP_DATA
,
/* data packet */
TFTPC_OP_ACK
,
/* acknowledgement */
TFTPC_OP_ERROR
,
/* error code */
TFTPC_OP_OPT
/* option code */
}
TFTPC_OPCODE_E
;
typedef
enum
tagTFTPC_PROTOCOL_ErrCode
{
TFTPC_PROTOCOL_USER_DEFINED
=
0
,
TFTPC_PROTOCOL_FILE_NOT_FOUND
,
TFTPC_PROTOCOL_ACCESS_ERROR
,
TFTPC_PROTOCOL_DISK_FULL
,
TFTPC_PROTOCOL_PROTO_ERROR
,
TFTPC_PROTOCOL_UNKNOWN_TRANSFER_ID
,
TFTPC_PROTOCOL_FILE_EXISTS
,
TFTPC_PROTOCOL_CANNOT_RESOLVE_HOSTNAME
}
TFTPC_PROT_ERRCODE_E
;
#ifndef TFTPC_MAX_SEND_REQ_ATTEMPTS
#define TFTPC_MAX_SEND_REQ_ATTEMPTS 5
/* tftp max attempts */
#endif
#ifndef TFTPC_TIMEOUT_PERIOD
#define TFTPC_TIMEOUT_PERIOD 5
/* tftp timeout period,unit :s */
#endif
#define TFTPC_SERVER_PORT 69
/* tftp server well known port no. */
/* MAX file size in TFTP is 32 MB.
Reason for keeping 75 here , is ((75*512=38400bytes)/1024) = 37MB. So the recv/Send Loop can
receive the complete MAX message from the network
*/
#define TFTPC_MAX_WAIT_IN_LOOP 75
#define TFTP_BLKSIZE 512
/* data block size (IEN-133) */
#define TFTP_HDRSIZE 4
/* TFTP header size */
#define TFTP_PKTSIZE (TFTP_BLKSIZE + TFTP_HDRSIZE)
/* Packet size */
#define TFTP_MAX_MODE_SIZE 9
/* max size of mode string */
#define TFTP_MAXERRSTRSIZE 100
/* max size of error message string */
#define TFTP_MAX_PATH_LENGTH 256
/* Max path or filename length */
#define TFTP_MAX_BLK_NUM (0xFFFFL)
/* MAximum block number */
/* IP address not including reserved IPs(0 and 127) and multicast addresses(Class D) */
#define TFTPC_IP_ADDR_MIN 0x01000000
#define TFTPC_IP_ADDR_EX_RESV 0x7effffff
#define TFTPC_IP_ADDR_CLASS_B 0x80000000
#define TFTPC_IP_ADDR_EX_CLASS_DE 0xdfffffff
#define TFTPC_FOUR 4
/* minimum packet size */
/****************************************************************************/
/* Structure definitions */
/****************************************************************************/
/* Tftp data packet */
typedef
struct
tagTFTPC_DATA
{
u16_t
usBlknum
;
/* block number */
u8_t
ucDataBuf
[
TFTP_BLKSIZE
];
/* Actual data */
}
TFTPC_DATA_S
;
/* TFTP error packet */
typedef
struct
tagTFTPC_ERROR
{
u16_t
usErrNum
;
/* error number */
u8_t
ucErrMesg
[
TFTP_MAXERRSTRSIZE
];
/* error message */
}
TFTPC_ERROR_S
;
/* TFTP packet format */
typedef
struct
tagTFTPC_PACKET
{
u16_t
usOpcode
;
/* Opcode value */
union
{
/* it contains mode and filename */
s8_t
ucName_Mode
[
TFTP_MAX_PATH_LENGTH
+
TFTP_MAX_MODE_SIZE
];
u16_t
usBlknum
;
/* Block Number */
TFTPC_DATA_S
stTFTP_Data
;
/* Data Packet */
TFTPC_ERROR_S
stTFTP_Err
;
/* Error Packet */
}
u
;
}
TFTPC_PACKET_S
;
/** @defgroup TFTP_Interfaces
* This section contains the TFTP Interfaces
*/
/*
Func Name: lwip_tftp_get_file_by_filename
*/
/**
* @ingroup TFTP_Interfaces
* @brief
* This API gets the source file from the server. It then stores the received file in the destination path
* on the client system.
*
* @param[in] ulHostAddr IP address of Host. This is the TFTP server IP. [NA]
* @param[in] usTftpServPort TFTP server port. If the value is passed as 0 then the default TFTP
* PORT 69 is used. [NA]
* @param[in] ucTftpTransMode File transfer mode, either TRANSFER_MODE_BINARY or TRANSFER_MODE_ASCII. [NA]
* @param[in] szSrcFileName Source file in the tftp server. [NA]
* @param[in] szDestDirPath Destination file path in the in the client. [NA]
* @param[out] [N/A]
*
* @return
* ERR_OK: On success \n
* TFTPC_ERR_CODE_E: On failure
*
* @note
* \n
* The behavior of this API is such that if the destination file already exists, it will be overwritten.
*/
u32_t
lwip_tftp_get_file_by_filename
(
u32_t
ulHostAddr
,
u16_t
usTftpServPort
,
u8_t
ucTftpTransMode
,
s8_t
*
szSrcFileName
,
s8_t
*
szDestDirPath
);
/* @defgroup TFTP_Interfaces
* This section contains the TFTP Interfaces
*/
/*
Func Name: lwip_tftp_put_file_by_filename
*/
/**
* @ingroup TFTP_Interfaces
* @brief
* This API reads the contents of the source file on the client system and sends it to the server and
* server then receives the data and stores it in the specified destination path.
*
* @param[in] ulHostAddr Indicates the IP address of Host. This is the TFTP server IP.
* @param[in] usTftpServPort Indicates the TFTP server port. If the value is passed as 0 then the default TFTP
* PORT 69 is used.
* @param[in] ucTftpTransMode Indicates the file transfer mode, either TRANSFER_MODE_BINARY or TRANSFER_MODE_ASCII.
* @param[in] szSrcFileName Indicates the source file in the client.
* @param[in] szDestDirPath Indicates the destination file path on the tftp server.
*
* @return
* ERR_OK: On success \n
* TFTPC_ERR_CODE_E: On failure
*
*/
u32_t
lwip_tftp_put_file_by_filename
(
u32_t
ulHostAddr
,
u16_t
usTftpServPort
,
u8_t
cTftpTransMode
,
s8_t
*
szSrcFileName
,
s8_t
*
szDestDirPath
);
#ifdef TFTP_TO_RAWMEM
/* @defgroup TFTP_Interfaces
* This section contains the TFTP Interfaces
*/
/*
Func Name: lwip_tftp_get_file_by_filename_to_rawmem
*/
/**
* @ingroup TFTP_Interfaces
* @brief
* This API gets the source file from the server. It then stores the received file in the target memory
* on the client system.
*
* @param[in] ulHostAddr Indicates the IP address of the Host. This is the TFTP server IP.
* @param[in] usTftpServPort Indicates the TFTP server port. If the value is passed as 0 then the default TFTP
* PORT 69 is used.
* @param[in] ucTftpTransMode Indicates the File transfer mode, either TRANSFER_MODE_BINARY or TRANSFER_MODE_ASCII.
* @param[in] szSrcFileName Indicates the Source file in the TFTP server.
* @param[in] szDestMemAddr Indicates the target memory address in the client.
* @param[in/out] ulFileLength Indicates the target memory address can cache the size of the content,
and The real size of the Source file.
*
* @return
* ERR_OK: On success \n
* TFTPC_ERR_CODE_E: On failure
* @note
* 1.You must define TFTP_TO_RAWMEM when using this API. \n
* 2.The behavior of this API is such that if the destination file already exists, it will be overwritten.
* @endcond
*/
u32_t
lwip_tftp_get_file_by_filename_to_rawmem
(
u32_t
ulHostAddr
,
u16_t
usTftpServPort
,
u8_t
ucTftpTransMode
,
s8_t
*
szSrcFileName
,
s8_t
*
szDestMemAddr
,
u32_t
*
ulFileLength
);
#endif
#if defined (__cplusplus) && __cplusplus
}
#endif
#endif
/* LWIP_TFTP */
#endif
/* LWIP_HDR_TFTPC_H */
net/lwip-2.1/enhancement/src/api_shell.c
浏览文件 @
8122da71
...
...
@@ -33,7 +33,7 @@
#define icmp6_hdr netinet_icmp6_hdr
#include <netinet/icmp6.h>
#undef icmp6_hdr
#include "
api_shell_fix
.h"
#include "
lwip/fixme
.h"
#include "lwip/opt.h"
#if LWIP_ENABLE_LOS_SHELL_CMD
...
...
@@ -62,7 +62,8 @@
#include <ctype.h>
#include <poll.h>
#include "api_shell.h"
#include "lwip/api_shell.h"
#include "lwip/tftpc.h"
#include "lwip/dns.h"
#include "lwip/netdb.h"
...
...
@@ -78,7 +79,7 @@
#include "shell.h"
#endif
#define
netif_find netifapi_netif_find_by_name
#define
LWIP_STATIC static
#if LWIP_ARP
extern
sys_sem_t
ip_conflict_detect
;
...
...
@@ -3163,8 +3164,10 @@ void netstat_internal(void *ctx)
int
recvQlen
=
0
;
int
sendQlen
=
0
;
u_int
proto
;
#if PF_PKT_SUPPORT
u8_t
netif_name
[
IFNAMSIZ
];
struct
netif
*
netif
=
NULL
;
#endif
if
(
ndata
==
NULL
)
{
return
;
...
...
net/lwip-2.1/enhancement/src/dhcps.c
0 → 100644
浏览文件 @
8122da71
此差异已折叠。
点击以展开。
net/lwip-2.1/enhancement/src/
api_shell_fix
.c
→
net/lwip-2.1/enhancement/src/
fixme
.c
浏览文件 @
8122da71
...
...
@@ -29,46 +29,26 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "api_shell_fix.h"
#include <time.h>
#include "lwip/fixme.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
)
...
...
@@ -85,32 +65,48 @@ err_t netif_dhcp_off(struct netif *netif)
old_gateway
=
netif
->
gw
;
if
(
netif_dhcp_data
(
netif
))
{
(
void
)
dhcp_release
(
netif
);
(
void
)
dhcp_stop
(
netif
);
(
void
)
dhcp_cleanup
(
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
);
(
void
)
netif_set_up
(
netif
);
return
ERR_OK
;
}
err_t
dhcp_is_bound
(
struct
netif
*
netif
)
{
struct
dhcp
*
dhcp
=
NULL
;
LWIP_ERROR
(
"netif != NULL"
,
(
netif
!=
NULL
),
return
ERR_ARG
);
dhcp
=
netif_dhcp_data
(
netif
);
LWIP_ERROR
(
"netif->dhcp != NULL"
,
(
dhcp
!=
NULL
),
return
ERR_ARG
);
if
(
dhcp
->
state
==
DHCP_STATE_BOUND
)
{
return
ERR_OK
;
}
else
{
return
ERR_INPROGRESS
;
}
}
#endif
/* LWIP_DHCP */
#if LWIP_DHCPS
#include "dhcps.h"
#include "
lwip/
dhcps.h"
static
err_t
netifapi_do_dhcps_start
(
struct
tcpip_api_call_data
*
m
)
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
;
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
;
}
...
...
@@ -124,8 +120,8 @@ err_t netifapi_dhcps_start(struct netif *netif, char *start_ip, u16_t ip_num)
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
;
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
);
...
...
@@ -216,19 +212,19 @@ static struct netif *netif_find_by_name(const char *name)
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
(
"lo"
,
name
)
==
0
&&
(
netif
->
name
[
0
]
==
'l'
&&
netif
->
name
[
1
]
==
'o'
))
{
LWIP_DEBUGF
(
NETIF_DEBUG
,
(
"netif_find_by_name: found lo
\n
"
));
return
netif
;
}
if
(
strcmp
(
netif
->
full_name
,
name
)
==
0
)
{
LWIP_DEBUGF
(
NETIF_DEBUG
,
(
"netif_find
: found %c%c
\n
"
,
name
[
0
],
name
[
1
]
));
LWIP_DEBUGF
(
NETIF_DEBUG
,
(
"netif_find
_by_name: found %s
\n
"
,
name
));
return
netif
;
}
}
LWIP_DEBUGF
(
NETIF_DEBUG
,
(
"netif_find
: didn't find %c%c
\n
"
,
name
[
0
],
name
[
1
]
));
LWIP_DEBUGF
(
NETIF_DEBUG
,
(
"netif_find
_by_name: didn't find %s
\n
"
,
name
));
return
NULL
;
}
...
...
@@ -294,7 +290,7 @@ err_t netif_set_mtu(struct netif *netif, u16_t 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
));
netif_get_name
(
netif
),
netif
->
mtu
));
return
ERR_OK
;
}
...
...
@@ -322,31 +318,35 @@ err_t netif_set_hwaddr(struct netif *netif, const unsigned char *hw_addr, int hw
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
]));
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
)
{
// FIXME
return
0
;
}
err_t
etharp_delete_arp_entry
(
struct
netif
*
netif
,
ip4_addr_t
*
ipaddr
)
{
// FIXME
return
0
;
}
err_t
lwip_dns_setserver
(
u8_t
numdns
,
ip_addr_t
*
dnsserver
)
{
// FIXME
return
0
;
}
err_t
lwip_dns_getserver
(
u8_t
numdns
,
ip_addr_t
*
dnsserver
)
{
// FIXME
return
0
;
}
...
...
@@ -354,57 +354,42 @@ err_t lwip_dns_getserver(u8_t numdns, ip_addr_t *dnsserver)
struct
raw_pcb
*
pkt_raw_pcbs
;
#endif
struct
raw_pcb
*
raw_pcbs
;
#if LWIP_RAW
struct
raw_pcb
*
raw_pcbs
;
/* already defined in raw.c, but is static */
#endif
/******************************************************************/
#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
;
}
#if LWIP_SNTP
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
;
}
#include <time.h>
u32_t
lwip_tftp_put_file_by_filename
(
u32_t
ulHostAddr
,
u16_t
usTftpServPort
,
u8_t
cTftpTransMode
,
s8_t
*
szSrcFileName
,
s8_t
*
szDestDirPath
)
int
lwip_sntp_start
(
int
server_num
,
char
**
sntp_server
,
struct
timeval
*
time
)
{
// FIXME
return
0
;
}
#endif
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"
"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
net/lwip-2.1/enhancement/src/tftpc.c
0 → 100644
浏览文件 @
8122da71
此差异已折叠。
点击以展开。
net/lwip-2.1/porting/include/lwip/dhcp.h
浏览文件 @
8122da71
...
...
@@ -32,13 +32,32 @@
#ifndef _LWIP_PORTING_DHCP_H_
#define _LWIP_PORTING_DHCP_H_
#include <lwip/opt.h>
#if LWIP_DHCPS
#define DHCP_OPTION_IDX_SERVER_ID DHCP_OPTION_IDX_SERVER_ID, \
DHCP_OPTION_IDX_REQUESTED_IP
#endif
#include_next <lwip/dhcp.h>
#if LWIP_DHCPS
#undef DHCP_OPTION_IDX_SERVER_ID
#endif
#include <lwip/prot/dhcp.h> // For DHCP_STATE_BOUND, DHCP_DISCOVER etc. by `mac/common/mac_data.c'
#ifdef __cplusplus
extern
"C"
{
#endif
#if LWIP_DHCPS
#define LWIP_HOOK_DHCP_PARSE_OPTION(netif, dhcp, state, msg, msg_type, option, len, pbuf, offset) \
LWIP_UNUSED_ARG(msg); \
break; \
case (DHCP_OPTION_REQUESTED_IP): \
LWIP_ERROR("len == 4", len == 4, return ERR_VAL); \
decode_idx = DHCP_OPTION_IDX_REQUESTED_IP;
#endif
err_t
dhcp_is_bound
(
struct
netif
*
netif
);
#ifdef __cplusplus
...
...
net/lwip-2.1/porting/include/lwip/lwipopts.h
浏览文件 @
8122da71
...
...
@@ -32,6 +32,7 @@
#ifndef _LWIP_PORTING_LWIPOPTS_H_
#define _LWIP_PORTING_LWIPOPTS_H_
#include "menuconfig.h"
// lwIP debug options, comment the ones you don't want
#if LWIP_DEBUG
...
...
@@ -215,6 +216,9 @@
#define LWIP_CONFIG_NUM_SOCKETS 128
#define IP_REASS_MAX_MEM_SIZE (MEM_SIZE / 4)
// Options for enhancement code, same for old lwipopts.h
#define LWIP_NETIF_PROMISC 1
#define LWIP_TFTP LOSCFG_NET_LWIP_SACK_TFTP
#define LWIP_DHCPS 1
#define LWIP_ENABLE_NET_CAPABILITY 1
...
...
net/lwip-2.1/porting/include/lwip/netif.h
浏览文件 @
8122da71
...
...
@@ -35,16 +35,23 @@
#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 netif_find netifapi_netif_find_by_name
#if LWIP_DHCPS
#define LWIP_NETIF_CLIENT_DATA_INDEX_DHCP LWIP_NETIF_CLIENT_DATA_INDEX_DHCP, \
LWIP_NETIF_CLIENT_DATA_INDEX_DHCPS
#endif
#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
#if LWIP_DHCPS
#undef LWIP_NETIF_CLIENT_DATA_INDEX_DHCP
#endif
#include <lwip/etharp.h> // For ETHARP_HWADDR_LEN, by `hieth-sf src/interface.c' and `wal/wal_net.c'
...
...
@@ -64,9 +71,7 @@ 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 PF_PKT_SUPPORT LWIP_NETIF_PROMISC
#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)
...
...
net/lwip-2.1/porting/include/lwip/netifapi.h
浏览文件 @
8122da71
...
...
@@ -45,6 +45,7 @@ err_t netifapi_dhcps_stop(struct netif *netif);
#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
);
struct
netif
*
netifapi_netif_find_by_name
(
const
char
*
name
);
#ifndef __LWIP__
#define netifapi_netif_add(a, b, c, d) netifapi_netif_add(a, b, c, d, (a)->state, driverif_init, tcpip_input)
...
...
net/lwip-2.1/porting/src/driverif.c
浏览文件 @
8122da71
...
...
@@ -44,7 +44,6 @@
#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
...
...
@@ -57,6 +56,9 @@ driverif_init_ifname(struct netif *netif)
struct
netif
*
tmpnetif
=
NULL
;
const
char
*
prefix
=
(
netif
->
link_layer_type
==
WIFI_DRIVER_IF
)
?
"wlan"
:
"eth"
;
netif
->
name
[
0
]
=
prefix
[
0
];
netif
->
name
[
1
]
=
prefix
[
1
];
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
)
{
...
...
@@ -140,7 +142,7 @@ driverif_input(struct netif *netif, struct pbuf *p)
#endif
#else
u16_t
ethhdr_type
;
struct
eth_hdr
*
ethhdr
=
NULL
;
struct
eth_hdr
*
ethhdr
=
NULL
;
#endif
err_t
ret
=
ERR_VAL
;
...
...
@@ -241,7 +243,6 @@ err_t
driverif_init
(
struct
netif
*
netif
)
{
u16_t
link_layer_type
;
err_t
ret
;
if
(
netif
==
NULL
)
{
return
ERR_IF
;
...
...
@@ -262,17 +263,7 @@ driverif_init(struct netif *netif)
#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 */
/*
...
...
@@ -285,21 +276,6 @@ driverif_init(struct netif *netif)
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
);
...
...
@@ -309,30 +285,30 @@ driverif_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
|
#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_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
;
...
...
net/lwip-2.1/porting/src/fixme.c
已删除
100755 → 0
浏览文件 @
f9b7df63
/*
* 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
net/lwip-2.1/porting/src/sockets.c
浏览文件 @
8122da71
...
...
@@ -31,7 +31,7 @@
#include <lwip/sockets.h>
#include <lwip/priv/tcpip_priv.h>
#include <
api_shell_fix
.h>
#include <
lwip/fixme
.h>
#if LWIP_ENABLE_NET_CAPABILITY
#include "capability_type.h"
...
...
@@ -39,8 +39,6 @@
#define BIND_SERVICE_CAP_MIN_PORT 1024
#endif
#define netif_find netifapi_netif_find_by_name
#define IOCTL_CMD_CASE_HANDLER() \
{ \
err_t err; \
...
...
@@ -86,7 +84,8 @@ int lwip_bind(int s, const struct sockaddr *name, socklen_t namelen)
return
lwip_bind_wrap
(
s
,
name
,
namelen
);
}
static
ssize_t
lwip_sendto_wrap
(
int
s
,
const
void
*
dataptr
,
size_t
size
,
int
flags
,
const
struct
sockaddr
*
to
,
socklen_t
tolen
);
static
ssize_t
lwip_sendto_wrap
(
int
s
,
const
void
*
dataptr
,
size_t
size
,
int
flags
,
const
struct
sockaddr
*
to
,
socklen_t
tolen
);
ssize_t
lwip_sendto
(
int
s
,
const
void
*
dataptr
,
size_t
size
,
int
flags
,
const
struct
sockaddr
*
to
,
socklen_t
tolen
)
{
return
lwip_sendto_wrap
(
s
,
dataptr
,
size
,
flags
,
to
,
tolen
);
...
...
@@ -227,12 +226,12 @@ static int lwip_bind_wrap(int s, const struct sockaddr *name, socklen_t namelen)
}
static
ssize_t
lwip_sendto_wrap
(
int
s
,
const
void
*
dataptr
,
size_t
size
,
int
flags
,
const
struct
sockaddr
*
to
,
socklen_t
tolen
)
const
struct
sockaddr
*
to
,
socklen_t
tolen
)
{
#if LWIP_ENABLE_NET_CAPABILITY
if
(
to
&&
((
to
->
sa_family
==
AF_INET
&&
tolen
>=
sizeof
(
struct
sockaddr_in
))
||
(
to
->
sa_family
==
AF_INET6
&&
tolen
>=
sizeof
(
struct
sockaddr_in6
))))
{
(
to
->
sa_family
==
AF_INET6
&&
tolen
>=
sizeof
(
struct
sockaddr_in6
))))
{
ip_addr_t
ipaddr
;
u16_t
port
;
...
...
@@ -366,7 +365,6 @@ int get_unused_socket_num(void)
// Options for lwip ioctl
#define LWIP_IOCTL_ROUTE 1
#define LWIP_IOCTL_IF 1
#define LWIP_NETIF_PROMISC 1
#define LWIP_NETIF_ETHTOOL 0
#define LWIP_IOCTL_IPV6DPCTD 0
#undef LWIP_IPV6_DUP_DETECT_ATTEMPTS
...
...
@@ -758,7 +756,7 @@ static u8_t lwip_ioctl_internal_SIOCSIFNETMASK(struct ifreq *ifr)
loc_netif
=
loc_netif
->
next
;
}
#if LWIP_DHCP
// LWIP_DHCP
#if LWIP_DHCP
if
((
netif_dhcp_data
(
netif
)
!=
NULL
)
&&
(
netif_dhcp_data
(
netif
)
->
state
!=
DHCP_STATE_OFF
))
{
(
void
)
netif_dhcp_off
(
netif
);
...
...
net/lwip-2.1/porting/src/sys_arch.c
浏览文件 @
8122da71
...
...
@@ -46,6 +46,7 @@ static u32_t lwprot_thread = LOS_ERRNO_TSK_ID_INVALID;
static
int
lwprot_count
=
0
;
#endif
/* LOSCFG_KERNEL_SMP == YES */
#define ROUND_UP_DIV(val, div) (((val) + (div) - 1) / (div))
/**
* Thread and System misc
...
...
@@ -59,11 +60,11 @@ sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg,
/* Create host Task */
task
.
pfnTaskEntry
=
(
TSK_ENTRY_FUNC
)
thread
;
task
.
uwStackSize
=
stackSize
;
task
.
uwStackSize
=
stackSize
;
task
.
pcName
=
(
char
*
)
name
;
task
.
usTaskPrio
=
prio
;
task
.
auwArgs
[
0
]
=
(
UINTPTR
)
arg
;
task
.
uwResved
=
LOS_TASK_STATUS_DETACHED
;
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
));
...
...
@@ -84,9 +85,17 @@ void sys_init(void)
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
);
return
(
u32_t
)((
LOS_TickCountGet
()
*
OS_SYS_MS_PER_SECOND
)
/
LOSCFG_BASE_CORE_TICK_PER_SECOND
);
}
#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
/**
* Protector
...
...
@@ -140,7 +149,7 @@ void sys_arch_unprotect(sys_prot_t pval)
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
*
));
UINT32
ret
=
LOS_QueueCreate
(
qName
,
(
UINT16
)
size
,
mbox
,
0
,
sizeof
(
void
*
));
switch
(
ret
)
{
case
LOS_OK
:
return
ERR_OK
;
...
...
@@ -184,8 +193,8 @@ 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
);
UINT64
tick
=
ROUND_UP_DIV
((
UINT64
)
timeoutMs
*
LOSCFG_BASE_CORE_TICK_PER_SECOND
,
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
;
...
...
@@ -202,7 +211,7 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeoutMs)
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
);
UINT32
ret
=
LOS_QueueRead
(
*
mbox
,
msg
?
msg
:
&
ignore
,
sizeof
(
void
*
),
0
);
switch
(
ret
)
{
case
LOS_OK
:
return
ERR_OK
;
...
...
@@ -255,7 +264,7 @@ void sys_sem_signal(sys_sem_t *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
;
UINT64
tick
=
ROUND_UP_DIV
((
UINT64
)
timeoutMs
*
LOSCFG_BASE_CORE_TICK_PER_SECOND
,
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
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录