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
4ebaf41d
Commit
4ebaf41d
authored
7 years ago
by
Jakob Olsson
Browse files
Options
Downloads
Patches
Plain Diff
untested apn parser
parent
26ff735c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libmobile.c
+42
-15
42 additions, 15 deletions
libmobile.c
with
42 additions
and
15 deletions
libmobile.c
+
42
−
15
View file @
4ebaf41d
...
@@ -18,6 +18,7 @@ void curl_cleaner(CURLcode *curl);
...
@@ -18,6 +18,7 @@ void curl_cleaner(CURLcode *curl);
size_t
write_func
(
void
*
buffer
,
size_t
size
,
size_t
nmemb
,
void
*
userp
);
size_t
write_func
(
void
*
buffer
,
size_t
size
,
size_t
nmemb
,
void
*
userp
);
int
apn_profile_idx
(
struct
json_object
*
apn_profiles
,
char
*
name
);
int
apn_profile_idx
(
struct
json_object
*
apn_profiles
,
char
*
name
);
int
get_apn_profiles_len
(
void
);
int
get_apn_profiles_len
(
void
);
struct
json_object
*
parse_apn_profiles
(
char
*
apn_profiles
);
/**
/**
* Function: curl_cleaner
* Function: curl_cleaner
...
@@ -138,6 +139,18 @@ success:
...
@@ -138,6 +139,18 @@ success:
return
len
;
return
len
;
}
}
/**
* Function: parse_apn_profiles
*
* Takes a string of APN profile configurations provided by zte-mf823 (which is in an awkward, difficult to read format)
* and transforms them into a more easily read and worked with JSON format.
*
* Parameters:
* apn_profiles - A character string containing the APN profiles.
* Returns:
* The newly generated JSON on success.
* NULL on failure.
*/
struct
json_object
*
parse_apn_profiles
(
char
*
apn_profiles
)
struct
json_object
*
parse_apn_profiles
(
char
*
apn_profiles
)
{
{
if
(
strlen
(
apn_profiles
)
<=
0
)
{
if
(
strlen
(
apn_profiles
)
<=
0
)
{
...
@@ -151,43 +164,57 @@ struct json_object *parse_apn_profiles(char *apn_profiles)
...
@@ -151,43 +164,57 @@ struct json_object *parse_apn_profiles(char *apn_profiles)
goto
fail
;
goto
fail
;
}
}
struct
json_object
*
parsed_profiles
=
json_object_new_object
();
struct
json_object
*
parsed_profiles
=
json_object_new_object
();
int
apn_counter
=
0
;
char
field_names
[
13
]
=
{
"profile_name"
,
"apn_name"
,
"mode"
,
"dunno"
,
"authentication"
,
"username?"
,
"password?"
,
"IPdunno"
,
"ddnunno?"
,
"dno"
,
"DNS_mode"
,
"IPv_username"
,
"IPv_password"
};
int
rv
;
json_object_object_foreach
(
apn_profiles_json
,
key
,
val
)
{
json_object_object_foreach
(
apn_profiles_json
,
key
,
val
)
{
char
*
apn
=
json_object_get_string
(
val
);
char
*
apn
_string
=
json_object_get_string
(
val
);
if
(
strlen
(
apn
)
<=
0
)
if
(
strlen
(
apn
_string
)
<=
0
)
goto
finished
;
goto
finished
;
int
i
;
struct
json_object
*
apn_profile
=
json_object_new_object
();
char
fields
[
13
]
=
{
"profile_name"
,
"apn_name"
,
"mode"
,
"dunno"
,
"authentication"
,
"username?"
,
"password?"
,
"IPdunno"
,
"ddnunno?"
,
"dno"
,
"DNS_mode"
,
"IPv_username"
,
"IPv_password"
};
for
(
i
=
0
;
i
<
13
;
i
++
)
{
int
field_counter
=
0
;
char
*
field_val
=
strtok
(
apn_string
,
"($)"
);
json_object_object_add
(
apn_profile
,
field_names
[
i
],
field_val
);
}
rv
=
json_object_object_add
(
parsed_profiles
,
sprintf
(
"%d"
,
apn_counter
),
apn_profile
);
//be careful here, do we need json_object_get(apn_profile)?
json_object_put
(
apn_profile
);
if
(
!
rv
)
{
DEBUG
(
"Error adding object!
\n
"
);
goto
free_objects
;
}
apn_counter
++
;
//json_put what??
printf
(
"FREE THEM CORRECTLY HERE!
\n
"
);
//best guess, free: apn_profile
}
}
goto
finished
;
free_object:
free_object
s
:
json_object_put
(
apn_profiles
);
json_object_put
(
apn_profiles
);
json_object_put
(
parsed_profiles
);
json_object_put
(
parsed_profiles
);
fail:
fail:
return
NULL
;
return
NULL
;
finished:
finished:
printf
(
"probably need to free apn_profiles_json!
\n
"
);
//best guess, free: apn_profiles_json
json_object_put
(
apn_profiles
);
json_object_put
(
parsed_profiles
);
return
parsed_profiles
;
return
parsed_profiles
;
}
}
char
*
mobile_connect_network
(
void
)
char
*
mobile_connect_network
(
void
)
{
{
char
query
[
1024
]
=
{
0
};
return
mobile_post_request
(
"isTest=false&goformId=CONNECT_NETWORK"
);
strncpy
(
query
,
"isTest=false&goformId=CONNECT_NETWORK"
,
1023
);
return
mobile_post_request
(
query
);
}
}
char
*
mobile_disconnect_network
(
void
)
char
*
mobile_disconnect_network
(
void
)
{
{
char
query
[
1024
]
=
{
0
};
return
mobile_post_request
(
"isTest=false&goformId=DISCONNECT_NETWORK"
);
// removed notcallback, why have it?
strncpy
(
query
,
"isTest=false&goformId=DISCONNECT_NETWORK"
,
1023
);
return
mobile_post_request
(
query
);
}
}
char
*
mobile_delete_apn
(
char
*
name
)
char
*
mobile_delete_apn
(
char
*
name
)
...
...
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