summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util.c218
1 files changed, 0 insertions, 218 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 2df7689b94..0142c25052 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -2232,224 +2232,6 @@ BOOL client_receive_smb(int fd,char *buffer, unsigned int timeout)
}
/****************************************************************************
- read a message from a udp fd.
-The timeout is in milliseconds
-****************************************************************************/
-BOOL receive_local_message(int fd, char *buffer, int buffer_len, unsigned int timeout)
-{
- struct sockaddr_in from;
- int fromlen = sizeof(from);
- int32 msg_len = 0;
-
- smb_read_error = 0;
-
- if(timeout != 0)
- {
- struct timeval to;
- fd_set fds;
- int selrtn;
-
- FD_ZERO(&fds);
- FD_SET(fd,&fds);
-
- to.tv_sec = timeout / 1000;
- to.tv_usec = (timeout % 1000) * 1000;
-
- selrtn = sys_select(fd+1,&fds,&to);
-
- /* Check if error */
- if(selrtn == -1)
- {
- /* something is wrong. Maybe the socket is dead? */
- smb_read_error = READ_ERROR;
- return False;
- }
-
- /* Did we timeout ? */
- if (selrtn == 0)
- {
- smb_read_error = READ_TIMEOUT;
- return False;
- }
- }
-
- /*
- * Read a loopback udp message.
- */
- msg_len = recvfrom(fd, &buffer[UDP_CMD_HEADER_LEN],
- buffer_len - UDP_CMD_HEADER_LEN, 0,
- (struct sockaddr *)&from, &fromlen);
-
- if(msg_len < 0)
- {
- DEBUG(0,("receive_local_message. Error in recvfrom. (%s).\n",strerror(errno)));
- return False;
- }
-
- /* Validate message length. */
- if(msg_len > (buffer_len - UDP_CMD_HEADER_LEN))
- {
- DEBUG(0,("receive_local_message: invalid msg_len (%d) max can be %d\n",
- msg_len,
- buffer_len - UDP_CMD_HEADER_LEN));
- return False;
- }
-
- /* Validate message from address (must be localhost). */
- if(from.sin_addr.s_addr != htonl(INADDR_LOOPBACK))
- {
- DEBUG(0,("receive_local_message: invalid 'from' address \
-(was %x should be 127.0.0.1\n", from.sin_addr.s_addr));
- return False;
- }
-
- /* Setup the message header */
- SIVAL(buffer,UDP_CMD_LEN_OFFSET,msg_len);
- SSVAL(buffer,UDP_CMD_PORT_OFFSET,ntohs(from.sin_port));
-
- return True;
-}
-
-/****************************************************************************
- structure to hold a linked list of local messages.
- for processing.
-****************************************************************************/
-
-typedef struct {
- ubi_slNode msg_next;
- char *msg_buf;
- int msg_len;
-} pending_message_list;
-
-static ubi_slList smb_oplock_queue = { NULL, (ubi_slNodePtr)&smb_oplock_queue, 0};
-
-/****************************************************************************
- Function to push a message onto the tail of a linked list of smb messages ready
- for processing.
-****************************************************************************/
-
-static BOOL push_local_message(ubi_slList *list_head, char *buf, int msg_len)
-{
- pending_message_list *msg = (pending_message_list *)
- malloc(sizeof(pending_message_list));
-
- if(msg == NULL)
- {
- DEBUG(0,("push_local_message: malloc fail (1)\n"));
- return False;
- }
-
- msg->msg_buf = (char *)malloc(msg_len);
- if(msg->msg_buf == NULL)
- {
- DEBUG(0,("push_local_message: malloc fail (2)\n"));
- free((char *)msg);
- return False;
- }
-
- memcpy(msg->msg_buf, buf, msg_len);
- msg->msg_len = msg_len;
-
- ubi_slAddTail( list_head, msg);
-
- return True;
-}
-
-/****************************************************************************
- Function to push a smb message onto a linked list of local smb messages ready
- for processing.
-****************************************************************************/
-
-BOOL push_oplock_pending_smb_message(char *buf, int msg_len)
-{
- return push_local_message(&smb_oplock_queue, buf, msg_len);
-}
-
-/****************************************************************************
- Do a select on an two fd's - with timeout.
-
- If a local udp message has been pushed onto the
- queue (this can only happen during oplock break
- processing) return this first.
-
- If a pending smb message has been pushed onto the
- queue (this can only happen during oplock break
- processing) return this next.
-
- If the first smbfd is ready then read an smb from it.
- if the second (loopback UDP) fd is ready then read a message
- from it and setup the buffer header to identify the length
- and from address.
- Returns False on timeout or error.
- Else returns True.
-
-The timeout is in milli seconds
-****************************************************************************/
-BOOL receive_message_or_smb(int smbfd, int oplock_fd,
- char *buffer, int buffer_len,
- int timeout, BOOL *got_smb)
-{
- fd_set fds;
- int selrtn;
- struct timeval to;
-
- smb_read_error = 0;
-
- *got_smb = False;
-
- /*
- * Check to see if we already have a message on the smb queue.
- * If so - copy and return it.
- */
-
- if(ubi_slCount(&smb_oplock_queue) != 0)
- {
- pending_message_list *msg = (pending_message_list *)ubi_slRemHead(&smb_oplock_queue);
- memcpy(buffer, msg->msg_buf, MIN(buffer_len, msg->msg_len));
-
- /* Free the message we just copied. */
- free((char *)msg->msg_buf);
- free((char *)msg);
- *got_smb = True;
-
- DEBUG(5,("receive_message_or_smb: returning queued smb message.\n"));
- return True;
- }
-
- FD_ZERO(&fds);
- FD_SET(smbfd,&fds);
- FD_SET(oplock_fd,&fds);
-
- to.tv_sec = timeout / 1000;
- to.tv_usec = (timeout % 1000) * 1000;
-
- selrtn = sys_select(MAX(smbfd,oplock_fd)+1,&fds,timeout>0?&to:NULL);
-
- /* Check if error */
- if(selrtn == -1) {
- /* something is wrong. Maybe the socket is dead? */
- smb_read_error = READ_ERROR;
- return False;
- }
-
- /* Did we timeout ? */
- if (selrtn == 0) {
- smb_read_error = READ_TIMEOUT;
- return False;
- }
-
- if (FD_ISSET(smbfd,&fds))
- {
- *got_smb = True;
- return receive_smb(smbfd, buffer, 0);
- }
- else
- {
- return receive_local_message(oplock_fd, buffer, buffer_len, 0);
- }
-}
-
-/****************************************************************************
send an smb to a fd
****************************************************************************/
BOOL send_smb(int fd,char *buffer)