Rename obscure defined constants.
authorChristopher R. Hertel (crh) <crh@samba.org>
Wed, 15 Feb 2012 03:51:35 +0000 (21:51 -0600)
committerSimo Sorce <idra@samba.org>
Thu, 16 Feb 2012 07:29:41 +0000 (08:29 +0100)
Replaced the undescriptive SMB_PORT1 and SMB_PORT2 defined constants
with the slightly more descriptive names NBT_SMB_PORT and TCP_SMB_PORT.
Also replaced several hard-coded references to the well-known port
numbers (139 and 445, respectively) as appropriate.

Small changes to clarify some comments regarding the two transport
types.

Signed-off-by: Simo Sorce <idra@samba.org>
Autobuild-User: Simo Sorce <idra@samba.org>
Autobuild-Date: Thu Feb 16 08:29:41 CET 2012 on sn-devel-104

source3/auth/auth_ntlmssp.c
source3/client/client.c
source3/include/smb.h
source3/lib/util_sock.c
source3/libsmb/libsmb_server.c
source3/libsmb/smbsock_connect.c
source3/nmbd/nmbd_synclists.c
source3/smbd/reply.c
source3/torture/torture.c
source3/utils/smbfilter.c
source3/winbindd/winbindd_cm.c

index 00a99c3f374e04c1390502864f1c2a7dd7eb5104..b5935e6b282783cac6c43348c4e97480d49423c1 100644 (file)
@@ -143,8 +143,8 @@ static NTSTATUS auth_ntlmssp_check_password(struct ntlmssp_state *ntlmssp_state,
        NTSTATUS nt_status;
        bool username_was_mapped;
 
-       /* the client has given us its machine name (which we otherwise would not get on port 445).
-          we need to possibly reload smb.conf if smb.conf includes depend on the machine name */
+       /* The client has given us its machine name (which we only get over NBT transport).
+          We need to possibly reload smb.conf if smb.conf includes depend on the machine name. */
 
        set_remote_machine_name(gensec_ntlmssp->ntlmssp_state->client.netbios_name, True);
 
index 89fd1d48957d64a9f1d997553f54b19713f5bbca..9d4ef158f24c6bf21cedca649ca733480e1b713a 100644 (file)
@@ -5168,7 +5168,7 @@ static int do_host_query(const char *query_host)
                }
        }
 
-       if (port != 139) {
+       if (port != NBT_SMB_PORT) {
 
                /* Workgroups simply don't make sense over anything
                   else but port 139... */
@@ -5177,7 +5177,8 @@ static int do_host_query(const char *query_host)
                status = cli_cm_open(talloc_tos(), NULL,
                                     have_ip ? dest_ss_str : query_host,
                                     "IPC$", auth_info, true, smb_encrypt,
-                                    max_protocol, 139, name_type, &cli);
+                                    max_protocol, NBT_SMB_PORT, name_type,
+                                    &cli);
                if (!NT_STATUS_IS_OK(status)) {
                        cli = NULL;
                }
@@ -5242,7 +5243,7 @@ static int do_message_op(struct user_auth_info *a_info)
        NTSTATUS status;
 
        status = cli_connect_nb(desthost, have_ip ? &dest_ss : NULL,
-                               port ? port : 139, name_type,
+                               port ? port : NBT_SMB_PORT, name_type,
                                lp_netbios_name(), SMB_SIGNING_DEFAULT, 0, &cli);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("Connection to %s failed. Error %s\n", desthost, nt_errstr(status));
@@ -5354,7 +5355,7 @@ static int do_message_op(struct user_auth_info *a_info)
                                exit(ENOMEM);
                        }
                        if( !port )
-                               port = 139;
+                               port = NBT_SMB_PORT;
                        message = true;
                        break;
                case 'I':
index 22653cd76a53d0ad8de73c6ead47952067274704..7dd77ec5da5696b869a8ab46ab23155698e16e2d 100644 (file)
@@ -44,8 +44,8 @@
 
 #define NMB_PORT 137
 #define DGRAM_PORT 138
-#define SMB_PORT1 445
-#define SMB_PORT2 139
+#define NBT_SMB_PORT  139   /* Port for SMB over NBT transport (IETF STD#19). */
+#define TCP_SMB_PORT  445   /* Port for SMB over naked TCP transport.         */
 #define SMB_PORTS "445 139"
 
 #define Undefined (-1)
index 9ade23c8bc7b68ebe2cba10122ac09d7758f1712..dcc41bb699e15c13bfbf5a2542d8bd63651c84ea 100644 (file)
@@ -482,8 +482,9 @@ int open_socket_in(int type,
 
        /* now we've got a socket - we need to bind it */
        if (bind(res, (struct sockaddr *)&sock, slen) == -1 ) {
-               if( DEBUGLVL(dlevel) && (port == SMB_PORT1 ||
-                               port == SMB_PORT2 || port == NMB_PORT) ) {
+               if( DEBUGLVL(dlevel) && (port == NMB_PORT ||
+                                        port == NBT_SMB_PORT ||
+                                        port == TCP_SMB_PORT) ) {
                        char addr[INET6_ADDRSTRLEN];
                        print_sockaddr(addr, sizeof(addr),
                                        &sock);
index 570b7ae8495d278e97b7bd00fa0d9e2cc144e3a9..f5fcaea62b0e0be314b4547d1e42ce3443c8cc3f 100644 (file)
@@ -420,7 +420,7 @@ SMBC_server_internal(TALLOC_CTX *ctx,
                /*
                 * Try 139 first for IPC$
                 */
-               status = cli_connect_nb(server_n, NULL, 139, 0x20,
+               status = cli_connect_nb(server_n, NULL, NBT_SMB_PORT, 0x20,
                                        smbc_getNetbiosName(context),
                                        SMB_SIGNING_DEFAULT, flags, &c);
        }
index 1926445c10205eece5e6e5b7d5ce48861645b837..d9d3b92c0ee3aeb1dc2840fe579d6c7c0c4f621a 100644 (file)
@@ -191,7 +191,7 @@ static struct tevent_req *nb_connect_send(TALLOC_CTX *mem_ctx,
 
        talloc_set_destructor(state, nb_connect_state_destructor);
 
-       subreq = open_socket_out_send(state, ev, addr, 139, 5000);
+       subreq = open_socket_out_send(state, ev, addr, NBT_SMB_PORT, 5000);
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
@@ -276,7 +276,7 @@ static void nb_connect_done(struct tevent_req *subreq)
                make_nmb_name(&state->called, state->called_name, 0x20);
 
                subreq = open_socket_out_send(state, state->ev, state->addr,
-                                             139, 5000);
+                                             NBT_SMB_PORT, 5000);
                if (tevent_req_nomem(subreq, req)) {
                        return;
                }
@@ -351,7 +351,7 @@ struct tevent_req *smbsock_connect_send(TALLOC_CTX *mem_ctx,
 
        talloc_set_destructor(state, smbsock_connect_state_destructor);
 
-       if (port == 139) {
+       if (port == NBT_SMB_PORT) {
                subreq = tevent_wakeup_send(state, ev, timeval_set(0, 0));
                if (tevent_req_nomem(subreq, req)) {
                        return tevent_req_post(req, ev);
@@ -374,7 +374,7 @@ struct tevent_req *smbsock_connect_send(TALLOC_CTX *mem_ctx,
         * port==0, try both
         */
 
-       state->req_445 = open_socket_out_send(state, ev, addr, 445, 5000);
+       state->req_445 = open_socket_out_send(state, ev, addr, TCP_SMB_PORT, 5000);
        if (tevent_req_nomem(state->req_445, req)) {
                return tevent_req_post(req, ev);
        }
@@ -382,7 +382,7 @@ struct tevent_req *smbsock_connect_send(TALLOC_CTX *mem_ctx,
                                req);
 
        /*
-        * After 5 msecs, fire the 139 request
+        * After 5 msecs, fire the 139 (NBT) request
         */
        state->req_139 = tevent_wakeup_send(
                state, ev, timeval_current_ofs(0, 5000));
@@ -445,14 +445,14 @@ static void smbsock_connect_connected(struct tevent_req *subreq)
                status = open_socket_out_recv(subreq, &state->sock);
                TALLOC_FREE(state->req_445);
                unfinished_req = state->req_139;
-               state->port = 445;
+               state->port = TCP_SMB_PORT;
 
        } else if (subreq == state->req_139) {
 
                status = nb_connect_recv(subreq, &state->sock);
                TALLOC_FREE(state->req_139);
                unfinished_req = state->req_445;
-               state->port = 139;
+               state->port = NBT_SMB_PORT;
 
        } else {
                tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
index e015f7ba7169ea58bfc08f946fc66fc50fa66a5c..1adccbd7d3541d74983d7b15fde6dab59c150be6 100644 (file)
@@ -81,7 +81,7 @@ static void sync_child(char *name, int nm_type,
 
        in_addr_to_sockaddr_storage(&ss, ip);
 
-       status = cli_connect_nb(name, &ss, 139, nm_type,
+       status = cli_connect_nb(name, &ss, NBT_SMB_PORT, nm_type,
                                get_local_machine_name(), SMB_SIGNING_DEFAULT,
                                0, &cli);
        if (!NT_STATUS_IS_OK(status)) {
index 5b0f7cf6c8ecd02a66218e1db3c6188b9d0a7255..557a32f0541dd42e1ce04ba32f3a3c63ab961a7f 100644 (file)
@@ -410,13 +410,13 @@ static bool netbios_session_retarget(struct smbd_server_connection *sconn,
        char *retarget;
        char *p;
        int retarget_type = 0x20;
-       int retarget_port = 139;
+       int retarget_port = NBT_SMB_PORT;
        struct sockaddr_storage retarget_addr;
        struct sockaddr_in *in_addr;
        bool ret = false;
        uint8_t outbuf[10];
 
-       if (get_socket_port(sconn->sock) != 139) {
+       if (get_socket_port(sconn->sock) != NBT_SMB_PORT) {
                return false;
        }
 
index b14f9ed873711da084ab73ce4aa06454a347ff16..0b2727cfcab337deb560cc8edd2f4fb212938442 100644 (file)
@@ -3094,7 +3094,7 @@ static bool run_bad_nbt_session(int dummy)
                return false;
        }
 
-       status = open_socket_out(&ss, 139, 10000, &fd);
+       status = open_socket_out(&ss, NBT_SMB_PORT, 10000, &fd);
        if (!NT_STATUS_IS_OK(status)) {
                d_fprintf(stderr, "open_socket_out failed: %s\n",
                          nt_errstr(status));
index 23f47550fa4262adbe59a6729bd2c06c140a0f2a..33f1a90cf9523e6267af41103fa8cf585621e819 100644 (file)
@@ -180,7 +180,7 @@ static void filter_child(int c, struct sockaddr_storage *dest_ss)
        int s = -1;
 
        /* we have a connection from a new client, now connect to the server */
-       status = open_socket_out(dest_ss, 445, LONG_CONNECT_TIMEOUT, &s);
+       status = open_socket_out(dest_ss, TCP_SMB_PORT, LONG_CONNECT_TIMEOUT, &s);
 
        if (s == -1) {
                char addr[INET6_ADDRSTRLEN];
@@ -278,7 +278,7 @@ static void start_filter(char *desthost)
        /* start listening on port 445 locally */
 
        zero_sockaddr(&my_ss);
-       s = open_socket_in(SOCK_STREAM, 445, 0, &my_ss, True);
+       s = open_socket_in(SOCK_STREAM, TCP_SMB_PORT, 0, &my_ss, True);
 
        if (s == -1) {
                d_printf("bind failed\n");
index 3373d96f0aad6a04d2df4aa413c9e89c3a9ed22a..020a092f296622c9fa775366d633d9158b7e2627 100644 (file)
@@ -1331,7 +1331,7 @@ static bool find_new_dc(TALLOC_CTX *mem_ctx,
                                    &dcnames, &num_dcnames)) {
                        return False;
                }
-               if (!add_sockaddr_to_array(mem_ctx, &dcs[i].ss, 445,
+               if (!add_sockaddr_to_array(mem_ctx, &dcs[i].ss, TCP_SMB_PORT,
                                      &addrs, &num_addrs)) {
                        return False;
                }