[at][sal] Add query and unregistered protocol family functions

This commit is contained in:
chenyong committed 2018-08-25 16:01:31 +08:00
1 parent 0d737de882
commit 192b177518
7 files changed
+159 -32

No files matched your search

+3
View File
@@ -16,6 +16,9 @@ if GetDepend('SAL_USING_LWIP'):
if GetDepend('SAL_USING_AT'):
src += Glob('impl/af_inet_at.c')
if GetDepend('SAL_USING_LWIP') or GetDepend('SAL_USING_AT'):
CPPPATH += [cwd + '/impl']
if GetDepend('SAL_USING_POSIX'):
src += Glob('dfs_net/*.c')
+40
View File
@@ -0,0 +1,40 @@
/*
* File : af_inet.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2018-08-25 ChenYong First version
*/
#ifndef __AF_INET_H__
#define __AF_INET_H__
#include <rtthread.h>
#ifdef SAL_USING_LWIP
/* lwIP protocol family register */
int lwip_inet_init(void);
#endif
#ifdef SAL_USING_AT
/* AT protocol family register */
int at_inet_init(void);
#endif
#endif /* __AF_INET_H__ */
@@ -26,6 +26,7 @@
#include <sal.h>
#include <at_socket.h>
#include <af_inet.h>
#ifdef SAL_USING_POSIX
#include <dfs_poll.h>
@@ -107,6 +108,7 @@ static int at_create(struct sal_socket *socket, int type, int protocol)
}
static const struct proto_family at_inet_family_ops = {
"at",
AF_AT,
AF_INET,
at_create,
@@ -34,6 +34,7 @@
#endif
#include <sal.h>
#include <af_inet.h>
#if LWIP_VERSION < 0x2000000
#define SELWAIT_T int
@@ -284,6 +285,7 @@ static int inet_create(struct sal_socket *socket, int type, int protocol)
}
static const struct proto_family lwip_inet_family_ops = {
"lwip",
AF_INET,
AF_INET,
inet_create,
+9 -4
View File
@@ -82,8 +82,9 @@ struct sal_socket
struct proto_family
{
int family; /* primary protocol families type*/
int sec_family; /* secondary protocol families type*/
char name[RT_NAME_MAX];
int family; /* primary protocol families type */
int sec_family; /* secondary protocol families type */
int (*create)(struct sal_socket *sal_socket, int type, int protocol); /* register socket options */
struct hostent* (*gethostbyname) (const char *name);
@@ -92,10 +93,14 @@ struct proto_family
int (*getaddrinfo) (const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res);
};
/* SAL socket initialization */
/* SAL(Socket Abstraction Layer) initialize */
int sal_init(void);
int sal_proto_family_register(const struct proto_family *pf);
struct sal_socket *sal_get_socket(int sock);
/* protocol family register and unregister operate */
int sal_proto_family_register(const struct proto_family *pf);
int sal_proto_family_unregister(const struct proto_family *pf);
struct proto_family *sal_proto_family_find(const char *name);
#endif /* SAL_H__ */
@@ -38,6 +38,7 @@ int gethostbyname_r(const char *name, struct hostent *ret, char *buf,
{
return sal_gethostbyname_r(name, ret, buf, buflen, result, h_errnop);
}
RTM_EXPORT(gethostbyname_r);
void freeaddrinfo(struct addrinfo *ai)
{
File diff suppressed because it is too large. Load diff