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
6f6fc320
Commit
6f6fc320
authored
7 years ago
by
Jakob Olsson
Browse files
Options
Downloads
Patches
Plain Diff
prepare for get ip from if_name, small error fixes
parent
bb272ad8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
common.c
+35
-0
35 additions, 0 deletions
common.c
common.h
+6
-4
6 additions, 4 deletions
common.h
dongle.c
+0
-2
0 additions, 2 deletions
dongle.c
dongle_apn.c
+16
-10
16 additions, 10 deletions
dongle_apn.c
dongle_network.c
+2
-2
2 additions, 2 deletions
dongle_network.c
dongle_pin.c
+6
-6
6 additions, 6 deletions
dongle_pin.c
with
65 additions
and
24 deletions
common.c
+
35
−
0
View file @
6f6fc320
#include
"common.h"
int
get_ip
(
char
*
if_name
)
{
struct
ifaddrs
*
ifaddr
,
*
ifa
;
int
s
;
char
host
[
NI_MAXHOST
];
if
(
strlen
(
if_name
)
==
0
)
return
-
1
;
if
(
getifaddrs
(
&
ifaddr
)
==
-
1
)
{
perror
(
"getifaddrs"
);
return
-
1
;
}
ifa
=
ifaddr
;
while
(
ifa
!=
NULL
)
{
if
(
strncmp
(
ifa
->
ifa_name
,
if_name
,
10
)
!=
0
)
{
ifa
=
ifa
->
ifa_next
;
continue
;
}
s
=
getnameinfo
(
ifa
->
ifa_addr
,
sizeof
(
struct
sockaddr_in
),
host
,
NI_MAXHOST
,
NULL
,
0
,
NI_NUMERICHOST
);
if
(
s
!=
0
)
{
printf
(
"hello %s
\n
"
,
ifa
->
ifa_addr
->
sa_data
);
printf
(
"getnameinfo() failed12312323: %s
\n
"
,
gai_strerror
(
s
));
return
-
1
;
}
if
(
ifa
->
ifa_addr
->
sa_family
==
AF_INET
)
{
printf
(
"ip %s
\n
"
,
host
);
}
}
return
0
;
}
int
print_to_ubus
(
struct
json_object
*
parsed_response
,
struct
ubus_context
*
ctx
,
struct
ubus_request_data
*
req
)
{
struct
blob_buf
bb
;
...
...
This diff is collapsed.
Click to expand it.
common.h
+
6
−
4
View file @
6f6fc320
...
...
@@ -12,6 +12,9 @@
#include
<time.h>
#include
<limits.h>
#include
<libubox/list.h>
#include
<ifaddrs.h>
#include
<sys/socket.h>
#include
<netdb.h>
#include
"libmobile.h"
#include
<json-c/json.h>
...
...
@@ -22,11 +25,12 @@
extern
int
debug
;
#define debug_print(...) \
do \
{ \
do { \
if (debug) \
fprintf(stderr, __VA_ARGS__); \
} while (0)
int
get_ip
(
char
*
if_name
);
/**
* Function: print_to_ubus
*
...
...
@@ -56,6 +60,4 @@ int print_to_ubus(struct json_object *parsed_response, struct ubus_context *ctx,
* Blob buffer containing the replicated json_object.
*/
struct
blob_buf
json_to_blob
(
struct
json_object
*
response
,
struct
blob_buf
bb
);
void
check_debug
(
void
);
#endif
This diff is collapsed.
Click to expand it.
dongle.c
+
0
−
2
View file @
6f6fc320
...
...
@@ -60,8 +60,6 @@ int main(int argc, char **argv)
if
(
rv
<
0
)
goto
fail
;
printf
(
"hello
\n
"
);
uloop_init
();
init_ubus
();
...
...
This diff is collapsed.
Click to expand it.
dongle_apn.c
+
16
−
10
View file @
6f6fc320
...
...
@@ -2,13 +2,14 @@
static
enum
{
IP
,
__IP_MAX
,
DEV
,
__IP_MAX
};
enum
{
IP1
,
APN_NAME
,
__APN_MAX
,
__APN_MAX
};
enum
{
...
...
@@ -16,23 +17,24 @@ enum {
PROFILE_NAME
,
WAN_APN
,
PDP_TYPE
,
__CREATE_MAX
,
__CREATE_MAX
};
static
const
struct
blobmsg_policy
ip_policy
[
__IP_MAX
]
=
{
[
IP
]
=
{.
name
=
"ip_addr"
,
.
type
=
BLOBMSG_TYPE_STRING
},
[
DEV
]
=
{.
name
=
"if_name"
,
.
type
=
BLOBMSG_TYPE_STRING
}
};
const
struct
blobmsg_policy
apn_policy
[
__APN_MAX
]
=
{
[
IP1
]
=
{.
name
=
"ip_addr"
,
.
type
=
BLOBMSG_TYPE_STRING
},
[
APN_NAME
]
=
{.
name
=
"profile_name"
,
.
type
=
BLOBMSG_TYPE_STRING
}
,
[
APN_NAME
]
=
{.
name
=
"profile_name"
,
.
type
=
BLOBMSG_TYPE_STRING
}
};
const
struct
blobmsg_policy
create_apn_policy
[
__CREATE_MAX
]
=
{
[
IP2
]
=
{.
name
=
"ip_addr"
,
.
type
=
BLOBMSG_TYPE_STRING
},
[
PROFILE_NAME
]
=
{.
name
=
"profile_name"
,
.
type
=
BLOBMSG_TYPE_STRING
},
[
WAN_APN
]
=
{.
name
=
"wan_apn"
,
.
type
=
BLOBMSG_TYPE_STRING
},
[
PDP_TYPE
]
=
{.
name
=
"pdp_type"
,
.
type
=
BLOBMSG_TYPE_STRING
}
,
[
PDP_TYPE
]
=
{.
name
=
"pdp_type"
,
.
type
=
BLOBMSG_TYPE_STRING
}
};
int
list_apn_profiles
(
struct
ubus_context
*
ctx
,
struct
ubus_object
*
obj
,
...
...
@@ -40,19 +42,23 @@ int list_apn_profiles(struct ubus_context *ctx, struct ubus_object *obj,
struct
blob_attr
*
msg
)
{
struct
blob_attr
*
tb
[
__IP_MAX
];
char
*
ip_addr
;
char
*
ip_addr
,
*
dev
;
struct
json_object
*
response
;
blobmsg_parse
(
ip_policy
,
__IP_MAX
,
tb
,
blob_data
(
msg
),
blob_len
(
msg
));
if
(
!
tb
[
IP
])
{
debug_print
(
"Please enter
both
an IP
address
!
\n
"
);
debug_print
(
"Please enter an IP
or DEV
!
\n
"
);
goto
fail_argument
;
}
ip_addr
=
(
char
*
)
blobmsg_data
(
tb
[
IP
]);
}
else
ip_addr
=
(
char
*
)
blobmsg_data
(
tb
[
IP
]);
if
(
tb
[
DEV
])
{
printf
(
"hello
\n
"
);
dev
=
(
char
*
)
blobmsg_data
(
tb
[
DEV
]);
get_ip
(
dev
);
}
response
=
mobile_get_apn_profiles
(
ip_addr
);
if
(
!
response
)
goto
fail_unknown
;
...
...
This diff is collapsed.
Click to expand it.
dongle_network.c
+
2
−
2
View file @
6f6fc320
...
...
@@ -2,11 +2,11 @@
static
enum
{
IP
,
__IP_MAX
,
__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
}
};
int
get_signal_strength
(
struct
ubus_context
*
ctx
,
struct
ubus_object
*
obj
,
...
...
This diff is collapsed.
Click to expand it.
dongle_pin.c
+
6
−
6
View file @
6f6fc320
...
...
@@ -7,25 +7,25 @@ enum {
IP1
,
NEW_PIN
,
CURRENT_PIN
,
__SET_PIN_MAX
,
__SET_PIN_MAX
};
enum
{
IP2
,
PIN
,
__PIN_MAX
,
__PIN_MAX
};
enum
{
IP3
,
__TRY_MAX
,
__TRY_MAX
};
enum
{
IP4
,
UNLOCK_PIN
,
PUK
,
__UNLOCK_MAX
,
__UNLOCK_MAX
};
const
struct
blobmsg_policy
set_pin_policy
[
__SET_PIN_MAX
]
=
{
...
...
@@ -403,7 +403,7 @@ int unlock_sim(struct ubus_context *ctx, struct ubus_object *obj,
struct
blob_attr
*
msg
)
{
struct
blob_attr
*
tb
[
__UNLOCK_MAX
];
char
*
pin
,
*
puk
,
ip_addr
;
char
*
pin
,
*
puk
,
*
ip_addr
;
struct
json_object
*
response
,
*
rv_json
;
int
rv
;
...
...
@@ -419,7 +419,7 @@ int unlock_sim(struct ubus_context *ctx, struct ubus_object *obj,
if
(
!
response
)
goto
fail_unknown
;
json_object_object_get_ex
(
response
,
"pinnumber"
,
rv_json
);
json_object_object_get_ex
(
response
,
"pinnumber"
,
&
rv_json
);
if
(
json_object_get_int
(
rv_json
)
>
0
)
goto
fail_unknown
;
...
...
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