Added prefer_ipv4 bool parameter to resolve_name().
[ira/wip.git] / source3 / utils / smbfilter.c
index d274e0929909b6fdec2e677514dddaf0da31cc16..83de0c4c37482662075a2007074bde51fdbee893 100644 (file)
@@ -91,8 +91,15 @@ static void filter_request(char *buf)
                        d_printf("sesion_request: %s -> %s\n",
                                 name1, name2);
                        if (netbiosname) {
-                               /* replace the destination netbios name */
-                               name_mangle(netbiosname, buf+4, 0x20);
+                               char *mangled = name_mangle(
+                                       talloc_tos(), netbiosname, 0x20);
+                               if (mangled != NULL) {
+                                       /* replace the destination netbios
+                                        * name */
+                                       memcpy(buf+4, mangled,
+                                              name_len(mangled));
+                                       TALLOC_FREE(mangled);
+                               }
                        }
                }
                return;
@@ -141,10 +148,11 @@ static bool send_smb(int fd, char *buffer)
 
 static void filter_child(int c, struct sockaddr_storage *dest_ss)
 {
-       int s;
+       NTSTATUS status;
+       int s = -1;
 
        /* we have a connection from a new client, now connect to the server */
-       s = open_socket_out(SOCK_STREAM, dest_ss, 445, LONG_CONNECT_TIMEOUT);
+       status = open_socket_out(dest_ss, 445, LONG_CONNECT_TIMEOUT, &s);
 
        if (s == -1) {
                char addr[INET6_ADDRSTRLEN];
@@ -212,7 +220,7 @@ static void start_filter(char *desthost)
 
        /* start listening on port 445 locally */
 
-       zero_addr(&my_ss);
+       zero_sockaddr(&my_ss);
        s = open_socket_in(SOCK_STREAM, 445, 0, &my_ss, True);
        
        if (s == -1) {
@@ -224,7 +232,7 @@ static void start_filter(char *desthost)
                d_printf("listen failed\n");
        }
 
-       if (!resolve_name(desthost, &dest_ss, 0x20)) {
+       if (!resolve_name(desthost, &dest_ss, 0x20, false)) {
                d_printf("Unable to resolve host %s\n", desthost);
                exit(1);
        }