]> git.sesse.net Git - vlc/blobdiff - src/stream_output/sap.c
All signedness fixes
[vlc] / src / stream_output / sap.c
index 7a0f1441d76fb891a1edaa6b6404ed7f3ae92f86..279821fbaca3c3243e601d514177ac93e1ece136 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * sap.c : SAP announce handler
  *****************************************************************************
- * Copyright (C) 2002-2005 VideoLAN
+ * Copyright (C) 2002-2005 the VideoLAN team
  * $Id$
  *
  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
@@ -259,7 +259,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
     char *psz_type = "application/sdp";
     int i_header_size;
     char *psz_head;
-    vlc_bool_t b_found = VLC_FALSE, b_ipv6;
+    vlc_bool_t b_found = VLC_FALSE, b_ipv6 = VLC_FALSE;
     sap_session_t *p_sap_session;
     mtime_t i_hash;
 
@@ -278,7 +278,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
     if( p_method->psz_address == NULL )
     {
         /* Determine SAP multicast address automatically */
-        char psz_buf[NI_MAXHOST], *ptr;
+        char psz_buf[NI_MAXNUMERICHOST], *ptr;
         const char *psz_addr;
         struct addrinfo hints, *res;
 
@@ -295,12 +295,11 @@ 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 );
+            i = vlc_getnameinfo( res->ai_addr, res->ai_addrlen, psz_buf,
+                                 sizeof( psz_buf ), NULL, NI_NUMERICHOST );
         if( i )
         {
             msg_Err( p_sap, "Invalid URI for SAP announce : %s : %s",
@@ -335,8 +334,6 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
         }
         else
         {
-            b_ipv6 = VLC_FALSE;
-
             /* See RFC2365 for IPv4 scopes */
             if( memcmp( psz_buf, "224.0.0.", 8 ) == 0 )
                 psz_addr = "224.0.0.255";
@@ -390,12 +387,16 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
         p_address->i_wfd = net_OpenUDP( p_sap, "", 0,
                                         p_address->psz_address,
                                         p_address->i_port );
+        if( p_address->i_wfd != -1 )
+            net_StopRecv( p_address->i_wfd );
 
         if( p_sap->b_control == VLC_TRUE )
         {
             p_address->i_rfd = net_OpenUDP( p_sap, p_method->psz_address,
                                             p_address->i_port,
                                             "", 0 );
+            if( p_address->i_rfd != -1 )
+                net_StopSend( p_address->i_rfd );
             p_address->i_buff = 0;
             p_address->b_enabled = VLC_TRUE;
             p_address->b_ready = VLC_FALSE;
@@ -482,8 +483,8 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
     psz_head[ i_header_size-1 ] = '\0';
     p_sap_session->i_length = i_header_size + strlen( p_sap_session->psz_sdp);
 
-    p_sap_session->psz_data = (char *)malloc( sizeof(char)*
-                                              p_sap_session->i_length );
+    p_sap_session->psz_data = (uint8_t *)malloc( sizeof(char)*
+                                                 p_sap_session->i_length );
 
     /* Build the final message */
     memcpy( p_sap_session->psz_data, psz_head, i_header_size );
@@ -586,7 +587,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 );
@@ -664,7 +665,7 @@ static int SDPGenerate( sap_handler_t *p_sap, session_descriptor_t *p_session )
 static int CalculateRate( sap_handler_t *p_sap, sap_address_t *p_address )
 {
     int i_read;
-    char buffer[SAP_MAX_BUFFER];
+    uint8_t buffer[SAP_MAX_BUFFER];
     int i_tot = 0;
     mtime_t i_temp;
     int i_rate;