]> git.sesse.net Git - vlc/blob - src/stream_output/sap.c
Fix heap buffer overflow
[vlc] / src / stream_output / sap.c
1 /*****************************************************************************
2  * sap.c : SAP announce handler
3  *****************************************************************************
4  * Copyright (C) 2002-2005 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Clément Stenac <zorglub@videolan.org>
8  *          Rémi Denis-Courmont <rem # videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28 #include <stdlib.h>                                                /* free() */
29 #include <stdio.h>                                              /* sprintf() */
30 #include <string.h>                                            /* strerror() */
31 #include <ctype.h>                                  /* tolower(), isxdigit() */
32
33 #include <vlc/vlc.h>
34 #include <vlc/sout.h>
35
36 #include "network.h"
37 #if defined( WIN32 ) || defined( UNDER_CE )
38 #   if defined(UNDER_CE) && defined(sockaddr_storage)
39 #       undef sockaddr_storage
40 #   endif
41 #   include <winsock2.h>
42 #   include <ws2tcpip.h>
43 #else
44 #   include <netdb.h>
45 #   include <arpa/inet.h>
46 #endif
47 #include "charset.h"
48
49 /* SAP is always on that port */
50 #define SAP_PORT 9875
51
52 #define DEFAULT_PORT "1234"
53
54 #undef EXTRA_DEBUG
55
56 /* SAP Specific structures */
57
58 /* 100ms */
59 #define SAP_IDLE ((mtime_t)(0.100*CLOCK_FREQ))
60 #define SAP_MAX_BUFFER 65534
61 #define MIN_INTERVAL 2
62 #define MAX_INTERVAL 300
63
64 /* A SAP announce address. For each of these, we run the
65  * control flow algorithm */
66 struct sap_address_t
67 {
68     char *psz_address;
69     char psz_machine[NI_MAXNUMERICHOST];
70     int i_port;
71     int i_rfd; /* Read socket */
72     int i_wfd; /* Write socket */
73
74     /* Used for flow control */
75     mtime_t t1;
76     vlc_bool_t b_enabled;
77     vlc_bool_t b_ready;
78     int i_interval;
79     int i_buff;
80     int i_limit;
81 };
82
83 /*****************************************************************************
84  * Local prototypes
85  *****************************************************************************/
86 static void RunThread( vlc_object_t *p_this);
87 static int CalculateRate( sap_handler_t *p_sap, sap_address_t *p_address );
88 static char *SDPGenerate( sap_handler_t *p_sap,
89                           const session_descriptor_t *p_session,
90                           const sap_address_t *p_addr );
91
92 static int announce_SendSAPAnnounce( sap_handler_t *p_sap,
93                                      sap_session_t *p_session );
94
95
96 static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
97                              session_descriptor_t *p_session );
98
99 static int announce_SAPAnnounceDel( sap_handler_t *p_sap,
100                              session_descriptor_t *p_session );
101
102 #define FREE( p ) if( p ) { free( p ); (p) = NULL; }
103
104
105 /**
106  * Create the SAP handler
107  *
108  * \param p_announce the parent announce_handler
109  * \return the newly created SAP handler or NULL on error
110  */
111 sap_handler_t *announce_SAPHandlerCreate( announce_handler_t *p_announce )
112 {
113     sap_handler_t *p_sap;
114
115     p_sap = vlc_object_create( p_announce, sizeof( sap_handler_t ) );
116
117     if( !p_sap )
118     {
119         msg_Err( p_announce, "out of memory" );
120         return NULL;
121     }
122
123     vlc_mutex_init( p_sap, &p_sap->object_lock );
124
125     p_sap->pf_add = announce_SAPAnnounceAdd;
126     p_sap->pf_del = announce_SAPAnnounceDel;
127
128     p_sap->i_sessions = 0;
129     p_sap->i_addresses = 0;
130     p_sap->i_current_session = 0;
131
132     p_sap->b_control = config_GetInt( p_sap, "sap-flow-control");
133
134     if( vlc_thread_create( p_sap, "sap handler", RunThread,
135                        VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
136     {
137         msg_Dbg( p_announce, "Unable to spawn SAP handler thread");
138         free( p_sap );
139         return NULL;
140     };
141     msg_Dbg( p_announce, "thread created, %i sessions", p_sap->i_sessions);
142     return p_sap;
143 }
144
145 /**
146  *  Destroy the SAP handler
147  *  \param p_this the SAP Handler to destroy
148  *  \return nothing
149  */
150 void announce_SAPHandlerDestroy( sap_handler_t *p_sap )
151 {
152     int i;
153
154     vlc_mutex_destroy( &p_sap->object_lock );
155
156     /* Free the remaining sessions */
157     for( i = 0 ; i< p_sap->i_sessions ; i++)
158     {
159         sap_session_t *p_session = p_sap->pp_sessions[i];
160         FREE( p_session->psz_sdp );
161         FREE( p_session->psz_data );
162         REMOVE_ELEM( p_sap->pp_sessions, p_sap->i_sessions , i );
163         FREE( p_session );
164     }
165
166     /* Free the remaining addresses */
167     for( i = 0 ; i< p_sap->i_addresses ; i++)
168     {
169         sap_address_t *p_address = p_sap->pp_addresses[i];
170         FREE( p_address->psz_address );
171         if( p_address->i_rfd > -1 )
172         {
173             net_Close( p_address->i_rfd );
174         }
175         if( p_address->i_wfd > -1 && p_sap->b_control )
176         {
177             net_Close( p_address->i_wfd );
178         }
179         REMOVE_ELEM( p_sap->pp_addresses, p_sap->i_addresses, i );
180         FREE( p_address );
181     }
182
183     /* Free the structure */
184     vlc_object_destroy( p_sap );
185 }
186
187 /**
188  * main SAP handler thread
189  * \param p_this the SAP Handler object
190  * \return nothing
191  */
192 static void RunThread( vlc_object_t *p_this)
193 {
194     sap_handler_t *p_sap = (sap_handler_t*)p_this;
195     sap_session_t *p_session;
196
197     while( !p_sap->b_die )
198     {
199         int i;
200
201         /* If needed, get the rate info */
202         if( p_sap->b_control == VLC_TRUE )
203         {
204             for( i = 0 ; i< p_sap->i_addresses ; i++)
205             {
206                 if( p_sap->pp_addresses[i]->b_enabled == VLC_TRUE )
207                 {
208                     CalculateRate( p_sap, p_sap->pp_addresses[i] );
209                 }
210             }
211         }
212
213         /* Find the session to announce */
214         vlc_mutex_lock( &p_sap->object_lock );
215         if( p_sap->i_sessions > p_sap->i_current_session + 1)
216         {
217             p_sap->i_current_session++;
218         }
219         else if( p_sap->i_sessions > 0)
220         {
221             p_sap->i_current_session = 0;
222         }
223         else
224         {
225             vlc_mutex_unlock( &p_sap->object_lock );
226             msleep( SAP_IDLE );
227             continue;
228         }
229         p_session = p_sap->pp_sessions[p_sap->i_current_session];
230         vlc_mutex_unlock( &p_sap->object_lock );
231
232         /* And announce it */
233         if( p_session->p_address->b_enabled == VLC_TRUE &&
234             p_session->p_address->b_ready == VLC_TRUE )
235         {
236             announce_SendSAPAnnounce( p_sap, p_session );
237         }
238
239         msleep( SAP_IDLE );
240     }
241 }
242
243 /* Add a SAP announce */
244 static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
245                              session_descriptor_t *p_session )
246 {
247     int i_header_size, i;
248     char *psz_head, psz_addr[NI_MAXNUMERICHOST];
249     vlc_bool_t b_ipv6 = VLC_FALSE;
250     sap_session_t *p_sap_session;
251     mtime_t i_hash;
252     struct addrinfo hints, *res;
253     struct sockaddr_storage addr;
254
255     vlc_mutex_lock( &p_sap->object_lock );
256
257     if( p_session->psz_uri == NULL )
258     {
259         vlc_mutex_unlock( &p_sap->object_lock );
260         msg_Err( p_sap, "*FIXME* Unexpected NULL URI for SAP announce" );
261         msg_Err( p_sap, "This should not happen. VLC needs fixing." );
262         return VLC_EGENERIC;
263     }
264
265     /* Determine SAP multicast address automatically */
266     memset( &hints, 0, sizeof( hints ) );
267     hints.ai_socktype = SOCK_DGRAM;
268     hints.ai_flags = AI_NUMERICHOST;
269
270     i = vlc_getaddrinfo( (vlc_object_t *)p_sap, p_session->psz_uri, 0,
271                          &hints, &res );
272     if( i )
273     {
274         vlc_mutex_unlock( &p_sap->object_lock );
275         msg_Err( p_sap, "Invalid URI for SAP announce: %s: %s",
276                  p_session->psz_uri, vlc_gai_strerror( i ) );
277         return VLC_EGENERIC;
278     }
279
280     if( (unsigned)res->ai_addrlen > sizeof( addr ) )
281     {
282         vlc_mutex_unlock( &p_sap->object_lock );
283         vlc_freeaddrinfo( res );
284         msg_Err( p_sap, "Unsupported address family of size %d > %u",
285                  res->ai_addrlen, sizeof( addr ) );
286         return VLC_EGENERIC;
287     }
288
289     memcpy( &addr, res->ai_addr, res->ai_addrlen );
290
291     switch( addr.ss_family )
292     {
293 #if defined (HAVE_INET_PTON) || defined (WIN32)
294         case AF_INET6:
295         {
296             /* See RFC3513 for list of valid IPv6 scopes */
297             struct in6_addr *a6 = &((struct sockaddr_in6 *)&addr)->sin6_addr;
298
299             memcpy( a6->s6_addr + 2, "\x00\x00\x00\x00\x00\x00"
300                    "\x00\x00\x00\x00\x00\x02\x7f\xfe", 14 );
301             if( IN6_IS_ADDR_MULTICAST( a6 ) )
302                  /* force flags to zero, preserve scope */
303                 a6->s6_addr[1] &= 0xf;
304             else
305                 /* Unicast IPv6 - assume global scope */
306                 memcpy( a6->s6_addr, "\xff\x0e", 2 );
307
308             b_ipv6 = VLC_TRUE;
309             break;
310         }
311 #endif
312
313         case AF_INET:
314         {
315             /* See RFC2365 for IPv4 scopes */
316             uint32_t ipv4;
317
318             ipv4 = ntohl( ((struct sockaddr_in *)&addr)->sin_addr.s_addr );
319             /* 224.0.0.0/24 => 224.0.0.255 */
320             if ((ipv4 & 0xffffff00) == 0xe0000000)
321                 ipv4 =  0xe00000ff;
322             else
323             /* 239.255.0.0/16 => 239.255.255.255 */
324             if ((ipv4 & 0xffff0000) == 0xefff0000)
325                 ipv4 =  0xefffffff;
326             else
327             /* 239.192.0.0/14 => 239.195.255.255 */
328             if ((ipv4 & 0xfffc0000) == 0xefc00000)
329                 ipv4 =  0xefc3ffff;
330             else
331             /* other addresses => 224.2.127.254 */
332                 ipv4 = 0xe0027ffe;
333             break;
334         }
335         
336         default:
337             vlc_mutex_unlock( &p_sap->object_lock );
338             vlc_freeaddrinfo( res );
339             msg_Err( p_sap, "Address family %d not supported by SAP",
340                      addr.ss_family );
341             return VLC_EGENERIC;
342     }
343
344     i = vlc_getnameinfo( (struct sockaddr *)&addr, res->ai_addrlen,
345                          psz_addr, sizeof( psz_addr ), NULL, NI_NUMERICHOST );
346     vlc_freeaddrinfo( res );
347
348     if( i )
349     {
350         vlc_mutex_unlock( &p_sap->object_lock );
351         msg_Err( p_sap, "%s", vlc_gai_strerror( i ) );
352         return VLC_EGENERIC;
353     }
354
355     msg_Dbg( p_sap, "using SAP address: %s", psz_addr);
356
357     /* XXX: Check for dupes */
358     p_sap_session = (sap_session_t*)malloc(sizeof(sap_session_t));
359     p_sap_session->p_address = NULL;
360
361     /* Add the address to the buffer */
362     for( i = 0; i < p_sap->i_addresses; i++)
363     {
364         if( !strcmp( psz_addr, p_sap->pp_addresses[i]->psz_address ) )
365         {
366             p_sap_session->p_address = p_sap->pp_addresses[i];
367             break;
368         }
369     }
370
371     if( p_sap_session->p_address == NULL )
372     {
373         sap_address_t *p_address = (sap_address_t *)
374                                     malloc( sizeof(sap_address_t) );
375         if( !p_address )
376         {
377             msg_Err( p_sap, "out of memory" );
378             return VLC_ENOMEM;
379         }
380         p_address->psz_address = strdup( psz_addr );
381         p_address->i_port  =  9875;
382         p_address->i_wfd = net_OpenUDP( p_sap, "", 0, psz_addr,
383                                         p_address->i_port );
384         if( p_address->i_wfd != -1 )
385         {
386             char *ptr;
387
388             net_StopRecv( p_address->i_wfd );
389             net_GetSockAddress( p_address->i_wfd, p_address->psz_machine,
390                                 NULL );
391
392             /* removes scope if present */
393             ptr = strchr( p_address->psz_machine, '%' );
394             if( ptr != NULL )
395                 *ptr = '\0';
396         }
397
398         if( p_sap->b_control == VLC_TRUE )
399         {
400             p_address->i_rfd = net_OpenUDP( p_sap, psz_addr,
401                                             p_address->i_port, "", 0 );
402             if( p_address->i_rfd != -1 )
403                 net_StopSend( p_address->i_rfd );
404             p_address->i_buff = 0;
405             p_address->b_enabled = VLC_TRUE;
406             p_address->b_ready = VLC_FALSE;
407             p_address->i_limit = 10000; /* 10000 bps */
408             p_address->t1 = 0;
409         }
410         else
411         {
412             p_address->b_enabled = VLC_TRUE;
413             p_address->b_ready = VLC_TRUE;
414             p_address->i_interval = config_GetInt( p_sap,"sap-interval");
415             p_address->i_rfd = -1;
416         }
417
418         if( p_address->i_wfd == -1 || (p_address->i_rfd == -1
419                                         && p_sap->b_control ) )
420         {
421             msg_Warn( p_sap, "disabling address" );
422             p_address->b_enabled = VLC_FALSE;
423         }
424
425         INSERT_ELEM( p_sap->pp_addresses,
426                      p_sap->i_addresses,
427                      p_sap->i_addresses,
428                      p_address );
429         p_sap_session->p_address = p_address;
430     }
431
432
433     /* Build the SAP Headers */
434     i_header_size = ( b_ipv6 ? 16 : 4 ) + 20;
435     psz_head = (char *) malloc( i_header_size * sizeof( char ) );
436     if( psz_head == NULL )
437     {
438         msg_Err( p_sap, "out of memory" );
439         return VLC_ENOMEM;
440     }
441
442     /* SAPv1, not encrypted, not compressed */
443     psz_head[0] = b_ipv6 ? 0x30 : 0x20;
444     psz_head[1] = 0x00; /* No authentification length */
445
446     i_hash = mdate();
447     psz_head[2] = (i_hash & 0xFF00) >> 8; /* Msg id hash */
448     psz_head[3] = (i_hash & 0xFF);        /* Msg id hash 2 */
449
450     inet_pton( b_ipv6 ? AF_INET6 : AF_INET, /* can't fail */
451                p_sap_session->p_address->psz_machine, psz_head + 4 );
452
453     memcpy( psz_head + (b_ipv6 ? 20 : 8), "application/sdp", 15 );
454
455     /* If needed, build the SDP */
456     if( p_session->psz_sdp == NULL )
457     {
458         p_session->psz_sdp = SDPGenerate( p_sap, p_session,
459                                           p_sap_session->p_address );
460         if( p_session->psz_sdp == NULL )
461         {
462             vlc_mutex_unlock( &p_sap->object_lock );
463             return VLC_ENOMEM;
464         }
465     }
466
467     p_sap_session->psz_sdp = strdup( p_session->psz_sdp );
468     p_sap_session->i_last = 0;
469
470     psz_head[ i_header_size-1 ] = '\0';
471     p_sap_session->i_length = i_header_size + strlen( p_sap_session->psz_sdp);
472
473     p_sap_session->psz_data = (uint8_t *)malloc( sizeof(char)*
474                                                  p_sap_session->i_length );
475
476     /* Build the final message */
477     memcpy( p_sap_session->psz_data, psz_head, i_header_size );
478     memcpy( p_sap_session->psz_data+i_header_size, p_sap_session->psz_sdp,
479             strlen( p_sap_session->psz_sdp) );
480
481     free( psz_head );
482
483     /* Enqueue the announce */
484     INSERT_ELEM( p_sap->pp_sessions,
485                  p_sap->i_sessions,
486                  p_sap->i_sessions,
487                  p_sap_session );
488     msg_Dbg( p_sap,"Addresses: %i  Sessions: %i",
489                    p_sap->i_addresses,p_sap->i_sessions);
490
491     /* Remember the SAP session for later deletion */
492     p_session->p_sap = p_sap_session;
493
494     vlc_mutex_unlock( &p_sap->object_lock );
495
496     return VLC_SUCCESS;
497 }
498
499 /* Remove a SAP Announce */
500 static int announce_SAPAnnounceDel( sap_handler_t *p_sap,
501                              session_descriptor_t *p_session )
502 {
503     int i;
504     vlc_mutex_lock( &p_sap->object_lock );
505
506     msg_Dbg( p_sap,"removing SAP announce %p",p_session->p_sap);
507
508     /* Dequeue the announce */
509     for( i = 0; i< p_sap->i_sessions; i++)
510     {
511         if( p_session->p_sap == p_sap->pp_sessions[i] )
512         {
513             REMOVE_ELEM( p_sap->pp_sessions,
514                          p_sap->i_sessions,
515                          i );
516
517             FREE( p_session->p_sap->psz_sdp );
518             FREE( p_session->p_sap->psz_data );
519             free( p_session->p_sap );
520             break;
521         }
522     }
523
524     /* XXX: Dequeue the address too if it is not used anymore
525      * TODO: - address refcount
526              - send a SAP deletion packet */
527
528     msg_Dbg( p_sap,"%i announces remaining", p_sap->i_sessions );
529
530     vlc_mutex_unlock( &p_sap->object_lock );
531
532     return VLC_SUCCESS;
533 }
534
535 static int announce_SendSAPAnnounce( sap_handler_t *p_sap,
536                                      sap_session_t *p_session )
537 {
538     int i_ret;
539
540     /* This announce has never been sent yet */
541     if( p_session->i_last == 0 )
542     {
543         p_session->i_next = mdate()+ p_session->p_address->i_interval*1000000;
544         p_session->i_last = 1;
545         return VLC_SUCCESS;
546     }
547
548     if( p_session->i_next < mdate() )
549     {
550 #ifdef EXTRA_DEBUG
551         msg_Dbg( p_sap, "Sending announce");
552 #endif
553         i_ret = net_Write( p_sap, p_session->p_address->i_wfd, NULL,
554                            p_session->psz_data,
555                            p_session->i_length );
556         if( i_ret != (int)p_session->i_length )
557         {
558             msg_Warn( p_sap, "SAP send failed on address %s (%i %i)",
559                    p_session->p_address->psz_address,
560                    i_ret, p_session->i_length );
561         }
562         p_session->i_last = p_session->i_next;
563         p_session->i_next = p_session->i_last
564                             + p_session->p_address->i_interval*1000000;
565     }
566     else
567     {
568         return VLC_SUCCESS;
569     }
570     return VLC_SUCCESS;
571 }
572
573 static char *SDPGenerate( sap_handler_t *p_sap,
574                           const session_descriptor_t *p_session,
575                           const sap_address_t *p_addr )
576 {
577     int64_t i_sdp_id = mdate();
578     int     i_sdp_version = 1 + p_sap->i_sessions + (rand()&0xfff);
579     char *psz_group, *psz_name, psz_uribuf[NI_MAXNUMERICHOST], *psz_uri,
580          *psz_sdp;
581     char ipv;
582
583     psz_group = p_session->psz_group;
584     psz_name = p_session->psz_name;
585
586     /* FIXME: really check that psz_uri is a real IP address
587      * FIXME: make a common function to obtain a canonical IP address */
588     ipv = ( strchr( p_session->psz_uri, ':' )  != NULL) ? '6' : '4';
589     if( *p_session->psz_uri == '[' )
590     {
591         char *ptr;
592
593         strncpy( psz_uribuf, p_session->psz_uri + 1, sizeof( psz_uribuf ) );
594         psz_uribuf[sizeof( psz_uribuf ) - 1] = '\0';
595         ptr = strchr( psz_uribuf, '%' );
596         if( ptr != NULL)
597             *ptr = '\0';
598         ptr = strchr( psz_uribuf, ']' );
599         if( ptr != NULL)
600             *ptr = '\0';
601         psz_uri = psz_uribuf;
602     }
603     else
604         psz_uri = p_session->psz_uri;
605
606     /* see the lists in modules/stream_out/rtp.c for compliance stuff */
607     if( asprintf( &psz_sdp,
608                             "v=0\r\n"
609                             "o=- "I64Fd" %d IN IP%c %s\r\n"
610                             "s=%s\r\n"
611                             "t=0 0\r\n"
612                             "c=IN IP%c %s/%d\r\n"
613                             "m=video %d udp %d\r\n"
614                             "a=tool:"PACKAGE_STRING"\r\n"
615                             "a=type:broadcast\r\n"
616                             "%s%s%s",
617                             i_sdp_id, i_sdp_version,
618                             ipv, p_addr->psz_machine,
619                             psz_name, ipv,
620                             psz_uri, p_session->i_ttl,
621                             p_session->i_port, p_session->i_payload,
622                             psz_group ? "a=x-plgroup:" : "",
623                             psz_group ?: "", psz_group ? "\r\n" : "" ) == -1 )
624         return NULL;
625     
626     msg_Dbg( p_sap, "Generated SDP (%i bytes):\n%s", strlen(psz_sdp),
627              psz_sdp );
628     return psz_sdp;
629 }
630
631 static int CalculateRate( sap_handler_t *p_sap, sap_address_t *p_address )
632 {
633     int i_read;
634     uint8_t buffer[SAP_MAX_BUFFER];
635     int i_tot = 0;
636     mtime_t i_temp;
637     int i_rate;
638
639     if( p_address->t1 == 0 )
640     {
641         p_address->t1 = mdate();
642         return VLC_SUCCESS;
643     }
644     do
645     {
646         /* Might be too slow if we have huge data */
647         i_read = net_ReadNonBlock( p_sap, p_address->i_rfd, NULL, buffer,
648                                    SAP_MAX_BUFFER, 0 );
649         i_tot += i_read;
650     } while( i_read > 0 && i_tot < SAP_MAX_BUFFER );
651
652     i_temp = mdate();
653
654     /* We calculate the rate every 5 seconds */
655     if( i_temp - p_address->t1 < 5000000 )
656     {
657         p_address->i_buff += i_tot;
658         return VLC_SUCCESS;
659     }
660
661     /* Bits/second */
662     i_rate = (int)(8*1000000*((mtime_t)p_address->i_buff + (mtime_t)i_tot ) /
663                         (i_temp - p_address->t1 ));
664
665     p_address->i_limit = 10000;
666
667     p_address->i_interval = ((1000*i_rate / p_address->i_limit) *
668                             (MAX_INTERVAL - MIN_INTERVAL))/1000 + MIN_INTERVAL;
669
670     if( p_address->i_interval > MAX_INTERVAL || p_address->i_interval < 0 )
671     {
672         p_address->i_interval = MAX_INTERVAL;
673     }
674 #ifdef EXTRA_DEBUG
675     msg_Dbg( p_sap,"%s:%i : Rate=%i, Interval = %i s",
676                     p_address->psz_address,p_address->i_port,
677                     i_rate,
678                     p_address->i_interval );
679 #endif
680
681     p_address->b_ready = VLC_TRUE;
682
683     p_address->t1 = i_temp;
684     p_address->i_buff = 0;
685
686     return VLC_SUCCESS;
687 }