diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-08-22 09:35:15 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-08-22 09:38:21 +0200 |
commit | 1ac18a06bb37d8745480a9af4fd6bc2f762bf265 (patch) | |
tree | 2074fb1f3cb16e483779dcd4f19db3d6c1c936c1 /src/mm-modem-helpers.c | |
parent | c15525a1b3c2006e614f75a372f374176f576c23 (diff) |
api,dbus: 'ip-type' property now given as a MMBearerIpFamily (u)
Instead of using a predefined set of string values for 'ip-type' in
Modem.CreateBearer() and Simple.Connect(), we'll use an enumeration. The
implementation will then need to convert the requested IP family type to e.g.
the correct PDP type in 3GPP modems.
This change also consolidates the use of enums in dictionary properties when
possible to do so, as with the Rm Protocol.
Diffstat (limited to 'src/mm-modem-helpers.c')
-rw-r--r-- | src/mm-modem-helpers.c | 68 |
1 files changed, 53 insertions, 15 deletions
diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c index 6019dfe9..6717ed26 100644 --- a/src/mm-modem-helpers.c +++ b/src/mm-modem-helpers.c @@ -500,9 +500,8 @@ mm_3gpp_parse_cops_test_response (const gchar *reply, static void mm_3gpp_pdp_context_free (MM3gppPdpContext *pdp) { - g_free (pdp->pdp_type); g_free (pdp->apn); - g_free (pdp); + g_slice_free (MM3gppPdpContext, pdp); } void @@ -540,21 +539,31 @@ mm_3gpp_parse_cgdcont_read_response (const gchar *reply, while (!inner_error && g_match_info_matches (match_info)) { - MM3gppPdpContext *pdp; - - pdp = g_new0 (MM3gppPdpContext, 1); - if (!mm_get_uint_from_match_info (match_info, 1, &pdp->cid)) { - inner_error = g_error_new (MM_CORE_ERROR, - MM_CORE_ERROR_FAILED, - "Couldn't parse CID from reply: '%s'", - reply); - break; - } - pdp->pdp_type = mm_get_string_unquoted_from_match_info (match_info, 2); - pdp->apn = mm_get_string_unquoted_from_match_info (match_info, 3); + gchar *str; + MMBearerIpFamily ip_family; + + str = mm_get_string_unquoted_from_match_info (match_info, 2); + ip_family = mm_3gpp_get_ip_family_from_pdp_type (str); + if (ip_family == MM_BEARER_IP_FAMILY_UNKNOWN) + mm_dbg ("Ignoring PDP context type: '%s'", str); + else { + MM3gppPdpContext *pdp; + + pdp = g_slice_new0 (MM3gppPdpContext); + if (!mm_get_uint_from_match_info (match_info, 1, &pdp->cid)) { + inner_error = g_error_new (MM_CORE_ERROR, + MM_CORE_ERROR_FAILED, + "Couldn't parse CID from reply: '%s'", + reply); + break; + } + pdp->pdp_type = ip_family; + pdp->apn = mm_get_string_unquoted_from_match_info (match_info, 3); - list = g_list_prepend (list, pdp); + list = g_list_prepend (list, pdp); + } + g_free (str); g_match_info_next (match_info, &inner_error); } @@ -1427,6 +1436,35 @@ mm_3gpp_parse_operator (const gchar *reply, /*************************************************************************/ +const gchar * +mm_3gpp_get_pdp_type_from_ip_family (MMBearerIpFamily family) +{ + switch (family) { + case MM_BEARER_IP_FAMILY_IPV4: + return "IP"; + case MM_BEARER_IP_FAMILY_IPV6: + return "IPV6"; + case MM_BEARER_IP_FAMILY_IPV4V6: + return "IPV4V6"; + default: + return NULL; + } +} + +MMBearerIpFamily +mm_3gpp_get_ip_family_from_pdp_type (const gchar *pdp_type) +{ + if (g_str_equal (pdp_type, "IP")) + return MM_BEARER_IP_FAMILY_IPV4; + if (g_str_equal (pdp_type, "IPV6")) + return MM_BEARER_IP_FAMILY_IPV6; + if (g_str_equal (pdp_type, "IPV4V6")) + return MM_BEARER_IP_FAMILY_IPV4V6; + return MM_BEARER_IP_FAMILY_UNKNOWN; +} + +/*************************************************************************/ + gboolean mm_cdma_parse_spservice_read_response (const gchar *reply, MMModemCdmaRegistrationState *out_cdma_1x_state, |