Commit 4c858d7e authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

net_GetPort() returns network-byte order port number from an address

parent 8fb67068
...@@ -317,6 +317,20 @@ static inline int net_GetPeerAddress( int fd, char *address, int *port ) ...@@ -317,6 +317,20 @@ static inline int net_GetPeerAddress( int fd, char *address, int *port )
? VLC_EGENERIC : 0; ? VLC_EGENERIC : 0;
} }
static inline uint16_t net_GetPort (const struct sockaddr *addr)
{
switch (addr->sa_family)
{
#ifdef AF_INET6
case AF_INET6:
return ((const struct sockaddr_in6 *)addr)->sin6_port;
#endif
case AF_INET:
return ((const struct sockaddr_in *)addr)->sin_port;
}
return 0;
}
# ifdef __cplusplus # ifdef __cplusplus
} }
# endif # endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment