Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
7f432665
Commit
7f432665
authored
Jun 26, 2005
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use integer rather than strings for UDP/TCP port numbers
parent
1a57857c
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
79 additions
and
73 deletions
+79
-73
include/network.h
include/network.h
+3
-2
include/vlc_symbols.h
include/vlc_symbols.h
+2
-2
modules/access/ftp.c
modules/access/ftp.c
+2
-2
src/misc/getaddrinfo.c
src/misc/getaddrinfo.c
+54
-27
src/misc/net.c
src/misc/net.c
+15
-37
src/stream_output/sap.c
src/stream_output/sap.c
+3
-3
No files found.
include/network.h
View file @
7f432665
...
...
@@ -388,6 +388,7 @@ VLC_EXPORT( int, __net_CheckIP, ( vlc_object_t *p_this, char *psz_ip, char **pps
# define NI_MAXHOST 1025
# define NI_MAXSERV 32
# endif
# define NI_MAXNUMERICHOST 48
# ifndef NI_NUMERICHOST
# define NI_NUMERICHOST 0x01
...
...
@@ -421,8 +422,8 @@ struct addrinfo
# endif
VLC_EXPORT
(
const
char
*
,
vlc_gai_strerror
,
(
int
)
);
VLC_EXPORT
(
int
,
vlc_getnameinfo
,
(
vlc_object_t
*
,
const
struct
sockaddr
*
,
int
,
char
*
,
int
,
char
*
,
int
,
int
)
);
VLC_EXPORT
(
int
,
vlc_getaddrinfo
,
(
vlc_object_t
*
,
const
char
*
,
const
char
*
,
const
struct
addrinfo
*
,
struct
addrinfo
**
)
);
VLC_EXPORT
(
int
,
vlc_getnameinfo
,
(
vlc_object_t
*
,
const
struct
sockaddr
*
,
int
,
char
*
,
int
,
int
*
,
int
)
);
VLC_EXPORT
(
int
,
vlc_getaddrinfo
,
(
vlc_object_t
*
,
const
char
*
,
int
,
const
struct
addrinfo
*
,
struct
addrinfo
**
)
);
VLC_EXPORT
(
void
,
vlc_freeaddrinfo
,
(
struct
addrinfo
*
)
);
#endif
include/vlc_symbols.h
View file @
7f432665
...
...
@@ -366,8 +366,8 @@ struct module_symbols_t
void
(
*
vout_SynchroEnd_inner
)
(
vout_synchro_t
*
,
int
,
vlc_bool_t
);
mtime_t
(
*
vout_SynchroDate_inner
)
(
vout_synchro_t
*
);
void
(
*
vout_SynchroNewPicture_inner
)
(
vout_synchro_t
*
,
int
,
int
,
mtime_t
,
mtime_t
,
int
,
vlc_bool_t
);
int
(
*
vlc_getaddrinfo_inner
)
(
vlc_object_t
*
,
const
char
*
,
const
char
*
,
const
struct
addrinfo
*
,
struct
addrinfo
**
);
int
(
*
vlc_getnameinfo_inner
)
(
vlc_object_t
*
,
const
struct
sockaddr
*
,
int
,
char
*
,
int
,
char
*
,
int
,
int
);
int
(
*
vlc_getaddrinfo_inner
)
(
vlc_object_t
*
,
const
char
*
,
int
,
const
struct
addrinfo
*
,
struct
addrinfo
**
);
int
(
*
vlc_getnameinfo_inner
)
(
vlc_object_t
*
,
const
struct
sockaddr
*
,
int
,
char
*
,
int
,
int
*
,
int
);
void
(
*
InitMD5_inner
)
(
struct
md5_s
*
);
void
(
*
EndMD5_inner
)
(
struct
md5_s
*
);
void
(
*
vlc_freeaddrinfo_inner
)
(
struct
addrinfo
*
);
...
...
modules/access/ftp.c
View file @
7f432665
...
...
@@ -240,7 +240,7 @@ static int Open( vlc_object_t *p_this )
if
(
ftp_ReadCommand
(
p_access
,
&
i_answer
,
NULL
)
==
2
)
{
char
hostaddr
[
NI_MAXHOST
];
char
hostaddr
[
NI_MAX
NUMERIC
HOST
];
struct
sockaddr_storage
addr
;
socklen_t
len
=
sizeof
(
addr
);
...
...
@@ -251,7 +251,7 @@ static int Open( vlc_object_t *p_this )
}
i_answer
=
vlc_getnameinfo
(
p_this
,
(
struct
sockaddr
*
)
&
addr
,
len
,
hostaddr
,
sizeof
(
hostaddr
),
NULL
,
0
,
hostaddr
,
sizeof
(
hostaddr
),
NULL
,
NI_NUMERICHOST
);
if
(
i_answer
)
{
...
...
src/misc/getaddrinfo.c
View file @
7f432665
...
...
@@ -494,8 +494,22 @@ __getaddrinfo (const char *node, const char *service,
int
vlc_getnameinfo
(
vlc_object_t
*
p_this
,
const
struct
sockaddr
*
sa
,
int
salen
,
char
*
host
,
int
hostlen
,
char
*
serv
,
int
servlen
,
int
flags
)
char
*
host
,
int
hostlen
,
int
*
portnum
,
int
flags
)
{
char
psz_servbuf
[
6
],
*
psz_serv
;
int
i_servlen
,
i_val
;
flags
|=
NI_NUMERICSERV
;
if
(
portnum
!=
NULL
)
{
psz_serv
=
psz_servbuf
;
i_servlen
=
sizeof
(
psz_servbuf
);
}
else
{
psz_serv
=
NULL
;
i_servlen
=
0
;
}
#ifdef WIN32
/*
* Here is the kind of kludge you need to keep binary compatibility among
...
...
@@ -514,11 +528,12 @@ int vlc_getnameinfo( vlc_object_t *p_this, const struct sockaddr *sa, int salen,
if
(
ws2_getnameinfo
!=
NULL
)
{
int
i_val
;
i_val
=
ws2_getnameinfo
(
sa
,
salen
,
host
,
hostlen
,
serv
,
servlen
,
flags
);
i_val
=
ws2_getnameinfo
(
sa
,
salen
,
host
,
hostlen
,
psz_serv
,
i_servlen
,
flags
);
FreeLibrary
(
wship6_module
);
if
(
portnum
!=
NULL
)
*
portnum
=
atoi
(
psz_serv
);
return
i_val
;
}
...
...
@@ -526,11 +541,11 @@ int vlc_getnameinfo( vlc_object_t *p_this, const struct sockaddr *sa, int salen,
}
#endif
#if HAVE_GETNAMEINFO
return
getnameinfo
(
sa
,
salen
,
host
,
hostlen
,
serv
,
servlen
,
flags
);
i_val
=
getnameinfo
(
sa
,
salen
,
host
,
hostlen
,
psz_serv
,
i_servlen
,
flags
);
#else
{
{
vlc_value_t
lock
;
int
i_val
;
/* my getnameinfo implementation is not thread-safe as it uses
* gethostbyaddr and the likes */
...
...
@@ -538,21 +553,39 @@ int vlc_getnameinfo( vlc_object_t *p_this, const struct sockaddr *sa, int salen,
var_Get
(
p_this
->
p_libvlc
,
"getnameinfo_mutex"
,
&
lock
);
vlc_mutex_lock
(
lock
.
p_address
);
i_val
=
__getnameinfo
(
sa
,
salen
,
host
,
hostlen
,
serv
,
servlen
,
flags
);
i_val
=
__getnameinfo
(
sa
,
salen
,
host
,
hostlen
,
psz_serv
,
i_servlen
,
flags
);
vlc_mutex_unlock
(
lock
.
p_address
);
return
i_val
;
}
}
#endif
if
(
portnum
!=
NULL
)
*
portnum
=
atoi
(
psz_serv
);
return
i_val
;
}
/* TODO: support for setting sin6_scope_id */
int
vlc_getaddrinfo
(
vlc_object_t
*
p_this
,
const
char
*
node
,
const
char
*
service
,
const
struct
addrinfo
*
p_hints
,
int
i_port
,
const
struct
addrinfo
*
p_hints
,
struct
addrinfo
**
res
)
{
struct
addrinfo
hints
;
char
psz_buf
[
NI_MAXHOST
],
*
psz_node
;
char
psz_buf
[
NI_MAXHOST
],
*
psz_node
,
psz_service
[
6
];
/*
* In VLC, we always use port number as integer rather than strings
* for historical reasons (and portability).
*/
if
(
(
i_port
>
65535
)
||
(
i_port
<
0
)
)
{
msg_Err
(
p_this
,
"invalid port number %d specified"
,
i_port
);
return
EAI_SERVICE
;
}
/* cannot overflow */
snprintf
(
psz_service
,
6
,
"%d"
,
i_port
);
/* Check if we have to force ipv4 or ipv6 */
if
(
p_hints
==
NULL
)
...
...
@@ -585,8 +618,6 @@ int vlc_getaddrinfo( vlc_object_t *p_this, const char *node,
if
(
(
node
==
NULL
)
||
(
node
[
0
]
==
'\0'
)
)
{
psz_node
=
NULL
;
if
(
service
==
NULL
)
service
=
""
;
}
else
{
...
...
@@ -608,10 +639,6 @@ int vlc_getaddrinfo( vlc_object_t *p_this, const char *node,
}
}
if
(
(
service
!=
NULL
)
&&
(
*
service
==
'\0'
)
)
/* We could put NULL, but you can't have both node and service NULL */
service
=
"0"
;
#ifdef WIN32
{
typedef
int
(
CALLBACK
*
GETADDRINFO
)
(
const
char
*
,
const
char
*
,
...
...
@@ -640,7 +667,7 @@ int vlc_getaddrinfo( vlc_object_t *p_this, const char *node,
}
#endif
#if HAVE_GETADDRINFO
return
getaddrinfo
(
psz_node
,
service
,
&
hints
,
res
);
return
getaddrinfo
(
psz_node
,
psz_
service
,
&
hints
,
res
);
#else
{
int
i_ret
;
...
...
src/misc/net.c
View file @
7f432665
...
...
@@ -85,11 +85,9 @@ int __net_OpenTCP( vlc_object_t *p_this, const char *psz_host, int i_port )
{
struct
addrinfo
hints
,
*
res
,
*
ptr
;
const
char
*
psz_realhost
;
char
*
psz_
realport
,
*
psz_
socks
;
int
i_val
,
i_handle
=
-
1
;
char
*
psz_socks
;
int
i_
realport
,
i_
val
,
i_handle
=
-
1
;
if
(
(
i_port
<
0
)
||
(
i_port
>
65535
)
)
return
-
1
;
/* I don't expect the next TCP version shortly */
if
(
i_port
==
0
)
i_port
=
80
;
/* historical VLC thing */
...
...
@@ -105,33 +103,25 @@ int __net_OpenTCP( vlc_object_t *p_this, const char *psz_host, int i_port )
*
psz
++
=
'\0'
;
psz_realhost
=
psz_socks
;
psz_realport
=
strdup
(
(
psz
!=
NULL
)
?
psz
:
"1080"
)
;
i_realport
=
(
psz
!=
NULL
)
?
atoi
(
psz
)
:
1080
;
msg_Dbg
(
p_this
,
"net: connecting to '%s:%
s
' for '%s:%d'"
,
psz_realhost
,
psz
_realport
,
psz_host
,
i_port
);
msg_Dbg
(
p_this
,
"net: connecting to '%s:%
d
' for '%s:%d'"
,
psz_realhost
,
i
_realport
,
psz_host
,
i_port
);
}
else
{
psz_realhost
=
psz_host
;
psz_realport
=
malloc
(
6
);
if
(
psz_realport
==
NULL
)
{
free
(
psz_socks
);
return
-
1
;
}
i_realport
=
i_port
;
sprintf
(
psz_realport
,
"%d"
,
i_port
);
msg_Dbg
(
p_this
,
"net: connecting to '%s:%s'"
,
psz_realhost
,
psz_realport
);
msg_Dbg
(
p_this
,
"net: connecting to '%s:%d'"
,
psz_realhost
,
i_realport
);
}
i_val
=
vlc_getaddrinfo
(
p_this
,
psz_realhost
,
psz_realport
,
&
hints
,
&
res
);
free
(
psz_realport
);
i_val
=
vlc_getaddrinfo
(
p_this
,
psz_realhost
,
i_realport
,
&
hints
,
&
res
);
if
(
i_val
)
{
msg_Err
(
p_this
,
"cannot resolve '%s' : %s"
,
psz_realhost
,
vlc_gai_strerror
(
i_val
)
);
msg_Err
(
p_this
,
"cannot resolve '%s
:%d
' : %s"
,
psz_realhost
,
i_realport
,
vlc_gai_strerror
(
i_val
)
);
free
(
psz_socks
);
return
-
1
;
}
...
...
@@ -322,29 +312,17 @@ int *__net_ListenTCP( vlc_object_t *p_this, const char *psz_host, int i_port )
{
struct
addrinfo
hints
,
*
res
,
*
ptr
;
int
i_val
,
*
pi_handles
,
i_size
;
char
*
psz_port
;
if
(
(
i_port
<
0
)
||
(
i_port
>
65535
)
)
return
NULL
;
/* I don't expect the next TCP version shortly */
if
(
i_port
==
0
)
i_port
=
80
;
/* historical VLC thing */
memset
(
&
hints
,
0
,
sizeof
(
hints
)
);
hints
.
ai_socktype
=
SOCK_STREAM
;
hints
.
ai_flags
=
AI_PASSIVE
;
psz_port
=
malloc
(
6
);
if
(
psz_port
==
NULL
)
return
NULL
;
sprintf
(
psz_port
,
"%d"
,
i_port
);
msg_Dbg
(
p_this
,
"net: listening to '%s:%s'"
,
psz_host
,
psz_port
);
msg_Dbg
(
p_this
,
"net: listening to '%s:%d'"
,
psz_host
,
i_port
);
i_val
=
vlc_getaddrinfo
(
p_this
,
psz_host
,
psz_port
,
&
hints
,
&
res
);
free
(
psz_port
);
i_val
=
vlc_getaddrinfo
(
p_this
,
psz_host
,
i_port
,
&
hints
,
&
res
);
if
(
i_val
)
{
msg_Err
(
p_this
,
"cannot resolve '%s
' : %s"
,
psz_hos
t
,
msg_Err
(
p_this
,
"cannot resolve '%s
:%d' : %s"
,
psz_host
,
i_por
t
,
vlc_gai_strerror
(
i_val
)
);
return
NULL
;
}
...
...
@@ -1110,7 +1088,7 @@ static int SocksHandshakeTCP( vlc_object_t *p_obj,
/* v4 only support ipv4 */
hints
.
ai_family
=
PF_INET
;
if
(
vlc_getaddrinfo
(
p_obj
,
psz_host
,
NULL
,
&
hints
,
&
p_res
)
)
if
(
vlc_getaddrinfo
(
p_obj
,
psz_host
,
0
,
&
hints
,
&
p_res
)
)
return
VLC_EGENERIC
;
buffer
[
0
]
=
i_socks_version
;
...
...
src/stream_output/sap.c
View file @
7f432665
...
...
@@ -295,12 +295,12 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
hints
.
ai_socktype
=
SOCK_DGRAM
;
hints
.
ai_flags
=
AI_NUMERICHOST
;
i
=
vlc_getaddrinfo
(
(
vlc_object_t
*
)
p_sap
,
p_session
->
psz_uri
,
NULL
,
i
=
vlc_getaddrinfo
(
(
vlc_object_t
*
)
p_sap
,
p_session
->
psz_uri
,
0
,
&
hints
,
&
res
);
if
(
i
==
0
)
i
=
vlc_getnameinfo
(
(
vlc_object_t
*
)
p_sap
,
res
->
ai_addr
,
res
->
ai_addrlen
,
psz_buf
,
sizeof
(
psz_buf
),
NULL
,
0
,
NI_NUMERICHOST
);
NULL
,
NI_NUMERICHOST
);
if
(
i
)
{
msg_Err
(
p_sap
,
"Invalid URI for SAP announce : %s : %s"
,
...
...
@@ -584,7 +584,7 @@ static int SDPGenerate( sap_handler_t *p_sap, session_descriptor_t *p_session )
{
int64_t
i_sdp_id
=
mdate
();
int
i_sdp_version
=
1
+
p_sap
->
i_sessions
+
(
rand
()
&
0xfff
);
char
*
psz_group
,
*
psz_name
,
psz_uribuf
[
48
],
*
psz_uri
;
char
*
psz_group
,
*
psz_name
,
psz_uribuf
[
NI_MAXNUMERICHOST
],
*
psz_uri
;
char
ipv
;
psz_group
=
convert_to_utf8
(
p_sap
,
p_session
->
psz_group
);
...
...
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