]> git.sesse.net Git - vlc/blob - src/network/udp.c
src: correctly honour source specific IP addresses in IGMPv3 requests on OS X (close...
[vlc] / src / network / udp.c
1 /*****************************************************************************
2  * udp.c:
3  *****************************************************************************
4  * Copyright (C) 2004-2006 VLC authors and VideoLAN
5  * Copyright © 2006-2007 Rémi Denis-Courmont
6  *
7  * $Id$
8  *
9  * Authors: Laurent Aimar <fenrir@videolan.org>
10  *          Rémi Denis-Courmont <rem # videolan.org>
11  *
12  * This program is free software; you can redistribute it and/or modify it
13  * under the terms of the GNU Lesser General Public License as published by
14  * the Free Software Foundation; either version 2.1 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * along with this program; if not, write to the Free Software Foundation,
24  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25  *****************************************************************************/
26
27 /*****************************************************************************
28  * Preamble
29  *****************************************************************************/
30 #ifdef HAVE_CONFIG_H
31 # include "config.h"
32 #endif
33
34 #include <vlc_common.h>
35
36 #include <errno.h>
37 #include <assert.h>
38
39 #include <vlc_network.h>
40
41 #ifdef _WIN32
42 #   undef EAFNOSUPPORT
43 #   define EAFNOSUPPORT WSAEAFNOSUPPORT
44 #else
45 #   include <unistd.h>
46 #   ifdef HAVE_NET_IF_H
47 #       include <net/if.h>
48 #   endif
49 #endif
50
51 #ifdef HAVE_LINUX_DCCP_H
52 # include <linux/dccp.h>
53 # ifndef SOCK_DCCP /* provisional API */
54 #  define SOCK_DCCP 6
55 # endif
56 #endif
57
58 #ifndef SOL_IP
59 # define SOL_IP IPPROTO_IP
60 #endif
61 #ifndef SOL_IPV6
62 # define SOL_IPV6 IPPROTO_IPV6
63 #endif
64 #ifndef IPPROTO_IPV6
65 # define IPPROTO_IPV6 41 /* IANA */
66 #endif
67 #ifndef SOL_DCCP
68 # define SOL_DCCP IPPROTO_DCCP
69 #endif
70 #ifndef IPPROTO_DCCP
71 # define IPPROTO_DCCP 33 /* IANA */
72 #endif
73 #ifndef SOL_UDPLITE
74 # define SOL_UDPLITE IPPROTO_UDPLITE
75 #endif
76 #ifndef IPPROTO_UDPLITE
77 # define IPPROTO_UDPLITE 136 /* IANA */
78 #endif
79
80 #if defined (HAVE_NETINET_UDPLITE_H)
81 # include <netinet/udplite.h>
82 #elif defined (__linux__)
83 /* still missing from glibc 2.6 */
84 # define UDPLITE_SEND_CSCOV     10
85 # define UDPLITE_RECV_CSCOV     11
86 #endif
87
88 extern int net_Socket( vlc_object_t *p_this, int i_family, int i_socktype,
89                        int i_protocol );
90
91 /* */
92 static int net_SetupDgramSocket (vlc_object_t *p_obj, int fd,
93                                  const struct addrinfo *ptr)
94 {
95 #ifdef SO_REUSEPORT
96     setsockopt (fd, SOL_SOCKET, SO_REUSEPORT, &(int){ 1 }, sizeof (int));
97 #endif
98
99 #if defined (_WIN32)
100     if (net_SockAddrIsMulticast (ptr->ai_addr, ptr->ai_addrlen)
101      && (sizeof (struct sockaddr_storage) >= ptr->ai_addrlen))
102     {
103         // This works for IPv4 too - don't worry!
104         struct sockaddr_in6 dumb =
105         {
106             .sin6_family = ptr->ai_addr->sa_family,
107             .sin6_port =  ((struct sockaddr_in *)(ptr->ai_addr))->sin_port
108         };
109
110         bind (fd, (struct sockaddr *)&dumb, ptr->ai_addrlen);
111     }
112     else
113 #endif
114     if (bind (fd, ptr->ai_addr, ptr->ai_addrlen))
115     {
116         msg_Err( p_obj, "socket bind error: %s", vlc_strerror_c(net_errno) );
117         net_Close (fd);
118         return -1;
119     }
120     return fd;
121 }
122
123 /* */
124 static int net_ListenSingle (vlc_object_t *obj, const char *host, int port,
125                              int protocol)
126 {
127     struct addrinfo hints = {
128         .ai_socktype = SOCK_DGRAM,
129         .ai_protocol = protocol,
130         .ai_flags = AI_PASSIVE | AI_NUMERICSERV | AI_IDN,
131     }, *res;
132
133     if (host && !*host)
134         host = NULL;
135
136     msg_Dbg (obj, "net: opening %s datagram port %d",
137              host ? host : "any", port);
138
139     int val = vlc_getaddrinfo (host, port, &hints, &res);
140     if (val)
141     {
142         msg_Err (obj, "Cannot resolve %s port %d : %s", host, port,
143                  gai_strerror (val));
144         return -1;
145     }
146
147     val = -1;
148
149     for (const struct addrinfo *ptr = res; ptr != NULL; ptr = ptr->ai_next)
150     {
151         int fd = net_Socket (obj, ptr->ai_family, ptr->ai_socktype,
152                              ptr->ai_protocol);
153         if (fd == -1)
154         {
155             msg_Dbg (obj, "socket error: %s", vlc_strerror_c(net_errno));
156             continue;
157         }
158
159 #ifdef IPV6_V6ONLY
160         /* Try dual-mode IPv6 if available. */
161         if (ptr->ai_family == AF_INET6)
162             setsockopt (fd, SOL_IPV6, IPV6_V6ONLY, &(int){ 0 }, sizeof (int));
163 #endif
164         fd = net_SetupDgramSocket( obj, fd, ptr );
165         if( fd == -1 )
166             continue;
167
168         if (net_SockAddrIsMulticast (ptr->ai_addr, ptr->ai_addrlen)
169          && net_Subscribe (obj, fd, ptr->ai_addr, ptr->ai_addrlen))
170         {
171             net_Close (fd);
172             continue;
173         }
174
175         val = fd;
176         break;
177     }
178
179     freeaddrinfo (res);
180     return val;
181 }
182
183
184 static int net_SetMcastHopLimit( vlc_object_t *p_this,
185                                  int fd, int family, int hlim )
186 {
187     int proto, cmd;
188
189     /* There is some confusion in the world whether IP_MULTICAST_TTL
190      * takes a byte or an int as an argument.
191      * BSD seems to indicate byte so we are going with that and use
192      * int as a fallback to be safe */
193     switch( family )
194     {
195 #ifdef IP_MULTICAST_TTL
196         case AF_INET:
197             proto = SOL_IP;
198             cmd = IP_MULTICAST_TTL;
199             break;
200 #endif
201
202 #ifdef IPV6_MULTICAST_HOPS
203         case AF_INET6:
204             proto = SOL_IPV6;
205             cmd = IPV6_MULTICAST_HOPS;
206             break;
207 #endif
208
209         default:
210             errno = EAFNOSUPPORT;
211             msg_Warn( p_this, "%s", vlc_strerror_c(EAFNOSUPPORT) );
212             return VLC_EGENERIC;
213     }
214
215     if( setsockopt( fd, proto, cmd, &hlim, sizeof( hlim ) ) < 0 )
216     {
217         /* BSD compatibility */
218         unsigned char buf;
219
220         msg_Dbg( p_this, "cannot set hop limit (%d): %s", hlim,
221                  vlc_strerror_c(net_errno) );
222         buf = (unsigned char)(( hlim > 255 ) ? 255 : hlim);
223         if( setsockopt( fd, proto, cmd, &buf, sizeof( buf ) ) )
224         {
225             msg_Err( p_this, "cannot set hop limit (%d): %s", hlim,
226                      vlc_strerror_c(net_errno) );
227             return VLC_EGENERIC;
228         }
229     }
230
231     return VLC_SUCCESS;
232 }
233
234
235 static int net_SetMcastOut (vlc_object_t *p_this, int fd, int family,
236                             const char *iface)
237 {
238     int scope = if_nametoindex (iface);
239     if (scope == 0)
240     {
241         msg_Err (p_this, "invalid multicast interface: %s", iface);
242         return -1;
243     }
244
245     switch (family)
246     {
247 #ifdef IPV6_MULTICAST_IF
248         case AF_INET6:
249             if (setsockopt (fd, SOL_IPV6, IPV6_MULTICAST_IF,
250                             &scope, sizeof (scope)) == 0)
251                 return 0;
252             break;
253 #endif
254
255 #ifdef __linux__
256         case AF_INET:
257         {
258             struct ip_mreqn req = { .imr_ifindex = scope };
259             if (setsockopt (fd, SOL_IP, IP_MULTICAST_IF,
260                             &req, sizeof (req)) == 0)
261                 return 0;
262             break;
263         }
264 #endif
265         default:
266             errno = EAFNOSUPPORT;
267     }
268     msg_Err (p_this, "cannot force multicast interface %s: %s", iface,
269              vlc_strerror_c(errno));
270     return -1;
271 }
272
273
274 static unsigned var_GetIfIndex (vlc_object_t *obj)
275 {
276     char *ifname = var_InheritString (obj, "miface");
277     if (ifname == NULL)
278         return 0;
279
280     unsigned ifindex = if_nametoindex (ifname);
281     if (ifindex == 0)
282         msg_Err (obj, "invalid multicast interface: %s", ifname);
283     free (ifname);
284     return ifindex;
285 }
286
287
288 /**
289  * IP-agnostic multicast join,
290  * with fallback to old APIs, and fallback from SSM to ASM.
291  */
292 static int
293 net_SourceSubscribe (vlc_object_t *obj, int fd,
294                      const struct sockaddr *src, socklen_t srclen,
295                      const struct sockaddr *grp, socklen_t grplen)
296 {
297 /* MCAST_JOIN_SOURCE_GROUP was introduced to OS X in v10.7, but it doesn't work,
298  * so ignore it to use the same code path as on 10.5 or 10.6 */
299 #if defined (MCAST_JOIN_SOURCE_GROUP) && !defined (__APPLE__)
300     /* Agnostic SSM multicast join */
301     int level;
302     struct group_source_req gsr;
303
304     memset (&gsr, 0, sizeof (gsr));
305     gsr.gsr_interface = var_GetIfIndex (obj);
306
307     switch (grp->sa_family)
308     {
309 #ifdef AF_INET6
310         case AF_INET6:
311         {
312             const struct sockaddr_in6 *g6 = (const struct sockaddr_in6 *)grp;
313
314             level = SOL_IPV6;
315             assert (grplen >= sizeof (struct sockaddr_in6));
316             if (g6->sin6_scope_id != 0)
317                 gsr.gsr_interface = g6->sin6_scope_id;
318             break;
319         }
320 #endif
321         case AF_INET:
322             level = SOL_IP;
323             break;
324         default:
325             errno = EAFNOSUPPORT;
326             return -1;
327     }
328
329     assert (grplen <= sizeof (gsr.gsr_group));
330     memcpy (&gsr.gsr_source, src, srclen);
331     assert (srclen <= sizeof (gsr.gsr_source));
332     memcpy (&gsr.gsr_group,  grp, grplen);
333     if (setsockopt (fd, level, MCAST_JOIN_SOURCE_GROUP,
334                     &gsr, sizeof (gsr)) == 0)
335         return 0;
336
337 #else
338     if (src->sa_family != grp->sa_family)
339     {
340         errno = EAFNOSUPPORT;
341         return -1;
342     }
343
344     switch (grp->sa_family)
345     {
346 # ifdef IP_ADD_SOURCE_MEMBERSHIP
347         /* IPv4-specific API */
348         case AF_INET:
349         {
350             struct ip_mreq_source imr;
351
352             memset (&imr, 0, sizeof (imr));
353             assert (grplen >= sizeof (struct sockaddr_in));
354             imr.imr_multiaddr = ((const struct sockaddr_in *)grp)->sin_addr;
355             assert (srclen >= sizeof (struct sockaddr_in));
356             imr.imr_sourceaddr = ((const struct sockaddr_in *)src)->sin_addr;
357             if (setsockopt (fd, SOL_IP, IP_ADD_SOURCE_MEMBERSHIP,
358                             &imr, sizeof (imr)) == 0)
359                 return 0;
360             break;
361         }
362 # endif
363         default:
364             errno = EAFNOSUPPORT;
365     }
366
367 #endif
368     msg_Err (obj, "cannot join source multicast group: %s",
369              vlc_strerror_c(net_errno));
370     msg_Warn (obj, "trying ASM instead of SSM...");
371     return net_Subscribe (obj, fd, grp, grplen);
372 }
373
374
375 int net_Subscribe (vlc_object_t *obj, int fd,
376                    const struct sockaddr *grp, socklen_t grplen)
377 {
378 /* MCAST_JOIN_GROUP was introduced to OS X in v10.7, but it doesn't work,
379  * so ignore it to use the same code as on 10.5 or 10.6 */
380 #if defined (MCAST_JOIN_GROUP) && !defined (__APPLE__)
381     /* Agnostic SSM multicast join */
382     int level;
383     struct group_req gr;
384
385     memset (&gr, 0, sizeof (gr));
386     gr.gr_interface = var_GetIfIndex (obj);
387
388     switch (grp->sa_family)
389     {
390 #ifdef AF_INET6
391         case AF_INET6:
392         {
393             const struct sockaddr_in6 *g6 = (const struct sockaddr_in6 *)grp;
394
395             level = SOL_IPV6;
396             assert (grplen >= sizeof (struct sockaddr_in6));
397             if (g6->sin6_scope_id != 0)
398                 gr.gr_interface = g6->sin6_scope_id;
399             break;
400         }
401 #endif
402         case AF_INET:
403             level = SOL_IP;
404             break;
405         default:
406             errno = EAFNOSUPPORT;
407             return -1;
408     }
409
410     assert (grplen <= sizeof (gr.gr_group));
411     memcpy (&gr.gr_group, grp, grplen);
412     if (setsockopt (fd, level, MCAST_JOIN_GROUP, &gr, sizeof (gr)) == 0)
413         return 0;
414
415 #else
416     switch (grp->sa_family)
417     {
418 # ifdef IPV6_JOIN_GROUP
419         case AF_INET6:
420         {
421             struct ipv6_mreq ipv6mr;
422             const struct sockaddr_in6 *g6 = (const struct sockaddr_in6 *)grp;
423
424             memset (&ipv6mr, 0, sizeof (ipv6mr));
425             assert (grplen >= sizeof (struct sockaddr_in6));
426             ipv6mr.ipv6mr_multiaddr = g6->sin6_addr;
427             ipv6mr.ipv6mr_interface = g6->sin6_scope_id;
428             if (!setsockopt (fd, SOL_IPV6, IPV6_JOIN_GROUP,
429                              &ipv6mr, sizeof (ipv6mr)))
430                 return 0;
431             break;
432         }
433 # endif
434 # ifdef IP_ADD_MEMBERSHIP
435         case AF_INET:
436         {
437             struct ip_mreq imr;
438
439             memset (&imr, 0, sizeof (imr));
440             assert (grplen >= sizeof (struct sockaddr_in));
441             imr.imr_multiaddr = ((const struct sockaddr_in *)grp)->sin_addr;
442             if (setsockopt (fd, SOL_IP, IP_ADD_MEMBERSHIP,
443                             &imr, sizeof (imr)) == 0)
444                 return 0;
445             break;
446         }
447 # endif
448         default:
449             errno = EAFNOSUPPORT;
450     }
451
452 #endif
453     msg_Err (obj, "cannot join multicast group: %s",
454              vlc_strerror_c(net_errno));
455     return -1;
456 }
457
458
459 static int net_SetDSCP( int fd, uint8_t dscp )
460 {
461     struct sockaddr_storage addr;
462     if( getsockname( fd, (struct sockaddr *)&addr, &(socklen_t){ sizeof (addr) }) )
463         return -1;
464
465     int level, cmd;
466
467     switch( addr.ss_family )
468     {
469 #ifdef IPV6_TCLASS
470         case AF_INET6:
471             level = SOL_IPV6;
472             cmd = IPV6_TCLASS;
473             break;
474 #endif
475
476         case AF_INET:
477             level = SOL_IP;
478             cmd = IP_TOS;
479             break;
480
481         default:
482 #ifdef ENOPROTOOPT
483             errno = ENOPROTOOPT;
484 #endif
485             return -1;
486     }
487
488     return setsockopt( fd, level, cmd, &(int){ dscp }, sizeof (int));
489 }
490
491 #undef net_ConnectDgram
492 /*****************************************************************************
493  * net_ConnectDgram:
494  *****************************************************************************
495  * Open a datagram socket to send data to a defined destination, with an
496  * optional hop limit.
497  *****************************************************************************/
498 int net_ConnectDgram( vlc_object_t *p_this, const char *psz_host, int i_port,
499                       int i_hlim, int proto )
500 {
501     struct addrinfo hints = {
502         .ai_socktype = SOCK_DGRAM,
503         .ai_protocol = proto,
504         .ai_flags = AI_NUMERICSERV | AI_IDN,
505     }, *res;
506     int       i_handle = -1;
507     bool      b_unreach = false;
508
509     if( i_hlim < 0 )
510         i_hlim = var_InheritInteger( p_this, "ttl" );
511
512     msg_Dbg( p_this, "net: connecting to [%s]:%d", psz_host, i_port );
513
514     int val = vlc_getaddrinfo (psz_host, i_port, &hints, &res);
515     if (val)
516     {
517         msg_Err (p_this, "cannot resolve [%s]:%d : %s", psz_host, i_port,
518                  gai_strerror (val));
519         return -1;
520     }
521
522     for (struct addrinfo *ptr = res; ptr != NULL; ptr = ptr->ai_next)
523     {
524         char *str;
525         int fd = net_Socket (p_this, ptr->ai_family, ptr->ai_socktype,
526                              ptr->ai_protocol);
527         if (fd == -1)
528             continue;
529
530         /* Allow broadcast sending */
531         setsockopt (fd, SOL_SOCKET, SO_BROADCAST, &(int){ 1 }, sizeof (int));
532
533         if( i_hlim >= 0 )
534             net_SetMcastHopLimit( p_this, fd, ptr->ai_family, i_hlim );
535
536         str = var_InheritString (p_this, "miface");
537         if (str != NULL)
538         {
539             net_SetMcastOut (p_this, fd, ptr->ai_family, str);
540             free (str);
541         }
542
543         net_SetDSCP (fd, var_InheritInteger (p_this, "dscp"));
544
545         if( connect( fd, ptr->ai_addr, ptr->ai_addrlen ) == 0 )
546         {
547             /* success */
548             i_handle = fd;
549             break;
550         }
551
552 #if defined( _WIN32 )
553         if( WSAGetLastError () == WSAENETUNREACH )
554 #else
555         if( errno == ENETUNREACH )
556 #endif
557             b_unreach = true;
558         else
559             msg_Warn( p_this, "%s port %d : %s", psz_host, i_port,
560                       vlc_strerror_c(errno) );
561         net_Close( fd );
562     }
563
564     freeaddrinfo( res );
565
566     if( i_handle == -1 )
567     {
568         if( b_unreach )
569             msg_Err( p_this, "Host %s port %d is unreachable", psz_host,
570                      i_port );
571         return -1;
572     }
573
574     return i_handle;
575 }
576
577 #undef net_OpenDgram
578 /*****************************************************************************
579  * net_OpenDgram:
580  *****************************************************************************
581  * OpenDgram a datagram socket and return a handle
582  *****************************************************************************/
583 int net_OpenDgram( vlc_object_t *obj, const char *psz_bind, int i_bind,
584                    const char *psz_server, int i_server, int protocol )
585 {
586     if ((psz_server == NULL) || (psz_server[0] == '\0'))
587         return net_ListenSingle (obj, psz_bind, i_bind, protocol);
588
589     msg_Dbg (obj, "net: connecting to [%s]:%d from [%s]:%d",
590              psz_server, i_server, psz_bind, i_bind);
591
592     struct addrinfo hints = {
593         .ai_socktype = SOCK_DGRAM,
594         .ai_protocol = protocol,
595         .ai_flags = AI_NUMERICSERV | AI_IDN,
596     }, *loc, *rem;
597
598     int val = vlc_getaddrinfo (psz_server, i_server, &hints, &rem);
599     if (val)
600     {
601         msg_Err (obj, "cannot resolve %s port %d : %s", psz_bind, i_bind,
602                  gai_strerror (val));
603         return -1;
604     }
605
606     hints.ai_flags |= AI_PASSIVE;
607     val = vlc_getaddrinfo (psz_bind, i_bind, &hints, &loc);
608     if (val)
609     {
610         msg_Err (obj, "cannot resolve %s port %d : %s", psz_bind, i_bind,
611                  gai_strerror (val));
612         freeaddrinfo (rem);
613         return -1;
614     }
615
616     val = -1;
617     for (struct addrinfo *ptr = loc; ptr != NULL; ptr = ptr->ai_next)
618     {
619         int fd = net_Socket (obj, ptr->ai_family, ptr->ai_socktype,
620                              ptr->ai_protocol);
621         if (fd == -1)
622             continue; // usually, address family not supported
623
624         fd = net_SetupDgramSocket( obj, fd, ptr );
625         if( fd == -1 )
626             continue;
627
628         for (struct addrinfo *ptr2 = rem; ptr2 != NULL; ptr2 = ptr2->ai_next)
629         {
630             if ((ptr2->ai_family != ptr->ai_family)
631              || (ptr2->ai_socktype != ptr->ai_socktype)
632              || (ptr2->ai_protocol != ptr->ai_protocol))
633                 continue;
634
635             if (net_SockAddrIsMulticast (ptr->ai_addr, ptr->ai_addrlen)
636               ? net_SourceSubscribe (obj, fd,
637                                      ptr2->ai_addr, ptr2->ai_addrlen,
638                                      ptr->ai_addr, ptr->ai_addrlen)
639               : connect (fd, ptr2->ai_addr, ptr2->ai_addrlen))
640             {
641                 msg_Err (obj, "cannot connect to %s port %d: %s",
642                          psz_server, i_server, vlc_strerror_c(net_errno));
643                 continue;
644             }
645             val = fd;
646             break;
647         }
648
649         if (val != -1)
650             break;
651
652         net_Close (fd);
653     }
654
655     freeaddrinfo (rem);
656     freeaddrinfo (loc);
657     return val;
658 }
659
660
661 /**
662  * net_SetCSCov:
663  * Sets the send and receive checksum coverage of a socket:
664  * @param fd socket
665  * @param sendcov payload coverage of sent packets (bytes), -1 for full
666  * @param recvcov minimum payload coverage of received packets, -1 for full
667  */
668 int net_SetCSCov (int fd, int sendcov, int recvcov)
669 {
670     int type;
671
672     if (getsockopt (fd, SOL_SOCKET, SO_TYPE,
673                     &type, &(socklen_t){ sizeof (type) }))
674         return VLC_EGENERIC;
675
676     switch (type)
677     {
678 #ifdef UDPLITE_RECV_CSCOV
679         case SOCK_DGRAM: /* UDP-Lite */
680             if (sendcov == -1)
681                 sendcov = 0;
682             else
683                 sendcov += 8; /* partial */
684             if (setsockopt (fd, SOL_UDPLITE, UDPLITE_SEND_CSCOV, &sendcov,
685                             sizeof (sendcov)))
686                 return VLC_EGENERIC;
687
688             if (recvcov == -1)
689                 recvcov = 0;
690             else
691                 recvcov += 8;
692             if (setsockopt (fd, SOL_UDPLITE, UDPLITE_RECV_CSCOV,
693                             &recvcov, sizeof (recvcov)))
694                 return VLC_EGENERIC;
695
696             return VLC_SUCCESS;
697 #endif
698 #ifdef DCCP_SOCKOPT_SEND_CSCOV
699         case SOCK_DCCP: /* DCCP and its ill-named socket type */
700             if ((sendcov == -1) || (sendcov > 56))
701                 sendcov = 0;
702             else
703                 sendcov = (sendcov + 3) / 4;
704             if (setsockopt (fd, SOL_DCCP, DCCP_SOCKOPT_SEND_CSCOV,
705                             &sendcov, sizeof (sendcov)))
706                 return VLC_EGENERIC;
707
708             if ((recvcov == -1) || (recvcov > 56))
709                 recvcov = 0;
710             else
711                 recvcov = (recvcov + 3) / 4;
712             if (setsockopt (fd, SOL_DCCP, DCCP_SOCKOPT_RECV_CSCOV,
713                             &recvcov, sizeof (recvcov)))
714                 return VLC_EGENERIC;
715
716             return VLC_SUCCESS;
717 #endif
718     }
719 #if !defined( UDPLITE_RECV_CSCOV ) && !defined( DCCP_SOCKOPT_SEND_CSCOV )
720     VLC_UNUSED(sendcov);
721     VLC_UNUSED(recvcov);
722 #endif
723
724     return VLC_EGENERIC;
725 }