feat: register initial SLIST command support

This commit is contained in:
Mario Fetka
2026-05-22 16:26:20 +02:00
parent bb868613d9
commit e4227bfda8
5 changed files with 181 additions and 8 deletions

View File

@@ -23,6 +23,7 @@ set(MARS_DOSUTILS_PUBLIC_TOOLS
map
mapdel
logout
slist
capture
endcap
)
@@ -40,6 +41,7 @@ if(MARS_NWE_BUILD_DOSUTILS)
ncpcall.c
login.c
map.c
slist.c
nwcrypt.c
nwdebug.c
nwtests.c

103
ncpcall.c
View File

@@ -283,3 +283,106 @@ int ncp_17_4b(uint8 *cryptkey, uint8 *objname, uint16 objtyp,
if (neterrno) return(-1);
return(0);
}
int ncp_17_37(uint32 last_id, uint16 objtyp, uint8 *pattern,
BINDERY_OBJECT *target)
/* scan bindery object */
{
struct {
uint16 len;
uint8 func;
uint8 last_id[4];
uint8 typ[2];
uint8 patlen;
uint8 pattern[48];
} req;
struct {
uint16 len;
uint8 object_id[4];
uint8 object_type[2];
uint8 object_name[48];
uint8 object_flags;
uint8 object_security;
uint8 object_has_prop;
} repl;
int patlen = (pattern) ? min(48, strlen(pattern)) : 1;
memset(&req, 0, sizeof(req));
memset(&repl, 0, sizeof(repl));
req.func = 0x37;
U32_TO_BE32(last_id, req.last_id);
U16_TO_BE16(objtyp, req.typ);
req.patlen = (uint8)patlen;
if (pattern) memcpy(req.pattern, pattern, patlen);
else req.pattern[0] = '*';
req.len = 8 + patlen;
repl.len = sizeof(repl) - sizeof(uint16);
neterrno = Net_Call(0xE300, &req, &repl);
if (neterrno) return(-1);
if (target) {
target->object_id = GET_BE32(repl.object_id);
target->object_type = GET_BE16(repl.object_type);
memcpy(target->object_name, repl.object_name, 48);
target->object_name[48] = '\0';
deb(target->object_name);
target->object_flags = repl.object_flags;
target->object_security = repl.object_security;
target->object_has_prop = repl.object_has_prop;
}
return(0);
}
int ncp_17_3d(uint16 objtyp, uint8 *objname, int segment,
uint8 *propname, NW_PROPERTY *target)
/* read bindery property value */
{
struct {
uint16 len;
uint8 func;
uint8 typ[2];
uint8 buff[1+48+1+1+16];
} req;
struct {
uint16 len;
uint8 value[128];
uint8 more_flag;
uint8 property_flag;
} repl;
uint8 *p = req.buff;
int objlen = min(48, strlen(objname));
int proplen = min(16, strlen(propname));
memset(&req, 0, sizeof(req));
memset(&repl, 0, sizeof(repl));
req.func = 0x3d;
U16_TO_BE16(objtyp, req.typ);
*p++ = (uint8)objlen;
memcpy(p, objname, objlen);
p += objlen;
*p++ = (uint8)segment;
*p++ = (uint8)proplen;
memcpy(p, propname, proplen);
req.len = 6 + objlen + proplen;
repl.len = sizeof(repl) - sizeof(uint16);
neterrno = Net_Call(0xE300, &req, &repl);
if (neterrno) return(-1);
if (target) {
memcpy(target->value, repl.value, 128);
target->more_flag = repl.more_flag;
target->property_flag = repl.property_flag;
}
return(0);
}

2
net.c
View File

@@ -34,9 +34,7 @@ static struct s_net_functions {
{"PATHDEL","removes search path" , func_path , 1},
{"PATHINS","insert search path" , func_path , 2},
{"LOGOUT", "logout from server", func_logout , 0},
#if 0
{"SLIST", "list servers", func_slist , 0},
#endif
{"PASSWD", "change password", func_passwd , 0},
#if 1
{"TESTS", "only testroutines!", func_tests , 0},

24
net.h
View File

@@ -58,7 +58,7 @@ typedef struct {
uint16 fragment_count; /* Anzahl Fragment Buffers */
uint8 *fragment_1;
uint16 fragment_1_size;
/* Knnen auch mehr sein */
/* K<EFBFBD>nnen auch mehr sein */
} ECB;
#include "kern.h"
@@ -106,6 +106,24 @@ typedef struct {
#define NWCLIENT 4
#define NWBIND 5
#define NCP_BINDERY_FSERVER 0x0004
typedef struct {
uint32 object_id;
uint16 object_type;
uint8 object_name[49];
uint8 object_flags;
uint8 object_security;
uint8 object_has_prop;
} BINDERY_OBJECT;
typedef struct {
uint8 value[128];
uint8 more_flag;
uint8 property_flag;
} NW_PROPERTY;
/* net.c */
extern char *funcname;
extern char prgpath[];
@@ -235,4 +253,8 @@ extern int func_tests (int argc, char *argv[], int mode);
extern int func_capture(int argc, char *argv[], int mode);
extern int ncp_17_37(uint32 last_id, uint16 objtyp, uint8 *pattern,
BINDERY_OBJECT *target);
extern int ncp_17_3d(uint16 objtyp, uint8 *objname, int segment,
uint8 *propname, NW_PROPERTY *target);

58
slist.c
View File

@@ -1,15 +1,63 @@
/* map.c 12-Jan-96 */
/****************************************************************
* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany *
****************************************************************/
/* slist.c - list known NetWare file servers, DOS mars-dosutils version */
#include "net.h"
static int usage(void)
{
fprintf(stderr, "usage:\t%s [pattern]\n", funcname);
return(-1);
}
static void print_net_node(uint8 *addr)
{
fprintf(stdout, "%08lX %02X%02X%02X%02X%02X%02X",
(unsigned long)GET_BE32(addr),
addr[4], addr[5], addr[6], addr[7], addr[8], addr[9]);
}
int func_slist(int argc, char *argv[], int mode)
{
BINDERY_OBJECT obj;
uint32 last_id = MAX_U32;
uint8 pattern[50];
int found = 0;
int result;
(void)mode;
if (argc > 2) return(usage());
if (argc == 2) strmaxcpy(pattern, argv[1], sizeof(pattern) - 1);
else strcpy(pattern, "*");
upstr(pattern);
fprintf(stdout, "\n%-52s%-10s%-12s\n",
"Known NetWare File Servers", "Network", "Node Address");
fprintf(stdout,
"-----------------------------------------------"
"---------------------------\n");
while ((result = ncp_17_37(last_id, NCP_BINDERY_FSERVER,
pattern, &obj)) == 0) {
NW_PROPERTY prop;
found = 1;
last_id = obj.object_id;
fprintf(stdout, "%-52s", obj.object_name);
if (!ncp_17_3d(NCP_BINDERY_FSERVER, obj.object_name,
1, "NET_ADDRESS", &prop)) {
print_net_node(prop.value);
}
fprintf(stdout, "\n");
if (last_id == MAX_U32) break;
}
if (!found)
fprintf(stdout, "No servers found\n");
return(0);
}