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
b3bedbbe
Commit
b3bedbbe
authored
7 years ago
by
Jakob Olsson
Browse files
Options
Downloads
Patches
Plain Diff
preparation to get host ip from /proc/net/route
parent
58bcc9c1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dfs.c
+0
-1
0 additions, 1 deletion
dfs.c
dongle_infrastructure.c
+66
-5
66 additions, 5 deletions
dongle_infrastructure.c
with
66 additions
and
6 deletions
dfs.c
+
0
−
1
View file @
b3bedbbe
...
@@ -34,7 +34,6 @@ bool search(char *path, struct list_head *list)
...
@@ -34,7 +34,6 @@ bool search(char *path, struct list_head *list)
void
clear_list
(
struct
list_head
*
list
)
void
clear_list
(
struct
list_head
*
list
)
{
{
struct
directory
*
dr
,
*
tmp
;
struct
directory
*
dr
,
*
tmp
;
print_list_dfs
(
list
);
if
(
list_empty
(
list
))
if
(
list_empty
(
list
))
return
;
return
;
...
...
This diff is collapsed.
Click to expand it.
dongle_infrastructure.c
+
66
−
5
View file @
b3bedbbe
...
@@ -54,7 +54,6 @@ int tag_missing_devices(void)
...
@@ -54,7 +54,6 @@ int tag_missing_devices(void)
}
}
dev
->
missing
++
;
dev
->
missing
++
;
printf
(
"added to missing counter!
\n
"
);
if
(
dev
->
missing
==
1
)
if
(
dev
->
missing
==
1
)
delete_device_by_obj
(
dev
);
delete_device_by_obj
(
dev
);
}
}
...
@@ -121,7 +120,6 @@ int delete_device_by_name(char *name)
...
@@ -121,7 +120,6 @@ int delete_device_by_name(char *name)
int
delete_device_by_obj
(
struct
device
*
dev
)
int
delete_device_by_obj
(
struct
device
*
dev
)
{
{
printf
(
"lets remove %s
\n
"
,
dev
->
usb
.
if_name
);
free
(
dev
->
usb
.
if_name
);
free
(
dev
->
usb
.
if_name
);
free
(
dev
->
ip
);
free
(
dev
->
ip
);
list_del
(
&
dev
->
list
);
list_del
(
&
dev
->
list
);
...
@@ -140,6 +138,29 @@ struct device *search_list(char *name)
...
@@ -140,6 +138,29 @@ struct device *search_list(char *name)
return
NULL
;
return
NULL
;
}
}
char
*
lexer_chr
(
char
**
input
,
char
delimiter
)
{
char
*
token
,
*
substr
;
printf
(
"%s
\n
"
,
*
input
);
if
(
strlen
(
*
input
)
==
0
)
{
debug_print
(
"empty input!
\n
"
);
return
NULL
;
}
printf
(
"%s
\n
"
,
*
input
);
token
=
strchr
(
*
input
,
delimiter
);
printf
(
"%s
\n
"
,
token
);
if
(
token
)
{
*
token
=
'\0'
;
substr
=
strdup
(
*
input
);
*
input
=
token
+
1
;
}
else
{
substr
=
strdup
(
*
input
);
*
input
[
0
]
=
'\0'
;
}
return
substr
;
}
char
*
lexer
(
char
**
input
,
char
*
delimiter
)
char
*
lexer
(
char
**
input
,
char
*
delimiter
)
{
{
char
*
token
,
*
substr
;
char
*
token
,
*
substr
;
...
@@ -212,6 +233,7 @@ char *get_usb_stat(char *path, char *dir, char *stat)
...
@@ -212,6 +233,7 @@ char *get_usb_stat(char *path, char *dir, char *stat)
fgets
(
contents
,
1024
,
f
);
fgets
(
contents
,
1024
,
f
);
remove_newline
(
contents
);
remove_newline
(
contents
);
fclose
(
f
);
fclose
(
f
);
return
strdup
(
contents
);
return
strdup
(
contents
);
fail:
fail:
return
NULL
;
return
NULL
;
...
@@ -273,7 +295,6 @@ char *get_device_name(char *dir_name)
...
@@ -273,7 +295,6 @@ char *get_device_name(char *dir_name)
}
}
if
(
strstr
(
dr
->
path
,
"net"
))
{
if
(
strstr
(
dr
->
path
,
"net"
))
{
printf
(
"de->d_name %s
\n
"
,
de
->
d_name
);
name
=
strdup
(
de
->
d_name
);
name
=
strdup
(
de
->
d_name
);
goto
success
;
goto
success
;
}
}
...
@@ -313,7 +334,6 @@ int get_devices(void)
...
@@ -313,7 +334,6 @@ int get_devices(void)
continue
;
continue
;
snprintf
(
product_path
,
PATH_MAX
,
"%s%s/product"
,
usb_path
,
de
->
d_name
);
snprintf
(
product_path
,
PATH_MAX
,
"%s%s/product"
,
usb_path
,
de
->
d_name
);
printf
(
"product_path %s
\n
"
,
product_path
);
memset
(
&
st
,
0
,
sizeof
(
struct
stat
));
memset
(
&
st
,
0
,
sizeof
(
struct
stat
));
rv
=
stat
(
product_path
,
&
st
);
rv
=
stat
(
product_path
,
&
st
);
...
@@ -376,6 +396,39 @@ fail:
...
@@ -376,6 +396,39 @@ fail:
return
NULL
;
return
NULL
;
}
}
char
*
get_device_ip_alt
(
char
*
device_name
)
{
char
route
[
1024
];
char
*
iface
,
*
destination
,
*
gateway
,
*
flags
;
FILE
*
fp
;
fp
=
fopen
(
"/proc/net/route"
,
"r"
);
if
(
!
fp
)
{
perror
(
"fopen"
);
goto
fail
;
}
while
((
fgets
(
route
,
1024
,
fp
))
!=
NULL
)
{
remove_newline
(
route
);
/*
1. delimiter on first tab, check if = usb0, else continue
2. delimiter on 4th tab, convert to binary, check if 3rd bit = 1, else continue
3. get destintion ip
*/
printf
(
"route %s
\n
"
,
route
);
printf
(
"some more test stuff
\n
"
);
iface
=
lexer_chr
(
&
route
,
'a'
);
printf
(
"iface %s
\n
"
,
iface
);
destination
=
lexer_chr
(
&
route
,
'a'
);
gateway
=
lexer_chr
(
&
route
,
'a'
);
flags
=
lexer_chr
(
&
route
,
'a'
);
printf
(
"iface %s, destination %s, gateway %s, flags %s
\n
"
,
iface
,
destination
,
gateway
,
flags
);
}
fclose
(
fp
);
fail:
return
NULL
;
}
char
*
get_device_ip
(
char
*
device_name
)
char
*
get_device_ip
(
char
*
device_name
)
{
{
int
fd
,
rv
;
int
fd
,
rv
;
...
@@ -495,6 +548,14 @@ int clear(struct ubus_context *ctx, struct ubus_object *obj,
...
@@ -495,6 +548,14 @@ int clear(struct ubus_context *ctx, struct ubus_object *obj,
return
0
;
return
0
;
}
}
int
test
(
struct
ubus_context
*
ctx
,
struct
ubus_object
*
obj
,
struct
ubus_request_data
*
req
,
const
char
*
method
,
struct
blob_attr
*
msg
)
{
get_device_ip_alt
(
NULL
);
return
0
;
}
int
remove_device
(
struct
ubus_context
*
ctx
,
struct
ubus_object
*
obj
,
int
remove_device
(
struct
ubus_context
*
ctx
,
struct
ubus_object
*
obj
,
struct
ubus_request_data
*
req
,
const
char
*
method
,
struct
ubus_request_data
*
req
,
const
char
*
method
,
struct
blob_attr
*
msg
)
struct
blob_attr
*
msg
)
...
@@ -516,7 +577,7 @@ fail:
...
@@ -516,7 +577,7 @@ fail:
}
}
struct
ubus_method
infrastructure_object_methods
[]
=
{
struct
ubus_method
infrastructure_object_methods
[]
=
{
//
UBUS_METHOD_NOARG("test", test),
UBUS_METHOD_NOARG
(
"test"
,
test
),
UBUS_METHOD_NOARG
(
"list"
,
print_list
),
UBUS_METHOD_NOARG
(
"list"
,
print_list
),
UBUS_METHOD_NOARG
(
"clear"
,
clear
),
UBUS_METHOD_NOARG
(
"clear"
,
clear
),
UBUS_METHOD
(
"remove_device"
,
remove_device
,
dev_policy
)
UBUS_METHOD
(
"remove_device"
,
remove_device
,
dev_policy
)
...
...
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