Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mdmngr
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
Issue 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
IOPSYS
mdmngr
Commits
a26e78e0
Commit
a26e78e0
authored
7 years ago
by
Jakob Olsson
Browse files
Options
Downloads
Patches
Plain Diff
adds get_devices to uloop on boot and every 5s, slight structure change
parent
06d53737
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
common.h
+1
-0
1 addition, 0 deletions
common.h
dongle.c
+9
-0
9 additions, 0 deletions
dongle.c
dongle.h
+6
-0
6 additions, 0 deletions
dongle.h
dongle_infrastructure.c
+15
-5
15 additions, 5 deletions
dongle_infrastructure.c
dongle_infrastructure.h
+2
-0
2 additions, 0 deletions
dongle_infrastructure.h
with
33 additions
and
5 deletions
common.h
+
1
−
0
View file @
a26e78e0
...
...
@@ -12,6 +12,7 @@
#include
<time.h>
#include
<limits.h>
#include
<libubox/list.h>
#include
<libubox/uloop.h>
#include
"libmobile.h"
#include
<json-c/json.h>
...
...
This diff is collapsed.
Click to expand it.
dongle.c
+
9
−
0
View file @
a26e78e0
...
...
@@ -8,12 +8,19 @@
struct
ubus_context
*
ctx
;
int
debug
;
struct
uloop_timeout
timeout
=
{
.
cb
=
get_devices
};
static
struct
option
long_options
[]
=
{
{
"debug"
,
required_argument
,
NULL
,
'd'
},
{
0
,
0
,
0
,
0
}
};
void
uloop_add_get_devices
(
struct
uloop_timeout
*
t
)
{
uloop_timeout_set
(
t
,
5000
);
uloop_timeout_add
(
t
);
}
int
parse_args
(
int
argc
,
char
**
argv
)
{
char
ch
;
...
...
@@ -62,6 +69,8 @@ int main(int argc, char **argv)
uloop_init
();
init_ubus
();
uloop_timeout_set
(
&
timeout
,
0
);
uloop_timeout_add
(
&
timeout
);
/*
rv = expose_apn_object(ctx);
if (rv < 0)
...
...
This diff is collapsed.
Click to expand it.
dongle.h
0 → 100644
+
6
−
0
View file @
a26e78e0
#ifndef DONGLE_H
#define DONGLE_H
void
uloop_add_get_devices
(
struct
uloop_timeout
*
t
);
#endif
\ No newline at end of file
This diff is collapsed.
Click to expand it.
dongle_infrastructure.c
+
15
−
5
View file @
a26e78e0
...
...
@@ -11,11 +11,15 @@
#include
<limits.h>
#include
"dongle_infrastructure.h"
#include
"dongle.h"
struct
device
{
struct
list_head
list
;
char
*
name
;
char
*
ip
;
struct
ubus_object
*
obj
;
struct
ubus_methods
*
methods
;
};
LIST_HEAD
(
devices
);
...
...
@@ -48,7 +52,7 @@ char *lexer(char **input, char *delimiter)
return
substr
;
}
int
*
get_devices
(
void
)
int
get_devices
(
struct
uloop_timeout
*
t
)
{
char
device_path
[
PATH_MAX
];
struct
dirent
*
de
;
...
...
@@ -92,6 +96,8 @@ int *get_devices(void)
goto
fail
;
}
node
->
name
=
strdup
(
de
->
d_name
);
node
->
ip
=
get_device_ip
(
node
->
name
);
printf
(
"added %s
\n
"
,
node
->
name
);
if
(
list_empty
(
&
devices
))
{
INIT_LIST_HEAD
(
&
devices
);
...
...
@@ -176,7 +182,9 @@ fail:
}
void
print_list
(
struct
ubus_context
*
ctx
,
struct
ubus_request_data
*
req
)
int
print_list
(
struct
ubus_context
*
ctx
,
struct
ubus_object
*
obj
,
struct
ubus_request_data
*
req
,
const
char
*
method
,
struct
blob_attr
*
msg
)
{
struct
device
*
net_dev
;
struct
blob_buf
bb
;
...
...
@@ -195,6 +203,7 @@ void print_list(struct ubus_context *ctx, struct ubus_request_data *req)
blobmsg_close_array
(
&
bb
,
arr
);
ubus_send_reply
(
ctx
,
req
,
bb
.
head
);
blob_buf_free
(
&
bb
);
return
0
;
}
int
get_device_ips
(
struct
ubus_context
*
ctx
,
struct
ubus_object
*
obj
,
...
...
@@ -208,12 +217,13 @@ int get_device_ips(struct ubus_context *ctx, struct ubus_object *obj,
memset
(
&
bb
,
0
,
sizeof
(
struct
blob_buf
));
blob_buf_init
(
&
bb
,
0
);
rv
=
get_devices
();
/*
rv = get_devices();
if (rv < 0)
goto fail;
*/
arr
=
blobmsg_open_array
(
&
bb
,
"network_devices"
);
list_for_each_entry
(
net_dev
,
&
devices
,
list
)
{
net_dev
->
ip
=
get_device_ip
(
net_dev
->
name
);
//
net_dev->ip = get_device_ip(net_dev->name);
table
=
blobmsg_open_table
(
&
bb
,
""
);
blobmsg_add_string
(
&
bb
,
"device_name"
,
net_dev
->
name
);
if
(
net_dev
->
ip
)
...
...
@@ -238,7 +248,7 @@ fail:
struct
ubus_method
infrastructure_object_methods
[]
=
{
UBUS_METHOD_NOARG
(
"list"
,
get_device_ips
)
UBUS_METHOD_NOARG
(
"list"
,
print_list
)
};
struct
ubus_object_type
infrastructure_object_type
=
UBUS_OBJECT_TYPE
(
"dongle"
,
infrastructure_object_methods
);
...
...
This diff is collapsed.
Click to expand it.
dongle_infrastructure.h
+
2
−
0
View file @
a26e78e0
...
...
@@ -3,4 +3,6 @@
#include
"common.h"
int
expose_infrastructure_object
(
struct
ubus_context
*
ctx
);
int
get_devices
(
struct
uloop_timeout
*
t
);
char
*
get_device_ip
(
char
*
device_name
);
#endif
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