mirror of git://git.sysmocom.de/ofono
atmodem: Add at_util_get_cgdcont_command
The function at_util_get_cgdcont_command computes the AT+CGDCONT string, as per 3GPP 27.007. It uses a second function, at_util_gprs_proto_to_pdp_type, that returns the pdp_type string for the command
This commit is contained in:
parent
0208c10e9b
commit
0d9a380ea0
|
@ -670,3 +670,30 @@ int at_util_gprs_auth_method_to_auth_prot(
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *at_util_gprs_proto_to_pdp_type(enum ofono_gprs_proto proto)
|
||||
{
|
||||
switch (proto) {
|
||||
case OFONO_GPRS_PROTO_IPV6:
|
||||
return "IPV6";
|
||||
case OFONO_GPRS_PROTO_IPV4V6:
|
||||
return "IPV4V6";
|
||||
break;
|
||||
case OFONO_GPRS_PROTO_IP:
|
||||
return "IP";
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *at_util_get_cgdcont_command(guint cid, enum ofono_gprs_proto proto,
|
||||
const char *apn)
|
||||
{
|
||||
const char *pdp_type = at_util_gprs_proto_to_pdp_type(proto);
|
||||
|
||||
if (!apn)
|
||||
return g_strdup_printf("AT+CGDCONT=%u", cid);
|
||||
|
||||
return g_strdup_printf("AT+CGDCONT=%u,\"%s\",\"%s\"", cid, pdp_type,
|
||||
apn);
|
||||
}
|
||||
|
|
|
@ -90,6 +90,19 @@ int at_util_get_ipv4_address_and_netmask(const char *addrnetmask,
|
|||
int at_util_gprs_auth_method_to_auth_prot(
|
||||
enum ofono_gprs_auth_method auth_method);
|
||||
|
||||
const char *at_util_gprs_proto_to_pdp_type(enum ofono_gprs_proto proto);
|
||||
|
||||
/*
|
||||
* at_util_get_cgdcont_command
|
||||
* if the apn pointer is NULL, the context will be removed: the resulting
|
||||
* string will be like: AT+CGDCONT=7
|
||||
* but if apn pointer is not NULL and the string is empty, then
|
||||
* this function will create a normal context with empty apn, like:
|
||||
* AT+CGDCONT=4,"IPV6",""
|
||||
*/
|
||||
char *at_util_get_cgdcont_command(guint cid, enum ofono_gprs_proto proto,
|
||||
const char *apn);
|
||||
|
||||
struct cb_data {
|
||||
void *cb;
|
||||
void *data;
|
||||
|
|
Loading…
Reference in New Issue