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
a0a0baf2
Commit
a0a0baf2
authored
7 years ago
by
Jakob Olsson
Browse files
Options
Downloads
Patches
Plain Diff
new approach through ubus call, gets IP addr, incomplete
parent
f45a2951
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
common.c
+17
-15
17 additions, 15 deletions
common.c
common.h
+0
-8
0 additions, 8 deletions
common.h
dongle_network.c
+21
-1
21 additions, 1 deletion
dongle_network.c
libmobile.c
+1
-1
1 addition, 1 deletion
libmobile.c
with
39 additions
and
25 deletions
common.c
+
17
−
15
View file @
a0a0baf2
#include
"common.h"
#include
"common.h"
int
get_ip
(
char
*
if_name
)
/*
{
TODO:
struct
ifaddrs
*
ifaddr
,
*
ifa
;
Initial
1. system call //"ubus call router.net ipv4_routes | grep -B 7 \"usb0\" | grep \"flag.
*H\" -B 4 | grep destination"
2. grep for [H]ost flag
3. find IP
getifaddrs
(
&
ifaddr
);
Once Successful
ifa
=
ifaddr
;
1. Implement by invoking ubus
while
(
ifa
!=
NULL
)
{
*/
if
(
strcmp
(
ifa
->
ifa_addr
,
if_name
)
!=
0
)
int
get_ip
(
char
*
if_name
)
continue
;
{
char
response
[
1024
]
=
{
0
};
FILE
*
fp
=
popen
(
"ubus call router.net ipv4_routes | grep -B 7
\"
usb0
\"
| grep
\"
flag.*H
\"
-B 4 | grep destination | cut -d ' ' -f2 | cut -d '
\"
' -f2"
,
"r"
);
if
(
ifa
->
ifa_addr
&&
ifa
->
ifa_addr
->
sa_family
==
AF_INET
)
{
fscanf
(
fp
,
"%s"
,
response
);
struct
sockaddr_in
*
pAddr
=
(
struct
sockaddr_in
*
)
ifa
->
ifa_addr
;
pclose
(
fp
);
printf
(
"ip: %s
\n
"
,
inet_ntoa
(
pAddr
->
sin_addr
));
printf
(
"%s
\n
"
,
response
);
}
ifa
=
ifa
->
ifa_next
;
}
freeififaddrs
(
ifaddr
);
return
0
;
return
0
;
}
}
...
...
This diff is collapsed.
Click to expand it.
common.h
+
0
−
8
View file @
a0a0baf2
...
@@ -12,14 +12,6 @@
...
@@ -12,14 +12,6 @@
#include
<time.h>
#include
<time.h>
#include
<limits.h>
#include
<limits.h>
#include
<libubox/list.h>
#include
<libubox/list.h>
#include
<ifaddrs.h>
#include
<sys/socket.h>
#include
<sys/ioctl.h>
#include
<netinet/in.h>
#include
<net/if.h>
#include
<arpa/inet.h>
#include
<sys/socket.h>
#include
<netdb.h>
#include
"libmobile.h"
#include
"libmobile.h"
#include
<json-c/json.h>
#include
<json-c/json.h>
...
...
This diff is collapsed.
Click to expand it.
dongle_network.c
+
21
−
1
View file @
a0a0baf2
...
@@ -2,11 +2,13 @@
...
@@ -2,11 +2,13 @@
static
enum
{
static
enum
{
IP
,
IP
,
DEV
,
__IP_MAX
__IP_MAX
};
};
static
const
struct
blobmsg_policy
ip_policy
[
__IP_MAX
]
=
{
static
const
struct
blobmsg_policy
ip_policy
[
__IP_MAX
]
=
{
[
IP
]
=
{.
name
=
"ip_addr"
,
.
type
=
BLOBMSG_TYPE_STRING
}
[
IP
]
=
{.
name
=
"ip_addr"
,
.
type
=
BLOBMSG_TYPE_STRING
},
[
DEV
]
=
{.
name
=
"dev"
,
.
type
=
BLOBMSG_TYPE_STRING
}
};
};
int
get_signal_strength
(
struct
ubus_context
*
ctx
,
struct
ubus_object
*
obj
,
int
get_signal_strength
(
struct
ubus_context
*
ctx
,
struct
ubus_object
*
obj
,
...
@@ -198,6 +200,23 @@ fail_unknown:
...
@@ -198,6 +200,23 @@ fail_unknown:
return
UBUS_STATUS_UNKNOWN_ERROR
;
return
UBUS_STATUS_UNKNOWN_ERROR
;
}
}
int
test_get_ip
(
struct
ubus_context
*
ctx
,
struct
ubus_object
*
obj
,
struct
ubus_request_data
*
req
,
const
char
*
method
,
struct
blob_attr
*
msg
)
{
struct
blob_attr
*
tb
[
__IP_MAX
];
char
*
dev
;
blobmsg_parse
(
ip_policy
,
__IP_MAX
,
tb
,
blob_data
(
msg
),
blob_len
(
msg
));
if
(
tb
[
DEV
])
{
dev
=
(
char
*
)
blobmsg_data
(
tb
[
DEV
]);
get_ip
(
dev
);
}
return
0
;
}
struct
ubus_method
network_object_methods
[]
=
{
struct
ubus_method
network_object_methods
[]
=
{
UBUS_METHOD
(
"signal_strength"
,
get_signal_strength
,
ip_policy
),
UBUS_METHOD
(
"signal_strength"
,
get_signal_strength
,
ip_policy
),
UBUS_METHOD
(
"connect"
,
connect_network
,
ip_policy
),
UBUS_METHOD
(
"connect"
,
connect_network
,
ip_policy
),
...
@@ -206,6 +225,7 @@ struct ubus_method network_object_methods[] = {
...
@@ -206,6 +225,7 @@ struct ubus_method network_object_methods[] = {
UBUS_METHOD
(
"enable_roaming"
,
enable_roaming
,
ip_policy
),
UBUS_METHOD
(
"enable_roaming"
,
enable_roaming
,
ip_policy
),
UBUS_METHOD
(
"disable_roaming"
,
disable_roaming
,
ip_policy
),
UBUS_METHOD
(
"disable_roaming"
,
disable_roaming
,
ip_policy
),
UBUS_METHOD
(
"roam_status"
,
roam_status
,
ip_policy
),
UBUS_METHOD
(
"roam_status"
,
roam_status
,
ip_policy
),
UBUS_METHOD
(
"get_ip"
,
test_get_ip
,
ip_policy
)
};
};
struct
ubus_object_type
network_object_type
=
UBUS_OBJECT_TYPE
(
"dongle"
,
network_object_methods
);
struct
ubus_object_type
network_object_type
=
UBUS_OBJECT_TYPE
(
"dongle"
,
network_object_methods
);
...
...
This diff is collapsed.
Click to expand it.
libmobile.c
+
1
−
1
View file @
a0a0baf2
...
@@ -562,6 +562,6 @@ struct json_object *mobile_unlock_sim(char *ip_addr, char *pin, char *puk)
...
@@ -562,6 +562,6 @@ struct json_object *mobile_unlock_sim(char *ip_addr, char *pin, char *puk)
char
query
[
1024
]
=
{
0
};
char
query
[
1024
]
=
{
0
};
snprintf
(
query
,
1023
,
"isTest=false&goformId=ENTER_PUK&PUKNumber=%s&PinNumber=%s&pin_save_flag=0"
,
puk
,
pin
);
snprintf
(
query
,
1023
,
"isTest=false&goformId=ENTER_PUK&PUKNumber=%s&PinNumber=%s&pin_save_flag=0"
,
puk
,
pin
);
printf
(
"query %s
\n
"
);
printf
(
"query %s
\n
"
,
query
);
return
prepare_request
(
ip_addr
,
query
,
POST
);
return
prepare_request
(
ip_addr
,
query
,
POST
);
}
}
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