summaryrefslogtreecommitdiff
path: root/components/net
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2019-03-17 09:33:47 +0800
committerGitHub <[email protected]>2019-03-17 09:33:47 +0800
commitd778c9df25cbbd8e202a0133453e4c8b8e179eff (patch)
tree6dd97c1487eacf0a6d858b7541866f865b9203de /components/net
parent2d69172ad39a52e574a22b4374ee89848d832fe8 (diff)
parent94e3f77f25249b52c6f72921a2d2564f68bcd6ff (diff)
Merge pull request #2455 from armink/lts-v3.1.x
Lts v3.1.x
Diffstat (limited to 'components/net')
-rw-r--r--components/net/at/Kconfig4
-rw-r--r--components/net/at/include/at_log.h3
-rw-r--r--components/net/lwip-1.4.1/src/arch/sys_arch.c4
-rw-r--r--components/net/lwip-1.4.1/src/include/netif/ethernetif.h40
-rw-r--r--components/net/lwip-1.4.1/src/netif/ethernetif.c4
-rw-r--r--components/net/lwip-2.0.2/src/include/netif/ethernetif.h40
-rw-r--r--components/net/lwip-2.0.2/src/netif/ethernetif.c4
-rw-r--r--components/net/lwip-2.1.0/src/arch/sys_arch.c6
-rw-r--r--components/net/lwip-2.1.0/src/include/netif/ethernetif.h40
-rw-r--r--components/net/lwip-2.1.0/src/netif/ethernetif.c14
-rw-r--r--components/net/sal_socket/socket/net_sockets.c62
-rw-r--r--components/net/sal_socket/src/sal_socket.c4
12 files changed, 142 insertions, 83 deletions
diff --git a/components/net/at/Kconfig b/components/net/at/Kconfig
index a1f1b8199d..b1909f86bf 100644
--- a/components/net/at/Kconfig
+++ b/components/net/at/Kconfig
@@ -74,6 +74,10 @@ if RT_USING_AT
config AT_PRINT_RAW_CMD
bool "Enable print RAW format AT command communication data"
default n
+
+ config AT_CMD_MAX_LEN
+ int "The maximum lenght of AT Commonds buffer"
+ default 128
endif
diff --git a/components/net/at/include/at_log.h b/components/net/at/include/at_log.h
index 278763d30e..fe8766ba95 100644
--- a/components/net/at/include/at_log.h
+++ b/components/net/at/include/at_log.h
@@ -12,9 +12,6 @@
* NOTE: DO NOT include this file on the header file.
*/
-#define DBG_ENABLE
-#define DBG_COLOR
-
#ifndef LOG_TAG
#define DBG_SECTION_NAME "at"
#else
diff --git a/components/net/lwip-1.4.1/src/arch/sys_arch.c b/components/net/lwip-1.4.1/src/arch/sys_arch.c
index 45c09e6137..dc20ee97a1 100644
--- a/components/net/lwip-1.4.1/src/arch/sys_arch.c
+++ b/components/net/lwip-1.4.1/src/arch/sys_arch.c
@@ -500,7 +500,9 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
ret = rt_mb_recv(*mbox, (rt_uint32_t *)msg, t);
if(ret == -RT_ETIMEOUT)
+ {
return SYS_ARCH_TIMEOUT;
+ }
else
{
LWIP_ASSERT("rt_mb_recv returned with error!", ret == RT_EOK);
@@ -531,7 +533,9 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg)
ret = rt_mb_recv(*mbox, (rt_uint32_t *)msg, 0);
if(ret == -RT_ETIMEOUT)
+ {
return SYS_ARCH_TIMEOUT;
+ }
else
{
if (ret == RT_EOK)
diff --git a/components/net/lwip-1.4.1/src/include/netif/ethernetif.h b/components/net/lwip-1.4.1/src/include/netif/ethernetif.h
index bdad32ec20..1c969e6e25 100644
--- a/components/net/lwip-1.4.1/src/include/netif/ethernetif.h
+++ b/components/net/lwip-1.4.1/src/include/netif/ethernetif.h
@@ -17,27 +17,35 @@
struct eth_device
{
- /* inherit from rt_device */
- struct rt_device parent;
+ /* inherit from rt_device */
+ struct rt_device parent;
- /* network interface for lwip */
- struct netif *netif;
- struct rt_semaphore tx_ack;
+ /* network interface for lwip */
+ struct netif *netif;
+ struct rt_semaphore tx_ack;
- rt_uint16_t flags;
- rt_uint8_t link_changed;
- rt_uint8_t link_status;
+ rt_uint16_t flags;
+ rt_uint8_t link_changed;
+ rt_uint8_t link_status;
- /* eth device interface */
- struct pbuf* (*eth_rx)(rt_device_t dev);
- rt_err_t (*eth_tx)(rt_device_t dev, struct pbuf* p);
+ /* eth device interface */
+ struct pbuf* (*eth_rx)(rt_device_t dev);
+ rt_err_t (*eth_tx)(rt_device_t dev, struct pbuf* p);
};
-rt_err_t eth_device_ready(struct eth_device* dev);
-rt_err_t eth_device_init(struct eth_device * dev, char *name);
-rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint16_t flag);
-rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up);
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ rt_err_t eth_device_ready(struct eth_device* dev);
+ rt_err_t eth_device_init(struct eth_device * dev, const char *name);
+ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_uint16_t flag);
+ rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up);
-int eth_system_device_init(void);
+ int eth_system_device_init(void);
+
+#ifdef __cplusplus
+}
+#endif
#endif /* __NETIF_ETHERNETIF_H__ */
diff --git a/components/net/lwip-1.4.1/src/netif/ethernetif.c b/components/net/lwip-1.4.1/src/netif/ethernetif.c
index 943d95f9ed..506f15b44c 100644
--- a/components/net/lwip-1.4.1/src/netif/ethernetif.c
+++ b/components/net/lwip-1.4.1/src/netif/ethernetif.c
@@ -177,7 +177,7 @@ static err_t eth_netif_device_init(struct netif *netif)
}
/* Keep old drivers compatible in RT-Thread */
-rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint16_t flags)
+rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_uint16_t flags)
{
struct netif* netif;
@@ -242,7 +242,7 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint16
return RT_EOK;
}
-rt_err_t eth_device_init(struct eth_device * dev, char *name)
+rt_err_t eth_device_init(struct eth_device * dev, const char *name)
{
rt_uint16_t flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
diff --git a/components/net/lwip-2.0.2/src/include/netif/ethernetif.h b/components/net/lwip-2.0.2/src/include/netif/ethernetif.h
index bdad32ec20..1c969e6e25 100644
--- a/components/net/lwip-2.0.2/src/include/netif/ethernetif.h
+++ b/components/net/lwip-2.0.2/src/include/netif/ethernetif.h
@@ -17,27 +17,35 @@
struct eth_device
{
- /* inherit from rt_device */
- struct rt_device parent;
+ /* inherit from rt_device */
+ struct rt_device parent;
- /* network interface for lwip */
- struct netif *netif;
- struct rt_semaphore tx_ack;
+ /* network interface for lwip */
+ struct netif *netif;
+ struct rt_semaphore tx_ack;
- rt_uint16_t flags;
- rt_uint8_t link_changed;
- rt_uint8_t link_status;
+ rt_uint16_t flags;
+ rt_uint8_t link_changed;
+ rt_uint8_t link_status;
- /* eth device interface */
- struct pbuf* (*eth_rx)(rt_device_t dev);
- rt_err_t (*eth_tx)(rt_device_t dev, struct pbuf* p);
+ /* eth device interface */
+ struct pbuf* (*eth_rx)(rt_device_t dev);
+ rt_err_t (*eth_tx)(rt_device_t dev, struct pbuf* p);
};
-rt_err_t eth_device_ready(struct eth_device* dev);
-rt_err_t eth_device_init(struct eth_device * dev, char *name);
-rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint16_t flag);
-rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up);
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ rt_err_t eth_device_ready(struct eth_device* dev);
+ rt_err_t eth_device_init(struct eth_device * dev, const char *name);
+ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_uint16_t flag);
+ rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up);
-int eth_system_device_init(void);
+ int eth_system_device_init(void);
+
+#ifdef __cplusplus
+}
+#endif
#endif /* __NETIF_ETHERNETIF_H__ */
diff --git a/components/net/lwip-2.0.2/src/netif/ethernetif.c b/components/net/lwip-2.0.2/src/netif/ethernetif.c
index 8b05e592d4..c22951186a 100644
--- a/components/net/lwip-2.0.2/src/netif/ethernetif.c
+++ b/components/net/lwip-2.0.2/src/netif/ethernetif.c
@@ -205,7 +205,7 @@ static err_t eth_netif_device_init(struct netif *netif)
}
/* Keep old drivers compatible in RT-Thread */
-rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint16_t flags)
+rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_uint16_t flags)
{
struct netif* netif;
@@ -269,7 +269,7 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint16
return RT_EOK;
}
-rt_err_t eth_device_init(struct eth_device * dev, char *name)
+rt_err_t eth_device_init(struct eth_device * dev, const char *name)
{
rt_uint16_t flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
diff --git a/components/net/lwip-2.1.0/src/arch/sys_arch.c b/components/net/lwip-2.1.0/src/arch/sys_arch.c
index ee96249bec..17ebdfbacf 100644
--- a/components/net/lwip-2.1.0/src/arch/sys_arch.c
+++ b/components/net/lwip-2.1.0/src/arch/sys_arch.c
@@ -49,6 +49,8 @@
#include "lwip/dhcp.h"
#include "lwip/inet.h"
+#include "netif/etharp.h"
+
#include <string.h>
#include <stdio.h>
@@ -75,6 +77,10 @@ static err_t netif_device_init(struct netif *netif)
/* copy device flags to netif flags */
netif->flags = ethif->flags;
+ netif->mtu = ETHERNET_MTU;
+
+ /* set output */
+ netif->output = etharp_output;
return ERR_OK;
}
diff --git a/components/net/lwip-2.1.0/src/include/netif/ethernetif.h b/components/net/lwip-2.1.0/src/include/netif/ethernetif.h
index bdad32ec20..1c969e6e25 100644
--- a/components/net/lwip-2.1.0/src/include/netif/ethernetif.h
+++ b/components/net/lwip-2.1.0/src/include/netif/ethernetif.h
@@ -17,27 +17,35 @@
struct eth_device
{
- /* inherit from rt_device */
- struct rt_device parent;
+ /* inherit from rt_device */
+ struct rt_device parent;
- /* network interface for lwip */
- struct netif *netif;
- struct rt_semaphore tx_ack;
+ /* network interface for lwip */
+ struct netif *netif;
+ struct rt_semaphore tx_ack;
- rt_uint16_t flags;
- rt_uint8_t link_changed;
- rt_uint8_t link_status;
+ rt_uint16_t flags;
+ rt_uint8_t link_changed;
+ rt_uint8_t link_status;
- /* eth device interface */
- struct pbuf* (*eth_rx)(rt_device_t dev);
- rt_err_t (*eth_tx)(rt_device_t dev, struct pbuf* p);
+ /* eth device interface */
+ struct pbuf* (*eth_rx)(rt_device_t dev);
+ rt_err_t (*eth_tx)(rt_device_t dev, struct pbuf* p);
};
-rt_err_t eth_device_ready(struct eth_device* dev);
-rt_err_t eth_device_init(struct eth_device * dev, char *name);
-rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint16_t flag);
-rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up);
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ rt_err_t eth_device_ready(struct eth_device* dev);
+ rt_err_t eth_device_init(struct eth_device * dev, const char *name);
+ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_uint16_t flag);
+ rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up);
-int eth_system_device_init(void);
+ int eth_system_device_init(void);
+
+#ifdef __cplusplus
+}
+#endif
#endif /* __NETIF_ETHERNETIF_H__ */
diff --git a/components/net/lwip-2.1.0/src/netif/ethernetif.c b/components/net/lwip-2.1.0/src/netif/ethernetif.c
index 910d7c3470..5a8e9d6149 100644
--- a/components/net/lwip-2.1.0/src/netif/ethernetif.c
+++ b/components/net/lwip-2.1.0/src/netif/ethernetif.c
@@ -156,6 +156,9 @@ static err_t eth_netif_device_init(struct netif *netif)
/* copy device flags to netif flags */
netif->flags = (ethif->flags & 0xff);
netif->mtu = ETHERNET_MTU;
+
+ /* set output */
+ netif->output = etharp_output;
#if LWIP_IPV6
netif->output_ip6 = ethip6_output;
@@ -207,7 +210,7 @@ static err_t eth_netif_device_init(struct netif *netif)
}
/* Keep old drivers compatible in RT-Thread */
-rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint16_t flags)
+rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_uint16_t flags)
{
struct netif* netif;
@@ -239,6 +242,9 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint16
/* maximum transfer unit */
netif->mtu = ETHERNET_MTU;
+ /* set linkoutput */
+ netif->linkoutput = ethernetif_linkoutput;
+
/* get hardware MAC address */
rt_device_control(&(dev->parent), NIOCTL_GADDR, netif->hwaddr);
@@ -262,16 +268,12 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint16
IP4_ADDR(&netmask, 0, 0, 0, 0);
#endif
netifapi_netif_add(netif, &ipaddr, &netmask, &gw, dev, eth_netif_device_init, tcpip_input);
-
- /* set output */
- netif->output = etharp_output;
- netif->linkoutput = ethernetif_linkoutput;
}
return RT_EOK;
}
-rt_err_t eth_device_init(struct eth_device * dev, char *name)
+rt_err_t eth_device_init(struct eth_device * dev, const char *name)
{
rt_uint16_t flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
diff --git a/components/net/sal_socket/socket/net_sockets.c b/components/net/sal_socket/socket/net_sockets.c
index 232b87ba1e..12024c8173 100644
--- a/components/net/sal_socket/socket/net_sockets.c
+++ b/components/net/sal_socket/socket/net_sockets.c
@@ -78,29 +78,39 @@ RTM_EXPORT(bind);
int shutdown(int s, int how)
{
- int socket;
+ int error = 0;
+ int socket = -1;
struct dfs_fd *d;
+ socket = dfs_net_getsocket(s);
+ if (socket < 0)
+ {
+ rt_set_errno(-ENOTSOCK);
+ return -1;
+ }
+
d = fd_get(s);
if (d == NULL)
{
rt_set_errno(-EBADF);
-
return -1;
}
-
- socket = dfs_net_getsocket(s);
+
if (sal_shutdown(socket, how) == 0)
{
- /* socket has been closed, delete it from file system fd */
- fd_put(d);
- fd_put(d);
-
- return 0;
+ error = 0;
+ }
+ else
+ {
+ rt_set_errno(-ENOTSOCK);
+ error = -1;
}
- return -1;
+ /* socket has been closed, delete it from file system fd */
+ fd_put(d);
+ fd_put(d);
+ return error;
}
RTM_EXPORT(shutdown);
@@ -228,7 +238,7 @@ int socket(int domain, int type, int protocol)
rt_set_errno(-ENOMEM);
- return -1;
+ return -1;
}
/* release the ref-count of fd */
@@ -240,25 +250,39 @@ RTM_EXPORT(socket);
int closesocket(int s)
{
- int socket = dfs_net_getsocket(s);
+ int error = 0;
+ int socket = -1;
struct dfs_fd *d;
+ socket = dfs_net_getsocket(s);
+ if (socket < 0)
+ {
+ rt_set_errno(-ENOTSOCK);
+ return -1;
+ }
+
d = fd_get(s);
- if(!d)
+ if (d == RT_NULL)
{
+ rt_set_errno(-EBADF);
return -1;
}
if (sal_closesocket(socket) == 0)
{
- /* socket has been closed, delete it from file system fd */
- fd_put(d);
- fd_put(d);
-
- return 0;
+ error = 0;
+ }
+ else
+ {
+ rt_set_errno(-ENOTSOCK);
+ error = -1;
}
- return -1;
+ /* socket has been closed, delete it from file system fd */
+ fd_put(d);
+ fd_put(d);
+
+ return error;
}
RTM_EXPORT(closesocket);
diff --git a/components/net/sal_socket/src/sal_socket.c b/components/net/sal_socket/src/sal_socket.c
index dba8e66254..771a56f061 100644
--- a/components/net/sal_socket/src/sal_socket.c
+++ b/components/net/sal_socket/src/sal_socket.c
@@ -19,10 +19,8 @@
#endif
#include <sal.h>
-#define DBG_ENABLE
-#define DBG_SECTION_NAME "SAL_SOC"
+#define DBG_SECTION_NAME "SAL_SKT"
#define DBG_LEVEL DBG_INFO
-#define DBG_COLOR
#include <rtdbg.h>
#define SOCKET_TABLE_STEP_LEN 4