chiark
/
gitweb
/
~ian
/
chiark-tcl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
scriptinv supports xargs and adns uses them
[chiark-tcl.git]
/
tuntap
/
tuntap.c
diff --git
a/tuntap/tuntap.c
b/tuntap/tuntap.c
index 8de8247416007bd913555a6dfeb2f91ed3330d5f..9deec5745a6cea82b4ae479d51dfa55bf6068f37 100644
(file)
--- a/
tuntap/tuntap.c
+++ b/
tuntap/tuntap.c
@@
-12,7
+12,6
@@
#include "tables.h"
#include "hbytes.h"
#include "tables.h"
#include "hbytes.h"
-#include "hbytes.h"
#include <sys/ioctl.h>
#include <linux/if.h>
#include <sys/ioctl.h>
#include <linux/if.h>
@@
-27,8
+26,6
@@
typedef struct TunSocket {
char *ifname;
} TuntapSocket;
char *ifname;
} TuntapSocket;
-IdDataTable tuntap_socks= { "tuntap" };
-
int do_tuntap_socket_raw_create(ClientData cd, Tcl_Interp *ip,
const char *ifname, void **sock_r) {
int fd, r;
int do_tuntap_socket_raw_create(ClientData cd, Tcl_Interp *ip,
const char *ifname, void **sock_r) {
int fd, r;
@@
-133,7
+130,7
@@
int do_tuntap_socket_raw_on_transmit(ClientData cd, Tcl_Interp *ip,
cancel(sock);
if (newscript) {
cancel(sock);
if (newscript) {
- rc= scriptinv_set(&sock->script,ip,newscript);
+ rc= scriptinv_set(&sock->script,ip,newscript
,0
);
if (rc) return rc;
sock->mtu= mtu;
if (rc) return rc;
sock->mtu= mtu;
@@
-143,15
+140,24
@@
int do_tuntap_socket_raw_on_transmit(ClientData cd, Tcl_Interp *ip,
return TCL_OK;
}
return TCL_OK;
}
-
int do_tuntap_socket_raw_close(ClientData cd, Tcl_Interp *ip,
void *sock_v) {
+
static void destroy(
void *sock_v) {
TuntapSocket *sock= sock_v;
TuntapSocket *sock= sock_v;
-
- int sockix;
cancel(sock);
close(sock->fd); /* nothing useful to be done with errors */
cancel(sock);
close(sock->fd); /* nothing useful to be done with errors */
- sockix= sock->ix;
TFREE(sock->msg_buf);
TFREE(sock);
TFREE(sock->msg_buf);
TFREE(sock);
- tuntap_socks.a[sockix]= 0;
+}
+
+static void destroy_idtabcb(Tcl_Interp *ip, void *sock_v) {
+ destroy(sock_v);
+}
+
+int do_tuntap_socket_raw_close(ClientData cd, Tcl_Interp *ip, void *sock) {
+ destroy(sock);
+ tabledataid_disposing(ip,sock,&tuntap_socks);
return TCL_OK;
}
return TCL_OK;
}
+
+const IdDataSpec tuntap_socks= {
+ "tuntap", "tuntap-table", destroy_idtabcb
+};