Implemented VPN_send()

This commit is contained in:
Pierre Pronchery 2010-09-05 17:12:22 +00:00
parent 00a73199f9
commit 16989243a4
2 changed files with 22 additions and 4 deletions

View File

@ -22,4 +22,5 @@ arg4=UINT32,flags
ret=INT32
arg1=INT32,fd
arg2=BUFFER_OUT,buf
arg3=UINT32,flags
arg3=UINT32,size
arg4=UINT32,flags

View File

@ -132,15 +132,16 @@ int32_t VPN_recv(int32_t fd, Buffer * buffer, uint32_t size, uint32_t flags)
if(_client_check(NULL, fd) == NULL)
return -1;
#ifdef DEBUG
fprintf(stderr, "DEBUG: %s(%d, buf, %u)\n", __func__, fd, flags);
fprintf(stderr, "DEBUG: %s(%d, buf, %u, %u)\n", __func__, fd, size,
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);
fprintf(stderr, "DEBUG: %s(%d, buf, %u, %u) => %d\n", __func__, fd,
size, flags, ret);
#endif
if(buffer_set_size(buffer, (ret < 0) ? 0 : ret) != 0)
{
@ -151,6 +152,22 @@ int32_t VPN_recv(int32_t fd, Buffer * buffer, uint32_t size, uint32_t flags)
}
/* VPN_send */
int32_t VPN_send(int32_t fd, Buffer * buffer, uint32_t size, uint32_t flags)
{
if(_client_check(NULL, fd) == NULL)
return -1;
#ifdef DEBUG
fprintf(stderr, "DEBUG: %s(%d, buf, %u, %u)\n", __func__, fd, size,
flags);
#endif
if(buffer_get_size(buffer) < size)
return -error_set_code(1, "%s", strerror(EINVAL));
/* FIXME implement flags */
return send(fd, buffer_get_data(buffer), size, 0);
}
/* private */
/* functions */
/* accessors */