gnokii-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-70


From: Daniele Forsi
Subject: [SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-70-g1600ab7
Date: Sun, 05 Dec 2010 22:18:02 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "libgnokii and core programs".

The branch, master has been updated
       via  1600ab73b08a83a040c8ec405aeb85f32d4b76bc (commit)
      from  7a2cc7d8539c37a444a5c3f51a8a9603f3bd6aff (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/gnokii.git/commit/?id=1600ab73b08a83a040c8ec405aeb85f32d4b76bc


commit 1600ab73b08a83a040c8ec405aeb85f32d4b76bc
Author: Daniele Forsi <address@hidden>
Date:   Sun Dec 5 23:16:30 2010 +0100

    Add phonet driver. See sample gnokiirc and README-6510 for details

diff --git a/ChangeLog b/ChangeLog
index 264fa68..95b0b83 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -26,6 +26,9 @@
     o free the cached file lists up on exist            (Paweł Kot)
     o fix crash when writing calendar notes to Series 40 3rd Ed.
       and later                                     (Daniele Forsi)
+    o add support for phonet Linux kernel driver for Nokia phones
+      over USB connections only (use connection=phonet port=usbpn0)
+                                                    (Daniele Forsi)
  * nk7110 driver updates
     o fix reading SMS from AR and TE                (Daniele Forsi)
  * win32 updates
diff --git a/Docs/README-6510 b/Docs/README-6510
index 9cc62d6..9be02f6 100644
--- a/Docs/README-6510
+++ b/Docs/README-6510
@@ -42,6 +42,7 @@ various connection media:
 | dlr3p                | dlr3p                 |
 | IrDA         | irda                  |
 | Bluetooth    | bluetooth             |
+| USB          | dku2libusb or phonet  |
 -----------------------------------------
 When you don't know what your cable is you can first try serial value.
 
@@ -69,6 +70,22 @@ Hint: For all these phones you can also use AT driver, as 
they all have a
 builtin hardware modem, but it usually supports less commands so it isn't
 recommended.
 
+* phonet Driver *
+
+Linux 2.6.28 and later versions provide a network kernel driver called
+"phonet" that conflicts with the dku2libusb driver provided by libgnokii and
+that can connect to the same phones.
+The port value is the device name as seen with "ifconfig", usually usbpn0.
+When using this driver you may encounter the following errors:
+* "Operation not permitted" - run as root:
+  setcap cap_sys_admin,cap_net_raw=+ep $(which gnokii)
+* "Address family not supported by protocol" - run "modprobe cdc_phonet" as
+  root and remove the cdc_phonet and phonet modules from the blacklist if
+  you put them there to use the dku2libusb driver
+* "No such device" - the phone isn't connected: choose "Nokia PC Suite" or
+  "Nokia mode" from phone's menu
+* "No route to host" - run as root "ifconfig usbpn0 up"
+
 * TODO *
 
  * implement further functionality
diff --git a/Docs/sample/gnokiirc b/Docs/sample/gnokiirc
index de5e1dd..2147f7c 100644
--- a/Docs/sample/gnokiirc
+++ b/Docs/sample/gnokiirc
@@ -45,6 +45,10 @@ port = none
 # to your computer using DKU2 cable. Numbering goes from 1 upwards.
 # Default is 1.
 # port = 1
+#
+# If you use connection type phonet use it to denote the network device to use.
+# See README-6510 for more details.
+# port = usbpn0
 
 # Change it according to instructions
 model = fake
@@ -85,9 +89,11 @@ model = fake
 # to understand what this changes if you're curious.
 initlength = default
 
-# The type of the connection, for IR set this to infrared or irda.
-# For the nk6110 driver only infrared is valid for the IrDA connection.
-# See Docs/gnokii-ir-howto for more detailes on this.
+# Most USB cables for Nokia phones should work with the libusb driver
+# (recommended)
+# connection = dku2libusb
+# and with the new kernel driver (Linux 2.6.28+)
+# connection = phonet
 # If you have 6210/6250/7110 phone and dau9p cable (the one you can
 # use with 6100 series and cannot use hardware modem from the phone)
 # you may want to use 'dau9p' value to get faster initialization.
@@ -96,10 +102,8 @@ initlength = default
 # Note that it is recommended and currently the best way to use this
 # cable with nk6510 driver.
 connection = serial
-# With DKU-2 cable use the following setting if you want to libusb driver
-# (recommended):
-# connection = dku2libusb
-# or the following setting if you want to use Linux kernel driver
+# With DKU-2 cable use the following setting with the now unsupported Linux
+# kernel driver that was provided with older libgnokii versions:
 # connection = dku2
 # With DKU-5 cable use the following setting
 # connection = dku5
@@ -110,6 +114,8 @@ connection = serial
 # For infrared connection with phones other than Nokia 6110/6130/6150 use:
 # connection = irda
 # Don't forget to run: 'irattach irda0 -s' or similiar before running gnokii
+# For the nk6110 driver only connection=infrared is valid for IrDA.
+# See Docs/gnokii-ir-howto for more detailes on this.
 # For connection with a PC/SC compatible Smart Card reader use:
 # connection = pcsc
 
diff --git a/common/device.c b/common/device.c
index f2978c4..ca087fe 100644
--- a/common/device.c
+++ b/common/device.c
@@ -41,7 +41,7 @@
 #include "devices/serial.h"
 #include "devices/tekram.h"
 #include "devices/dku2libusb.h"
-
+#include "devices/socketphonet.h"
 
 GNOKII_API int device_getfd(struct gn_statemachine *state)
 {
@@ -78,6 +78,9 @@ int device_open(const char *file, int with_odd_parity, int 
with_async,
        case GN_CT_DKU2LIBUSB:
                state->device.fd = fbusdku2usb_open(state);
                break;
+       case GN_CT_SOCKETPHONET:
+               state->device.fd = socketphonet_open(file, with_async, state);
+               break;
        default:
                state->device.fd = -1;
                break;
@@ -110,6 +113,9 @@ void device_close(struct gn_statemachine *state)
        case GN_CT_DKU2LIBUSB:
                fbusdku2usb_close(state);
                break;
+       case GN_CT_SOCKETPHONET:
+               socketphonet_close(state);
+               break;
        default:
                break;
        }
@@ -139,6 +145,7 @@ void device_setdtrrts(int dtr, int rts, struct 
gn_statemachine *state)
        case GN_CT_Tekram:
        case GN_CT_TCP:
        case GN_CT_DKU2LIBUSB:
+       case GN_CT_SOCKETPHONET:
        default:
                break;
        }
@@ -161,6 +168,7 @@ void device_changespeed(int speed, struct gn_statemachine 
*state)
        case GN_CT_Bluetooth:
        case GN_CT_TCP:
        case GN_CT_DKU2LIBUSB:
+       case GN_CT_SOCKETPHONET:
        default:
                break;
        }
@@ -183,6 +191,8 @@ size_t device_read(__ptr_t buf, size_t nbytes, struct 
gn_statemachine *state)
                return tcp_read(state->device.fd, buf, nbytes, state);
        case GN_CT_DKU2LIBUSB:
                return fbusdku2usb_read(buf, nbytes, state);
+       case GN_CT_SOCKETPHONET:
+               return socketphonet_read(state->device.fd, buf, nbytes, state);
        default:
                break;
        }
@@ -206,6 +216,8 @@ size_t device_write(const __ptr_t buf, size_t n, struct 
gn_statemachine *state)
                return tcp_write(state->device.fd, buf, n, state);
        case GN_CT_DKU2LIBUSB:
                return fbusdku2usb_write(buf, n, state);
+       case GN_CT_SOCKETPHONET:
+               return socketphonet_write(state->device.fd, buf, n, state);
        default:
                break;
        }
@@ -229,6 +241,8 @@ int device_select(struct timeval *timeout, struct 
gn_statemachine *state)
                return tcp_select(state->device.fd, timeout, state);
        case GN_CT_DKU2LIBUSB:
                return fbusdku2usb_select(timeout, state);
+       case GN_CT_SOCKETPHONET:
+               return socketphonet_select(state->device.fd, timeout, state);
        default:
                break;
        }
diff --git a/common/devices/Makefile.am b/common/devices/Makefile.am
index 011d6c3..8d389f0 100644
--- a/common/devices/Makefile.am
+++ b/common/devices/Makefile.am
@@ -12,7 +12,8 @@ UNIX_FILES = \
        unixbluetooth.c \
        osxbluetooth.c \
        unixirda.c \
-       tcp.c
+       tcp.c \
+       socketphonet.c
 
 if WIN32
 PLATFORM_FILES = $(WIN32_FILES)
diff --git a/common/devices/socketphonet.c b/common/devices/socketphonet.c
new file mode 100644
index 0000000..362f763
--- /dev/null
+++ b/common/devices/socketphonet.c
@@ -0,0 +1,173 @@
+/*
+
+  G N O K I I
+
+  A Linux/Unix toolset and driver for the mobile phones.
+
+  This file is part of gnokii.
+
+  Gnokii 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 2 of the License, or
+  (at your option) any later version.
+
+  Gnokii 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 gnokii; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+  Copyright (C) 2010 Daniele Forsi
+
+  This file provides an API for accessing functions via the phonet Linux 
kernel module.
+  See README for more details on supported mobile phones.
+
+  The various routines are called socketphonet_(whatever).
+
+*/
+
+#include "config.h"
+
+#include "gnokii.h"
+
+#ifndef HAVE_SOCKETPHONET
+
+int socketphonet_close(struct gn_statemachine *state)
+{
+       return -1;
+}
+
+int socketphonet_open(const char *interface, int with_async, struct 
gn_statemachine *state)
+{
+       return -1;
+}
+
+size_t socketphonet_read(int fd, __ptr_t buf, size_t nbytes, struct 
gn_statemachine *state)
+{
+       return -1;
+}
+
+size_t socketphonet_write(int fd, const __ptr_t buf, size_t n, struct 
gn_statemachine *state)
+{
+       return -1;
+}
+
+int socketphonet_select(int fd, struct timeval *timeout, struct 
gn_statemachine *state)
+{
+       return -1;
+}
+
+#else
+
+/* System header files */
+#include <sys/socket.h>
+#include <linux/phonet.h>
+
+/* Various header files */
+#include "compat.h"
+#include "links/fbus-common.h"
+#include "links/fbus-phonet.h"
+#include "device.h"
+#include "devices/serial.h"
+#include "gnokii-internal.h"
+
+static struct sockaddr_pn addr = { .spn_family = AF_PHONET, .spn_dev = 
FBUS_DEVICE_PHONE };
+
+int socketphonet_close(struct gn_statemachine *state)
+{
+       return close(state->device.fd);
+}
+
+int socketphonet_open(const char *interface, int with_async, struct 
gn_statemachine *state)
+{
+       int fd, retcode;
+
+       fd = socket(PF_PHONET, SOCK_DGRAM, 0);
+       if (fd == -1) {
+               perror("socket");
+               return -1;
+       }
+
+       if (bind(fd, (struct sockaddr *)&addr, sizeof(addr))) {
+               perror("bind");
+               close(fd);
+               return -1;
+       }
+
+       if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, interface, 
strlen(interface))) {
+               perror("setsockopt");
+               close(fd);
+               return -1;
+       }
+
+       /* Make filedescriptor asynchronous. */
+
+       /* We need to supply FNONBLOCK (or O_NONBLOCK) again as it would get 
reset
+        * by F_SETFL as a side-effect!
+        */
+#ifdef FNONBLOCK
+       retcode = fcntl(fd, F_SETFL, (with_async ? FASYNC : 0) | FNONBLOCK);
+#else
+#  ifdef FASYNC
+       retcode = fcntl(fd, F_SETFL, (with_async ? FASYNC : 0) | O_NONBLOCK);
+#  else
+       retcode = fcntl(fd, F_SETFL, O_NONBLOCK);
+       if (retcode != -1)
+               retcode = ioctl(fd, FIOASYNC, &with_async);
+#  endif
+#endif
+       if (retcode == -1) {
+               perror("fcntl");
+               close(fd);
+               return -1;
+       }
+
+       return fd;
+}
+
+size_t socketphonet_read(int fd, __ptr_t buf, size_t nbytes, struct 
gn_statemachine *state)
+{
+       int received;
+       unsigned char *frame = buf;
+
+       received = recvfrom(fd, buf + 8, sizeof(buf) - 8, 0, NULL, NULL);
+       if (received == -1) {
+               perror("recvfrom");
+               return -1;
+       }
+
+       /* Hack!!! REbuild header as expected by phonet_rx_statemachine() */
+       frame[0] = FBUS_PHONET_DKU2_FRAME_ID;
+       frame[1] = FBUS_PHONET_BLUETOOTH_DEVICE_PC;
+       frame[2] = FBUS_DEVICE_PHONE;
+       frame[3] = addr.spn_resource;
+       frame[4] = received >> 8;
+       frame[5] = received & 0xff;
+       return received + 8;
+}
+
+size_t socketphonet_write(int fd, const __ptr_t buf, size_t n, struct 
gn_statemachine *state)
+{
+       int sent;
+       const unsigned char *frame = buf;
+
+       addr.spn_resource = frame[3];
+
+       sent = sendto(fd, buf + 8, n - 8, 0, (struct sockaddr *)&addr, 
sizeof(addr));
+       if (sent == -1) {
+               perror("sendto");
+               return -1;
+       }
+
+       return sent + 8;
+}
+
+int socketphonet_select(int fd, struct timeval *timeout, struct 
gn_statemachine *state)
+{
+       return serial_select(fd, timeout, state);
+}
+
+#endif /* HAVE_SOCKETPHONET */
diff --git a/common/gsm-common.c b/common/gsm-common.c
index d3ec556..da1b98c 100644
--- a/common/gsm-common.c
+++ b/common/gsm-common.c
@@ -204,6 +204,7 @@ GNOKII_API const char 
*gn_connection_type2str(gn_connection_type t)
        case GN_CT_DKU2:        return _("DKU2 (kernel support)");
        case GN_CT_DKU2LIBUSB:  return _("DKU2 (libusb support)");
        case GN_CT_PCSC:        return _("Smart Card reader (libpcsc support)");
+       case GN_CT_SOCKETPHONET:        return _("Linux Phonet (kernel 
support)");
        default:                return _("Unknown");
        }
 }
diff --git a/common/libfunctions.c b/common/libfunctions.c
index 92dff29..fd18099 100644
--- a/common/libfunctions.c
+++ b/common/libfunctions.c
@@ -501,7 +501,10 @@ static struct { gn_connection_type ct; const char *str; } 
connectiontypes[] = {
 #ifndef WIN32
        { GN_CT_TCP,        "tcp" },
 #endif
-       { GN_CT_Tekram,     "tekram" }
+       { GN_CT_Tekram,     "tekram" },
+#ifdef HAVE_SOCKETPHONET
+       { GN_CT_SOCKETPHONET, "phonet" },
+#endif
 };
 
 GNOKII_API gn_connection_type gn_get_connectiontype(const char 
*connection_type_string)
@@ -571,6 +574,12 @@ GNOKII_API int 
gn_lib_is_connectiontype_supported(gn_connection_type ct)
 #else
                return 1;
 #endif
+       case GN_CT_SOCKETPHONET:
+#ifndef HAVE_SOCKETPHONET
+               return 0;
+#else
+               return 1;
+#endif
        default:
                return 0;
        }
diff --git a/common/links/Makefile.am b/common/links/Makefile.am
index 118be48..c4301bf 100644
--- a/common/links/Makefile.am
+++ b/common/links/Makefile.am
@@ -5,6 +5,7 @@ libLINKS_la_SOURCES = \
        atbus.c \
        fbus.c \
        fbus-phonet.c \
+       socket-phonet.c \
        fbus-3110.c \
        m2bus.c \
        gnbus.c \
diff --git a/common/links/fbus-phonet.c b/common/links/fbus-phonet.c
index ebec49e..37a69b2 100644
--- a/common/links/fbus-phonet.c
+++ b/common/links/fbus-phonet.c
@@ -323,6 +323,7 @@ gn_error phonet_initialise(struct gn_statemachine *state)
        case GN_CT_DKU2:
        case GN_CT_DKU2LIBUSB:
        case GN_CT_Bluetooth:
+       case GN_CT_SOCKETPHONET:
                if (phonet_open(state) == true)
                        error = GN_ERR_NONE;
                break;
diff --git a/common/phones/nk6510.c b/common/phones/nk6510.c
index cd4d5b1..ea7ef68 100644
--- a/common/phones/nk6510.c
+++ b/common/phones/nk6510.c
@@ -47,6 +47,7 @@
 #include "phones/nk6510.h"
 #include "links/fbus.h"
 #include "links/fbus-phonet.h"
+#include "links/socket-phonet.h"
 #include "phones/nokia.h"
 #include "map.h"
 
@@ -625,6 +626,7 @@ static gn_error NK6510_Initialise(struct gn_statemachine 
*state)
                case GN_CT_DKU2:
                case GN_CT_DKU2LIBUSB:
                case GN_CT_Irda:
+               case GN_CT_SOCKETPHONET:
                        err = phonet_initialise(state);
                        /* Don't loop forever */
                        attempt = 3;
diff --git a/configure.in b/configure.in
index 13d6649..f6a57e2 100644
--- a/configure.in
+++ b/configure.in
@@ -447,6 +447,21 @@ if test "$enable_libusb" = "yes"; then
        )
 fi
 
+dnl ======================== Checks for Linux Phonet support
+USE_SOCKETPHONET="no"
+AC_ARG_ENABLE(phonet,
+              AC_HELP_STRING([--disable-phonet],
+                             [disable phonet support (default is autodetected)]
+                            ),,
+              [enable_phonet=yes])
+if test "$enable_phonet" = "yes"; then
+       AC_CHECK_HEADER(linux/phonet.h,
+               [AC_DEFINE(HAVE_SOCKETPHONET, 1, [Whether Phonet is available])
+                USE_SOCKETPHONET="yes"],,
+               [#include <sys/socket.h>
+                #include <linux/phonet.h>])
+fi
+
 dnl ======================== Checks for gethostbyname support
 AC_CHECK_FUNC(gethostbyname, ,
        AC_CHECK_LIB(nsl, gethostbyname, TCP_LIBS="-lnsl"
@@ -1034,6 +1049,7 @@ AC_SUBST(WIN32_CROSS)
 
 AC_SUBST(HAVE_LIBICAL)
 AC_SUBST(HAVE_LIBUSB)
+AC_SUBST(HAVE_SOCKETPHONET)
 
 AC_OUTPUT(
          Makefile
@@ -1106,6 +1122,7 @@ echo "
     ical read support:  $USE_LIBICAL
     Bluetooth:          $USE_BLUETOOTH
     libusb support:     $USE_LIBUSB
+    phonet support:     $USE_SOCKETPHONET
     libpcsclite support:$USE_LIBPCSCLITE
     readline support:   $USE_READLINE
     Security:           $security
diff --git a/include/devices/socketphonet.h b/include/devices/socketphonet.h
new file mode 100644
index 0000000..83a4939
--- /dev/null
+++ b/include/devices/socketphonet.h
@@ -0,0 +1,41 @@
+/*
+
+  G N O K I I
+
+  A Linux/Unix toolset and driver for the mobile phones.
+
+  This file is part of gnokii.
+
+  Gnokii 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 2 of the License, or
+  (at your option) any later version.
+
+  Gnokii 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 gnokii; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+  Copyright (C) 2010 Daniele Forsi
+
+  This file provides an API for accessing functions via the phonet Linux 
kernel module.
+  See README for more details on supported mobile phones.
+
+  The various routines are called socketphonet_(whatever).
+
+*/
+
+#ifndef _gnokii_devices_linuxphonet_h
+#define _gnokii_devices_linuxphonet_h
+
+int socketphonet_close(struct gn_statemachine *state);
+int socketphonet_open(const char *interface, int with_async, struct 
gn_statemachine *state);
+size_t socketphonet_read(int fd, __ptr_t buf, size_t nbytes, struct 
gn_statemachine *state);
+size_t socketphonet_write(int fd, const __ptr_t buf, size_t n, struct 
gn_statemachine *state);
+int socketphonet_select(int fd, struct timeval *timeout, struct 
gn_statemachine *state);
+
+#endif /* #ifndef _gnokii_devices_linuxphonet_h */
diff --git a/include/gnokii/common.h b/include/gnokii/common.h
index c003f06..45df638 100644
--- a/include/gnokii/common.h
+++ b/include/gnokii/common.h
@@ -53,7 +53,8 @@ typedef enum {
        GN_CT_M2BUS,    /* Serial connection with M2BUS protocol */
        GN_CT_DKU2,     /* DKU2 usb connection using nokia_dku2 kernel driver */
        GN_CT_DKU2LIBUSB, /* DKU2 usb connection using libusb */
-       GN_CT_PCSC      /* PC/SC SIM Card reader using libpsclite */
+       GN_CT_PCSC,     /* PC/SC SIM Card reader using libpsclite */
+       GN_CT_SOCKETPHONET /* Linux PHONET kernel driver */
 } gn_connection_type;
 
 GNOKII_API const char *gn_connection_type2str(gn_connection_type t);

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                          |    3 +
 Docs/README-6510                                   |   17 ++
 Docs/sample/gnokiirc                               |   20 ++-
 common/device.c                                    |   16 ++-
 common/devices/Makefile.am                         |    3 +-
 common/devices/socketphonet.c                      |  173 ++++++++++++++++++++
 common/gsm-common.c                                |    1 +
 common/libfunctions.c                              |   11 +-
 common/links/Makefile.am                           |    1 +
 common/links/fbus-phonet.c                         |    1 +
 common/phones/nk6510.c                             |    2 +
 configure.in                                       |   17 ++
 include/{phones/atsam.h => devices/socketphonet.h} |   24 ++--
 include/gnokii/common.h                            |    3 +-
 14 files changed, 269 insertions(+), 23 deletions(-)
 create mode 100644 common/devices/socketphonet.c
 copy include/{phones/atsam.h => devices/socketphonet.h} (55%)


hooks/post-receive
-- 
libgnokii and core programs



reply via email to

[Prev in Thread] Current Thread [Next in Thread]