Commit e7ef1d97 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

Implement net_SetDSCP() to set Diffserv code point on a socket.

parent 429c5e99
......@@ -102,6 +102,7 @@ VLC_EXPORT( int, __net_OpenUDP, ( vlc_object_t *p_this, const char *psz_bind, in
VLC_EXPORT( void, net_Close, ( int fd ) );
VLC_EXPORT( void, net_ListenClose, ( int *fd ) );
VLC_EXPORT( int, net_SetDSCP, ( int fd, uint8_t dscp ) );
/* Functions to read from or write to the networking layer */
struct virtual_socket_t
......
......@@ -533,6 +533,7 @@ struct module_symbols_t
playlist_item_t * (*playlist_GetPreferredNode_inner) (playlist_t *p_playlist, playlist_item_t *p_node);
int (*utf8_fprintf_inner) (FILE *, const char *, ...);
int (*utf8_vfprintf_inner) (FILE *stream, const char *fmt, va_list ap);
int (*net_SetDSCP_inner) (int fd, uint8_t dscp);
};
# if defined (__PLUGIN__)
# define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
......@@ -1001,6 +1002,7 @@ struct module_symbols_t
# define playlist_GetPreferredNode (p_symbols)->playlist_GetPreferredNode_inner
# define utf8_fprintf (p_symbols)->utf8_fprintf_inner
# define utf8_vfprintf (p_symbols)->utf8_vfprintf_inner
# define net_SetDSCP (p_symbols)->net_SetDSCP_inner
# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
/******************************************************************
* STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.
......@@ -1472,6 +1474,7 @@ struct module_symbols_t
((p_symbols)->playlist_GetPreferredNode_inner) = playlist_GetPreferredNode; \
((p_symbols)->utf8_fprintf_inner) = utf8_fprintf; \
((p_symbols)->utf8_vfprintf_inner) = utf8_vfprintf; \
((p_symbols)->net_SetDSCP_inner) = net_SetDSCP; \
(p_symbols)->net_ConvertIPv4_deprecated = NULL; \
(p_symbols)->__playlist_ItemNew_deprecated = NULL; \
(p_symbols)->__playlist_ItemCopy_deprecated = NULL; \
......
......@@ -2,6 +2,8 @@
* udp.c:
*****************************************************************************
* Copyright (C) 2004-2006 the VideoLAN team
* Copyright © 2006 Rémi Denis-Courmont
*
* $Id$
*
* Authors: Laurent Aimar <fenrir@videolan.org>
......@@ -166,6 +168,40 @@ static int net_SetMcastIface( vlc_object_t *p_this,
return VLC_SUCCESS;
}
int net_SetDSCP( int fd, uint8_t dscp )
{
struct sockaddr_storage addr;
if( getsockname( fd, (struct sockaddr *)&addr, &(socklen_t){ sizeof (addr) }) )
return -1;
int level, cmd;
switch( addr.ss_family )
{
#ifdef IPV6_TCLASS
case AF_INET6:
level = SOL_IPV6;
cmd = IPV6_TCLASS;
break;
#endif
case AF_INET:
level = SOL_IP;
cmd = IP_TOS;
break;
default:
#ifdef ENOPROTOOPT
errno = ENOPROTOOPT;
#endif
return -1;
}
return setsockopt( fd, level, cmd, &(int){ dscp }, sizeof (int));
}
/*****************************************************************************
* __net_ConnectUDP:
*****************************************************************************
......
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