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);
}
}
- if (port != 139) {
+ if (port != NBT_SMB_PORT) {
/* Workgroups simply don't make sense over anything
else but port 139... */
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;
}
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));
exit(ENOMEM);
}
if( !port )
- port = 139;
+ port = NBT_SMB_PORT;
message = true;
break;
case 'I':
#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)
/* 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);
/*
* 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);
}
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);
}
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;
}
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);
* 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);
}
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));
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);
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)) {
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;
}
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));
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];
/* 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");
&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;
}