mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
Add read() to socketwrapper. Metze please check.
Jeremy.
This commit is contained in:
parent
ac77482e87
commit
5ce12a0565
@ -121,6 +121,7 @@
|
||||
#define real_sendmsg sendmsg
|
||||
#define real_ioctl ioctl
|
||||
#define real_recv recv
|
||||
#define real_read read
|
||||
#define real_send send
|
||||
#define real_readv readv
|
||||
#define real_writev writev
|
||||
@ -669,7 +670,9 @@ enum swrap_packet_type {
|
||||
SWRAP_SEND_RST,
|
||||
SWRAP_CLOSE_SEND,
|
||||
SWRAP_CLOSE_RECV,
|
||||
SWRAP_CLOSE_ACK
|
||||
SWRAP_CLOSE_ACK,
|
||||
SWRAP_READ,
|
||||
SWRAP_READ_RST
|
||||
};
|
||||
|
||||
struct swrap_file_hdr {
|
||||
@ -2039,6 +2042,34 @@ _PUBLIC_ ssize_t swrap_recv(int s, void *buf, size_t len, int flags)
|
||||
return ret;
|
||||
}
|
||||
|
||||
_PUBLIC_ ssize_t swrap_read(int s, void *buf, size_t len)
|
||||
{
|
||||
int ret;
|
||||
struct socket_info *si = find_socket_info(s);
|
||||
|
||||
if (!si) {
|
||||
return real_read(s, buf, len);
|
||||
}
|
||||
|
||||
if (si->type == SOCK_STREAM) {
|
||||
/* cut down to 1500 byte packets for stream sockets,
|
||||
* which makes it easier to format PCAP capture files
|
||||
* (as the caller will simply continue from here) */
|
||||
len = MIN(len, 1500);
|
||||
}
|
||||
|
||||
ret = real_read(s, buf, len);
|
||||
if (ret == -1 && errno != EAGAIN && errno != ENOBUFS) {
|
||||
swrap_dump_packet(si, NULL, SWRAP_READ_RST, NULL, 0);
|
||||
} else if (ret == 0) { /* END OF FILE */
|
||||
swrap_dump_packet(si, NULL, SWRAP_READ_RST, NULL, 0);
|
||||
} else if (ret > 0) {
|
||||
swrap_dump_packet(si, NULL, SWRAP_READ, buf, ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
_PUBLIC_ ssize_t swrap_send(int s, const void *buf, size_t len, int flags)
|
||||
{
|
||||
|
@ -52,6 +52,7 @@ ssize_t swrap_sendto(int s, const void *buf, size_t len, int flags, const struct
|
||||
ssize_t swrap_sendmsg(int s, const struct msghdr *msg, int flags);
|
||||
int swrap_ioctl(int s, int req, void *ptr);
|
||||
ssize_t swrap_recv(int s, void *buf, size_t len, int flags);
|
||||
ssize_t swrap_read(int s, void *buf, size_t len);
|
||||
ssize_t swrap_send(int s, const void *buf, size_t len, int flags);
|
||||
int swrap_readv(int s, const struct iovec *vector, size_t count);
|
||||
int swrap_writev(int s, const struct iovec *vector, size_t count);
|
||||
@ -124,6 +125,11 @@ int swrap_close(int);
|
||||
#endif
|
||||
#define recv(s,buf,len,flags) swrap_recv(s,buf,len,flags)
|
||||
|
||||
#ifdef read
|
||||
#undef read
|
||||
#endif
|
||||
#define read(s,buf,len) swrap_read(s,buf,len)
|
||||
|
||||
#ifdef send
|
||||
#undef send
|
||||
#endif
|
||||
|
@ -1100,7 +1100,7 @@ REPLACETORT_OBJ = @libreplacedir@/test/testsuite.o \
|
||||
@libreplacedir@/test/os2_delete.o \
|
||||
@libreplacedir@/test/strptime.o \
|
||||
@libreplacedir@/test/main.o \
|
||||
$(LIBREPLACE_OBJ)
|
||||
$(LIBREPLACE_OBJ) $(SOCKET_WRAPPER_OBJ)
|
||||
|
||||
DEBUG2HTML_OBJ = utils/debug2html.o utils/debugparse.o
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user