Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
86
Issues
86
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Switch - Software
Commits
c3b836b3
Commit
c3b836b3
authored
Oct 12, 2020
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rvlan: factorize vlan changing
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
53937a9a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
29 deletions
+28
-29
radiusvlan.c
userspace/tools/radiusvlan.c
+28
-29
No files found.
userspace/tools/radiusvlan.c
View file @
c3b836b3
...
...
@@ -98,6 +98,27 @@ int rvlan_mac_is_local(uint8_t *address)
return
0
;
}
/* Helper for calling the wrs_vlan executable */
int
rvlan_change_vlan
(
struct
rvlan_dev
*
dev
)
{
char
cmdstr
[
128
];
/*
*Call wrsw_vlans, But port sets are global so request an
* outer action with the change_pending flag.
*/
sprintf
(
cmdstr
,
"/wr/bin/wrs_vlans --port %i --pvid %i "
" > /tmp/rvlan-cmd-stdout 2> /tmp/rvlan-cmd-stderr"
,
dev
->
portnr
,
dev
->
chosen_vlan
);
if
(
system
(
cmdstr
))
{
fprintf
(
stderr
,
"%s: can't set vlan %i for %i (%s)
\n
"
,
prgname
,
dev
->
chosen_vlan
,
dev
->
portnr
,
dev
->
name
);
return
-
1
;
}
rvlan_change_pending
++
;
return
0
;
}
/* Authentication of a port is a state machine */
int
rvlan_fsm
(
struct
rvlan_dev
*
dev
,
fd_set
*
rdset
)
{
...
...
@@ -108,7 +129,6 @@ int rvlan_fsm(struct rvlan_dev *dev, fd_set *rdset)
struct
sockaddr_in
from
;
socklen_t
fromlen
=
sizeof
(
from
);
static
unsigned
char
frame
[
512
];
static
char
cmdstr
[
128
];
int
pipe0
[
2
],
pipe1
[
2
];
/* First of all, process up/down changes */
...
...
@@ -125,6 +145,9 @@ int rvlan_fsm(struct rvlan_dev *dev, fd_set *rdset)
break
;
case
RVLAN_JUSTUP
:
/* Turn into temporary auth vlan, but ignore errors */
dev
->
chosen_vlan
=
rvlan_auth_vlan
;
rvlan_change_vlan
(
dev
);
/* prepare the sniffing socket */
sock
=
socket
(
PF_PACKET
,
SOCK_RAW
,
htons
(
ETH_P_ALL
));
if
(
sock
<
0
)
{
...
...
@@ -330,24 +353,11 @@ int rvlan_fsm(struct rvlan_dev *dev, fd_set *rdset)
dev
->
fsm_state
=
RVLAN_CONFIG
;
break
;
case
RVLAN_CONFIG
:
/*
* Call wrsw_vlans here. Still, port lists are
* global so request an outer action with the
* change_pending flag.
*/
sprintf
(
cmdstr
,
"/wr/bin/wrs_vlans --port %i --pvid %i "
" > /tmp/rvlan-cmd-stdout 2> /tmp/rvlan-cmd-stderr"
,
dev
->
portnr
,
dev
->
chosen_vlan
);
if
(
system
(
cmdstr
))
{
fprintf
(
stderr
,
"%s: can't set vlan %i for %i (%s)
\n
"
,
prgname
,
dev
->
chosen_vlan
,
dev
->
portnr
,
dev
->
name
);
if
(
rvlan_change_vlan
(
dev
)
<
0
)
return
-
1
;
}
dev
->
fsm_state
=
RVLAN_CONFIGURED
;
rvlan_change_pending
++
;
break
;
case
RVLAN_CONFIGURED
:
break
;
...
...
@@ -523,7 +533,7 @@ int rvlan_prepare_poll(void)
int
rvlan_initial_check
(
void
)
{
struct
rvlan_dev
*
dev
;
char
path
[
64
],
upbuf
[
16
]
,
cmdstr
[
128
]
;
char
path
[
64
],
upbuf
[
16
];
FILE
*
f
;
int
ret
,
up
=
1
;
...
...
@@ -545,19 +555,8 @@ int rvlan_initial_check(void)
up
=
0
;
}
dev
->
up_now
=
up
;
if
(
up
)
{
if
(
up
)
dev
->
fsm_state
=
RVLAN_JUSTUP
;
dev
->
chosen_vlan
=
rvlan_auth_vlan
;
rvlan_change_pending
++
;
sprintf
(
cmdstr
,
"wrs_vlans --port %i --pvid %i "
"> /dev/null 2> /dev/null"
,
dev
->
portnr
,
dev
->
chosen_vlan
);
if
(
system
(
cmdstr
))
{
fprintf
(
stderr
,
"%s: %s: can't set vlan %i
\n
"
,
prgname
,
dev
->
name
,
dev
->
chosen_vlan
);
continue
;
}
}
if
(
verbose
)
printf
(
"%s
\n
"
,
up
?
"up"
:
"down"
);
}
...
...
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