Hi Vijay,

> +static void at_cgcontrdp_cb(gboolean ok, GAtResult *result, gpointer 
> user_data)
> +{
> +     struct ofono_packet_service *ps = user_data;
> +     struct packet_service_data *psd = ofono_packet_service_get_data(ps);
> +     GAtResultIter iter;
> +     int cid, bearer_id;
> +     const char *apn, *address, *gateway, *dns1, *dns2;
> +     const char *dns[3];
> +     struct ofono_default_context_param *param;
> +
> +     if (!ok)
> +             return;
> +
> +     g_at_result_iter_init(&iter, result);
> +
> +     if (g_at_result_iter_next(&iter, "+CGCONTRDP:") == FALSE)
> +             return;
> +
> +     if (g_at_result_iter_next_number(&iter, &cid) == FALSE)
> +             return;
> +
> +     if (g_at_result_iter_next_number(&iter, &bearer_id) == FALSE)
> +             return;
> +
> +     if (g_at_result_iter_next_string(&iter, &apn) == FALSE)
> +             return;
> +
> +     if (g_at_result_iter_next_string(&iter, &address) == FALSE)
> +             goto out;
> +
> +     if (g_at_result_iter_next_string(&iter, &gateway) == FALSE)
> +             goto out;
> +
> +     if (g_at_result_iter_next_string(&iter, &dns1) == FALSE)
> +             goto out;
> +
> +     if (g_at_result_iter_next_string(&iter, &dns2) == FALSE)
> +             goto out;
> +
> +     dns[0] = dns1;
> +     dns[1] = dns2;
> +     dns[2] = 0;
> +
> +out:
> +     param = g_new0(struct ofono_default_context_param, 1);
> +     if (param == NULL)
> +             return;
> +
> +     param->cid = cid;
> +     param->proto = psd->default_context_type;
> +     param->apn = apn;
> +     param->address = address;
> +     param->gateway = gateway;
> +     param->dns = dns;
> +
> +     ofono_packet_service_default_context_notify(ps, param);
> +
> +     g_free(param);
> +     param = NULL;
> +}
> +
> +static void at_cgdcont_cb(gboolean ok, GAtResult *result, gpointer user_data)
> +{
> +     struct ofono_packet_service *ps = user_data;
> +     struct packet_service_data *psd = ofono_packet_service_get_data(ps);
> +     GAtResultIter iter;
> +     int cid;
> +     const char *pdp_type;
> +     char buf[64];
> +     gboolean found = FALSE;
> +
> +     if (!ok)
> +             return;
> +
> +     g_at_result_iter_init(&iter, result);
> +
> +     while (!found && g_at_result_iter_next(&iter, "+CGDCONT:")) {
> +             if (g_at_result_iter_next_number(&iter, &cid) == FALSE)
> +                     return;
> +
> +             if (psd->default_cid != cid)
> +                     continue;
> +
> +             g_at_result_iter_next_string(&iter, &pdp_type);
> +
> +             found = TRUE;
> +     }
> +
> +     if (found == FALSE)
> +             return;
> +
> +     if (g_str_equal(pdp_type, "IP"))
> +             psd->default_context_type = OFONO_PACKET_PROTO_IP;
> +     else if (g_str_equal(pdp_type, "IPV6"))
> +             psd->default_context_type = OFONO_PACKET_PROTO_IPV6;
> +     else if (g_str_equal(pdp_type, "IPV4V6"))
> +             psd->default_context_type = OFONO_PACKET_PROTO_IPV4V6;
> +
> +     snprintf(buf, sizeof(buf), "AT+CGCONTRDP=%i", psd->default_cid);

this looks wrong to me. Reading the CGDCONT information is not going to
help us. We should just read CGCONTRDP if available or CGADDR it not.

If we are a dual stack, then we will see two lines of CGCONTRDP, if not
then I assume we can tell from the address if we are IP or IPV6. Same
applies to CGADDR in case CGCONTRDP is not available.

And of course we need to keep CGPIAF in mind.

For me it is also important if <IM_CN_Signalling_Flag> is set or not
since that tells us that this is the IMS context. And I would expect
that all networks will use that one as default context.

> +     g_at_chat_send(psd->chat, buf, cgcontrdp_prefix, at_cgcontrdp_cb,
> +                                                             ps, NULL);
> +}
> +
>  static void at_packet_service_registration_status(
>                                       struct ofono_packet_service *ps,
>                                       ofono_packet_service_status_cb_t cb,
> @@ -138,6 +273,13 @@ static void at_packet_service_registration_status(
>               break;
>       }
>  
> +     if (ofono_packet_service_get_technology(ps) ==
> +                                             ACCESS_TECHNOLOGY_EUTRAN) {
> +             if (g_at_chat_send(psd->chat, "AT+CEREG?", cereg_prefix,
> +                                     at_cereg_cb, cbd, g_free) > 0)
> +                     return;
> +     }
> +
>       if (g_at_chat_send(psd->chat, "AT+CGREG?", cgreg_prefix,
>                               at_cgreg_cb, cbd, g_free) > 0)
>               return;
> @@ -160,9 +302,23 @@ static void cgreg_notify(GAtResult *result, gpointer 
> user_data)
>       ofono_packet_service_status_notify(ps, status);
>  }
>  
> +static void cereg_notify(GAtResult *result, gpointer user_data)
> +{
> +     struct ofono_packet_service *ps = user_data;
> +     int status;
> +     struct packet_service_data *psd = ofono_packet_service_get_data(ps);
> +
> +     if (at_util_parse_reg_unsolicited(result, "+CEREG:", &status,
> +                             NULL, NULL, NULL, psd->vendor) == FALSE)
> +             return;
> +
> +     ofono_packet_service_status_notify(ps, status);
> +}
> +
>  static void cgev_notify(GAtResult *result, gpointer user_data)
>  {
>       struct ofono_packet_service *ps = user_data;
> +     struct packet_service_data *psd = ofono_packet_service_get_data(ps);
>       GAtResultIter iter;
>       const char *event;
>  
> @@ -179,6 +335,35 @@ static void cgev_notify(GAtResult *result, gpointer 
> user_data)
>               ofono_packet_service_detached_notify(ps);
>               return;
>       }
> +
> +     if (g_str_has_prefix(event, "ME PDN ACT")) {
> +             /*
> +              * As per 27.007, this even it sent when the mobile termination
> +              * has activated a context. The context represents a PDN
> +              * connection in LTE or a Primary PDP context in GSM/UMTS.
> +              * The <cid> for this context is provided to the TE. This event
> +              * is sent either in result of explicit context activation
> +              * request (+CGACT), or in result of implicit context activation
> +              * request associated to attach request (+CGATT=1).
> +              */
> +             int cid;
> +
> +             cid = g_ascii_strtoll(&event[11], NULL, 0);
> +
> +             /*
> +              * Assumption: context id for default EPS context will have
> +              * value outside the ranges indicated in the test form of
> +              * the command +CGDCONT.
> +              */

That is still an assumption that needs to be confirmed. So does the
default context activation from just uses APN == "" and then the network
picks the APN to activate. Or does it just use the APN value from CID 1
for example.

Regards

Marcel


_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to