Implemented VPN_recv()

This commit is contained in:
Pierre Pronchery 2010-09-05 17:07:29 +00:00
parent 4f0b854fe3
commit 00a73199f9
2 changed files with 29 additions and 1 deletions

View File

@ -15,7 +15,8 @@ arg2=STRING,name
ret=INT32 ret=INT32
arg1=INT32,fd arg1=INT32,fd
arg2=BUFFER_IN,buf arg2=BUFFER_IN,buf
arg3=UINT32,flags arg3=UINT32,size
arg4=UINT32,flags
[send] [send]
ret=INT32 ret=INT32

View File

@ -124,6 +124,33 @@ int32_t VPN_connect(uint32_t protocol, String const * uri)
} }
/* VPN_recv */
int32_t VPN_recv(int32_t fd, Buffer * buffer, uint32_t size, uint32_t flags)
{
int32_t ret;
if(_client_check(NULL, fd) == NULL)
return -1;
#ifdef DEBUG
fprintf(stderr, "DEBUG: %s(%d, buf, %u)\n", __func__, fd, flags);
#endif
if(buffer_set_size(buffer, size) != 0)
return -1;
/* FIXME implement flags */
ret = recv(fd, buffer_get_data(buffer), size, 0);
#ifdef DEBUG
fprintf(stderr, "DEBUG: %s(%d, buf, %u) => %d\n", __func__, fd, flags,
ret);
#endif
if(buffer_set_size(buffer, (ret < 0) ? 0 : ret) != 0)
{
memset(buffer_get_data(buffer), 0, size);
return -1;
}
return ret;
}
/* private */ /* private */
/* functions */ /* functions */
/* accessors */ /* accessors */