Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
0d737de8
R
rt-thread
项目概览
BaiXuePrincess
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
0d737de8
编写于
8月 24, 2018
作者:
Lawlieta
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[net][at] Modify AT Socket log information, fix at_freeaddrinfo() implement
上级
2725e412
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
44 addition
and
38 deletion
+44
-38
components/net/at/at_socket/at_socket.c
components/net/at/at_socket/at_socket.c
+43
-37
components/net/at/at_socket/at_socket.h
components/net/at/at_socket/at_socket.h
+1
-1
未找到文件。
components/net/at/at_socket/at_socket.c
浏览文件 @
0d737de8
...
...
@@ -36,10 +36,9 @@
#ifdef DBG_SECTION_NAME
#undef DBG_SECTION_NAME
#define DBG_SECTION_NAME "
[AT_SOC]
"
#define DBG_SECTION_NAME "
AT_SOC
"
#endif
#define HTONS_PORT(x) ((((x) & 0x00ffUL) << 8) | (((x) & 0xff00UL) >> 8))
#define NIPQUAD(addr) \
((unsigned char *)&addr)[0], \
...
...
@@ -89,7 +88,7 @@ static size_t at_recvpkt_put(rt_slist_t *rlist, const char *ptr, size_t length)
at_recv_pkt_t
pkt
;
pkt
=
(
at_recv_pkt_t
)
rt_calloc
(
1
,
sizeof
(
struct
at_recv_pkt
));
if
(
!
pkt
)
if
(
pkt
==
RT_NULL
)
{
LOG_E
(
"No memory for receive packet table!"
);
return
0
;
...
...
@@ -340,7 +339,7 @@ int at_socket(int domain, int type, int protocol)
/* allocate and initialize a new AT socket */
sock
=
alloc_socket
();
if
(
!
sock
)
if
(
sock
==
RT_NULL
)
{
LOG_E
(
"Allocate a new AT socket failed!"
);
return
RT_NULL
;
...
...
@@ -381,14 +380,16 @@ int at_closesocket(int socket)
struct
at_socket
*
sock
;
enum
at_socket_state
last_state
;
if
(
!
at_dev_ops
)
if
(
at_dev_ops
==
RT_NULL
)
{
LOG_E
(
"Please register AT device socket options first!"
);
return
-
1
;
}
if
((
sock
=
at_get_socket
(
socket
))
==
RT_NULL
)
sock
=
at_get_socket
(
socket
);
if
(
sock
==
RT_NULL
)
{
return
-
1
;
}
last_state
=
sock
->
state
;
...
...
@@ -410,14 +411,16 @@ int at_shutdown(int socket, int how)
{
struct
at_socket
*
sock
;
if
(
!
at_dev_ops
)
if
(
at_dev_ops
==
RT_NULL
)
{
LOG_E
(
"Please register AT device socket options first!"
);
return
-
1
;
}
if
((
sock
=
at_get_socket
(
socket
))
==
RT_NULL
)
sock
=
at_get_socket
(
socket
);
if
(
sock
==
RT_NULL
)
{
return
-
1
;
}
if
(
sock
->
state
==
AT_SOCKET_CONNECT
)
{
...
...
@@ -434,7 +437,9 @@ int at_bind(int socket, const struct sockaddr *name, socklen_t namelen)
{
if
(
at_get_socket
(
socket
)
==
RT_NULL
)
{
return
-
1
;
}
return
0
;
}
...
...
@@ -470,7 +475,8 @@ static void at_recv_notice_cb(int socket, at_socket_evt_t event, const char *buf
RT_ASSERT
(
bfsz
);
RT_ASSERT
(
event
==
AT_SOCKET_EVT_RECV
);
if
((
sock
=
at_get_socket
(
socket
))
==
RT_NULL
)
sock
=
at_get_socket
(
socket
);
if
(
sock
==
RT_NULL
)
return
;
/* put receive buffer to receiver packet list */
...
...
@@ -506,14 +512,13 @@ int at_connect(int socket, const struct sockaddr *name, socklen_t namelen)
char
ipstr
[
16
]
=
{
0
};
int
result
=
0
;
if
(
!
at_dev_ops
)
if
(
at_dev_ops
==
RT_NULL
)
{
LOG_E
(
"Please register AT device socket options first!"
);
return
-
1
;
}
sock
=
at_get_socket
(
socket
);
if
(
!
sock
)
if
(
sock
==
RT_NULL
)
{
result
=
-
1
;
goto
__exit
;
...
...
@@ -560,21 +565,19 @@ int at_recvfrom(int socket, void *mem, size_t len, int flags, struct sockaddr *f
int
result
=
0
;
size_t
recv_len
=
0
;
if
(
!
mem
||
len
==
0
)
if
(
mem
==
RT_NULL
||
len
==
0
)
{
LOG_E
(
"AT recvfrom input data or length error!"
);
result
=
-
1
;
goto
__exit
;
return
-
1
;
}
if
(
!
at_dev_ops
)
if
(
at_dev_ops
==
RT_NULL
)
{
LOG_E
(
"Please register AT device socket options first!"
);
return
-
1
;
}
sock
=
at_get_socket
(
socket
);
if
(
!
sock
)
if
(
sock
==
RT_NULL
)
{
result
=
-
1
;
goto
__exit
;
...
...
@@ -686,14 +689,13 @@ int at_sendto(int socket, const void *data, size_t size, int flags, const struct
struct
at_socket
*
sock
;
int
len
,
result
=
0
;
if
(
!
at_dev_ops
)
if
(
at_dev_ops
==
RT_NULL
)
{
LOG_E
(
"Please register AT device socket options first!"
);
result
=
-
1
;
goto
__exit
;
}
if
(
!
data
||
size
==
0
)
if
(
data
==
RT_NULL
||
size
==
0
)
{
LOG_E
(
"AT sendto input data or size error!"
);
result
=
-
1
;
...
...
@@ -701,7 +703,7 @@ int at_sendto(int socket, const void *data, size_t size, int flags, const struct
}
sock
=
at_get_socket
(
socket
);
if
(
!
sock
)
if
(
sock
==
RT_NULL
)
{
result
=
-
1
;
goto
__exit
;
...
...
@@ -780,14 +782,14 @@ int at_getsockopt(int socket, int level, int optname, void *optval, socklen_t *o
struct
at_socket
*
sock
;
int32_t
timeout
;
if
(
!
optval
||
!
optlen
)
if
(
optval
==
RT_NULL
||
optlen
==
RT_NULL
)
{
LOG_E
(
"AT getsocketopt input option value or option length error!"
);
return
-
1
;
}
sock
=
at_get_socket
(
socket
);
if
(
!
sock
)
if
(
sock
==
RT_NULL
)
{
return
-
1
;
}
...
...
@@ -827,14 +829,14 @@ int at_setsockopt(int socket, int level, int optname, const void *optval, sockle
{
struct
at_socket
*
sock
;
if
(
!
optval
)
if
(
optval
==
RT_NULL
)
{
LOG_E
(
"AT setsockopt input option value error!"
);
return
-
1
;
}
sock
=
at_get_socket
(
socket
);
if
(
!
sock
)
if
(
sock
==
RT_NULL
)
{
return
-
1
;
}
...
...
@@ -923,15 +925,14 @@ struct hostent *at_gethostbyname(const char *name)
static
char
s_hostname
[
DNS_MAX_NAME_LENGTH
+
1
];
size_t
idx
=
0
;
if
(
!
name
)
if
(
name
==
RT_NULL
)
{
LOG_E
(
"AT gethostbyname input name error!"
);
return
RT_NULL
;
}
if
(
!
at_dev_ops
)
if
(
at_dev_ops
==
RT_NULL
)
{
LOG_E
(
"Please register AT device socket options first!"
);
return
RT_NULL
;
}
...
...
@@ -983,12 +984,13 @@ int at_getaddrinfo(const char *nodename, const char *servname,
{
return
EAI_FAIL
;
}
if
(
!
at_dev_ops
)
*
res
=
RT_NULL
;
if
(
at_dev_ops
==
RT_NULL
)
{
LOG_E
(
"Please register AT device socket options first!"
);
return
EAI_FAIL
;
}
*
res
=
RT_NULL
;
if
((
nodename
==
RT_NULL
)
&&
(
servname
==
RT_NULL
))
{
return
EAI_NONAME
;
...
...
@@ -1085,10 +1087,10 @@ int at_getaddrinfo(const char *nodename, const char *servname,
struct
sockaddr_in
*
sa4
=
(
struct
sockaddr_in
*
)
sa
;
/* set up sockaddr */
sa4
->
sin_addr
.
s_addr
=
addr
.
u_addr
.
ip4
.
addr
;
sa4
->
sin_family
=
AF_
A
T
;
sa4
->
sin_family
=
AF_
INE
T
;
sa4
->
sin_len
=
sizeof
(
struct
sockaddr_in
);
sa4
->
sin_port
=
htons
((
u16_t
)
port_nr
);
ai
->
ai_family
=
AF_
A
T
;
ai
->
ai_family
=
AF_
INE
T
;
/* set up addrinfo */
if
(
hints
!=
RT_NULL
)
...
...
@@ -1114,9 +1116,13 @@ int at_getaddrinfo(const char *nodename, const char *servname,
void
at_freeaddrinfo
(
struct
addrinfo
*
ai
)
{
if
(
ai
!=
RT_NULL
)
struct
addrinfo
*
next
;
while
(
ai
!=
NULL
)
{
next
=
ai
->
ai_next
;
rt_free
(
ai
);
ai
=
next
;
}
}
...
...
components/net/at/at_socket/at_socket.h
浏览文件 @
0d737de8
...
...
@@ -144,7 +144,7 @@ void at_scoket_device_register(const struct at_device_ops *ops);
#ifndef RT_USING_SAL
#define socket(domain, type, protocol) at_socket(domain, type, protocol)
#define closes
co
ket(socket) at_closesocket(socket)
#define closes
oc
ket(socket) at_closesocket(socket)
#define shutdown(socket, how) at_shutdown(socket, how)
#define bind(socket, name, namelen) at_bind(socket, name, namelen)
#define connect(socket, name, namelen) at_connect(socket, name, namelen)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录