Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
9bb3f2d0
Commit
9bb3f2d0
authored
Feb 24, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
listen: no CamelCase
Renamed functions.
parent
d89ba3bc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
30 deletions
+31
-30
listen.c
src/listen.c
+24
-23
listen.h
src/listen.h
+3
-3
main.c
src/main.c
+2
-2
zeroconf-avahi.c
src/zeroconf-avahi.c
+1
-1
zeroconf-bonjour.c
src/zeroconf-bonjour.c
+1
-1
No files found.
src/listen.c
View file @
9bb3f2d0
...
...
@@ -64,16 +64,16 @@ struct listen_socket {
};
static
struct
listen_socket
*
listen_sockets
;
int
boundP
ort
;
int
listen_p
ort
;
static
gboolean
listen_in_event
(
GIOChannel
*
source
,
GIOCondition
condition
,
gpointer
data
);
static
int
establishListen
(
int
pf
,
const
struct
sockaddr
*
addrp
,
socklen_t
addrlen
)
static
int
listen_add_address
(
int
pf
,
const
struct
sockaddr
*
addrp
,
socklen_t
addrlen
)
{
int
sock
;
int
allowR
euse
=
ALLOW_REUSE
;
const
int
r
euse
=
ALLOW_REUSE
;
#ifdef HAVE_STRUCT_UCRED
int
passcred
=
1
;
#endif
...
...
@@ -83,8 +83,8 @@ static int establishListen(int pf, const struct sockaddr *addrp,
if
((
sock
=
socket
(
pf
,
SOCK_STREAM
,
0
))
<
0
)
g_error
(
"socket < 0"
);
if
(
setsockopt
(
sock
,
SOL_SOCKET
,
SO_REUSEADDR
,
(
char
*
)
&
allowReuse
,
sizeof
(
allowR
euse
))
<
0
)
{
if
(
setsockopt
(
sock
,
SOL_SOCKET
,
SO_REUSEADDR
,
&
reuse
,
sizeof
(
r
euse
))
<
0
)
{
g_error
(
"problems setsockopt'ing: %s"
,
strerror
(
errno
));
}
...
...
@@ -115,7 +115,8 @@ static int establishListen(int pf, const struct sockaddr *addrp,
}
#ifdef HAVE_IPV6
static
bool
ipv6Supported
(
void
)
static
bool
is_ipv6_enabled
(
void
)
{
int
s
;
s
=
socket
(
AF_INET6
,
SOCK_STREAM
,
0
);
...
...
@@ -127,8 +128,8 @@ static bool ipv6Supported(void)
#endif
static
void
parseListenConfigP
aram
(
G_GNUC_UNUSED
unsigned
int
port
,
const
struct
config_param
*
param
)
listen_add_config_p
aram
(
G_GNUC_UNUSED
unsigned
int
port
,
const
struct
config_param
*
param
)
{
const
struct
sockaddr
*
addrp
;
socklen_t
addrlen
;
...
...
@@ -136,7 +137,7 @@ parseListenConfigParam(G_GNUC_UNUSED unsigned int port,
struct
sockaddr_in
sin4
;
#ifdef HAVE_IPV6
struct
sockaddr_in6
sin6
;
int
useIpv6
=
ipv6Support
ed
();
int
ipv6_enabled
=
is_ipv6_enabl
ed
();
memset
(
&
sin6
,
0
,
sizeof
(
struct
sockaddr_in6
));
sin6
.
sin6_port
=
htons
(
port
);
...
...
@@ -151,11 +152,11 @@ parseListenConfigParam(G_GNUC_UNUSED unsigned int port,
#ifdef HAVE_TCP
g_debug
(
"binding to any address"
);
#ifdef HAVE_IPV6
if
(
useIpv6
)
{
if
(
ipv6_enabled
)
{
sin6
.
sin6_addr
=
in6addr_any
;
addrp
=
(
const
struct
sockaddr
*
)
&
sin6
;
addrlen
=
sizeof
(
struct
sockaddr_in6
);
if
(
establishListen
(
PF_INET6
,
addrp
,
addrlen
)
<
0
)
if
(
listen_add_address
(
PF_INET6
,
addrp
,
addrlen
)
<
0
)
BINDERROR
();
}
#endif
...
...
@@ -163,9 +164,9 @@ parseListenConfigParam(G_GNUC_UNUSED unsigned int port,
addrp
=
(
const
struct
sockaddr
*
)
&
sin4
;
addrlen
=
sizeof
(
struct
sockaddr_in
);
#ifdef HAVE_IPV6
if
((
establishListen
(
PF_INET
,
addrp
,
addrlen
)
<
0
)
&&
!
useIpv6
)
{
if
((
listen_add_address
(
PF_INET
,
addrp
,
addrlen
)
<
0
)
&&
!
ipv6_enabled
)
{
#else
if
(
establishListen
(
PF_INET
,
addrp
,
addrlen
)
<
0
)
{
if
(
listen_add_address
(
PF_INET
,
addrp
,
addrlen
)
<
0
)
{
#endif
BINDERROR
();
}
...
...
@@ -189,7 +190,7 @@ parseListenConfigParam(G_GNUC_UNUSED unsigned int port,
addrp
=
(
const
struct
sockaddr
*
)
&
s_un
;
addrlen
=
sizeof
(
s_un
);
if
(
establishListen
(
PF_UNIX
,
addrp
,
addrlen
)
<
0
)
if
(
listen_add_address
(
PF_UNIX
,
addrp
,
addrlen
)
<
0
)
g_error
(
"unable to bind to %s: %s"
,
param
->
value
,
strerror
(
errno
));
...
...
@@ -223,8 +224,8 @@ parseListenConfigParam(G_GNUC_UNUSED unsigned int port,
param
->
value
,
param
->
line
,
gai_strerror
(
ret
));
for
(
i
=
ai
;
i
!=
NULL
;
i
=
i
->
ai_next
)
if
(
establishListen
(
i
->
ai_family
,
i
->
ai_addr
,
i
->
ai_addrlen
)
<
0
)
if
(
listen_add_address
(
i
->
ai_family
,
i
->
ai_addr
,
i
->
ai_addrlen
)
<
0
)
BINDERROR
();
freeaddrinfo
(
ai
);
...
...
@@ -242,7 +243,7 @@ parseListenConfigParam(G_GNUC_UNUSED unsigned int port,
g_error
(
"IPv4 address expected for host
\"
%s
\"
at line %i"
,
param
->
value
,
param
->
line
);
if
(
establishListen
(
AF_INET
,
he
->
h_addr
,
he
->
h_length
)
<
0
)
if
(
listen_add_address
(
AF_INET
,
he
->
h_addr
,
he
->
h_length
)
<
0
)
BINDERROR
();
#endif
/* !WIN32 */
#else
/* HAVE_TCP */
...
...
@@ -251,21 +252,21 @@ parseListenConfigParam(G_GNUC_UNUSED unsigned int port,
}
}
void
listen
OnPor
t
(
void
)
void
listen
_global_ini
t
(
void
)
{
int
port
=
config_get_positive
(
CONF_PORT
,
DEFAULT_PORT
);
const
struct
config_param
*
param
=
config_get_next_param
(
CONF_BIND_TO_ADDRESS
,
NULL
);
do
{
parseListenConfigP
aram
(
port
,
param
);
listen_add_config_p
aram
(
port
,
param
);
}
while
((
param
=
config_get_next_param
(
CONF_BIND_TO_ADDRESS
,
param
)));
boundP
ort
=
port
;
listen_p
ort
=
port
;
}
void
closeAllListenSockets
(
void
)
void
listen_global_finish
(
void
)
{
g_debug
(
"
closeAllListenSockets
called"
);
g_debug
(
"
listen_global_finish
called"
);
while
(
listen_sockets
!=
NULL
)
{
struct
listen_socket
*
ls
=
listen_sockets
;
...
...
src/listen.h
View file @
9bb3f2d0
...
...
@@ -19,10 +19,10 @@
#ifndef MPD_LISTEN_H
#define MPD_LISTEN_H
extern
int
boundP
ort
;
extern
int
listen_p
ort
;
void
listen
OnPor
t
(
void
);
void
listen
_global_ini
t
(
void
);
void
closeAllListenSockets
(
void
);
void
listen_global_finish
(
void
);
#endif
src/main.c
View file @
9bb3f2d0
...
...
@@ -226,7 +226,7 @@ int main(int argc, char *argv[])
tag_lib_init
();
log_init
(
options
.
verbose
,
options
.
stdOutput
);
listen
OnPor
t
();
listen
_global_ini
t
();
daemonize_set_user
();
...
...
@@ -297,7 +297,7 @@ int main(int argc, char *argv[])
playerKill
();
finishZeroconf
();
client_manager_deinit
();
closeAllListenSockets
();
listen_global_finish
();
finishPlaylist
();
start
=
clock
();
...
...
src/zeroconf-avahi.c
View file @
9bb3f2d0
...
...
@@ -114,7 +114,7 @@ static void avahiRegisterService(AvahiClient * c)
ret
=
avahi_entry_group_add_service
(
avahiGroup
,
AVAHI_IF_UNSPEC
,
AVAHI_PROTO_UNSPEC
,
0
,
avahiName
,
SERVICE_TYPE
,
NULL
,
NULL
,
boundP
ort
,
NULL
);
NULL
,
listen_p
ort
,
NULL
);
if
(
ret
<
0
)
{
g_warning
(
"Failed to add service %s: %s"
,
SERVICE_TYPE
,
avahi_strerror
(
ret
));
...
...
src/zeroconf-bonjour.c
View file @
9bb3f2d0
...
...
@@ -61,7 +61,7 @@ void init_zeroconf_osx(const char *serviceName)
DNSServiceErrorType
error
=
DNSServiceRegister
(
&
dnsReference
,
0
,
0
,
serviceName
,
SERVICE_TYPE
,
NULL
,
NULL
,
htons
(
boundP
ort
),
0
,
htons
(
listen_p
ort
),
0
,
NULL
,
dnsRegisterCallback
,
NULL
);
...
...
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