* [PATCH 1/2] atmodem/atutil: at_util_gprs_proto_to_pdp_type
@ 2018-10-22 18:56 Giacinto Cifelli
2018-10-22 18:56 ` [PATCH 2/2] atmodem/atutil: at_util_get_cgdcont_command Giacinto Cifelli
2018-10-22 20:04 ` [PATCH 1/2] atmodem/atutil: at_util_gprs_proto_to_pdp_type Denis Kenzior
0 siblings, 2 replies; 5+ messages in thread
From: Giacinto Cifelli @ 2018-10-22 18:56 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2123 bytes --]
This function converts the ofono enum ofono_gprs_auth_method
into the value of the 3GPP 27.007 to pass to the AT command
---
drivers/atmodem/atutil.c | 16 ++++++++++++++++
drivers/atmodem/atutil.h | 3 +++
2 files changed, 19 insertions(+)
diff --git a/drivers/atmodem/atutil.c b/drivers/atmodem/atutil.c
index 6f4e8a20..ed57b55a 100644
--- a/drivers/atmodem/atutil.c
+++ b/drivers/atmodem/atutil.c
@@ -3,6 +3,7 @@
* oFono - Open Source Telephony
*
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
+ * Copyright (C) 2018 Gemalto M2M
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -27,6 +28,7 @@
#include <gatchat.h>
#include <string.h>
#include <stdlib.h>
+#include <stdio.h>
#include <errno.h>
#define OFONO_API_SUBJECT_TO_CHANGE
@@ -654,3 +656,17 @@ int at_util_get_ipv4_address_and_netmask(const char *addrnetmask,
return ret;
}
+
+int at_util_auth_type_from_method(enum ofono_gprs_auth_method auth_method)
+{
+ switch (auth_method) {
+ case OFONO_GPRS_AUTH_METHOD_PAP:
+ return 1;
+ case OFONO_GPRS_AUTH_METHOD_CHAP:
+ return 2;
+ case OFONO_GPRS_AUTH_METHOD_NONE:
+ return 0;
+ }
+
+ return 0;
+}
diff --git a/drivers/atmodem/atutil.h b/drivers/atmodem/atutil.h
index 7113a4cd..006ad65a 100644
--- a/drivers/atmodem/atutil.h
+++ b/drivers/atmodem/atutil.h
@@ -3,6 +3,7 @@
* oFono - Open Source Telephony
*
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
+ * Copyright (C) 2018 Gemalto M2M
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -86,6 +87,8 @@ void at_util_sim_state_query_free(struct at_util_sim_state_query *req);
int at_util_get_ipv4_address_and_netmask(const char *addrnetmask,
char *address, char *netmask);
+int at_util_auth_type_from_method(enum ofono_gprs_auth_method auth_method);
+
struct cb_data {
void *cb;
void *data;
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] atmodem/atutil: at_util_get_cgdcont_command
2018-10-22 18:56 [PATCH 1/2] atmodem/atutil: at_util_gprs_proto_to_pdp_type Giacinto Cifelli
@ 2018-10-22 18:56 ` Giacinto Cifelli
2018-10-22 20:06 ` Denis Kenzior
2018-10-22 20:04 ` [PATCH 1/2] atmodem/atutil: at_util_gprs_proto_to_pdp_type Denis Kenzior
1 sibling, 1 reply; 5+ messages in thread
From: Giacinto Cifelli @ 2018-10-22 18:56 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2163 bytes --]
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
---
drivers/atmodem/atutil.c | 27 +++++++++++++++++++++++++++
drivers/atmodem/atutil.h | 13 +++++++++++++
2 files changed, 40 insertions(+)
diff --git a/drivers/atmodem/atutil.c b/drivers/atmodem/atutil.c
index ed57b55a..7725513a 100644
--- a/drivers/atmodem/atutil.c
+++ b/drivers/atmodem/atutil.c
@@ -670,3 +670,30 @@ int at_util_auth_type_from_method(enum ofono_gprs_auth_method auth_method)
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);
+}
diff --git a/drivers/atmodem/atutil.h b/drivers/atmodem/atutil.h
index 006ad65a..a924b6f0 100644
--- a/drivers/atmodem/atutil.h
+++ b/drivers/atmodem/atutil.h
@@ -89,6 +89,19 @@ int at_util_get_ipv4_address_and_netmask(const char *addrnetmask,
int at_util_auth_type_from_method(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;
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] atmodem/atutil: at_util_gprs_proto_to_pdp_type
2018-10-22 18:56 [PATCH 1/2] atmodem/atutil: at_util_gprs_proto_to_pdp_type Giacinto Cifelli
2018-10-22 18:56 ` [PATCH 2/2] atmodem/atutil: at_util_get_cgdcont_command Giacinto Cifelli
@ 2018-10-22 20:04 ` Denis Kenzior
2018-10-23 3:01 ` Giacinto Cifelli
1 sibling, 1 reply; 5+ messages in thread
From: Denis Kenzior @ 2018-10-22 20:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 690 bytes --]
Hi Giacinto,
On 10/22/2018 01:56 PM, Giacinto Cifelli wrote:
> This function converts the ofono enum ofono_gprs_auth_method
> into the value of the 3GPP 27.007 to pass to the AT command
> ---
> drivers/atmodem/atutil.c | 16 ++++++++++++++++
> drivers/atmodem/atutil.h | 3 +++
> 2 files changed, 19 insertions(+)
>
Your commit header does not match the patch contents or description.
You might want to slow down a bit.
Anyway, I renamed this to at_util_gprs_auth_method_to_auth_proto to
match 3GPP naming & the naming of the pdp_type conversion function in
the next patch. And fixed up the commit description / header.
Applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] atmodem/atutil: at_util_get_cgdcont_command
2018-10-22 18:56 ` [PATCH 2/2] atmodem/atutil: at_util_get_cgdcont_command Giacinto Cifelli
@ 2018-10-22 20:06 ` Denis Kenzior
0 siblings, 0 replies; 5+ messages in thread
From: Denis Kenzior @ 2018-10-22 20:06 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 482 bytes --]
Hi Giacinto,
On 10/22/2018 01:56 PM, Giacinto Cifelli wrote:
> 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
> ---
> drivers/atmodem/atutil.c | 27 +++++++++++++++++++++++++++
> drivers/atmodem/atutil.h | 13 +++++++++++++
> 2 files changed, 40 insertions(+)
>
Applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] atmodem/atutil: at_util_gprs_proto_to_pdp_type
2018-10-22 20:04 ` [PATCH 1/2] atmodem/atutil: at_util_gprs_proto_to_pdp_type Denis Kenzior
@ 2018-10-23 3:01 ` Giacinto Cifelli
0 siblings, 0 replies; 5+ messages in thread
From: Giacinto Cifelli @ 2018-10-23 3:01 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 905 bytes --]
Hi Denis,
On Mon, Oct 22, 2018 at 10:04 PM Denis Kenzior <denkenz@gmail.com> wrote:
>
> Hi Giacinto,
>
> On 10/22/2018 01:56 PM, Giacinto Cifelli wrote:
> > This function converts the ofono enum ofono_gprs_auth_method
> > into the value of the 3GPP 27.007 to pass to the AT command
> > ---
> > drivers/atmodem/atutil.c | 16 ++++++++++++++++
> > drivers/atmodem/atutil.h | 3 +++
> > 2 files changed, 19 insertions(+)
> >
>
> Your commit header does not match the patch contents or description.
> You might want to slow down a bit.
yes, I noticed that too late. Thank you for taking it anyway.
>
> Anyway, I renamed this to at_util_gprs_auth_method_to_auth_proto to
> match 3GPP naming & the naming of the pdp_type conversion function in
> the next patch. And fixed up the commit description / header.
>
> Applied, thanks.
>
> Regards,
> -Denis
Regards,
Giacinto
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-10-23 3:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-22 18:56 [PATCH 1/2] atmodem/atutil: at_util_gprs_proto_to_pdp_type Giacinto Cifelli
2018-10-22 18:56 ` [PATCH 2/2] atmodem/atutil: at_util_get_cgdcont_command Giacinto Cifelli
2018-10-22 20:06 ` Denis Kenzior
2018-10-22 20:04 ` [PATCH 1/2] atmodem/atutil: at_util_gprs_proto_to_pdp_type Denis Kenzior
2018-10-23 3:01 ` Giacinto Cifelli
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.