aboutsummaryrefslogtreecommitdiff
path: root/src/inet.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/inet.c')
-rw-r--r--src/inet.c43
1 files changed, 4 insertions, 39 deletions
diff --git a/src/inet.c b/src/inet.c
index b7f3ae5..312a45b 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -1,8 +1,10 @@
1/*=========================================================================*\ 1/*=========================================================================*\
2* Internet domain functions 2* Internet domain functions
3* LuaSocket toolkit
3* 4*
4* RCS ID: $Id$ 5* RCS ID: $Id$
5\*=========================================================================*/ 6\*=========================================================================*/
7#include <stdio.h>
6#include <string.h> 8#include <string.h>
7 9
8#include <lua.h> 10#include <lua.h>
@@ -16,7 +18,6 @@
16\*=========================================================================*/ 18\*=========================================================================*/
17static int inet_global_toip(lua_State *L); 19static int inet_global_toip(lua_State *L);
18static int inet_global_tohostname(lua_State *L); 20static int inet_global_tohostname(lua_State *L);
19
20static void inet_pushresolved(lua_State *L, struct hostent *hp); 21static void inet_pushresolved(lua_State *L, struct hostent *hp);
21 22
22static luaL_reg func[] = { 23static luaL_reg func[] = {
@@ -43,11 +44,6 @@ void inet_open(lua_State *L)
43/*-------------------------------------------------------------------------*\ 44/*-------------------------------------------------------------------------*\
44* Returns all information provided by the resolver given a host name 45* Returns all information provided by the resolver given a host name
45* or ip address 46* or ip address
46* Lua Input: address
47* address: ip address or hostname to dns lookup
48* Lua Returns
49* On success: first IP address followed by a resolved table
50* On error: nil, followed by an error message
51\*-------------------------------------------------------------------------*/ 47\*-------------------------------------------------------------------------*/
52static int inet_global_toip(lua_State *L) 48static int inet_global_toip(lua_State *L)
53{ 49{
@@ -72,11 +68,6 @@ static int inet_global_toip(lua_State *L)
72/*-------------------------------------------------------------------------*\ 68/*-------------------------------------------------------------------------*\
73* Returns all information provided by the resolver given a host name 69* Returns all information provided by the resolver given a host name
74* or ip address 70* or ip address
75* Lua Input: address
76* address: ip address or host name to reverse dns lookup
77* Lua Returns
78* On success: canonic name followed by a resolved table
79* On error: nil, followed by an error message
80\*-------------------------------------------------------------------------*/ 71\*-------------------------------------------------------------------------*/
81static int inet_global_tohostname(lua_State *L) 72static int inet_global_tohostname(lua_State *L)
82{ 73{
@@ -102,11 +93,6 @@ static int inet_global_tohostname(lua_State *L)
102\*=========================================================================*/ 93\*=========================================================================*/
103/*-------------------------------------------------------------------------*\ 94/*-------------------------------------------------------------------------*\
104* Retrieves socket peer name 95* Retrieves socket peer name
105* Input:
106* sock: socket
107* Lua Returns
108* On success: ip address and port of peer
109* On error: nil
110\*-------------------------------------------------------------------------*/ 96\*-------------------------------------------------------------------------*/
111int inet_meth_getpeername(lua_State *L, p_sock ps) 97int inet_meth_getpeername(lua_State *L, p_sock ps)
112{ 98{
@@ -123,11 +109,6 @@ int inet_meth_getpeername(lua_State *L, p_sock ps)
123 109
124/*-------------------------------------------------------------------------*\ 110/*-------------------------------------------------------------------------*\
125* Retrieves socket local name 111* Retrieves socket local name
126* Input:
127* sock: socket
128* Lua Returns
129* On success: local ip address and port
130* On error: nil
131\*-------------------------------------------------------------------------*/ 112\*-------------------------------------------------------------------------*/
132int inet_meth_getsockname(lua_State *L, p_sock ps) 113int inet_meth_getsockname(lua_State *L, p_sock ps)
133{ 114{
@@ -147,8 +128,6 @@ int inet_meth_getsockname(lua_State *L, p_sock ps)
147\*=========================================================================*/ 128\*=========================================================================*/
148/*-------------------------------------------------------------------------*\ 129/*-------------------------------------------------------------------------*\
149* Passes all resolver information to Lua as a table 130* Passes all resolver information to Lua as a table
150* Input
151* hp: hostent structure returned by resolver
152\*-------------------------------------------------------------------------*/ 131\*-------------------------------------------------------------------------*/
153static void inet_pushresolved(lua_State *L, struct hostent *hp) 132static void inet_pushresolved(lua_State *L, struct hostent *hp)
154{ 133{
@@ -185,12 +164,6 @@ static void inet_pushresolved(lua_State *L, struct hostent *hp)
185 164
186/*-------------------------------------------------------------------------*\ 165/*-------------------------------------------------------------------------*\
187* Tries to connect to remote address (address, port) 166* Tries to connect to remote address (address, port)
188* Input
189* ps: pointer to socket
190* address: host name or ip address
191* port: port number to bind to
192* Returns
193* NULL in case of success, error message otherwise
194\*-------------------------------------------------------------------------*/ 167\*-------------------------------------------------------------------------*/
195const char *inet_tryconnect(p_sock ps, const char *address, 168const char *inet_tryconnect(p_sock ps, const char *address,
196 unsigned short port) 169 unsigned short port)
@@ -224,12 +197,6 @@ const char *inet_tryconnect(p_sock ps, const char *address,
224 197
225/*-------------------------------------------------------------------------*\ 198/*-------------------------------------------------------------------------*\
226* Tries to bind socket to (address, port) 199* Tries to bind socket to (address, port)
227* Input
228* sock: pointer to socket
229* address: host name or ip address
230* port: port number to bind to
231* Returns
232* NULL in case of success, error message otherwise
233\*-------------------------------------------------------------------------*/ 200\*-------------------------------------------------------------------------*/
234const char *inet_trybind(p_sock ps, const char *address, unsigned short port, 201const char *inet_trybind(p_sock ps, const char *address, unsigned short port,
235 int backlog) 202 int backlog)
@@ -264,10 +231,6 @@ const char *inet_trybind(p_sock ps, const char *address, unsigned short port,
264 231
265/*-------------------------------------------------------------------------*\ 232/*-------------------------------------------------------------------------*\
266* Tries to create a new inet socket 233* Tries to create a new inet socket
267* Input
268* sock: pointer to socket
269* Returns
270* NULL if successfull, error message on error
271\*-------------------------------------------------------------------------*/ 234\*-------------------------------------------------------------------------*/
272const char *inet_trycreate(p_sock ps, int type) 235const char *inet_trycreate(p_sock ps, int type)
273{ 236{
@@ -299,3 +262,5 @@ int inet_aton(const char *cp, struct in_addr *inp)
299 return 1; 262 return 1;
300} 263}
301#endif 264#endif
265
266