Commit 48498c85 authored by Clément Stenac's avatar Clément Stenac

* Now able to announce IPv6 sessions. For each program, you just have to

say if they are IPv6.
   (VLC needs VERY small changes to be able to read them)

* Improved IPv6 announces (multi-scope)

* Ability to give the specify the TTL of the program, instead of just
saying 15
parent 3f1c8016
VERSION=0.2.0
CFLAGS= -Wall -Wstrict-prototypes
CFLAGS= -Wall -Wstrict-prototypes -g
FILES=program message parser broadcast
FILES_O=$(FILES:%=%.o)
......
......@@ -2,7 +2,7 @@
* broadcast.cpp : SAP Broadcast class
****************************************************************************
* Copyright (C) 1998-2003 VideoLAN
* $Id: broadcast.cpp,v 1.2 2003/06/14 21:45:12 zorglub Exp $
* $Id: broadcast.cpp,v 1.3 2003/06/16 10:26:47 zorglub Exp $
*
* Authors: Damien Lucas <nitrox@videolan.org>
*
......@@ -73,9 +73,17 @@ int Broadcast::Initv4(void)
return 0;
}
int Broadcast::Initv6(void)
int Broadcast::Initv6(char scope)
{
group = SAP_IPV6_LOCAL_ADDR;
group=(char *)malloc(32 * sizeof(char)); /* Size of an IPv6 address */
if(!group)
{
perror("malloc");
return(-1);
}
sprintf( group , "%s%c%s" , SAP_IPV6_ADDR_1 , scope , SAP_IPV6_ADDR_2);
unsigned char ip_address[16];
if ((fd=socket(AF_INET6,SOCK_DGRAM,0)) < 0)
{
......@@ -107,6 +115,9 @@ int Broadcast::Initv6(void)
perror("setsockopt");
return(-1);
}
if(group) free(group);
return 0;
}
......
......@@ -2,7 +2,7 @@
* broacast.h : SAP Broadcast Class definition
****************************************************************************
* Copyright (C) 1998-2003 VideoLAN
* $Id: broadcast.h,v 1.2 2003/06/14 21:45:12 zorglub Exp $
* $Id: broadcast.h,v 1.3 2003/06/16 10:26:47 zorglub Exp $
*
* Authors: Damien Lucas <nitrox@videolan.org>
*
......@@ -23,7 +23,8 @@
#define HELLO_PORT 9875
#define SAP_IPV4_ADDR "224.2.127.254"
#define SAP_IPV6_LOCAL_ADDR "FF02:0:0:0:0:0:2:7FFE"
#define SAP_IPV6_ADDR_1 "FF0" /* You must put the scope after */
#define SAP_IPV6_ADDR_2 ":0:0:0:0:0:2:7FFE"
class Broadcast {
......@@ -31,7 +32,7 @@ class Broadcast {
Broadcast(unsigned int t);
~Broadcast();
int Initv4(void);
int Initv6(void);
int Initv6(char scope);
int Send(Message*,int);
private:
......
......@@ -2,7 +2,7 @@
* message.cpp : SAP Message class
****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: message.cpp,v 1.4 2003/06/14 21:45:12 zorglub Exp $
* $Id: message.cpp,v 1.5 2003/06/16 10:26:47 zorglub Exp $
*
* Authors: Damien Lucas <nitrox@videolan.org>
* Philippe Van Hecke <philippe.vanhecke@belnet.be>
......@@ -146,7 +146,13 @@ void Message::AddProgram(Program *p)
fprintf(stderr, "Announcing permanent session instead\n");
}
string m="m=audio "+p->GetPort()+" udp 14\n";
string c="c=IN IP4 "+p->GetAddress()+"/15\n";
string c;
if(p->GetIPVersion() == 6)
c="c=IN IP6 ["+p->GetAddress()+"]/"+p->GetTTL()+"\n";
else
c="c=IN IP4 "+p->GetAddress()+"/"+p->GetTTL()+"\n";
// TODO ttl type should be specified
string a="a=type:test\n";
......
......@@ -2,10 +2,9 @@
* parser.cpp : SAP configuration file parser
****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: parser.cpp,v 1.3 2003/06/14 21:45:12 zorglub Exp $
* $Id: parser.cpp,v 1.4 2003/06/16 10:26:47 zorglub Exp $
*
* Authors: Fabrice Ollivier <cif@via.ecp.fr>
* Arnaud Schauly <gitan@via.ecp.fr>
* Authors: Arnaud Schauly <gitan@via.ecp.fr>
* Clment Stenac <zorglub@via.ecp.fr>
* Damien Lucas <nitrox@videolan.org>
* Philippe Van Hecke <philippe.vanhecke@belnet.be>
......@@ -49,6 +48,7 @@ Config::Config(string f)
{
file=f;
ttl=DEFAULT_TTL;
scope=DEFAULT_SCOPE;
}
Config::~Config()
......@@ -97,6 +97,13 @@ int Config::GetIPVersion()
return ipversion;
}
char Config::GetScope()
{
// printf("%s\n",scope);
// printf("%c\n",scope[0]);
return scope[0];
}
/**********************************************************
* Gets what is before delim in source. Puts it into dest *
**********************************************************/
......@@ -159,7 +166,7 @@ int Config::Parse()
{
memset(line,'0',1024);
fgets(line,1024,fd);
if(!strlen(line))
if(!strlen(line))
{
break;
}
......@@ -172,12 +179,17 @@ int Config::Parse()
ttl=atoi(tline);
}
if(strstr(line,"ipversion="))
if(strstr(line,"sap_ipversion="))
{
strgeta(line,tline,'=');
ipversion=atoi(tline);
}
if(strstr(line,"ipv6_scope="))
{
strgeta(line,tline,'=');
scope=strdup(tline);
// scope=tline;
}
if(strstr(line,"[program]"))
{
......@@ -186,7 +198,7 @@ int Config::Parse()
/* We were in a program with at least one field filled */
if (!pp->GetPort().length())
{
pp->SetPort("1234");
pp->SetPort(DEFAULT_PORT);
}
Programs.push_back(pp);
pp=new Program();
......@@ -200,6 +212,20 @@ int Config::Parse()
something=1;
pp->SetName(tline);
}
if(strstr(line,"program_ttl="))
{
strgeta(line,tline,'=');
something=1;
pp->SetTTL(tline);
}
if(strstr(line,"program_ipversion="))
{
strgeta(line,tline,'=');
something=1;
pp->SetIPVersion(tline);
}
if(strstr(line,"user="))
{
......
......@@ -2,7 +2,7 @@
* parser.h : SAP configuration file parser definition
****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: parser.h,v 1.2 2003/06/14 21:45:12 zorglub Exp $
* $Id: parser.h,v 1.3 2003/06/16 10:26:47 zorglub Exp $
*
* Authors: Fabrice Ollivier <cif@via.ecp.fr>
* Arnaud Schauly <gitan@via.ecp.fr>
......@@ -38,12 +38,14 @@ class Config
bool GetDotMode(void);
void SetFile(char*);
int GetIPVersion();
char GetScope();
vector<Program*> Programs;
private:
string file;
int ttl;
int ipversion;
char * scope;
bool daemon;
bool dot;
void strgetb(char *source,char *dest,char delim);
......
......@@ -2,7 +2,7 @@
* program.cpp : SAP Program class
****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: program.cpp,v 1.3 2003/05/25 21:41:19 alexis Exp $
* $Id: program.cpp,v 1.4 2003/06/16 10:26:47 zorglub Exp $
*
* Authors: Damien Lucas <nitrox@videolan.org>
* Philippe Van Hecke <philippe.vanhecke@belnet.be>
......@@ -35,8 +35,14 @@ using namespace std;
Program::Program()
{
/* Set default Values */
permanent=true;
return;
program_ipversion=4;
program_ttl="15";
machine="localhost";
user="VideoLAN";
site="http://www.videolan.org";
return;
}
Program::~Program() {return;}
......@@ -46,6 +52,10 @@ string Program::GetMachine(void) {return machine;}
string Program::GetSite(void) {return site;}
string Program::GetAddress(void){return address;}
string Program::GetPort(void){return port;}
string Program::GetTTL(void){return program_ttl;}
int Program::GetIPVersion(void){return program_ipversion;};
bool Program::IsPermanent(void){return permanent;}
void Program::SetName(char* n){name=n;}
......@@ -54,6 +64,8 @@ void Program::SetMachine(char* m){machine=m;}
void Program::SetSite(char* s){site=s;}
void Program::SetAddress(char* a){address=a;}
void Program::SetPort(char* p){port=p;}
void Program::SetTTL(char *p){program_ttl=p;}
void Program::SetIPVersion(char *p){program_ipversion=atoi(p);}
Program::Program(string n, string u, string m, string s, string a,string p)
{
......
......@@ -2,7 +2,7 @@
* program.h : SAP programs classes definition
****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: program.h,v 1.3 2003/05/25 21:41:19 alexis Exp $
* $Id: program.h,v 1.4 2003/06/16 10:26:47 zorglub Exp $
*
* Authors: Damien Lucas <nitrox@videolan.org>
*
......@@ -34,12 +34,16 @@ class Program
string GetSite();
string GetAddress();
string GetPort();
string GetTTL();
int GetIPVersion();
void SetName(char*);
void SetUser(char*);
void SetMachine(char*);
void SetSite(char*);
void SetAddress(char*);
void SetPort(char *);
void SetTTL(char *);
void SetIPVersion(char *);
bool IsPermanent();
private:
......@@ -48,7 +52,9 @@ class Program
string machine;
string site;
string address;
string port;
string port;
string program_ttl;
int program_ipversion;
bool permanent;
uint32_t start_time;
uint32_t stop_time;
......
......@@ -2,23 +2,31 @@
[global]
ttl=255 # TTL (Time To Live) of the SAP announces. You should put 255
ipversion=4 # Version of IP Protocol to use: 4 for IPv4, 6 for IPv6
sap_ipversion=4 # Version of IP Protocol to use: 4 for IPv4, 6 for IPv6
ipv6_scope=A
# This is the "scope" of the IPv6 announce (if it exists)
# it is between 1 and F. For link-local multicast, use 2
# Then you should have one "[program]" section per program announced
# IPv4 exemple
[program]
name=TV1 # Name of the program (as will show up in the VLC playlist)
user=videolan# Name of the streaming entity
machine=vlcs.via.ecp.fr # Name of the streaming machine
site=www.videolan.org # Site of the streaming entity
address=239.255.12.12 # Multicast IP address of the program
port=1234
address=239.255.42.12 # Multicast IP address of the program
port=1234 # UDP Port. Default is 1234
program_ttl=24 # TTL for this program (15 is the default value)
program_ipversion=4 # 4 or 6 (4 is the default value)
# IPv6 exemple
[program]
name=TV2
user=videolan
machine=vlcs.via.ecp.fr
site=www.videolan.org
address=239.255.12.13
program_ttl=24
program_ipversion=6
address=ff03::1242
port=1234
......@@ -2,7 +2,7 @@
* sapserver.cpp : SAP discovery service mini-server
****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: sapserver.cpp,v 1.11 2003/06/14 21:45:12 zorglub Exp $
* $Id: sapserver.cpp,v 1.12 2003/06/16 10:26:47 zorglub Exp $
*
* Authors: Fabrice Ollivier <cif@via.ecp.fr>
* Arnaud Schauly <gitan@via.ecp.fr>
......@@ -115,7 +115,7 @@ int main(int argc, char *argv[])
if(config->GetIPVersion() == 6)
{
fprintf(stdout,"+ Using IPv6\n");
i_init_status=broadcast->Initv6();
i_init_status=broadcast->Initv6(config->GetScope());
}
else
{
......
......@@ -2,7 +2,7 @@
* sapserver.cpp : SAP discovery service classes definition
****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: sapserver.h,v 1.3 2003/05/25 22:28:57 alexis Exp $
* $Id: sapserver.h,v 1.4 2003/06/16 10:26:47 zorglub Exp $
*
* Authors: Fabrice Ollivier <cif@via.ecp.fr>
* Arnaud Schauly <gitan@via.ecp.fr>
......@@ -32,6 +32,9 @@
#define DEFAULT_CONF "/etc/sap.cfg"
#define DEFAULT_TTL 10
#define DEFAULT_SCOPE "2"
#define DEFAULT_PORT "1234"
#define SAP_ON 1
#define SAP_OFF 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment