summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaulK <contact@paulk.fr>2011-12-29 14:47:34 +0100
committerPaulK <contact@paulk.fr>2011-12-29 14:47:34 +0100
commitb2c23f06ffb49f4a9f342c39928c41882d96e282 (patch)
tree885bf0ee0968a2016e14c5e944cace070c88306b
parent16fd5fb67ba755fa65253eaaf861f46dc1135147 (diff)
downloadhardware_replicant_libsamsung-ril-b2c23f06ffb49f4a9f342c39928c41882d96e282.tar.gz
hardware_replicant_libsamsung-ril-b2c23f06ffb49f4a9f342c39928c41882d96e282.tar.bz2
hardware_replicant_libsamsung-ril-b2c23f06ffb49f4a9f342c39928c41882d96e282.zip
Added preliminary data support
-rw-r--r--Android.mk5
-rw-r--r--gprs.c145
-rw-r--r--net.c4
-rw-r--r--samsung-ril.c12
-rw-r--r--samsung-ril.h5
5 files changed, 166 insertions, 5 deletions
diff --git a/Android.mk b/Android.mk
index 9ef3ba4..2011585 100644
--- a/Android.mk
+++ b/Android.mk
@@ -34,7 +34,8 @@ LOCAL_SRC_FILES := \
net.c \
sms.c \
call.c \
- snd.c
+ snd.c \
+ gprs.c
LOCAL_SHARED_LIBRARIES := \
libcutils libutils libril
@@ -62,7 +63,7 @@ LOCAL_PRELINK_MODULE := false
ifeq (foo,foo)
# build shared library
LOCAL_SHARED_LIBRARIES += \
- libcutils libutils
+ libcutils libnetutils libutils
LOCAL_LDLIBS += -lpthread
LOCAL_CFLAGS += -DRIL_SHLIB
LOCAL_MODULE:= libsamsung-ril
diff --git a/gprs.c b/gprs.c
new file mode 100644
index 0000000..60b9831
--- /dev/null
+++ b/gprs.c
@@ -0,0 +1,145 @@
+/**
+ * This file is part of samsung-ril.
+ *
+ * Copyright (C) 2011 Denis 'GNUtoo' Carikli <GNUtoo@no-log.org>
+ * Copyright (C) 2011 Paul Kocialkowski <contact@oaulk.fr>
+ *
+ * samsung-ril is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * samsung-ril is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with samsung-ril. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#define LOG_TAG "RIL-GPRS"
+#include <utils/Log.h>
+
+#include "samsung-ril.h"
+#include "util.h"
+
+/* FIXME: we don't want these hardcoded */
+#define INTERFACE "rmnet0"
+#define IP_STRING_SIZE 15 + 1
+
+// TODO: Put this in libsamsung-ipc headers
+extern void ipc_gprs_define_pdp_context_setup(struct ipc_gprs_define_pdp_context *message, char *apn);
+
+// libnetutils missing prototype
+
+extern int ifc_configure(const char *ifname,
+ in_addr_t address,
+ in_addr_t netmask,
+ in_addr_t gateway,
+ in_addr_t dns1,
+ in_addr_t dns2);
+
+void ril_request_setup_data_call(RIL_Token t, void *data, int length)
+{
+ char *username = NULL;
+ char *password = NULL;
+ char *apn = NULL;
+
+ struct ipc_gprs_define_pdp_context setup_apn_message;
+ struct ipc_gprs_pdp_context activate_message;
+
+ /* get the apn, username and password */
+ apn = ((char **) data)[2];
+ username = ((char **) data)[3];
+
+ if(username != NULL) {
+ if(strlen(username) < 2)
+ username = "dummy";
+ } else {
+ username = "dummy";
+ }
+
+ password = ((char **) data)[4];
+
+ if(password != NULL) {
+ if(strlen(password) < 2)
+ password = "dummy";
+ } else {
+ password = "dummy";
+ }
+
+ LOGD("Requesting data connection to APN '%s'\n", apn);
+
+ /* create the structs with the apn */
+ ipc_gprs_define_pdp_context_setup(&setup_apn_message, apn);
+
+ /* send the struct to the modem */
+ ipc_fmt_send(IPC_GPRS_DEFINE_PDP_CONTEXT, IPC_TYPE_SET,
+ (void *) &setup_apn_message, sizeof(struct ipc_gprs_define_pdp_context), reqGetId(t));
+
+ //TODO: Wait for IPC_GEN_PHONE_RES, split in 2 functions
+
+ /* create the structs with the username/password tuple */
+ ipc_gprs_pdp_context_setup(&activate_message, username, password);
+
+ /* activate the connection */
+ ipc_fmt_send(IPC_GPRS_PDP_CONTEXT, IPC_TYPE_SET,
+ (void *) &activate_message, sizeof(struct ipc_gprs_pdp_context), reqGetId(t));
+
+ //TODO: Wait for IPC_GEN_PHONE_RES, only return to RILJ if it fails
+}
+
+void ipc_gprs_ip_configuration(struct ipc_message_info *info)
+{
+ /* Quick and dirty configuration, TODO: Handle that better */
+
+ struct ipc_gprs_ip_configuration *ip_config = (struct ipc_gprs_ip_configuration *) info->data;
+
+ char local_ip[IP_STRING_SIZE];
+ char gateway[IP_STRING_SIZE];
+ char subnet_mask[IP_STRING_SIZE];
+ char dns1[IP_STRING_SIZE];
+ char dns2[IP_STRING_SIZE];
+
+ char *response[3];
+ int rc;
+
+ /* TODO: transform that into some macros */
+ snprintf(local_ip, IP_STRING_SIZE, "%i.%i.%i.%i",(ip_config->ip)[0],(ip_config->ip)[1],
+ (ip_config->ip)[2],(ip_config->ip)[3]);
+
+ snprintf(gateway, IP_STRING_SIZE, "%i.%i.%i.%i",(ip_config->gateway)[0],(ip_config->gateway)[1],
+ (ip_config->gateway)[2],(ip_config->gateway)[3]);
+
+ snprintf(subnet_mask, IP_STRING_SIZE, "%i.%i.%i.%i",(ip_config->subnet_mask)[0],(ip_config->subnet_mask)[1],
+ (ip_config->subnet_mask)[2],(ip_config->subnet_mask)[3]);
+
+ snprintf(dns1, IP_STRING_SIZE, "%i.%i.%i.%i",(ip_config->dns1)[0],(ip_config->dns1)[1],
+ (ip_config->dns1)[2],(ip_config->dns1)[3]);
+
+ snprintf(dns2, IP_STRING_SIZE , "%i.%i.%i.%i",(ip_config->dns2)[0],(ip_config->dns2)[1],
+ (ip_config->dns2)[2],(ip_config->dns2)[3]);
+
+ LOGD("GPRS configuration: ip:%s, gateway:%s, subnet_mask:%s, dns1:%s, dns2:%s",
+ local_ip, gateway, subnet_mask ,dns1, dns2);
+
+ rc = ifc_configure(INTERFACE,
+ inet_addr(local_ip),
+ inet_addr(subnet_mask),
+ inet_addr(gateway),
+ inet_addr(dns1),
+ inet_addr(dns2));
+
+ // FIXME: check rc
+
+ response[0] = "0"; //FIXME: connection id
+ response[1] = INTERFACE;
+ response[2] = local_ip;
+
+ RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_SUCCESS, response, sizeof(response));
+}
diff --git a/net.c b/net.c
index 686f6e6..b05c9fc 100644
--- a/net.c
+++ b/net.c
@@ -160,8 +160,10 @@ void ipc2ril_reg_state_resp(struct ipc_net_regist *netinfo, char *response[15])
asprintf(&response[0], "%d", reg_state);
asprintf(&response[1], "%x", netinfo->lac);
asprintf(&response[2], "%x", netinfo->cid);
- if(act)
+ if(act > 0)
asprintf(&response[3], "%d", act);
+ else
+ response[3] = NULL;
}
/**
diff --git a/samsung-ril.c b/samsung-ril.c
index d3c7aa2..8aafac7 100644
--- a/samsung-ril.c
+++ b/samsung-ril.c
@@ -49,6 +49,7 @@
* - gen phone res queue
* - SMS ret isn't NULL (tpid)
* - Android "0" net type (logs)!
+ * - add MIC_MUTE from RILJ
*/
/**
@@ -258,10 +259,13 @@ void ipc_fmt_dispatch(struct ipc_message_info *info)
case IPC_CALL_STATUS:
ipc_call_status(info);
break;
+ /* GPRS */
+ case IPC_GPRS_IP_CONFIGURATION:
+ ipc_gprs_ip_configuration(info);
+ break;
/* OTHER */
-
case IPC_GEN_PHONE_RES:
-// respondGenPhonRes(info);
+ respondGenPhonRes(info);
break;
default:
LOGD("Unknown msgtype: %04x", info->type);
@@ -420,6 +424,10 @@ void onRequest(int request, void *data, size_t datalen, RIL_Token t)
case RIL_REQUEST_DTMF_STOP:
ril_request_dtmf_stop(t);
break;
+ /* GPRS */
+ case RIL_REQUEST_SETUP_DATA_CALL:
+ ril_request_setup_data_call(t, data, datalen);
+ break;
/* OTHER */
case RIL_REQUEST_SCREEN_STATE:
/* This doesn't affect anything */
diff --git a/samsung-ril.h b/samsung-ril.h
index ab471aa..a331313 100644
--- a/samsung-ril.h
+++ b/samsung-ril.h
@@ -266,4 +266,9 @@ void ril_request_dtmf_stop(RIL_Token t);
void srs_snd_set_call_clock_sync(struct srs_message *message);
+/* GPRS */
+
+void ril_request_setup_data_call(RIL_Token t, void *data, int length);
+void ipc_gprs_ip_configuration(struct ipc_message_info *info);
+
#endif