/*
eXosip - This is the eXtended osip library.
Copyright (C) 2002,2003,2004,2005,2006,2007 Aymeric MOIZARD - [email protected]
eXosip 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.
eXosip 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef ENABLE_MPATROL
#include <mpatrol.h>
#endif
#include <osipparser2/osip_port.h>
#include "eXosip2.h"
#if defined(_WIN32_WCE)
#elif defined(WIN32)
#include <windns.h>
#include <malloc.h>
#else
#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#ifdef HAVE_ARPA_NAMESER_H
#include <arpa/nameser.h>
#endif
#ifdef HAVE_NAMESER8_COMPAT_H
#include <nameser8_compat.h>
#include <resolv8_compat.h>
#elif defined(HAVE_RESOLV_H) || defined(OpenBSD) || defined(FreeBSD) || defined(NetBSD)
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
#include <arpa/nameser_compat.h>
#endif
#include <resolv.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
#endif
extern eXosip_t eXosip;
extern int ipv6_enable;
#if defined(__arc__)
#define USE_GETHOSTBYNAME
#endif
#if defined(USE_GETHOSTBYNAME)
void eXosip_freeaddrinfo(struct addrinfo *ai)
{
struct addrinfo *next;
while (ai) {
next = ai->ai_next;
free(ai);
ai = next;
}
}
struct namebuf {
struct hostent hostentry;
char *h_addr_list[2];
struct in_addr addrentry;
char h_name[16]; /* 123.123.123.123 = 15 letters is maximum */
};
static struct addrinfo *osip_he2ai(struct hostent *he, int port, int protocol)
{
struct addrinfo *ai;
struct addrinfo *prevai = NULL;
struct addrinfo *firstai = NULL;
struct sockaddr_in *addr;
int i;
struct in_addr *curr;
if (!he)
/* no input == no output! */
return NULL;
for (i = 0; (curr = (struct in_addr *) he->h_addr_list[i]); i++) {
ai = calloc(1, sizeof(struct addrinfo) + sizeof(struct sockaddr_in));
if (!ai)
break;
if (!firstai)
/* store the pointer we want to return from this function */
firstai = ai;
if (prevai)
/* make the previous entry point to this */
prevai->ai_next = ai;
ai->ai_family = AF_INET; /* we only support this */
if (protocol == IPPROTO_UDP)
ai->ai_socktype = SOCK_DGRAM;
else
ai->ai_socktype = SOCK_STREAM;
ai->ai_addrlen = sizeof(struct sockaddr_in);
/* make the ai_addr point to the address immediately following this struct
and use that area to store the address */
ai->ai_addr = (struct sockaddr *) ((char *) ai + sizeof(struct addrinfo));
/* leave the rest of the struct filled with zero */
addr = (struct sockaddr_in *) ai->ai_addr; /* storage area for this info */
memcpy((char *) &(addr->sin_addr), curr, sizeof(struct in_addr));
addr->sin_family = he->h_addrtype;
addr->sin_port = htons((unsigned short) port);
prevai = ai;
}
return firstai;
}
/*
* osip_ip2addr() takes a 32bit ipv4 internet address as input parameter
* together with a pointer to the string version of the address, and it
* returns a struct addrinfo chain filled in correctly with information for this
* address/host.
*
* The input parameters ARE NOT checked for validity but they are expected
* to have been checked already when this is called.
*/
static struct addrinfo *osip_ip2addr(in_addr_t num, const char *hostname, int port,
int protocol)
{
struct addrinfo *ai;
struct hostent *h;
struct in_addr *addrentry;
struct namebuf buffer;
struct namebuf *buf = &buffer;
h = &buf->hostentry;
h->h_addr_list = &buf->h_addr_list[0];
addrentry = &buf->addrentry;
addrentry->s_addr = num;
h->h_addr_list[0] = (char *) addrentry;
h->h_addr_list[1] = NULL;
h->h_addrtype = AF_INET;
h->h_length = sizeof(*addrentry);
h->h_name = &buf->h_name[0];
h->h_aliases = NULL;
/* Now store the dotted version of the address */
snprintf((char *) h->h_name, 16, "%s", hostname);
ai = osip_he2ai(h, port, protocol);
return ai;
}
static int eXosip_inet_pton(int family, const char *src, void *dst)
{
if (strchr(src, ':')) /* possible IPv6 address */
return OSIP_UNDEFINED_ERROR; /* (inet_pton(AF_INET6, src, dst)); */
else if (strchr(src, '.')) { /* possible IPv4 address */
struct in_addr *tmp = dst;
tmp->s_addr = inet_addr(src); /* already in N. byte order */
if (tmp->s_addr == INADDR_NONE)
return 0;
return 1; /* (inet_pton(AF_INET, src, dst)); */
} else /* Impossibly a valid ip address */
return INADDR_NONE;
}
/*
* osip_getaddrinfo() - the ipv4 synchronous version.
*
* The original code to this function was from the Dancer source code, written
* by Bjorn Reese, it has since been patched and modified considerably.
*
* gethostbyname_r() is the thread-safe version of the gethostbyname()
* function. When we build for plain IPv4, we attempt to use this
* function. There are _three_ different gethostbyname_r() versions, and we
* detect which one this platform supports in the configure script and set up
* the HAVE_GETHOSTBYNAME_R_3, HAVE_GETHOSTBYNAME_R_5 or
* HAVE_GETHOSTBYNAME_R_6 defines accordingly. Note that HAVE_GETADDRBYNAME
* has the corresponding rules. This is primarily on *nix. Note that some unix
* flavours have thread-safe versions of the plain gethostbyname() etc.
*
*/
int
eXosip_get_addrinfo(struct addrinfo **addrinfo,
const char *hostname, int port, int protocol)
{
struct hostent *h = NULL;
in_addr_t in;
struct hostent *buf = NULL;
char portbuf[10];
*addrinfo = NULL; /* default return */
if (port < 0) /* -1 for SRV record */
return OSIP_BADPARAMETER;
snprintf(portbuf, sizeof(portbuf), "%i", port);
if (1 == eXosip_inet_pton(AF_INET, hostname, &in))
/* This is a dotted IP address 123.123.123.123-style */
{
*addrinfo = osip_ip2addr(in, hostname, port, protocol);
return OSIP_SUCCESS;
}
#if defined(HAVE_GETHOSTBYNAME_R)
/*
* gethostbyname_r() is the preferred resolve function for many platforms.
* Since there are three different versions of it, the following code is
* somewhat #ifdef-ridden.
*/
else {
int h_errnop;
int res = ERANGE;
buf = (struct hostent *) calloc(CURL_HOSTENT_SIZE, 1);
if (!buf)
return NULL; /* major failure */
/*
* The clearing of the buffer is a workaround for a gethostbyname_r bug in
* qnx nto and it is also _required_ for some of these functions on some
* platforms.
*/
#ifdef HAVE_GETHOSTBYNAME_R_5
/* Solaris, IRIX and more */
(void) res; /* prevent compiler warning */
h = gethostbyname_r(hostname,
(struct hostent *) buf,
(char *) buf + sizeof(struct hostent),
CURL_HOSTENT_SIZE - sizeof(struct hostent), &h_errnop);
/* If the buffer is too small, it returns NULL and sets errno to
* ERANGE. The errno is thread safe if this is compiled with
* -D_REENTRANT as then the 'errno' variable is a macro defined to get
* used properly for threads.
*/
if (h) {
;
} else
#endif /* HAVE_GETHOSTBYNAME_R_5 */
#ifdef HAVE_GETHOSTBYNAME_R_6
/* Linux */
res = gethostbyname_r(hostname, (struct hostent *) buf, (char *) buf + sizeof(struct hostent), CURL_HOSTENT_SIZE - sizeof(struct hostent), &h, /* DIFFERENCE */
&h_errnop);
/* Redhat 8, using glibc 2.2.93 changed the behavior. Now all of a
* sudden this function returns EAGAIN if the given buffer size is too
* small. Previous versions are known to return ERANGE for the same
* problem.
*
* This wouldn't be such a big problem if older versions wouldn't
* sometimes return EAGAIN on a common failure case. Alas, we can't
没有合适的资源?快使用搜索试试~ 我知道了~
libeXosip2-3.6.0.zip_eXosip2_libeXosi_libeXosip2_libeXosip2-3.6_
共105个文件
c:36个
h:15个
in:14个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 70 浏览量
2022-09-24
04:18:37
上传
评论
收藏 562KB ZIP 举报
温馨提示
exosip2, 3.6.0, 一個SIP的開源協議棧, 開發環境是Linux
资源推荐
资源详情
资源评论
收起资源包目录
libeXosip2-3.6.0.zip_eXosip2_libeXosi_libeXosip2_libeXosip2-3.6_ (105个子文件)
Makefile.am 1KB
Makefile.am 428B
Makefile.am 303B
Makefile.am 181B
Makefile.am 124B
Makefile.am 117B
Makefile.am 61B
Makefile.am 58B
Makefile.am 50B
Makefile.am 24B
Makefile.am 20B
AUTHORS 33B
eXutils.c 100KB
eXtl_tls.c 85KB
udp.c 68KB
jcallback.c 55KB
eXtl_tcp.c 43KB
eXosip.c 41KB
eXcall_api.c 41KB
jrequest.c 31KB
eXtl_dtls.c 30KB
eXconf.c 30KB
rijndael.c 29KB
jauth.c 29KB
eXtl_udp.c 22KB
eXinsubscription_api.c 18KB
eXsubscription_api.c 13KB
jevents.c 13KB
jresponse.c 12KB
eXregister_api.c 9KB
sip_reg.c 9KB
sdp_offans.c 8KB
milenage.c 7KB
inet_ntop.c 6KB
misc.c 6KB
jpipe.c 6KB
jdialog.c 6KB
jreg.c 5KB
eXpublish_api.c 5KB
eXmessage_api.c 4KB
eXoptions_api.c 4KB
jnotify.c 4KB
jsubscribe.c 4KB
eXtransport.c 4KB
jcall.c 3KB
jpublish.c 3KB
eXrefer_api.c 2KB
eXtl.c 927B
ChangeLog 6KB
configure 425KB
COPYING 18KB
eXosip2.def 2KB
eXosip2.def 2KB
depcomp 18KB
ht1-callcontrol.dox 5KB
ht0-initialize.dox 3KB
ht2-registration.dox 2KB
DoxyFile 9KB
config.guess 45KB
eXosip2.h 20KB
eXosip.h 16KB
eX_setup.h 7KB
eX_call.h 7KB
eX_subscribe.h 6KB
eX_register.h 3KB
eX_message.h 3KB
eX_options.h 3KB
eX_publish.h 2KB
eXtransport.h 2KB
eX_refer.h 2KB
jpipe.h 2KB
milenage.h 1KB
inet_ntop.h 1KB
rijndael.h 894B
Makefile.in 23KB
Makefile.in 21KB
Makefile.in 17KB
Makefile.in 17KB
Makefile.in 17KB
Makefile.in 16KB
Makefile.in 14KB
configure.in 11KB
Makefile.in 10KB
Makefile.in 10KB
Makefile.in 10KB
Makefile.in 10KB
config.h.in 4KB
doxygen.dox.in 3KB
INSTALL 9KB
install-sh 5KB
INSTALL.linux 370B
aclocal.m4 315KB
acx_pthread.m4 9KB
aclocal-include.m4 367B
missing 10KB
mkinstalldirs 729B
NEWS 2KB
README 2KB
ltmain.sh 238KB
autogen.sh 3KB
共 105 条
- 1
- 2
资源评论
林当时
- 粉丝: 100
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功