Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
ffbs-gluon
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
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ffbs
ffbs-gluon
Commits
8c362e3b
Commit
8c362e3b
authored
1 year ago
by
Jan Luebbe
Committed by
chrissi^
3 months ago
Browse files
Options
Downloads
Patches
Plain Diff
gluon-radv-filterd: respondd: update to use netlink instead of sysfs
parent
a5698491
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
package/gluon-radv-filterd/src/respondd.c
+62
-10
62 additions, 10 deletions
package/gluon-radv-filterd/src/respondd.c
with
62 additions
and
10 deletions
package/gluon-radv-filterd/src/respondd.c
+
62
−
10
View file @
8c362e3b
...
...
@@ -8,8 +8,57 @@
#include
<unistd.h>
#include
<fcntl.h>
#include
<netlink/netlink.h>
#include
<netlink/genl/genl.h>
#include
<netlink/genl/ctrl.h>
#include
<batadv-genl.h>
#include
"mac.h"
struct
mode_netlink_opts
{
bool
is_server
;
struct
batadv_nlquery_opts
query_opts
;
};
static
const
enum
batadv_nl_attrs
mode_mandatory
[]
=
{
BATADV_ATTR_GW_MODE
,
};
static
int
parse_mode_netlink_cb
(
struct
nl_msg
*
msg
,
void
*
arg
)
{
struct
nlattr
*
attrs
[
BATADV_ATTR_MAX
+
1
];
struct
nlmsghdr
*
nlh
=
nlmsg_hdr
(
msg
);
struct
batadv_nlquery_opts
*
query_opts
=
arg
;
struct
genlmsghdr
*
ghdr
;
struct
mode_netlink_opts
*
opts
;
uint8_t
mode
;
opts
=
batadv_container_of
(
query_opts
,
struct
mode_netlink_opts
,
query_opts
);
if
(
!
genlmsg_valid_hdr
(
nlh
,
0
))
return
NL_OK
;
ghdr
=
nlmsg_data
(
nlh
);
if
(
ghdr
->
cmd
!=
BATADV_CMD_GET_MESH_INFO
)
return
NL_OK
;
if
(
nla_parse
(
attrs
,
BATADV_ATTR_MAX
,
genlmsg_attrdata
(
ghdr
,
0
),
genlmsg_len
(
ghdr
),
batadv_genl_policy
))
return
NL_OK
;
if
(
batadv_genl_missing_attrs
(
attrs
,
mode_mandatory
,
BATADV_ARRAY_SIZE
(
mode_mandatory
)))
return
NL_OK
;
mode
=
nla_get_u8
(
attrs
[
BATADV_ATTR_GW_MODE
]);
opts
->
is_server
=
mode
==
BATADV_GW_MODE_SERVER
;
return
NL_OK
;
}
static
struct
json_object
*
get_radv_filter
()
{
FILE
*
f
=
popen
(
"exec ebtables-tiny -L RADV_FILTER"
,
"r"
);
char
*
line
=
NULL
;
...
...
@@ -40,16 +89,19 @@ static struct json_object * get_radv_filter() {
static
struct
json_object
*
respondd_provider_statistics
()
{
struct
json_object
*
ret
=
json_object_new_object
();
char
buf
[
6
];
int
fd
=
open
(
"/sys/class/net/bat0/mesh/gw_mode"
,
O_RDONLY
);
if
(
fd
==
-
1
)
{
perror
(
"error opening gateway info file"
);
return
ret
;
}
memset
(
buf
,
0
,
sizeof
(
buf
));
read
(
fd
,
buf
,
sizeof
(
buf
));
close
(
fd
);
if
(
strncmp
(
buf
,
"server"
,
6
)
==
0
)
{
struct
mode_netlink_opts
opts
=
{
.
is_server
=
false
,
.
query_opts
=
{
.
err
=
0
,
},
};
batadv_genl_query
(
"bat0"
,
BATADV_CMD_GET_MESH_INFO
,
parse_mode_netlink_cb
,
0
,
&
opts
.
query_opts
);
if
(
opts
.
is_server
)
{
// We are a batman gateway, do not write gateway6
return
ret
;
}
...
...
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