nmblookup.c: Added -A ability to do status on ip address.
authorJeremy Allison <jra@samba.org>
Fri, 10 Oct 1997 01:32:26 +0000 (01:32 +0000)
committerJeremy Allison <jra@samba.org>
Fri, 10 Oct 1997 01:32:26 +0000 (01:32 +0000)
smb.h: Added defines we will need for NT SMB calls.
trans2.c: Fixed SMB_QUERY_FILE_ALT_NAME_INFO return - this is only
for short name returns (and only used when you negotiate NT SMB calls
to boot !).
Jeremy (jallison@whistle.com)
(This used to be commit 53915bd160eda8c099482ddcef74d1d7606e752b)

source3/include/smb.h
source3/smbd/trans2.c
source3/utils/nmblookup.c

index d0baa669928d7c8ec5bbb6ce120cdceba3a73b79..54ce9e88e8804e039e568ef5aff6bfee0f26d3fb 100644 (file)
@@ -438,8 +438,8 @@ typedef struct id_info_1
   DOM_LOGON_ID      logon_id;            /* logon ID */
   UNIHDR            hdr_user_name;       /* user name unicode header */
   UNIHDR            hdr_workgroup_name;  /* workgroup name unicode header */
-  ARC4_OWF          arc4_lm_owf;         /* rc4 LM OWF Password */
-  ARC4_OWF          arc4_nt_owf;         /* rc4 NT OWF Password */
+  ARC4_OWF          arc4_lm_owf;         /* arc4 LM OWF Password */
+  ARC4_OWF          arc4_nt_owf;         /* arc4 NT OWF Password */
   UNISTR2           uni_domain_name;     /* domain name unicode string */
   UNISTR2           uni_user_name;       /* user name unicode string */
   UNISTR2           uni_workgroup_name;  /* workgroup name unicode string */
@@ -1305,23 +1305,38 @@ struct connect_record
 #define SMBfindnclose    0x35   /* Terminate a TRANSACT2_FINDNOTIFYFIRST */
 #define SMBulogoffX      0x74   /* user logoff */
 
-
-/* these are the TRANS2 sub commands */
-#define TRANSACT2_OPEN          0
-#define TRANSACT2_FINDFIRST     1
-#define TRANSACT2_FINDNEXT      2
-#define TRANSACT2_QFSINFO       3
-#define TRANSACT2_SETFSINFO     4
-#define TRANSACT2_QPATHINFO     5
-#define TRANSACT2_SETPATHINFO   6
-#define TRANSACT2_QFILEINFO     7
-#define TRANSACT2_SETFILEINFO   8
-#define TRANSACT2_FSCTL         9
-#define TRANSACT2_IOCTL           10
-#define TRANSACT2_FINDNOTIFYFIRST 11
-#define TRANSACT2_FINDNOTIFYNEXT  12
-#define TRANSACT2_MKDIR           13
-
+/* NT SMB extensions. */
+#define SMBnttrans       0xA0   /* NT transact */
+#define SMBnttranss      0xA1   /* NT transact secondary */
+#define SMBntcreateX     0xA2   /* NT create and X */
+#define SMBntcancel      0xA4   /* NT cancel */
+
+/* These are the TRANS2 sub commands */
+#define TRANSACT2_OPEN                        0
+#define TRANSACT2_FINDFIRST                   1
+#define TRANSACT2_FINDNEXT                    2
+#define TRANSACT2_QFSINFO                     3
+#define TRANSACT2_SETFSINFO                   4
+#define TRANSACT2_QPATHINFO                   5
+#define TRANSACT2_SETPATHINFO                 6
+#define TRANSACT2_QFILEINFO                   7
+#define TRANSACT2_SETFILEINFO                 8
+#define TRANSACT2_FSCTL                       9
+#define TRANSACT2_IOCTL                     0xA
+#define TRANSACT2_FINDNOTIFYFIRST           0xB
+#define TRANSACT2_FINDNOTIFYNEXT            0xC
+#define TRANSACT2_MKDIR                     0xD
+#define TRANSACT2_SESSION_SETUP             0xE
+#define TRANSACT2_GET_DFS_REFERRAL         0x10
+#define TRANSACT2_REPORT_DFS_INCONSISTANCY 0x11
+
+/* These are the NT transact sub commands. */
+#define NT_TRANSACT_CREATE                1
+#define NT_TRANSACT_IOCTL                 2
+#define NT_TRANSACT_SET_SECURITY_DESC     3
+#define NT_TRANSACT_NOTIFY_CHANGE         4
+#define NT_TRANSACT_RENAME                5
+#define NT_TRANSACT_QUERY_SECURITY_DESC   6
 
 /* these are the trans2 sub fields for primary requests */
 #define smb_tpscnt smb_vwv0
index 092a069a6e33b4a66d7d5fe24c3c453466df293c..a56df9cb9cc68f03a4ed6017eb289f8bf4a2c4fe 100644 (file)
@@ -1181,12 +1181,32 @@ static int call_trans2qfilepathinfo(char *inbuf, char *outbuf, int length,
       data_size = 4;
       break;
 
-    case SMB_QUERY_FILE_NAME_INFO:
+    /* Get the 8.3 name - used if NT SMB was negotiated. */
     case SMB_QUERY_FILE_ALT_NAME_INFO:
+      {
+        pstring short_name;
+        pstrcpy(short_name,fname);
+        /* Mangle if not already 8.3 */
+        if(!is_8_3(short_name, True))
+        {
+          if(!name_map_mangle(short_name,True,SNUM(cnum)))
+            *short_name = '\0';
+        }
+        strncpy(pdata + 4,short_name,12);
+        (pdata + 4)[12] = 0;
+        strupper(pdata + 4);
+        l = strlen(pdata + 4);
+        data_size = 4 + l;
+        SIVAL(pdata,0,l);
+      }
+      break;
+
+    case SMB_QUERY_FILE_NAME_INFO:
       data_size = 4 + l;
       SIVAL(pdata,0,l);
       pstrcpy(pdata+4,fname);
       break;
+
     case SMB_QUERY_FILE_ALLOCATION_INFO:
     case SMB_QUERY_FILE_END_OF_FILEINFO:
       data_size = 8;
index 36905aa5ae33dd1674e24f78fd9640636fb8114e..63ca156449f062a28283f400d15ad7480aa3f676 100644 (file)
@@ -88,6 +88,8 @@ static void usage(void)
   printf("\t-B broadcast address  the address to use for broadcasts\n");
   printf("\t-M                    searches for a master browser\n");
   printf("\t-S                    lookup node status as well\n");
+  printf("\t-r                    Use root port 137 (Win95 only replies to this)\n");
+  printf("\t-A                    Do a node status on <name> as an IP Address\n");
   printf("\n");
 }
 
@@ -108,6 +110,7 @@ int main(int argc,char *argv[])
   static pstring servicesf = CONFIGFILE;
   struct in_addr bcast_addr;
   BOOL got_bcast = False;
+  BOOL lookup_by_ip = False;
   
   DEBUGLEVEL = 1;
   *lookup = 0;
@@ -118,7 +121,7 @@ int main(int argc,char *argv[])
 
   charset_initialise();
 
-  while ((opt = getopt(argc, argv, "d:B:i:s:SMrh")) != EOF)
+  while ((opt = getopt(argc, argv, "d:B:i:s:SMrhA")) != EOF)
     switch (opt)
       {
       case 'B':
@@ -149,6 +152,9 @@ int main(int argc,char *argv[])
        usage();
        exit(0);
        break;
+      case 'A':
+        lookup_by_ip = True;
+        break;
       default:
        usage();
        exit(1);
@@ -182,6 +188,16 @@ int main(int argc,char *argv[])
 
       fstrcpy(lookup,argv[i]);
 
+      if(lookup_by_ip)
+      {
+        strcpy(lookup,"*");
+        ip = *interpret_addr2(argv[i]);
+        printf("Looking up status of %s\n",inet_ntoa(ip));
+        name_status(ServerFD,lookup,lookup_type,True,ip,NULL,NULL,NULL);
+        printf("\n");
+        continue;
+      }
+
       if (find_master) {
        if (*lookup == '-') {
          strcpy(lookup,"\01\02__MSBROWSE__\02");