libnmb: Move "read_packet" to nmbd
authorVolker Lendecke <vl@samba.org>
Tue, 16 Jan 2018 15:21:08 +0000 (16:21 +0100)
committerJeremy Allison <jra@samba.org>
Wed, 24 Jan 2018 04:48:19 +0000 (05:48 +0100)
It's only used there

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Jan 24 05:48:19 CET 2018 on sn-devel-144

source3/libsmb/nmblib.c
source3/libsmb/nmblib.h
source3/nmbd/nmbd_packets.c

index c262c2820e286f825482cb7843a1dd6ed156145a..bac43400b3a53d8a037bb249e423f709d11cc1f4 100644 (file)
@@ -874,41 +874,6 @@ struct packet_struct *parse_packet_talloc(TALLOC_CTX *mem_ctx,
        return result;
 }
 
-/*******************************************************************
- 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.
-******************************************************************/
-
-struct packet_struct *read_packet(int fd,enum packet_type packet_type)
-{
-       struct packet_struct *packet;
-       struct sockaddr_storage sa;
-       struct sockaddr_in *si = (struct sockaddr_in *)&sa;
-       char buf[MAX_DGRAM_SIZE];
-       int length;
-
-       length = read_udp_v4_socket(fd,buf,sizeof(buf),&sa);
-       if (length < MIN_DGRAM_SIZE || sa.ss_family != AF_INET) {
-               return NULL;
-       }
-
-       packet = parse_packet(buf,
-                       length,
-                       packet_type,
-                       si->sin_addr,
-                       ntohs(si->sin_port));
-       if (!packet)
-               return NULL;
-
-       packet->recv_fd = fd;
-       packet->send_fd = -1;
-
-       DEBUG(5,("Received a packet of len %d from (%s) port %d\n",
-                length, inet_ntoa(packet->ip), packet->port ) );
-
-       return(packet);
-}
-
 /*******************************************************************
  Send a udp packet on a already open socket.
 ******************************************************************/
index 1956ea7efdffba74a4e8e5f5d820edb0bd052e2b..a0624ed085c0f78296501e4c7f80b51e8a5f3a66 100644 (file)
@@ -44,7 +44,6 @@ struct packet_struct *parse_packet_talloc(TALLOC_CTX *mem_ctx,
                                          enum packet_type packet_type,
                                          struct in_addr ip,
                                          int port);
-struct packet_struct *read_packet(int fd,enum packet_type packet_type);
 void make_nmb_name( struct nmb_name *n, const char *name, int type);
 bool nmb_name_equal(struct nmb_name *n1, struct nmb_name *n2);
 int build_packet(char *buf, size_t buflen, struct packet_struct *p);
index 2b7cc82f341e66e09d42af13be66971ceed2f0a4..bbcb9582ec5d260ddb7c7ae75fc700109905242d 100644 (file)
@@ -1879,6 +1879,41 @@ static void nmbd_fd_handler(struct tevent_context *ev,
        attr->triggered = true;
 }
 
+/*******************************************************************
+ 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.
+******************************************************************/
+
+static struct packet_struct *read_packet(int fd,enum packet_type packet_type)
+{
+       struct packet_struct *packet;
+       struct sockaddr_storage sa;
+       struct sockaddr_in *si = (struct sockaddr_in *)&sa;
+       char buf[MAX_DGRAM_SIZE];
+       int length;
+
+       length = read_udp_v4_socket(fd,buf,sizeof(buf),&sa);
+       if (length < MIN_DGRAM_SIZE || sa.ss_family != AF_INET) {
+               return NULL;
+       }
+
+       packet = parse_packet(buf,
+                       length,
+                       packet_type,
+                       si->sin_addr,
+                       ntohs(si->sin_port));
+       if (!packet)
+               return NULL;
+
+       packet->recv_fd = fd;
+       packet->send_fd = -1;
+
+       DEBUG(5,("Received a packet of len %d from (%s) port %d\n",
+                length, inet_ntoa(packet->ip), packet->port ) );
+
+       return(packet);
+}
+
 /****************************************************************************
   Listens for NMB or DGRAM packets, and queues them.
   return True if the socket is dead