From 31fbab7eba5d25c5b717ca786b215686ec77b195 Mon Sep 17 00:00:00 2001 From: batrick Date: Tue, 21 Sep 2010 20:01:16 +0000 Subject: [PATCH] Moved receive_buf function (not in use yet, until Lua 5.2) next to other receive functions. --- nse_nsock.cc | 58 ++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/nse_nsock.cc b/nse_nsock.cc index 8d58801b9..9ed3d405c 100644 --- a/nse_nsock.cc +++ b/nse_nsock.cc @@ -587,35 +587,6 @@ static int l_receive_bytes (lua_State *L) return yield(L, nu, "RECEIVE BYTES", FROM, 0, NULL); } -static int l_get_info (lua_State *L) -{ - nse_nsock_udata *nu = check_nsock_udata(L, 1, 1); - int status; - int protocol; // tcp or udp - int af; // address family - struct sockaddr local; - struct sockaddr remote; - char *ipstring_local = (char *) lua_newuserdata(L, sizeof(char) * INET6_ADDRSTRLEN); - char *ipstring_remote = (char *) lua_newuserdata(L, sizeof(char) * INET6_ADDRSTRLEN); - - status = nsi_getlastcommunicationinfo(nu->nsiod, &protocol, &af, - &local, &remote, sizeof(sockaddr)); - - lua_pushboolean(L, true); - lua_pushstring(L, inet_ntop_both(af, &local, ipstring_local)); - lua_pushnumber(L, inet_port_both(af, &local)); - lua_pushstring(L, inet_ntop_both(af, &remote, ipstring_remote)); - lua_pushnumber(L, inet_port_both(af, &remote)); - return 5; -} - -static int l_set_timeout (lua_State *L) -{ - nse_nsock_udata *nu = check_nsock_udata(L, 1, 0); - nu->timeout = luaL_checkint(L, 2); - return success(L); -} - #if 0 /* Lua 5.2 */ static int l_receive_buf (lua_State *L) @@ -686,6 +657,35 @@ static int l_receive_buf (lua_State *L) } #endif +static int l_get_info (lua_State *L) +{ + nse_nsock_udata *nu = check_nsock_udata(L, 1, 1); + int status; + int protocol; // tcp or udp + int af; // address family + struct sockaddr local; + struct sockaddr remote; + char *ipstring_local = (char *) lua_newuserdata(L, sizeof(char) * INET6_ADDRSTRLEN); + char *ipstring_remote = (char *) lua_newuserdata(L, sizeof(char) * INET6_ADDRSTRLEN); + + status = nsi_getlastcommunicationinfo(nu->nsiod, &protocol, &af, + &local, &remote, sizeof(sockaddr)); + + lua_pushboolean(L, true); + lua_pushstring(L, inet_ntop_both(af, &local, ipstring_local)); + lua_pushnumber(L, inet_port_both(af, &local)); + lua_pushstring(L, inet_ntop_both(af, &remote, ipstring_remote)); + lua_pushnumber(L, inet_port_both(af, &remote)); + return 5; +} + +static int l_set_timeout (lua_State *L) +{ + nse_nsock_udata *nu = check_nsock_udata(L, 1, 0); + nu->timeout = luaL_checkint(L, 2); + return success(L); +} + static void sleep_callback (nsock_pool nsp, nsock_event nse, void *ud) { lua_State *L = (lua_State *) ud;