summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--reader_linux.c41
-rw-r--r--reader_linux.h3
3 files changed, 47 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 760a07e..f1a77fb 100644
--- a/Makefile
+++ b/Makefile
@@ -2,10 +2,12 @@
CFLAGS += -g -Wall -Wpedantic
CORE_OBJS = control.o reader.o config.o command.o
-PLUGINS = reader_yhy.so
+PLUGINS = reader_yhy.so reader_linux.so
reader_yhy.so: LDLIBS = -lyhy
reader_yhy.so: LDFLAGS += -L. -Wl,-rpath .
+reader_linux.so: LDLIBS += $(shell pkg-config --libs libnl-genl-3.0)
+reader_linux.so: CFLAGS += $(shell pkg-config --cflags libnl-genl-3.0)
%.so: CFLAGS += -shared -fPIC
diff --git a/reader_linux.c b/reader_linux.c
new file mode 100644
index 0000000..588d5f0
--- /dev/null
+++ b/reader_linux.c
@@ -0,0 +1,41 @@
+#include <stdio.h>
+#include <sys/socket.h>
+#include <netlink/netlink.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/ctrl.h>
+#include <linux/nfc.h>
+
+static struct nl_sock* nl_socket = NULL;
+static int genl_group = -1;
+
+int init(){
+ nl_socket = nl_socket_alloc();
+ if(!nl_socket || genl_connect(nl_socket)){
+ printf("Failed to connect to netlink\n");
+ return 1;
+ }
+
+ genl_group = genl_ctrl_resolve(nl_socket, NFC_GENL_NAME);
+ if(genl_group < 0){
+ printf("Failed to resolve NFC netlink control\n");
+ return 1;
+ }
+
+ //TODO
+
+ return 1;
+}
+
+int handle(int fd){
+ //TODO
+ return 1;
+}
+
+int scan(){
+ //TODO
+ return 1;
+}
+
+static void __attribute__((destructor)) cleanup(){
+ nl_socket_free(nl_socket);
+}
diff --git a/reader_linux.h b/reader_linux.h
new file mode 100644
index 0000000..303fbaa
--- /dev/null
+++ b/reader_linux.h
@@ -0,0 +1,3 @@
+int init();
+int handle(int fd);
+int scan();