mirror of
https://github.com/sailfishos/ofono
synced 2025-12-01 15:11:04 +08:00
common: Move proto and auth_method related helpers
the following functions: gprs_proto_to_string gprs_proto_from_string gprs_auth_method_to_string gprs_auth_method_from_string are moved from gprs.c to common.c, with related declaration in common.h so that they can also be accessed from lte core functions
This commit is contained in:
committed by
Adam Pigg
parent
6674cc3340
commit
022b31b075
@@ -791,3 +791,64 @@ const char *ofono_access_technology_to_string(enum ofono_access_technology tech)
|
||||
{
|
||||
return registration_tech_to_string(tech);
|
||||
}
|
||||
|
||||
const char *gprs_proto_to_string(enum ofono_gprs_proto proto)
|
||||
{
|
||||
switch (proto) {
|
||||
case OFONO_GPRS_PROTO_IP:
|
||||
return "ip";
|
||||
case OFONO_GPRS_PROTO_IPV6:
|
||||
return "ipv6";
|
||||
case OFONO_GPRS_PROTO_IPV4V6:
|
||||
return "dual";
|
||||
};
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean gprs_proto_from_string(const char *str, enum ofono_gprs_proto *proto)
|
||||
{
|
||||
if (g_str_equal(str, "ip")) {
|
||||
*proto = OFONO_GPRS_PROTO_IP;
|
||||
return TRUE;
|
||||
} else if (g_str_equal(str, "ipv6")) {
|
||||
*proto = OFONO_GPRS_PROTO_IPV6;
|
||||
return TRUE;
|
||||
} else if (g_str_equal(str, "dual")) {
|
||||
*proto = OFONO_GPRS_PROTO_IPV4V6;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
const char *gprs_auth_method_to_string(enum ofono_gprs_auth_method auth)
|
||||
{
|
||||
switch (auth) {
|
||||
case OFONO_GPRS_AUTH_METHOD_CHAP:
|
||||
return "chap";
|
||||
case OFONO_GPRS_AUTH_METHOD_PAP:
|
||||
return "pap";
|
||||
case OFONO_GPRS_AUTH_METHOD_NONE:
|
||||
return "none";
|
||||
};
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean gprs_auth_method_from_string(const char *str,
|
||||
enum ofono_gprs_auth_method *auth)
|
||||
{
|
||||
if (g_str_equal(str, "chap")) {
|
||||
*auth = OFONO_GPRS_AUTH_METHOD_CHAP;
|
||||
return TRUE;
|
||||
} else if (g_str_equal(str, "pap")) {
|
||||
*auth = OFONO_GPRS_AUTH_METHOD_PAP;
|
||||
return TRUE;
|
||||
} else if (g_str_equal(str, "none")) {
|
||||
*auth = OFONO_GPRS_AUTH_METHOD_NONE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -211,3 +211,10 @@ const char *packet_bearer_to_string(int bearer);
|
||||
|
||||
gboolean is_valid_apn(const char *apn);
|
||||
const char *call_status_to_string(enum call_status status);
|
||||
|
||||
const char *gprs_proto_to_string(enum ofono_gprs_proto proto);
|
||||
gboolean gprs_proto_from_string(const char *str, enum ofono_gprs_proto *proto);
|
||||
|
||||
const char *gprs_auth_method_to_string(enum ofono_gprs_auth_method auth);
|
||||
gboolean gprs_auth_method_from_string(const char *str,
|
||||
enum ofono_gprs_auth_method *auth);
|
||||
|
||||
@@ -237,73 +237,6 @@ static gboolean gprs_context_string_to_type(const char *str,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static const char *gprs_proto_to_string(enum ofono_gprs_proto proto)
|
||||
{
|
||||
switch (proto) {
|
||||
case OFONO_GPRS_PROTO_IP:
|
||||
return "ip";
|
||||
case OFONO_GPRS_PROTO_IPV6:
|
||||
return "ipv6";
|
||||
case OFONO_GPRS_PROTO_IPV4V6:
|
||||
return "dual";
|
||||
};
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gboolean gprs_proto_from_string(const char *str,
|
||||
enum ofono_gprs_proto *proto)
|
||||
{
|
||||
if (g_str_equal(str, "ip")) {
|
||||
*proto = OFONO_GPRS_PROTO_IP;
|
||||
return TRUE;
|
||||
} else if (g_str_equal(str, "ipv6")) {
|
||||
*proto = OFONO_GPRS_PROTO_IPV6;
|
||||
return TRUE;
|
||||
} else if (g_str_equal(str, "dual")) {
|
||||
*proto = OFONO_GPRS_PROTO_IPV4V6;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static const char *gprs_auth_method_to_string(enum ofono_gprs_auth_method auth)
|
||||
{
|
||||
switch (auth) {
|
||||
case OFONO_GPRS_AUTH_METHOD_ANY:
|
||||
return "any";
|
||||
case OFONO_GPRS_AUTH_METHOD_NONE:
|
||||
return "none";
|
||||
case OFONO_GPRS_AUTH_METHOD_CHAP:
|
||||
return "chap";
|
||||
case OFONO_GPRS_AUTH_METHOD_PAP:
|
||||
return "pap";
|
||||
};
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gboolean gprs_auth_method_from_string(const char *str,
|
||||
enum ofono_gprs_auth_method *auth)
|
||||
{
|
||||
if (g_str_equal(str, "chap")) {
|
||||
*auth = OFONO_GPRS_AUTH_METHOD_CHAP;
|
||||
return TRUE;
|
||||
} else if (g_str_equal(str, "pap")) {
|
||||
*auth = OFONO_GPRS_AUTH_METHOD_PAP;
|
||||
return TRUE;
|
||||
} else if (g_str_equal(str, "any")) {
|
||||
*auth = OFONO_GPRS_AUTH_METHOD_ANY;
|
||||
return TRUE;
|
||||
} else if (g_str_equal(str, "none")) {
|
||||
*auth = OFONO_GPRS_AUTH_METHOD_NONE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static unsigned int gprs_cid_alloc(struct ofono_gprs *gprs)
|
||||
{
|
||||
return idmap_alloc(gprs->cid_map);
|
||||
|
||||
Reference in New Issue
Block a user