From: Luke G. <lu...@us...> - 2004-03-25 19:15:47
|
Update of /cvsroot/jungerl/jungerl/lib/tuntap/c_src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6506/c_src Modified Files: tun_drv.c Log Message: Use 'output' function instead of 'control' for getting packets. Index: tun_drv.c =================================================================== RCS file: /cvsroot/jungerl/jungerl/lib/tuntap/c_src/tun_drv.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- tun_drv.c 5 May 2003 23:55:23 -0000 1.4 +++ tun_drv.c 25 Mar 2004 19:04:57 -0000 1.5 @@ -23,7 +23,6 @@ #define REPLY_OK 1 #define REQUEST_GET_DEVICE 0 -#define REQUEST_WRITE 1 #define REQUEST_ACTIVE 2 #define ACTIVE_FALSE 0 @@ -134,12 +133,6 @@ switch (cmd) { case REQUEST_GET_DEVICE: return ctl_reply(REPLY_OK, state->dev, strlen(state->dev), rbuf, rsize); - case REQUEST_WRITE: - if (write(state->fd, buf, len) > 0) { - return ctl_reply(REPLY_OK, "", 0, rbuf, rsize); - } else { - return ctl_reply(REPLY_ERROR, "", 0, rbuf, rsize); - } case REQUEST_ACTIVE: state->active = (int)*buf; switch (state->active) { @@ -172,6 +165,13 @@ } } +static void tun_output(ErlDrvData data, char* buf, int len) +{ + struct tun_state *state = (struct tun_state *)data; + if (write(state->fd, buf, len) < 0) + driver_failure_posix(state->port, errno); +} + static void tun_input(ErlDrvData data, ErlDrvEvent nil) { struct tun_state *state = (struct tun_state *)data; @@ -240,6 +240,7 @@ tun_driver_entry.stop = tun_stop; tun_driver_entry.ready_input = tun_input; tun_driver_entry.control = tun_ctl; + tun_driver_entry.output = tun_output; tun_driver_entry.driver_name = "tun_drv"; return &tun_driver_entry; } |