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
4462a3a5
Commit
4462a3a5
authored
Jun 12, 2014
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools/wrsw_vlans: error checking, simplification
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
48228ed6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
22 deletions
+21
-22
wrsw_vlans.c
userspace/tools/wrsw_vlans.c
+21
-22
No files found.
userspace/tools/wrsw_vlans.c
View file @
4462a3a5
...
...
@@ -124,7 +124,10 @@ int main(int argc, char *argv[])
array
[
8
*
sizeof
(
portmask
)
-
NPORTS
];
}
if
(
argc
==
1
)
{
print_help
(
prgname
);
exit
(
0
);
}
rtud_ch
=
minipc_client_create
(
"rtud"
,
0
);
if
(
!
rtud_ch
)
{
fprintf
(
stderr
,
"%s: Can't connect to RTUd mini-rpc server
\n
"
,
...
...
@@ -337,12 +340,12 @@ void list_rtu_vlans(void)
do
{
if
(
minipc_call
(
rtud_ch
,
MINIPC_TIMEOUT
,
&
rtud_export_get_vd_list
,
&
vlist
,
idx
)
<
0
)
{
fprintf
(
stderr
,
"%s: minipc_call: %s
\n
"
,
prgname
,
strerror
(
errno
));
fprintf
(
stderr
,
"%s: minipc_call: %s
(%s)
\n
"
,
prgname
,
strerror
(
errno
),
strerror
(
*
(
int
*
)
&
vlist
));
return
;
}
for
(
i
=
0
;
i
<
vlist
.
num_entries
;
++
i
)
{
ventry
=
&
vlist
.
list
[
i
];
printf
(
"%4d %4d 0x%8x "
,
ventry
->
vid
,
ventry
->
fid
,
ventry
->
port_mask
);
printf
(
"%4d %4d 0x%
0
8x "
,
ventry
->
vid
,
ventry
->
fid
,
ventry
->
port_mask
);
if
(
ventry
->
drop
==
0
)
printf
(
"NO "
);
else
printf
(
"YES"
);
if
(
ventry
->
has_prio
==
0
)
printf
(
" -- "
);
...
...
@@ -368,6 +371,7 @@ int clear_all()
&
rtud_export_get_vd_list
,
&
vlist
,
idx
)
<
0
)
{
/* Duplicated from above */
fprintf
(
stderr
,
"%s: minipc_call: %s
\n
"
,
prgname
,
strerror
(
errno
));
fprintf
(
stderr
,
"%s: minipc_call: %s (%s)
\n
"
,
prgname
,
strerror
(
errno
),
strerror
(
*
(
int
*
)
&
vlist
));
return
-
1
;
}
...
...
@@ -391,32 +395,27 @@ int clear_all()
int
set_rtu_vlan
(
int
vid
,
int
fid
,
int
pmask
,
int
drop
,
int
prio
,
int
del
,
int
flags
)
{
st
atic
struct
rtu_vlans_t
*
cur
;
st
ruct
rtu_vlans_t
*
cur
=
rtu_vlans
;
;
if
(
vid
>
0
&&
rtu_vlans
==
NULL
)
{
/* allocate first element of the list */
rtu_vlans
=
(
struct
rtu_vlans_t
*
)
malloc
(
sizeof
(
struct
rtu_vlans_t
)
);
if
(
rtu_vlans
==
NULL
)
{
fprintf
(
stderr
,
"Could not allocate rtu_vlans
\n
"
);
return
-
1
;
}
cur
=
rtu_vlans
;
if
(
!
rtu_vlans
&&
vid
<=
0
)
{
fprintf
(
stderr
,
"%s: missing
\"
--rvid <vid>
\"
before rtu cmd
\n
"
,
prgname
);
return
-
1
;
}
else
if
(
vid
>
0
)
{
/* allocate next element of the list */
cur
->
next
=
(
struct
rtu_vlans_t
*
)
malloc
(
sizeof
(
struct
rtu_vlans_t
)
);
if
(
cur
->
next
==
NULL
)
{
fprintf
(
stderr
,
"
Could not allocate next rtu_vlans
\n
"
);
if
(
vid
>
0
)
{
cur
=
calloc
(
1
,
sizeof
(
*
cur
)
);
if
(
!
cur
)
{
fprintf
(
stderr
,
"
%s: %s
\n
"
,
prgname
,
strerror
(
errno
)
);
return
-
1
;
}
cur
=
cur
->
next
;
}
if
(
vid
>
0
)
{
bzero
(
cur
,
sizeof
(
struct
rtu_vlans_t
));
cur
->
vid
=
vid
;
cur
->
fid
=
vid
;
cur
->
flags
|=
VALID_VID
;
/* link to the list, next time head is "cur" */
cur
->
next
=
rtu_vlans
;
rtu_vlans
=
cur
;
}
if
(
flags
&
VALID_FID
)
cur
->
fid
=
fid
;
...
...
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