summaryrefslogtreecommitdiff
path: root/gisi
diff options
context:
space:
mode:
authorAki Niemi <aki.niemi@nokia.com>2010-04-21 10:47:16 +0300
committerAki Niemi <aki.niemi@nokia.com>2010-04-21 10:48:29 +0300
commit22103491a4171a55a2593bb1b727b086c13df7c6 (patch)
treef96b7673ab33732c62137b495bd3723d52a624bd /gisi
parent3dc106c627f858317df5d15ed019673cd8c83193 (diff)
downloadofono-22103491a4171a55a2593bb1b727b086c13df7c6.tar.gz
gisi: move g_isi_modem_by_name to separate file
This fixes build warnings that resulted from conflicts between linux/if.h and net/if.h.
Diffstat (limited to 'gisi')
-rw-r--r--gisi/modem.c36
-rw-r--r--gisi/modem.h27
-rw-r--r--gisi/netlink.c23
3 files changed, 59 insertions, 27 deletions
diff --git a/gisi/modem.c b/gisi/modem.c
new file mode 100644
index 00000000..dedec56e
--- /dev/null
+++ b/gisi/modem.c
@@ -0,0 +1,36 @@
+/**
+ * Copyright (C) 2010 Nokia Corporation. All rights reserved.
+ *
+ * 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 published by the Free Software Foundation.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <errno.h>
+#include <net/if.h>
+
+#include "modem.h"
+
+GIsiModem *g_isi_modem_by_name(char const *name)
+{
+ unsigned index = if_nametoindex(name);
+
+ if (errno == 0)
+ errno = ENODEV;
+
+ return (GIsiModem *)(void *)(uintptr_t)index;
+}
diff --git a/gisi/modem.h b/gisi/modem.h
index 7c314e4e..1a36288f 100644
--- a/gisi/modem.h
+++ b/gisi/modem.h
@@ -1,5 +1,7 @@
-/**
- * Copyright (C) 2009 Nokia Corporation. All rights reserved.
+/*
+ * This file is part of oFono - Open Source Telephony
+ *
+ * Copyright (C) 2010 Nokia Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -15,11 +17,19 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
-#ifndef GISI_MODEM_H
-#define GISI_MODEM_H
+
+#ifndef __GISI_MODEM_H
+#define __GISI_MODEM_H
#include <stdint.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void (*GIsiDebugFunc) (const void *restrict data, size_t len,
+ void *opaque);
+
typedef struct _GIsiModem GIsiModem;
static inline unsigned g_isi_modem_index(GIsiModem *m)
@@ -27,9 +37,10 @@ static inline unsigned g_isi_modem_index(GIsiModem *m)
return (uintptr_t)m;
}
-GIsiModem *g_isi_modem_by_name(char const *name);
-
-typedef void (*GIsiDebugFunc) (const void *restrict data, size_t len,
- void *opaque);
+GIsiModem *g_isi_modem_by_name(const char *name);
+#ifdef __cplusplus
+}
#endif
+
+#endif /* __GISI_MODEM_H */
diff --git a/gisi/netlink.c b/gisi/netlink.c
index 6e37b333..1a18b458 100644
--- a/gisi/netlink.c
+++ b/gisi/netlink.c
@@ -76,21 +76,6 @@ struct _GPhonetNetlink {
unsigned interface;
};
-/* if_nametoindex is in #include <net/if.h>,
- but it is not compatible with <linux/if.h> */
-
-extern unsigned if_nametoindex (char const *name);
-
-GIsiModem *g_isi_modem_by_name(char const *name)
-{
- unsigned index = if_nametoindex(name);
-
- if (errno == 0)
- errno = ENODEV;
-
- return (GIsiModem *)(void *)(uintptr_t)index;
-}
-
static inline GIsiModem *make_modem(unsigned idx)
{
return (void *)(uintptr_t)idx;
@@ -113,15 +98,15 @@ GPhonetNetlink *g_pn_netlink_by_modem(GIsiModem *idx)
return NULL;
}
-GPhonetNetlink *g_pn_netlink_by_name(char const *ifname)
+GPhonetNetlink *g_pn_netlink_by_name(const char *ifname)
{
if (ifname == NULL) {
return g_pn_netlink_by_modem(make_modem(0));
} else {
- unsigned index = if_nametoindex(ifname);
- if (index == 0)
+ GIsiModem *idx = g_isi_modem_by_name(ifname);
+ if (!idx)
return NULL;
- return g_pn_netlink_by_modem(make_modem(index));
+ return g_pn_netlink_by_modem(idx);
}
}