Browse Source

Unfinished nl changes

Serj Kalichev 10 years ago
parent
commit
36b4ee071a
2 changed files with 20 additions and 8 deletions
  1. 13 5
      nl.c
  2. 7 3
      nl.h

+ 13 - 5
nl.c

@@ -11,7 +11,7 @@
 
 #include "nl.h"
 
-int nl_init(void)
+nl_fds_t * nl_init(void)
 {
 	struct sockaddr_nl nl_addr;
 	int nl;
@@ -34,13 +34,21 @@ int nl_init(void)
 	return nl;
 }
 
-void nl_close(int nl)
+void nl_close(nl_fds_t *nl_fds)
 {
-	if (nl >= 0)
-		close(nl);
+	int fd;
+	int i;
+
+	if (!nl_fds)
+		return;
+
+	for (i = 0; i < NL_FDS_LEN; i++) {
+		if (nl_fds[i] >= 0)
+			close(nl_fds[i]);
+	}
 }
 
-int nl_poll(int nl, int timeout)
+int nl_poll(nl_fds_t *nl_fds, int timeout)
 {
 	struct pollfd pfd;
 	char buf[10];

+ 7 - 3
nl.h

@@ -1,8 +1,12 @@
 #ifndef _nl_h
 #define _nl_h
 
-int nl_init(void);
-void nl_close(int nl);
-int nl_poll(int nl, int timeout);
+#define NL_FDS_LEN 2
+
+typedef int nl_fds_t;
+
+nl_fds_t * nl_init(void);
+void nl_close(nl_fds_t *nl_fds);
+int nl_poll(nl_fds_t *nl_fds, int timeout);
 
 #endif