summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am14
-rw-r--r--gisi/modem.c36
-rw-r--r--gisi/modem.h27
-rw-r--r--gisi/netlink.c23
4 files changed, 68 insertions, 32 deletions
diff --git a/Makefile.am b/Makefile.am
index b6df9515..86ccf1b5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -41,11 +41,15 @@ builtin_cflags =
gdbus_sources = gdbus/gdbus.h gdbus/mainloop.c gdbus/object.c gdbus/watch.c
-gisi_sources = gisi/phonet.h gisi/modem.h gisi/netlink.h gisi/netlink.c \
- gisi/socket.h gisi/socket.c gisi/client.h gisi/client.c \
- gisi/server.h gisi/server.c \
- gisi/pep.h gisi/pep.c gisi/pipe.h gisi/pipe.c gisi/iter.h \
- gisi/iter.c gisi/verify.c
+gisi_sources = gisi/modem.h gisi/modem.c \
+ gisi/netlink.h gisi/netlink.c \
+ gisi/socket.h gisi/socket.c \
+ gisi/client.h gisi/client.c \
+ gisi/server.h gisi/server.c \
+ gisi/pep.h gisi/pep.c \
+ gisi/pipe.h gisi/pipe.c \
+ gisi/iter.h gisi/iter.c \
+ gisi/verify.c gisi/phonet.h
gatchat_sources = gatchat/gatchat.h gatchat/gatchat.c \
gatchat/gatresult.h gatchat/gatresult.c \
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);
}
}