lib: Move read_udp_v4_socket() to nmbd
authorVolker Lendecke <vl@samba.org>
Fri, 17 Jul 2020 10:40:28 +0000 (12:40 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 17 Aug 2020 19:35:37 +0000 (19:35 +0000)
This is the only consumer of it

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/include/proto.h
source3/lib/util_sock.c
source3/nmbd/nmbd_packets.c

index fe3acde078ebc192ffaf6985969a50d2d7d58bd2..1c505579b9dbf37683ef85c5f978c475619f774e 100644 (file)
@@ -525,10 +525,6 @@ const char *client_socket_addr(int fd, char *addr, size_t addr_len);
 int client_socket_port(int fd);
 bool is_a_socket(int fd);
 void set_socket_options(int fd, const char *options);
-ssize_t read_udp_v4_socket(int fd,
-                       char *buf,
-                       size_t len,
-                       struct sockaddr_storage *psa);
 NTSTATUS read_fd_with_timeout(int fd, char *buf,
                                  size_t mincnt, size_t maxcnt,
                                  unsigned int time_out,
index fb64c0e61cd782280aae2e8351cf549b49205c16..590e8f4d55c6a7f89aac8b1bb3721e7b4cd79066 100644 (file)
@@ -56,48 +56,6 @@ bool is_a_socket(int fd)
        return(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&v, &l) == 0);
 }
 
-/****************************************************************************
- Read from a socket.
-****************************************************************************/
-
-ssize_t read_udp_v4_socket(int fd,
-                       char *buf,
-                       size_t len,
-                       struct sockaddr_storage *psa)
-{
-       ssize_t ret;
-       socklen_t socklen = sizeof(*psa);
-       struct sockaddr_in *si = (struct sockaddr_in *)psa;
-
-       memset((char *)psa,'\0',socklen);
-
-       ret = (ssize_t)sys_recvfrom(fd,buf,len,0,
-                       (struct sockaddr *)psa,&socklen);
-       if (ret <= 0) {
-               /* Don't print a low debug error for a non-blocking socket. */
-               if (errno == EAGAIN) {
-                       DEBUG(10,("read_udp_v4_socket: returned EAGAIN\n"));
-               } else {
-                       DEBUG(2,("read_udp_v4_socket: failed. errno=%s\n",
-                               strerror(errno)));
-               }
-               return 0;
-       }
-
-       if (psa->ss_family != AF_INET) {
-               DEBUG(2,("read_udp_v4_socket: invalid address family %d "
-                       "(not IPv4)\n", (int)psa->ss_family));
-               return 0;
-       }
-
-       DEBUG(10,("read_udp_v4_socket: ip %s port %d read: %lu\n",
-                       inet_ntoa(si->sin_addr),
-                       si->sin_port,
-                       (unsigned long)ret));
-
-       return ret;
-}
-
 /****************************************************************************
  Read data from a file descriptor with a timout in msec.
  mincount = if timeout, minimum to read before returning
index bbcb9582ec5d260ddb7c7ae75fc700109905242d..be9e091f0062d78a33c17a8be3d79b5f12443244 100644 (file)
@@ -1879,6 +1879,49 @@ static void nmbd_fd_handler(struct tevent_context *ev,
        attr->triggered = true;
 }
 
+/****************************************************************************
+ Read from a socket.
+****************************************************************************/
+
+static ssize_t read_udp_v4_socket(
+       int fd,
+       char *buf,
+       size_t len,
+       struct sockaddr_storage *psa)
+{
+       ssize_t ret;
+       socklen_t socklen = sizeof(*psa);
+       struct sockaddr_in *si = (struct sockaddr_in *)psa;
+
+       memset((char *)psa,'\0',socklen);
+
+       ret = (ssize_t)sys_recvfrom(fd,buf,len,0,
+                       (struct sockaddr *)psa,&socklen);
+       if (ret <= 0) {
+               /* Don't print a low debug error for a non-blocking socket. */
+               if (errno == EAGAIN) {
+                       DEBUG(10,("read_udp_v4_socket: returned EAGAIN\n"));
+               } else {
+                       DEBUG(2,("read_udp_v4_socket: failed. errno=%s\n",
+                               strerror(errno)));
+               }
+               return 0;
+       }
+
+       if (psa->ss_family != AF_INET) {
+               DEBUG(2,("read_udp_v4_socket: invalid address family %d "
+                       "(not IPv4)\n", (int)psa->ss_family));
+               return 0;
+       }
+
+       DEBUG(10,("read_udp_v4_socket: ip %s port %d read: %lu\n",
+                       inet_ntoa(si->sin_addr),
+                       si->sin_port,
+                       (unsigned long)ret));
+
+       return ret;
+}
+
 /*******************************************************************
  Read a packet from a socket and parse it, returning a packet ready
  to be used or put on the queue. This assumes a UDP socket.