Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
94dc48da
Commit
94dc48da
authored
9 years ago
by
Martine Lenders
Browse files
Options
Downloads
Patches
Plain Diff
shell: sc_netif: add set/unset for promiscous mode
parent
ac25058f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sys/shell/commands/sc_netif.c
+74
-1
74 additions, 1 deletion
sys/shell/commands/sc_netif.c
with
74 additions
and
1 deletion
sys/shell/commands/sc_netif.c
+
74
−
1
View file @
94dc48da
...
@@ -80,6 +80,11 @@ static void _set_usage(char *cmd_name)
...
@@ -80,6 +80,11 @@ static void _set_usage(char *cmd_name)
" *
\"
state
\"
- set the device state
\n
"
);
" *
\"
state
\"
- set the device state
\n
"
);
}
}
static
void
_flag_usage
(
char
*
cmd_name
)
{
printf
(
"usage: %s <if_id> [-]{promisc|autoack|preload}"
,
cmd_name
);
}
static
void
_print_netconf
(
ng_netconf_opt_t
opt
)
static
void
_print_netconf
(
ng_netconf_opt_t
opt
)
{
{
switch
(
opt
)
{
switch
(
opt
)
{
...
@@ -147,6 +152,8 @@ void _netif_list(kernel_pid_t dev)
...
@@ -147,6 +152,8 @@ void _netif_list(kernel_pid_t dev)
int16_t
i16
;
int16_t
i16
;
int
res
;
int
res
;
ng_netconf_state_t
state
;
ng_netconf_state_t
state
;
ng_netconf_enable_t
enable
;
bool
linebreak
=
false
;
printf
(
"Iface %2d "
,
dev
);
printf
(
"Iface %2d "
,
dev
);
...
@@ -197,6 +204,31 @@ void _netif_list(kernel_pid_t dev)
...
@@ -197,6 +204,31 @@ void _netif_list(kernel_pid_t dev)
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
res
=
ng_netapi_get
(
dev
,
NETCONF_OPT_PROMISCUOUSMODE
,
0
,
&
enable
,
sizeof
(
enable
));
if
((
res
>=
0
)
&&
(
enable
==
NETCONF_ENABLE
))
{
printf
(
"PROMISC "
);
linebreak
=
true
;
}
res
=
ng_netapi_get
(
dev
,
NETCONF_OPT_AUTOACK
,
0
,
&
enable
,
sizeof
(
enable
));
if
((
res
>=
0
)
&&
(
enable
==
NETCONF_ENABLE
))
{
printf
(
"AUTOACK "
);
linebreak
=
true
;
}
res
=
ng_netapi_get
(
dev
,
NETCONF_OPT_PRELOADING
,
0
,
&
enable
,
sizeof
(
enable
));
if
((
res
>=
0
)
&&
(
enable
==
NETCONF_ENABLE
))
{
printf
(
"PRELOAD "
);
linebreak
=
true
;
}
if
(
linebreak
)
{
printf
(
"
\n
"
);
}
res
=
ng_netapi_get
(
dev
,
NETCONF_OPT_SRC_LEN
,
0
,
&
u16
,
sizeof
(
u16
));
res
=
ng_netapi_get
(
dev
,
NETCONF_OPT_SRC_LEN
,
0
,
&
u16
,
sizeof
(
u16
));
if
(
res
>=
0
)
{
if
(
res
>=
0
)
{
...
@@ -273,6 +305,15 @@ static void _netif_set_i16(kernel_pid_t dev, ng_netconf_opt_t opt,
...
@@ -273,6 +305,15 @@ static void _netif_set_i16(kernel_pid_t dev, ng_netconf_opt_t opt,
printf
(
" on interface %"
PRIkernel_pid
" to %i
\n
"
,
dev
,
val
);
printf
(
" on interface %"
PRIkernel_pid
" to %i
\n
"
,
dev
,
val
);
}
}
static
void
_netif_set_flag
(
kernel_pid_t
dev
,
ng_netconf_opt_t
opt
,
ng_netconf_enable_t
set
)
{
if
(
ng_netapi_set
(
dev
,
opt
,
0
,
&
set
,
sizeof
(
ng_netconf_enable_t
))
<
0
)
{
puts
(
"error: unable to set option"
);
}
printf
(
"success: %sset option
\n
"
,
(
set
)
?
""
:
"un"
);
}
static
void
_netif_set_addr
(
kernel_pid_t
dev
,
ng_netconf_opt_t
opt
,
static
void
_netif_set_addr
(
kernel_pid_t
dev
,
ng_netconf_opt_t
opt
,
char
*
addr_str
)
char
*
addr_str
)
{
{
...
@@ -361,6 +402,32 @@ static void _netif_set(char *cmd_name, kernel_pid_t dev, char *key, char *value)
...
@@ -361,6 +402,32 @@ static void _netif_set(char *cmd_name, kernel_pid_t dev, char *key, char *value)
}
}
}
}
static
int
_netif_flag
(
char
*
cmd
,
kernel_pid_t
dev
,
char
*
flag
)
{
ng_netconf_enable_t
set
=
NETCONF_ENABLE
;
if
(
flag
[
0
]
==
'-'
)
{
set
=
NETCONF_DISABLE
;
flag
++
;
}
if
(
strcmp
(
flag
,
"promisc"
)
==
0
)
{
_netif_set_flag
(
dev
,
NETCONF_OPT_PROMISCUOUSMODE
,
set
);
}
else
if
(
strcmp
(
flag
,
"preload"
)
==
0
)
{
_netif_set_flag
(
dev
,
NETCONF_OPT_PRELOADING
,
set
);
}
else
if
(
strcmp
(
flag
,
"autoack"
)
==
0
)
{
_netif_set_flag
(
dev
,
NETCONF_OPT_AUTOACK
,
set
);
}
else
{
_flag_usage
(
cmd
);
return
1
;
}
return
0
;
}
/* shell commands */
/* shell commands */
int
_netif_send
(
int
argc
,
char
**
argv
)
int
_netif_send
(
int
argc
,
char
**
argv
)
{
{
...
@@ -441,12 +508,18 @@ int _netif_config(int argc, char **argv)
...
@@ -441,12 +508,18 @@ int _netif_config(int argc, char **argv)
}
}
/* TODO implement add for IP addresses */
/* TODO implement add for IP addresses */
else
{
return
_netif_flag
(
argv
[
0
],
dev
,
argv
[
2
]);
}
}
}
else
{
else
{
puts
(
"error: invalid interface given"
);
puts
(
"error: invalid interface given"
);
}
}
}
}
printf
(
"usage: %s [<if_id> set <key> <value>]]
\n
"
,
argv
[
0
]);
printf
(
"usage: %s <if_id>
\n
"
,
argv
[
0
]);
_set_usage
(
argv
[
0
]);
_flag_usage
(
argv
[
0
]);
return
1
;
return
1
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment