- msg_Dbg( p_sout, "creating IPv4 SAP socket" );
-
- /* Fill the socket descriptor */
- socket_desc.i_type = NETWORK_UDP;
- socket_desc.psz_bind_addr = "";
- socket_desc.i_bind_port = 0;
- socket_desc.psz_server_addr = SAP_IPV4_ADDR;
- socket_desc.i_server_port = SAP_PORT;
- socket_desc.i_handle = 0;
-
- /* Call the network module */
- p_sout->p_private = (void*) &socket_desc;
- if( !( p_network = module_Need( p_sout, "network", "ipv4" ) ) )
- {
- msg_Warn( p_sout, "failed to open a connection (udp)" );
- return NULL;
- }
- module_Unneed( p_sout, p_network );
-
- p_sap->i_socket = socket_desc.i_handle;
- if( p_sap->i_socket < 0 )
- {
- msg_Warn( p_sout, "unable to initialize SAP" );
- return NULL;
- }
- }
- else
- {
- msg_Dbg( p_sout, "creating IPv6 SAP socket with scope %s",
- psz_v6_scope );
-
- /* Initialize and build the IPv6 address to broadcast to */
- sap_ipv6_addr = (char *) malloc( 28 * sizeof(char) );
- if ( !sap_ipv6_addr )
- {
- msg_Err( p_sout, "out of memory" );
- return NULL;
- }
- sprintf( sap_ipv6_addr, "%s%c%s",
- SAP_IPV6_ADDR_1, psz_v6_scope[0], SAP_IPV6_ADDR_2 );
-
- /* Fill the socket descriptor */
- socket_desc.i_type = NETWORK_UDP;
- socket_desc.psz_bind_addr = "";
- socket_desc.i_bind_port = 0;
- socket_desc.psz_server_addr = sap_ipv6_addr;
- socket_desc.i_server_port = SAP_PORT;
- socket_desc.i_handle = 0;
-
- /* Call the network module */
- p_sout->p_private = (void *) &socket_desc;
- if( !( p_network = module_Need( p_sout, "network", "ipv6" ) ) )
- {
- msg_Warn( p_sout, "failed to open a connection (udp)" );
- return NULL;
- }
- module_Unneed( p_sout, p_network );
-
- p_sap->i_socket = socket_desc.i_handle;
- if( p_sap->i_socket <= 0 )
- {
- msg_Warn( p_sout, "unable to initialize SAP" );
- return NULL;
- }
-
- /* Free what we allocated */
- if( sap_ipv6_addr )
- {
- free( sap_ipv6_addr );
- }