#if defined(_KERNEL) || defined(_FAKE_KERNEL)
#include <sys/types.h>
#include <sys/sunddi.h>
#else
#include <string.h>
#endif
#include <smbsrv/string.h>
#include <smbsrv/smbinfo.h>
typedef struct smb_native {
int sn_value;
const char *sn_name;
} smb_native_t;
int
smbnative_os_value(const char *native_os)
{
static smb_native_t os_table[] = {
{ NATIVE_OS_WINNT, "Windows NT 4.0" },
{ NATIVE_OS_WINNT, "Windows NT" },
{ NATIVE_OS_WIN95, "Windows 4.0" },
{ NATIVE_OS_WIN2000, "Windows 5.0" },
{ NATIVE_OS_WIN2000, "Windows 5.1" },
{ NATIVE_OS_WIN2000, "Windows 2000" },
{ NATIVE_OS_WIN2000, "Windows 2002" },
{ NATIVE_OS_WIN2000, "Windows .NET" },
{ NATIVE_OS_WIN2000, "Windows Server" },
{ NATIVE_OS_WIN2000, "Windows XP" },
{ NATIVE_OS_WINNT, "UNIX" },
{ NATIVE_OS_MACOS, "MacOS" }
};
int i;
int len;
const char *name;
if (native_os == NULL)
return (NATIVE_OS_UNKNOWN);
if (*native_os == '\0')
return (NATIVE_OS_WIN2000);
for (i = 0; i < sizeof (os_table)/sizeof (os_table[0]); ++i) {
name = os_table[i].sn_name;
len = strlen(name);
if (smb_strcasecmp(name, native_os, len) == 0)
return (os_table[i].sn_value);
}
return (NATIVE_OS_UNKNOWN);
}
int
smbnative_lm_value(const char *native_lm)
{
static smb_native_t lm_table[] = {
{ NATIVE_LM_NT, "NT LAN Manager 4.0" },
{ NATIVE_LM_NT, "Windows NT" },
{ NATIVE_LM_NT, "Windows 4.0" },
{ NATIVE_LM_NT, "DAVE" }
};
int i;
int len;
const char *name;
if (native_lm == NULL || *native_lm == '\0')
return (NATIVE_LM_WIN2000);
for (i = 0; i < sizeof (lm_table)/sizeof (lm_table[0]); ++i) {
name = lm_table[i].sn_name;
len = strlen(name);
if ((smb_strcasecmp(name, native_lm, len) == 0) ||
(smb_strcasecmp(&name[1], native_lm, len - 1) == 0)) {
return (lm_table[i].sn_value);
}
}
return (NATIVE_LM_WIN2000);
}
int
smbnative_pdc_value(const char *native_lm)
{
static smb_native_t pdc_table[] = {
{ PDC_WINNT, "NT LAN Manager 4.0" },
{ PDC_WINNT, "Windows NT 4.0" },
{ PDC_WINNT, "Windows NT" },
{ PDC_WINNT, "Windows 4.0" },
{ PDC_WINNT, "DAVE" },
{ PDC_SAMBA, "Samba" }
};
int i;
int len;
const char *name;
if (native_lm == NULL || *native_lm == '\0')
return (PDC_WIN2000);
for (i = 0; i < sizeof (pdc_table)/sizeof (pdc_table[0]); ++i) {
name = pdc_table[i].sn_name;
len = strlen(name);
if ((smb_strcasecmp(name, native_lm, len) == 0) ||
(smb_strcasecmp(&name[1], native_lm, len - 1) == 0)) {
return (pdc_table[i].sn_value);
}
}
return (PDC_WIN2000);
}
const char *
smbnative_os_str(smb_version_t *version)
{
int i;
static smb_native_t osstr_table[] = {
{ SMB_MAJOR_NT, "Windows NT" },
{ SMB_MAJOR_2000, "Windows 2000" },
{ SMB_MAJOR_XP, "Windows XP" },
{ SMB_MAJOR_2003, "Windows Server 2003" },
{ SMB_MAJOR_VISTA, "" },
{ SMB_MAJOR_2008, "" },
{ SMB_MAJOR_2008R2, "" }
};
for (i = 0; i < sizeof (osstr_table)/sizeof (osstr_table[0]); ++i) {
if (version->sv_major == osstr_table[i].sn_value)
return (osstr_table[i].sn_name);
}
return (osstr_table[1].sn_name);
}
const char *
smbnative_lm_str(smb_version_t *version)
{
int i;
static smb_native_t lmstr_table[] = {
{ SMB_MAJOR_NT, "NT LAN Manager 4.0" },
{ SMB_MAJOR_2000, "Windows 2000 LAN Manager" },
{ SMB_MAJOR_XP, "Windows 2002 5.1" },
{ SMB_MAJOR_2003, "Windows Server 2003 5.2" },
{ SMB_MAJOR_VISTA, "" },
{ SMB_MAJOR_2008, "" },
{ SMB_MAJOR_2008R2, "" }
};
for (i = 0; i < sizeof (lmstr_table)/sizeof (lmstr_table[0]); ++i) {
if (version->sv_major == lmstr_table[i].sn_value)
return (lmstr_table[i].sn_name);
}
return (lmstr_table[1].sn_name);
}