From: <lu...@us...> - 2003-05-05 20:41:54
|
Update of /cvsroot/jungerl/jungerl/lib/tuntap/src In directory sc8-pr-cvs1:/tmp/cvs-serv14643/src Modified Files: tuntap.erl Log Message: Added flow control: tuntap:set_active(Tap, true|false|once). There is no blocking-read function for active-false. However, you can achieve this by setting active-once and waiting until a message arrives. Index: tuntap.erl =================================================================== RCS file: /cvsroot/jungerl/jungerl/lib/tuntap/src/tuntap.erl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- tuntap.erl 6 Mar 2003 06:58:30 -0000 1.4 +++ tuntap.erl 5 May 2003 20:41:50 -0000 1.5 @@ -17,13 +17,18 @@ -export([init/0, open_tun/0, open_tap/0, open_tuntap/2, - device_name/1, write/2]). + device_name/1, write/2, set_active/2]). -define(REPLY_ERROR, 0). -define(REPLY_OK, 1). -define(REQUEST_GET_DEVICE, 0). -define(REQUEST_WRITE, 1). +-define(REQUEST_ACTIVE, 2). + +-define(ACTIVE_FALSE, 0). +-define(ACTIVE_TRUE, 1). +-define(ACTIVE_ONCE, 2). %% Returns: ok init() -> @@ -55,5 +60,13 @@ %% Returns: ok write(Port, Packet) -> [?REPLY_OK] = erlang:port_control(Port, ?REQUEST_WRITE, Packet), + ok. + +set_active(Port, false) -> set_active1(Port, ?ACTIVE_FALSE); +set_active(Port, true) -> set_active1(Port, ?ACTIVE_TRUE); +set_active(Port, once) -> set_active1(Port, ?ACTIVE_ONCE). + +set_active1(Port, Arg) -> + [?REPLY_OK] = erlang:port_control(Port, ?REQUEST_ACTIVE, [Arg]), ok. |