Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
belle-sip
Commits
2f0eb176
Commit
2f0eb176
authored
Feb 01, 2013
by
Ghislain MARY
Browse files
Successful DNS resolution on Windows.
parent
08c044be
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
4 deletions
+64
-4
configure.ac
configure.ac
+1
-1
src/belle_sip_loop.c
src/belle_sip_loop.c
+8
-1
src/belle_sip_resolver.c
src/belle_sip_resolver.c
+6
-0
src/dns.c
src/dns.c
+45
-2
src/dns.h
src/dns.h
+4
-0
No files found.
configure.ac
View file @
2f0eb176
...
...
@@ -141,7 +141,7 @@ case "$target_os" in
;;
*mingw*)
CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0501"
LIBS="$LIBS -lws2_32"
LIBS="$LIBS -lws2_32
-liphlpapi
"
LDFLAGS="$LDFLAGS -Wl,--export-all-symbols"
;;
esac
...
...
src/belle_sip_loop.c
View file @
2f0eb176
...
...
@@ -123,7 +123,14 @@ static unsigned int belle_sip_source_get_revents(belle_sip_source_t *s,belle_sip
}
static
int
belle_sip_poll
(
belle_sip_pollfd_t
*
pfd
,
int
count
,
int
duration
){
DWORD
ret
=
WaitForMultipleObjectsEx
(
count
,
pfd
,
FALSE
,
duration
,
FALSE
);
DWORD
ret
;
if
(
count
==
0
)
{
Sleep
(
duration
);
return
0
;
}
ret
=
WaitForMultipleObjectsEx
(
count
,
pfd
,
FALSE
,
duration
,
FALSE
);
if
(
ret
==
WAIT_FAILED
){
belle_sip_error
(
"WaitForMultipleObjectsEx() failed."
);
return
-
1
;
...
...
src/belle_sip_resolver.c
View file @
2f0eb176
...
...
@@ -25,7 +25,9 @@
static
struct
dns_resolv_conf
*
resconf
(
belle_sip_resolver_context_t
*
ctx
)
{
#ifndef _WIN32
const
char
*
path
;
#endif
int
error
;
if
(
ctx
->
resconf
)
...
...
@@ -36,6 +38,9 @@ static struct dns_resolv_conf *resconf(belle_sip_resolver_context_t *ctx) {
return
NULL
;
}
#ifdef _WIN32
error
=
dns_resconf_loadwin
(
ctx
->
resconf
);
#else
path
=
"/etc/resolv.conf"
;
error
=
dns_resconf_loadpath
(
ctx
->
resconf
,
path
);
if
(
error
)
{
...
...
@@ -49,6 +54,7 @@ static struct dns_resolv_conf *resconf(belle_sip_resolver_context_t *ctx) {
belle_sip_error
(
"%s dns_nssconf_loadpath error [%s]: %s"
,
__FUNCTION__
,
path
,
dns_strerror
(
error
));
return
NULL
;
}
#endif
return
ctx
->
resconf
;
}
...
...
src/dns.c
View file @
2f0eb176
...
...
@@ -49,7 +49,7 @@
#include <string.h>
/* memcpy(3) strlen(3) memmove(3) memchr(3) memcmp(3) strchr(3) strsep(3) strcspn(3) */
#ifdef _MSC_VER
#define strcasecmp _stricmp
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#else
#include <strings.h>
/* strcasecmp(3) strncasecmp(3) */
...
...
@@ -68,10 +68,12 @@
#if _WIN32
#ifndef FD_SETSIZE
#define FD_SETSIZE
256
#define FD_SETSIZE
512
#endif
#include <winsock2.h>
#include <ws2tcpip.h>
#include <IPHlpApi.h>
#pragma comment(lib, "IPHLPAPI.lib")
#else
#include <sys/types.h>
/* FD_SETSIZE socklen_t */
#include <sys/select.h>
/* FD_ZERO FD_SET fd_set select(2) */
...
...
@@ -3571,7 +3573,11 @@ struct dns_hosts *dns_hosts_local(int *error_) {
if
(
!
(
hosts
=
dns_hosts_open
(
&
error
)))
goto
error
;
#ifdef _WIN32
if
((
error
=
dns_hosts_loadpath
(
hosts
,
"C:/Windows/System32/drivers/etc/hosts"
)))
#else
if
((
error
=
dns_hosts_loadpath
(
hosts
,
"/etc/hosts"
)))
#endif
goto
error
;
return
hosts
;
...
...
@@ -4272,6 +4278,43 @@ int dns_resconf_loadpath(struct dns_resolv_conf *resconf, const char *path) {
}
/* dns_resconf_loadpath() */
#ifdef _WIN32
int
dns_resconf_loadwin
(
struct
dns_resolv_conf
*
resconf
)
{
FIXED_INFO
*
pFixedInfo
;
ULONG
ulOutBufLen
;
DWORD
dwRetVal
;
IP_ADDR_STRING
*
pIPAddr
;
unsigned
sa_count
=
0
;
int
error
;
pFixedInfo
=
(
FIXED_INFO
*
)
malloc
(
sizeof
(
FIXED_INFO
));
if
(
pFixedInfo
==
NULL
)
{
return
-
1
;
}
ulOutBufLen
=
sizeof
(
FIXED_INFO
);
if
(
GetNetworkParams
(
pFixedInfo
,
&
ulOutBufLen
)
==
ERROR_BUFFER_OVERFLOW
)
{
free
(
pFixedInfo
);
pFixedInfo
=
(
FIXED_INFO
*
)
malloc
(
ulOutBufLen
);
if
(
pFixedInfo
==
NULL
)
{
return
-
1
;
}
}
if
((
dwRetVal
=
GetNetworkParams
(
pFixedInfo
,
&
ulOutBufLen
))
==
NO_ERROR
)
{
memset
(
resconf
->
search
,
'\0'
,
sizeof
resconf
->
search
);
memcpy
(
resconf
->
search
[
0
],
pFixedInfo
->
DomainName
,
sizeof
pFixedInfo
->
DomainName
);
pIPAddr
=
&
pFixedInfo
->
DnsServerList
;
do
{
error
=
dns_resconf_pton
(
&
resconf
->
nameserver
[
sa_count
],
pIPAddr
->
IpAddress
.
String
);
pIPAddr
=
pIPAddr
->
Next
;
}
while
(
!
error
&&
pIPAddr
&&
(
sa_count
<
lengthof
(
resconf
->
nameserver
)));
}
return
0
;
}
#endif
/* dns_resconf_loadwin() */
struct
dns_anyconf
{
char
*
token
[
16
];
unsigned
count
;
...
...
src/dns.h
View file @
2f0eb176
...
...
@@ -908,6 +908,10 @@ int dns_resconf_loadfile(struct dns_resolv_conf *, FILE *);
int
dns_resconf_loadpath
(
struct
dns_resolv_conf
*
,
const
char
*
);
#ifdef _WIN32
int
dns_resconf_loadwin
(
struct
dns_resolv_conf
*
);
#endif
int
dns_nssconf_loadfile
(
struct
dns_resolv_conf
*
,
FILE
*
);
int
dns_nssconf_loadpath
(
struct
dns_resolv_conf
*
,
const
char
*
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment