Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
fbb3c3d6
Commit
fbb3c3d6
authored
Jun 16, 2000
by
Sam Hocevar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
. le code des VLAN devrait refonctionner
parent
e1e77d20
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
145 additions
and
86 deletions
+145
-86
src/input/input_vlan.c
src/input/input_vlan.c
+145
-86
No files found.
src/input/input_vlan.c
View file @
fbb3c3d6
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
#include <unistd.h>
/* close() */
#include <unistd.h>
/* close() */
#include <string.h>
/* strerror(), bzero() */
#include <string.h>
/* strerror(), bzero() */
#include <stdlib.h>
/* free() */
#include <stdlib.h>
/* free() */
#include <sys/time.h>
/* timeval */
#if defined(SYS_BSD) || defined(SYS_BEOS)
#if defined(SYS_BSD) || defined(SYS_BEOS)
#include <netinet/in.h>
/* struct in_addr */
#include <netinet/in.h>
/* struct in_addr */
...
@@ -68,7 +69,6 @@ typedef struct input_vlan_s
...
@@ -68,7 +69,6 @@ typedef struct input_vlan_s
/*****************************************************************************
/*****************************************************************************
* Local prototypes
* Local prototypes
*****************************************************************************/
*****************************************************************************/
static
int
ZeTrucMucheFunction
(
int
Channel
);
/*****************************************************************************
/*****************************************************************************
* input_VlanCreate: initialize global vlan method data
* input_VlanCreate: initialize global vlan method data
...
@@ -118,6 +118,17 @@ void input_VlanDestroy( void )
...
@@ -118,6 +118,17 @@ void input_VlanDestroy( void )
free
(
p_main
->
p_vlan
);
free
(
p_main
->
p_vlan
);
}
}
/*****************************************************************************
* input_VlanLeave: leave a vlan
*****************************************************************************
* This function tells the vlan library that the designed interface is no more
* locked and than vlan changes can occur.
*****************************************************************************/
void
input_VlanLeave
(
int
i_vlan_id
)
{
/* XXX?? */
}
/*****************************************************************************
/*****************************************************************************
* input_VlanJoin: join a vlan
* input_VlanJoin: join a vlan
*****************************************************************************
*****************************************************************************
...
@@ -134,6 +145,26 @@ int input_VlanJoin( int i_vlan_id )
...
@@ -134,6 +145,26 @@ int input_VlanJoin( int i_vlan_id )
#ifdef SYS_BEOS
#ifdef SYS_BEOS
return
(
-
1
);
return
(
-
1
);
#else
#else
#define SERVER "138.195.130.90"
#define INTERFACE "eth0"
/* default server port */
#define VLANSERVER_PORT 6010
int
socket_cl
;
int
fromlen
;
struct
ifreq
interface
;
struct
sockaddr_in
sa_server
;
struct
sockaddr_in
sa_client
;
unsigned
int
version
=
12
;
char
mess
[
80
];
struct
timeval
*
date_cl
;
struct
timeval
time
;
long
unsigned
int
date
;
int
nbanswer
;
char
answer
;
fd_set
rfds
;
/* If last change is too recent, wait a while */
/* If last change is too recent, wait a while */
if
(
mdate
()
-
p_main
->
p_vlan
->
last_change
<
INPUT_VLAN_CHANGE_DELAY
)
if
(
mdate
()
-
p_main
->
p_vlan
->
last_change
<
INPUT_VLAN_CHANGE_DELAY
)
{
{
...
@@ -144,106 +175,134 @@ int input_VlanJoin( int i_vlan_id )
...
@@ -144,106 +175,134 @@ int input_VlanJoin( int i_vlan_id )
p_main
->
p_vlan
->
i_vlan_id
=
i_vlan_id
;
p_main
->
p_vlan
->
i_vlan_id
=
i_vlan_id
;
intf_Msg
(
"Joining VLAN %d (channel %d)
\n
"
,
i_vlan_id
+
2
,
i_vlan_id
);
intf_Msg
(
"Joining VLAN %d (channel %d)
\n
"
,
i_vlan_id
+
2
,
i_vlan_id
);
return
(
ZeTrucMucheFunction
(
i_vlan_id
)
);
/* FIXME: join vlan ?? */
#endif
/* SYS_BEOS */
}
/*****************************************************************************
* input_VlanLeave: leave a vlan
*****************************************************************************
* This function tells the vlan library that the designed interface is no more
* locked and than vlan changes can occur.
*****************************************************************************/
void
input_VlanLeave
(
int
i_vlan_id
)
{
/* XXX?? */
}
/* following functions are local */
static
int
ZeTrucMucheFunction
(
int
Channel
)
{
#ifdef SYS_LINUX
int
i_socket
;
char
*
ipaddr
;
struct
ifreq
interface
;
struct
sockaddr_in
sa_server
;
struct
sockaddr_in
sa_client
;
char
mess
[
80
];
/*
/*
*Looking for informations about the eth0 interface
*Looking for informations about the eth0 interface
*/
*/
interface
.
ifr_addr
.
sa_family
=
AF_INET
;
interface
.
ifr_addr
.
sa_family
=
AF_INET
;
strcpy
(
interface
.
ifr_name
,
main_GetPszVariable
(
INPUT_IFACE_VAR
,
INPUT_IFACE_DEFAULT
)
);
strcpy
(
interface
.
ifr_name
,
INTERFACE
);
i_socket
=
socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
/* Looking for the interface IP address */
/*
ioctl
(
i_socket
,
SIOCGIFDSTADDR
,
&
interface
);
* Initialysing the socket
ipaddr
=
inet_ntoa
((
*
(
struct
sockaddr_in
*
)(
&
(
interface
.
ifr_addr
))).
sin_addr
);
*/
socket_cl
=
socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
intf_DbgMsg
(
"socket %d
\n
"
,
socket_cl
);
/* Looking for the interface MAC address */
ioctl
(
i_socket
,
SIOCGIFHWADDR
,
&
interface
);
close
(
i_socket
);
/*
/*
* Getting
address, port, ... of the server
* Getting
the server's information
*/
*/
bzero
(
&
sa_server
,
sizeof
(
struct
sockaddr_in
));
/* Initialize */
bzero
(
&
sa_server
,
sizeof
(
struct
sockaddr_in
)
);
/* sin_family is ALWAYS set to AF_INET (see in man 7 ip)*/
sa_server
.
sin_family
=
AF_INET
;
sa_server
.
sin_family
=
AF_INET
;
/* Giving port on to connect after having convert it*/
sa_server
.
sin_port
=
htons
(
VLANSERVER_PORT
);
sa_server
.
sin_port
=
htons
(
main_GetIntVariable
(
INPUT_VLAN_PORT_VAR
,
INPUT_VLAN_PORT_DEFAULT
));
inet_aton
(
SERVER
,
&
(
sa_server
.
sin_addr
));
/* Giving address after having convert it into binary data*/
inet_aton
(
main_GetPszVariable
(
INPUT_VLAN_SERVER_VAR
,
INPUT_VLAN_SERVER_DEFAULT
),
&
(
sa_server
.
sin_addr
)
);
/*
/*
*
Getting address, port, ... of the client
*
Looking for the interface MAC address
*/
*/
ioctl
(
socket_cl
,
SIOCGIFHWADDR
,
&
interface
);
/* Initialize */
intf_DbgMsg
(
"macaddr == %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x
\n
"
,
bzero
(
&
sa_client
,
sizeof
(
struct
sockaddr_in
)
);
/* sin_family is ALWAYS set to AF_INET (see in man 7 ip)*/
sa_client
.
sin_family
=
AF_INET
;
/* Giving port on to connect after having convert it*/
sa_client
.
sin_port
=
htons
(
0
);
/* Giving address after having convert it into binary data*/
inet_aton
(
ipaddr
,
&
(
sa_client
.
sin_addr
)
);
/* Initialization of the socket */
i_socket
=
socket
(
AF_INET
,
SOCK_DGRAM
,
17
);
/* XXX?? UDP */
/* SOCK_DGRAM because here we use DATAGRAM
* Sachant qu'il y a un #define AF_INET = PF_INET dans sys/socket.h et que PF_INET est le IP protocol family ...
* Protocol is in #define, should be 17 for udp */
/* Elaborate the message to send */
sprintf
(
mess
,
"%d %s %2.2x%2.2x%2.2x%2.2x%2.2x%2.2x %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x
\n
"
,
Channel
,
ipaddr
,
interface
.
ifr_hwaddr
.
sa_data
[
0
]
&
0xff
,
interface
.
ifr_hwaddr
.
sa_data
[
0
]
&
0xff
,
interface
.
ifr_hwaddr
.
sa_data
[
1
]
&
0xff
,
interface
.
ifr_hwaddr
.
sa_data
[
1
]
&
0xff
,
interface
.
ifr_hwaddr
.
sa_data
[
2
]
&
0xff
,
interface
.
ifr_hwaddr
.
sa_data
[
2
]
&
0xff
,
interface
.
ifr_hwaddr
.
sa_data
[
3
]
&
0xff
,
interface
.
ifr_hwaddr
.
sa_data
[
3
]
&
0xff
,
interface
.
ifr_hwaddr
.
sa_data
[
4
]
&
0xff
,
interface
.
ifr_hwaddr
.
sa_data
[
4
]
&
0xff
,
interface
.
ifr_hwaddr
.
sa_data
[
5
]
&
0xff
,
interface
.
ifr_hwaddr
.
sa_data
[
5
]
&
0xff
);
/*
* Getting date of the client
*/
date_cl
=
malloc
(
sizeof
(
struct
timeval
));
if
(
gettimeofday
(
date_cl
,
0
)
==
-
1
)
{
return
-
1
;
}
date
=
date_cl
->
tv_sec
;
intf_DbgMsg
(
"date %lu
\n
"
,
date
);
/*
* Build of the message
*/
sprintf
(
mess
,
"%d %u %lu %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x
\n
"
,
i_vlan_id
,
version
,
date
,
interface
.
ifr_hwaddr
.
sa_data
[
0
]
&
0xff
,
interface
.
ifr_hwaddr
.
sa_data
[
0
]
&
0xff
,
interface
.
ifr_hwaddr
.
sa_data
[
1
]
&
0xff
,
interface
.
ifr_hwaddr
.
sa_data
[
1
]
&
0xff
,
interface
.
ifr_hwaddr
.
sa_data
[
2
]
&
0xff
,
interface
.
ifr_hwaddr
.
sa_data
[
2
]
&
0xff
,
interface
.
ifr_hwaddr
.
sa_data
[
3
]
&
0xff
,
interface
.
ifr_hwaddr
.
sa_data
[
3
]
&
0xff
,
interface
.
ifr_hwaddr
.
sa_data
[
4
]
&
0xff
,
interface
.
ifr_hwaddr
.
sa_data
[
4
]
&
0xff
,
interface
.
ifr_hwaddr
.
sa_data
[
5
]
&
0xff
interface
.
ifr_hwaddr
.
sa_data
[
5
]
&
0xff
);
);
intf_DbgMsg
(
"The message is %s
\n
"
,
mess
);
/* Send the message */
intf_DbgMsg
(
"%s
\n
"
,
mess
);
sendto
(
i_socket
,
mess
,
80
,
0
,(
struct
sockaddr
*
)
&
sa_server
,
sizeof
(
struct
sockaddr
));
/*Close the socket */
/*
close
(
i_socket
);
* Open the socket 2
#endif
*/
bzero
(
&
sa_client
,
sizeof
(
struct
sockaddr_in
));
sa_client
.
sin_family
=
AF_INET
;
sa_client
.
sin_port
=
htons
(
4312
);
sa_client
.
sin_addr
.
s_addr
=
INADDR_ANY
;
intf_DbgMsg
(
"socket %d
\n
"
,
socket_cl
=
socket
(
AF_INET
,
SOCK_DGRAM
,
0
));
fromlen
=
sizeof
(
struct
sockaddr
);
intf_DbgMsg
(
"bind %i
\n
"
,
bind
(
socket_cl
,
(
struct
sockaddr
*
)(
&
sa_client
),
sizeof
(
struct
sockaddr
)));
/*
* Send the message
*/
sendto
(
socket_cl
,
mess
,
80
,
0
,
(
struct
sockaddr
*
)(
&
sa_server
),
sizeof
(
struct
sockaddr
));
{
unsigned
z
;
printf
(
"BBP
\n
"
);
z
=
0
;
do
{
z
++
;}
while
(
mess
[
z
]
!=
':'
);
do
{
z
++
;}
while
(
mess
[
z
]
!=
'e'
);
printf
(
"meuuh %d %d
\n
"
,(
unsigned
)
mess
[
z
+
3
],(
unsigned
)
mess
[
z
+
4
]);
}
printf
(
"BBP2
\n
"
);
/*
* Waiting 5 sec for one answer from the server
*/
time
.
tv_sec
=
5
;
time
.
tv_usec
=
0
;
FD_ZERO
(
&
rfds
);
FD_SET
(
socket_cl
,
&
rfds
);
nbanswer
=
select
(
socket_cl
+
1
,
&
rfds
,
NULL
,
NULL
,
&
time
);
if
(
nbanswer
==
0
)
{
intf_DbgMsg
(
"no answer
\n
"
);
}
else
if
(
nbanswer
==
-
1
)
{
intf_DbgMsg
(
"I couldn't recieve the answer
\n
"
);
}
else
{
recvfrom
(
socket_cl
,
&
answer
,
sizeof
(
char
),
0
,
(
struct
sockaddr
*
)(
&
sa_client
),
&
fromlen
);
intf_DbgMsg
(
"the answer : %hhd
\n
"
,
answer
);
if
(
answer
==
-
1
)
{
intf_DbgMsg
(
"The server doesn't succed to create the thread
\n
"
);
}
else
if
(
answer
==
0
)
{
intf_DbgMsg
(
"The server try to change the channel
\n
"
);
}
else
{
intf_DbgMsg
(
"I don't know what is this answer !
\n
"
);
}
}
/*
* Close the socket
*/
close
(
socket_cl
);
return
0
;
return
0
;
#endif
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment