[0/5] Phonet build work-arounds

Rémi Denis-Courmont remi at remlab.net
Fri Jul 3 07:47:48 PDT 2009


 configure.ac           |   40 ++++++++++++++++++++++++++++++++++++++++
 drivers/atmodem/at.h   |    4 ----
 drivers/isimodem/isi.h |    4 ----
 gisi/client.c          |    8 +++-----
 gisi/netlink.c         |    7 +++----
 gisi/socket.c          |    9 +++------
 6 files changed, 49 insertions(+), 23 deletions(-)

-- 
Rémi Denis-Courmont
-------------- next part --------------
From 44ed0e385e79c1230ecc6a3d583e1095eee7f9a0 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?R=C3=A9mi=20Denis-Courmont?= <remi.denis-courmont at nokia.com>
Date: Thu, 2 Jul 2009 13:43:34 +0300
Subject: [PATCH 1/5] Do not include <config.h> from headers

From: Rémi Denis-Courmont <remi.denis-courmont at nokia.com>

It should be included _first_ in all modules, and it is not proof
against multiple inclusions.
---
 drivers/atmodem/at.h   |    4 ----
 drivers/isimodem/isi.h |    4 ----
 2 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/drivers/atmodem/at.h b/drivers/atmodem/at.h
index 0300282..3cc3cb1 100644
--- a/drivers/atmodem/at.h
+++ b/drivers/atmodem/at.h
@@ -19,10 +19,6 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 struct at_data {
 	GAtChat *parser;
 	struct ofono_modem *modem;
diff --git a/drivers/isimodem/isi.h b/drivers/isimodem/isi.h
index b89a694..e808bfd 100644
--- a/drivers/isimodem/isi.h
+++ b/drivers/isimodem/isi.h
@@ -21,10 +21,6 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 #define DECLARE_FAILURE(e) 			\
 	struct ofono_error e;			\
 	e.type = OFONO_ERROR_TYPE_FAILURE;	\
-- 
1.6.0.4
-------------- next part --------------
From 3a7f8f26eb788a100742f8e64afb11cc7d35e15e Mon Sep 17 00:00:00 2001
From: =?utf-8?q?R=C3=A9mi=20Denis-Courmont?= <remi.denis-courmont at nokia.com>
Date: Thu, 2 Jul 2009 11:20:23 +0300
Subject: [PATCH 2/5] Centralized check for (A|P)F_PHONET

From: Rémi Denis-Courmont <remi.denis-courmont at nokia.com>

---
 configure.ac   |   10 ++++++++++
 gisi/client.c  |    3 ---
 gisi/netlink.c |    3 ---
 gisi/socket.c  |    4 ----
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/configure.ac b/configure.ac
index 9ba745f..a8d0d3f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -80,6 +80,16 @@ AC_SUBST([GDBUS_LIBS], ['$(top_builddir)/gdbus/libgdbus.la $(DBUS_LIBS)'])
 AC_SUBST([GATCHAT_CFLAGS], ['-I$(top_srcdir)/gatchat'])
 AC_SUBST([GATCHAT_LIBS], ['$(top_builddir)/gatchat/libgatchat.la'])
 
+AC_CHECK_DECLS([AF_PHONET], [], [],
+[#include <sys/types.h>
+#include <sys/socket.h>
+])
+AH_BOTTOM(
+[#if !HAVE_DECL_AF_PHONET
+#define AF_PHONET 35
+#define PF_PHONET AF_PHONET
+#endif
+])
 AC_SUBST([GISI_CFLAGS], ['-I$(top_srcdir)'])
 AC_SUBST([GISI_LIBS], ['$(top_builddir)/gisi/libgisi.la'])
 
diff --git a/gisi/client.c b/gisi/client.c
index ae8b030..1d99c80 100644
--- a/gisi/client.c
+++ b/gisi/client.c
@@ -36,9 +36,6 @@
 #include <glib.h>
 #include <linux/types.h>
 #include <linux/phonet.h>
-#ifndef AF_PHONET
-#define AF_PHONET 35
-#endif
 
 #include "socket.h"
 #include "client.h"
diff --git a/gisi/netlink.c b/gisi/netlink.c
index d555588..5689f51 100644
--- a/gisi/netlink.c
+++ b/gisi/netlink.c
@@ -36,9 +36,6 @@
 #ifndef SOL_NETLINK
 #define SOL_NETLINK 270 /* libc!? */
 #endif
-#ifndef AF_PHONET
-#define AF_PHONET 35
-#endif
 #include <linux/rtnetlink.h>
 #include <linux/phonet.h>
 #include <glib.h>
diff --git a/gisi/socket.c b/gisi/socket.c
index 6f72120..ac69009 100644
--- a/gisi/socket.c
+++ b/gisi/socket.c
@@ -35,10 +35,6 @@
 #include <linux/phonet.h>
 #include <glib.h>
 
-#ifndef AF_PHONET
-#define AF_PHONET 35
-#define PF_PHONET AF_PHONET
-#endif
 #include "socket.h"
 
 GIOChannel *phonet_new(uint8_t resource)
-- 
1.6.0.4
-------------- next part --------------
From 02af1c71959afb9a1c1533630f316e29a851da6f Mon Sep 17 00:00:00 2001
From: =?utf-8?q?R=C3=A9mi=20Denis-Courmont?= <remi.denis-courmont at nokia.com>
Date: Thu, 2 Jul 2009 11:07:56 +0300
Subject: [PATCH 3/5] Check and use netphonet/phonet.h instead of linux/phonet.h

From: Rémi Denis-Courmont <remi.denis-courmont at nokia.com>

---
 configure.ac   |    4 ++++
 gisi/client.c  |    5 +++--
 gisi/netlink.c |    4 +++-
 gisi/socket.c  |    5 +++--
 4 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index a8d0d3f..2989956 100644
--- a/configure.ac
+++ b/configure.ac
@@ -80,6 +80,10 @@ AC_SUBST([GDBUS_LIBS], ['$(top_builddir)/gdbus/libgdbus.la $(DBUS_LIBS)'])
 AC_SUBST([GATCHAT_CFLAGS], ['-I$(top_srcdir)/gatchat'])
 AC_SUBST([GATCHAT_LIBS], ['$(top_builddir)/gatchat/libgatchat.la'])
 
+AC_CHECK_HEADERS([netphonet/phonet.h], [], [],
+[#include <sys/types.h>
+#include <sys/socket.h>
+])
 AC_CHECK_DECLS([AF_PHONET], [], [],
 [#include <sys/types.h>
 #include <sys/socket.h>
diff --git a/gisi/client.c b/gisi/client.c
index 1d99c80..555ff30 100644
--- a/gisi/client.c
+++ b/gisi/client.c
@@ -33,9 +33,10 @@
 #include <sys/socket.h>
 #include <sys/uio.h>
 #include <errno.h>
+#ifdef HAVE_NETPHONET_PHONET_H
+#include <netphonet/phonet.h>
+#endif
 #include <glib.h>
-#include <linux/types.h>
-#include <linux/phonet.h>
 
 #include "socket.h"
 #include "client.h"
diff --git a/gisi/netlink.c b/gisi/netlink.c
index 5689f51..45f463e 100644
--- a/gisi/netlink.c
+++ b/gisi/netlink.c
@@ -33,11 +33,13 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/socket.h>
+#ifdef HAVE_NETPHONET_PHONET_H
+#include <netphonet/phonet.h>
+#endif
 #ifndef SOL_NETLINK
 #define SOL_NETLINK 270 /* libc!? */
 #endif
 #include <linux/rtnetlink.h>
-#include <linux/phonet.h>
 #include <glib.h>
 
 #include "netlink.h"
diff --git a/gisi/socket.c b/gisi/socket.c
index ac69009..3f9aa02 100644
--- a/gisi/socket.c
+++ b/gisi/socket.c
@@ -31,8 +31,9 @@
 #include <sys/ioctl.h>
 #include <unistd.h>
 #include <fcntl.h>
-#include <linux/types.h>
-#include <linux/phonet.h>
+#ifdef HAVE_NETPHONET_PHONET_H
+#include <netphonet/phonet.h>
+#endif
 #include <glib.h>
 
 #include "socket.h"
-- 
1.6.0.4
-------------- next part --------------
From 18d147cc5f15b04f8e018f1ae64b297a9742f999 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?R=C3=A9mi=20Denis-Courmont?= <remi.denis-courmont at nokia.com>
Date: Thu, 2 Jul 2009 11:31:05 +0300
Subject: [PATCH 4/5] Replace sockaddr_pn if missing

From: Rémi Denis-Courmont <remi.denis-courmont at nokia.com>

---
 configure.ac |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index 2989956..c5f9d87 100644
--- a/configure.ac
+++ b/configure.ac
@@ -88,11 +88,28 @@ AC_CHECK_DECLS([AF_PHONET], [], [],
 [#include <sys/types.h>
 #include <sys/socket.h>
 ])
+AC_CHECK_TYPES([struct sockaddr_pn], [], [],
+[#include <sys/types.h>
+#include <sys/socket.h>
+#ifdef HAVE_NETPHONET_PHONET_H
+#include <netphonet/phonet.h>
+#endif
+])
 AH_BOTTOM(
 [#if !HAVE_DECL_AF_PHONET
 #define AF_PHONET 35
 #define PF_PHONET AF_PHONET
 #endif
+
+#ifndef HAVE_STRUCT_SOCKADDR_PN
+struct sockaddr_pn {
+	unsigned short	spn_family;
+	unsigned char	spn_obj;
+	unsigned char	spn_dev;
+	unsigned char	spn_resource;
+	unsigned char	spn_zero[11];
+};
+#endif
 ])
 AC_SUBST([GISI_CFLAGS], ['-I$(top_srcdir)'])
 AC_SUBST([GISI_LIBS], ['$(top_builddir)/gisi/libgisi.la'])
-- 
1.6.0.4
-------------- next part --------------
From 1d7d45e6412b657a063c0d6be43e10b1125b1468 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?R=C3=A9mi=20Denis-Courmont?= <remi.denis-courmont at nokia.com>
Date: Fri, 3 Jul 2009 17:34:05 +0300
Subject: [PATCH 5/5] Replace RTNLGRP_PHONET_IFADDR if missing

From: Rémi Denis-Courmont <remi.denis-courmont at nokia.com>

---
 configure.ac |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index c5f9d87..65fad6e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -95,6 +95,11 @@ AC_CHECK_TYPES([struct sockaddr_pn], [], [],
 #include <netphonet/phonet.h>
 #endif
 ])
+AC_CHECK_DECLS([RTNLGRP_PHONET_IFADDR], [], [],
+[#include <sys/types.h>
+#include <sys/socket.h>
+#include <linux/rtnetlink.h>
+])
 AH_BOTTOM(
 [#if !HAVE_DECL_AF_PHONET
 #define AF_PHONET 35
@@ -110,6 +115,10 @@ struct sockaddr_pn {
 	unsigned char	spn_zero[11];
 };
 #endif
+
+#if !HAVE_DECL_RTNLGRP_PHONET_IFADDR
+#define RTNLGRP_PHONET_IFADDR (RTNLGRP_ND_USEROPT + 1)
+#endif
 ])
 AC_SUBST([GISI_CFLAGS], ['-I$(top_srcdir)'])
 AC_SUBST([GISI_LIBS], ['$(top_builddir)/gisi/libgisi.la'])
-- 
1.6.0.4


More information about the ofono mailing list