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
39848809
Commit
39848809
authored
Jul 21, 2017
by
Adam Wujek
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[BUG: 1571] fix case-sensitive input to rtu_stat
Signed-off-by:
Adam Wujek
<
adam.wujek@cern.ch
>
parent
3b308099
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
4 deletions
+22
-4
mac.h
userspace/libwr/include/libwr/mac.h
+1
-0
mac.c
userspace/libwr/mac.c
+17
-0
rtu_stat.c
userspace/tools/rtu_stat.c
+4
-4
No files found.
userspace/libwr/include/libwr/mac.h
View file @
39848809
...
...
@@ -65,5 +65,6 @@ char *mac_to_string(uint8_t mac[ETH_ALEN]);
char
*
mac_to_buffer
(
uint8_t
mac
[
ETH_ALEN
],
char
buffer
[
ETH_ALEN_STR
]);
int
mac_from_str
(
uint8_t
*
tomac
,
const
char
*
fromstr
);
int
mac_verify
(
char
*
mac_str
);
int
mac_to_lower
(
char
*
mac_str
);
#endif
/* __WHITERABBIT_RTU_MAC_H */
userspace/libwr/mac.c
View file @
39848809
...
...
@@ -28,6 +28,7 @@
#include <libwr/mac.h>
#include <stdio.h>
#include <ctype.h>
/**
* \brief Helper function to convert mac address into a string
...
...
@@ -86,3 +87,19 @@ int mac_verify(char *mac_str)
}
return
-
1
;
}
/**
* \brief Function to lowercase the mac address
*/
int
mac_to_lower
(
char
*
mac_str
)
{
int
i
;
if
(
ETH_ALEN_STR
!=
strnlen
(
mac_str
,
ETH_ALEN_STR
)
+
1
)
return
-
1
;
for
(
i
=
0
;
i
<
ETH_ALEN_STR
;
i
++
)
mac_str
[
i
]
=
tolower
(
mac_str
[
i
]);
return
0
;
}
userspace/tools/rtu_stat.c
View file @
39848809
...
...
@@ -462,7 +462,7 @@ int main(int argc, char **argv)
printf
(
"Wrong port mask 0x%s
\n
"
,
argv
[
4
]);
exit
(
1
);
}
if
(
mac_verify
(
argv
[
3
]))
{
if
(
mac_
to_lower
(
argv
[
3
])
||
mac_
verify
(
argv
[
3
]))
{
fprintf
(
stderr
,
"rtu_stat: Wrong MAC %s
\n
"
,
argv
[
3
]);
exit
(
1
);
}
...
...
@@ -494,7 +494,7 @@ int main(int argc, char **argv)
printf
(
"Wrong port number %s
\n
"
,
argv
[
3
]);
exit
(
1
);
}
if
(
mac_verify
(
argv
[
2
]))
{
if
(
mac_
to_lower
(
argv
[
2
])
||
mac_
verify
(
argv
[
2
]))
{
fprintf
(
stderr
,
"rtu_stat: Wrong MAC %s
\n
"
,
argv
[
2
]);
exit
(
1
);
}
...
...
@@ -527,7 +527,7 @@ int main(int argc, char **argv)
printf
(
"Wrong port mask 0x%s
\n
"
,
argv
[
4
]);
exit
(
1
);
}
if
(
mac_verify
(
argv
[
3
]))
{
if
(
mac_
to_lower
(
argv
[
3
])
||
mac_
verify
(
argv
[
3
]))
{
fprintf
(
stderr
,
"rtu_stat: Wrong MAC %s
\n
"
,
argv
[
3
]);
exit
(
1
);
}
...
...
@@ -558,7 +558,7 @@ int main(int argc, char **argv)
printf
(
"Wrong port number %s
\n
"
,
argv
[
3
]);
exit
(
1
);
}
if
(
mac_verify
(
argv
[
2
]))
{
if
(
mac_
to_lower
(
argv
[
2
])
||
mac_
verify
(
argv
[
2
]))
{
fprintf
(
stderr
,
"rtu_stat: Wrong MAC %s
\n
"
,
argv
[
2
]);
exit
(
1
);
}
...
...
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