]> git.sesse.net Git - vlc/commitdiff
* include/stream_output.h: add a ip_version field to sap_address_t
authorDerk-Jan Hartman <hartman@videolan.org>
Tue, 10 Aug 2004 15:02:11 +0000 (15:02 +0000)
committerDerk-Jan Hartman <hartman@videolan.org>
Tue, 10 Aug 2004 15:02:11 +0000 (15:02 +0000)
  This way we can later on set IP6 instead of IP4 in a SDP.
* modules/stream_out/rtp.c: accept sdp=sap as a valid option.
* src/stream_output/sap.c:
  - Set the SAP packet Hash headerfield to a unique value based on mtime
    Patch by Philippe van Hecke <philippe at belnet dot be>
  - Set SAP packet IPv6 field to 1 if we are a ipv6 session
  - Made some preperations for setting the origin ip address in the header as well,
    anyone any ideas on how to retrieve the current origin IP address???

THANKS
include/stream_output.h
modules/stream_out/rtp.c
src/stream_output/sap.c

diff --git a/THANKS b/THANKS
index 47d96764d46748a8495c587a255fa7a60dd16e80..2c1bc54e9d9a39d4aa458617786aa75c26820afe 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -72,6 +72,7 @@ Olivier Aubert <oaubert@bat710.univ-lyon1.fr> - clone list patch
 Olivier Pomel <pomel@via.ecp.fr> - original VLC code
 Øyvind Kolbu <oyvindk@world-online.no> - FreeBSD patches
 Paul Mackerras <paulus@linuxcare.com.au> - AltiVec IDCT and motion
+Philippe Van Hecke <philippe at belnet dot be> - SAP header hash patch
 Régis Duchesne <regis@via.ecp.fr> - original VLC code
 Remco Poortinga <poortinga@telin.nl> - IPv6 multicast patch
 Rene Gollent <rgollent@u.arizona.edu> - BeOS interface fix
index 5be60619d1e7d476fa4a348a41c71b45dd02b441..45f6bc0585652c6249a8b934cf14249194ac78c0 100644 (file)
@@ -276,6 +276,7 @@ struct announce_method_t
 struct sap_address_t
 {
     char *psz_address;
+    int i_ip_version;
     int i_port;
     int i_rfd; /* Read socket */
     int i_wfd; /* Write socket */
index d52dd32395994acf108ebc570824235abcf61069..59dc36cd3b1300f8d609f10a2536ebee1fd4ef5b 100644 (file)
@@ -654,7 +654,8 @@ static void SDPHandleUrl( sout_stream_t *p_stream, char *psz_url )
             msg_Err( p_stream, "cannot export sdp as rtsp" );
         }
     }
-    else if( url.psz_protocol && !strcasecmp( url.psz_protocol, "sap" ) )
+    else if( ( url.psz_protocol && !strcasecmp( url.psz_protocol, "sap" ) ) || 
+             ( url.psz_host && !strcasecmp( url.psz_host, "sap" ) ) )
     {
         p_sys->b_export_sap = VLC_TRUE;
         SapSetup( p_stream );
index 94facfa352828c8b5c76f0e76adf52119a8f3957..465696897fdb6df6708d2fd08cd70f3ceed2788a 100644 (file)
@@ -215,6 +215,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
     char *psz_head;
     vlc_bool_t b_found = VLC_FALSE;
     sap_session_t *p_sap_session;
+    mtime_t i_hash;
 
     vlc_mutex_lock( &p_sap->object_lock );
 
@@ -281,6 +282,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
             return VLC_ENOMEM;
         }
         p_address->psz_address = strdup( p_method->psz_address );
+        p_address->i_ip_version = p_method->i_ip_version;
         p_address->i_port  =  9875;
         p_address->i_wfd = net_OpenUDP( p_sap, "", 0,
                                         p_address->psz_address,
@@ -319,7 +321,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
     }
 
     /* Build the SAP Headers */
-    i_header_size = 8 + strlen( psz_type ) + 1;
+    i_header_size = ( p_method->i_ip_version == 6 ? 20 : 8 ) + strlen( psz_type ) + 1;
     psz_head = (char *) malloc( i_header_size * sizeof( char ) );
     if( ! psz_head )
     {
@@ -327,17 +329,52 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
         return VLC_ENOMEM;
     }
 
-    psz_head[0] = 0x20; /* Means IPv4, not encrypted, not compressed */
-    psz_head[1] = 0x00; /* No authentification */
-    psz_head[2] = 0x42; /* Msg id hash */
-    psz_head[3] = 0x12; /* Msg id hash 2 */
+    psz_head[0] = 0x20; /* Means SAPv1, IPv4, not encrypted, not compressed */
+    psz_head[1] = 0x00; /* No authentification length */
 
-    psz_head[4] = 0x01; /* Source IP  FIXME: we should get the real address */
-    psz_head[5] = 0x02; /* idem */
-    psz_head[6] = 0x03; /* idem */
-    psz_head[7] = 0x04; /* idem */
+    i_hash = mdate();
+    psz_head[2] = (i_hash & 0xFF00) >> 8; /* Msg id hash */
+    psz_head[3] = (i_hash & 0xFF);        /* Msg id hash 2 */
+
+    if( p_method->i_ip_version == 6 )
+    {
+        /* in_addr_t ip_server = inet_addr( ip ); */
+        psz_head[0] |= 0x10; /* Set IPv6 */
+
+        psz_head[4] = 0x01; /* Source IP  FIXME: we should get the real address */
+        psz_head[5] = 0x02; /* idem */
+        psz_head[6] = 0x03; /* idem */
+        psz_head[7] = 0x04; /* idem */
+
+        psz_head[8] = 0x01; /* Source IP  FIXME: we should get the real address */
+        psz_head[9] = 0x02; /* idem */
+        psz_head[10] = 0x03; /* idem */
+        psz_head[11] = 0x04; /* idem */
+
+        psz_head[12] = 0x01; /* Source IP  FIXME: we should get the real address */
+        psz_head[13] = 0x02; /* idem */
+        psz_head[14] = 0x03; /* idem */
+        psz_head[15] = 0x04; /* idem */
+
+        psz_head[16] = 0x01; /* Source IP  FIXME: we should get the real address */
+        psz_head[17] = 0x02; /* idem */
+        psz_head[18] = 0x03; /* idem */
+        psz_head[19] = 0x04; /* idem */
+
+        strncpy( psz_head + 20, psz_type, 15 );
+    }
+    else
+    {
+        /* in_addr_t ip_server = inet_addr( ip) */
+        /* Source IP  FIXME: we should get the real address */
+        psz_head[4] = 0x01; /* ip_server */
+        psz_head[5] = 0x02; /* ip_server>>8 */
+        psz_head[6] = 0x03; /* ip_server>>16 */
+        psz_head[7] = 0x04; /* ip_server>>24 */
+
+        strncpy( psz_head + 8, psz_type, 15 );
+    }
 
-    strncpy( psz_head + 8, psz_type, 15 );
     psz_head[ i_header_size-1 ] = '\0';
     p_sap_session->i_length = i_header_size + strlen( p_sap_session->psz_sdp);
 
@@ -386,8 +423,9 @@ static int announce_SAPAnnounceDel( sap_handler_t *p_sap,
         }
     }
 
-    /* XXX: Dequeue the adress too if it is not used anymore
-     * TODO: address refcount */
+    /* XXX: Dequeue the address too if it is not used anymore
+     * TODO: - address refcount
+             - send a SAP deletion packet */  
 
     msg_Dbg( p_sap,"%i announces remaining", p_sap->i_sessions );