mars_nwe-0.96.pl08

This commit is contained in:
Mario Fetka 2011-11-13 00:38:56 +01:00
parent 01778ec986
commit 28334ea9f1
34 changed files with 2449 additions and 1158 deletions

22
CHANGES
View File

@ -1,5 +1,5 @@
Sorry, this is in German only. :-(
Aenderungen in mars_nwe bis zum : 22-Jan-96
Aenderungen in mars_nwe bis zum : 08-Feb-96
--------------------------------
Erste 'oeffentliche' Version
^^^^^^^^^^ VERSION 0.94 ^^^^^^^^
@ -61,4 +61,24 @@ Erste 'oeffentliche' Version
net < angebbarer anzahl tics ist. (z.B. fuer IPX ueber ISDN)
- Verarbeitung von 'PIPE Jobs' eingebaut.
- Bug beim Drucken korrigiert. (nprint funktionierte nicht)
- 0x17, 0x35 u. 0x37 upstr objname eingebaut.
- auf USL 2.xx (UnixWare (tm)) wieder zum Laufen gebracht.
- kann nun auch ohne internen Router (RIP/SAP) erzeugt werden.
dafuer define INTERNAL_RIP_SAP in config.h eingebaut.
- kann auch als standalone router only Fileserver Aktivitaet
verwendet werden.
Dafuer define FILE_SERVER_INACTIV in config.h eingebaut.
- mk.li erweitert.
- Schalter zum Testen von namespace calls eingebaut. config.h
- config.h um folgende Konstanten erweitert.
NETWORK_SERIAL_NMBR 0x44444444L /* Serial Number 4 Byte */
NETWORK_APPL_NMBR 0x2222 /* Applikation Number 2 Byte */
- Schalter fuer das aktivieren von Namespace services calls
in config.h eingebaut. define WITH_NAME_SPACE_CALLS
- Schalter 'm' fuer removable volumes ( z.B. CDROMS )
eingebaut. (Lauri Tischler)
- func 0x17, ufunc 0x15 eingebaut.

21
INSTALL
View File

@ -1,3 +1,22 @@
=========> !! important NOTE !!
You can configure mars_nwe in two ways.
1. You want mars_nwe to handle routing/sap and configuring
ipx-interfaces. This is the default mode.
You do not need any other ipx-tool or routers/daemons.
In this modus the correct coexisting working
of mars_nwe, dosemu, ncpfs or Caldera's nwclient was tested.
-> you must use kernel < 1.3.60 or use kernel >= 1.3.60 and compile
your kernel with IPX-option CONFIG_IPX_INTERN=N
In mars_nwe/config.h there must exist the following line:
#define INTERNAL_RIP_SAP 1
2. You want to run mars_nwe only as a fileserver and use
special tools to configure ipx and rip/sap routers.
-> In this mode you must use tools like ipx-configure and
ripd to configure ipx-interfaces, routes and handle rip/sap.
In mars_nwe/config.h there must exist the following line:
#define INTERNAL_RIP_SAP 0
=========> create programs
1. call make.
2. perhaps you must modify mk.li and config.h
@ -28,7 +47,7 @@ kill of nwserv or with the right dos client programm
nw.ini file gives the time in seconds, before the server
really shuts down.
Viel Erfolg / good Luck :-)
good luck :-)
Martin
(mstover@freeway.de)

View File

@ -1,3 +1,25 @@
=========> !! wichtiger HINWEIS !!
Mars_nwe kann auf Arten konfiguriert werden.
1. Mars_nwe soll die IPX-Routen automatisch setzen,
die IPX-Interfaces per ini/conf Datei konfigurieren
und als RIP/SAP Router arbeiten.
Dieses ist der default Modus. Es werden keine weiteren
Programme wie ipx-configure oder IPX rip/sap Daemons
benoetigt.
In diesem Modus wurde das korrekte Zusammenspiel mit
dosemu, ncpfs oder Caldera's nwclient getestet.
-> Es muss ein Kernel < 1.3.60 oder aber ein Kernel >= 1.3.60,
kompiliert mit IPX-Option CONFIG_IPX_INTERN=N, verwendet werden.
In mars_nwe/config.h muss folgende Zeile vorhanden sein.
#define INTERNAL_RIP_SAP 1
2. Mars_nwe soll nur als File Server Verwendung finden.
-> Die IPX-Interfaces muessen durch andere Programme/Tools
wie 'ipx-configure' oder aehnliche eingerichtet werden
und es muss ein rip/sap router/daemon eingerichtet sein.
In mars_nwe/config.h muss folgende Zeile vorhanden sein.
#define INTERNAL_RIP_SAP 0
=========> Programme erzeugen
1. make aufrufen.
2. mk.li und config.h evtl. anpassen

View File

@ -1,5 +1,7 @@
# Makefile mars_nwe: 06-Dec-95
# Makefile mars_nwe: 31-Jan-96
VPATH=
all: rmeflag mk.li config.h nw.ini
@if [ -r .eflag ] ; then \
echo ""; \
@ -9,7 +11,7 @@ all: rmeflag mk.li config.h nw.ini
echo "Please make your changes and run make again"; \
echo "********************************************************"; \
echo "";\
echo ""; else ./mk.li && (\
echo ""; else ./mk.li && (\
if [ -r .mk.notes ] ; then echo "" ; \
echo ""; \
echo "********************************************************" ; \
@ -61,12 +63,12 @@ config.h: examples/config.h
echo "and change it to your requirements." >> .eflag ; fi
rmeflag:
@ - rm -f .eflag
@- rm -f .eflag
nw.ini: examples/nw.ini
@if [ -r $@ ] ; then echo "NOTE:examples/$@ is newer then $@" > .mk.notes ; \
echo "please compare examples/$@ with $@" >> .mk.notes; \
echo "make the changes you need and touch $@" >> .mk.notes; \
else cp -a examples/$@ . ; \
else cp examples/$@ . ; \
echo "$@ created (from examples/$@) Please edit $@" > .mk.notes;\
echo "and change it to your requirements." >> .mk.notes ; fi

457
connect.c
View File

@ -1,5 +1,5 @@
/* connect.c 22-Jan-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
/* connect.c 23-Jan-96 */
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -34,6 +34,7 @@ static int default_uid=-1;
static int default_gid=-1;
#include "nwvolume.h"
#include "nwfile.h"
#include "connect.h"
NW_DIR dirs[MAX_NW_DIRS];
@ -41,13 +42,10 @@ int used_dirs=0;
static int connect_is_init = 0;
#define MAX_FILEHANDLES 80
#define MAX_DIRHANDLES 80
static FILE_HANDLE file_handles[MAX_FILEHANDLES];
static DIR_HANDLE dir_handles[MAX_DIRHANDLES];
static int anz_fhandles=0;
static int anz_dirhandles=0;
static char *build_unix_name(NW_PATH *nwpath, int modus)
@ -65,79 +63,18 @@ static char *build_unix_name(NW_PATH *nwpath, int modus)
strcpy(unixname, "ZZZZZZZZZZZZ"); /* vorsichthalber */
return(unixname);
}
strcpy(unixname, nw_volumes[volume].unixname); /* first UNIXNAME VOLUME */
strcpy(unixname, (char*)nw_volumes[volume].unixname); /* first UNIXNAME VOLUME */
p = pp = unixname+strlen(unixname);
strcpy(p, nwpath->path); /* now the path */
p += strlen(nwpath->path);
strcpy(p, (char*)nwpath->path); /* now the path */
p += strlen((char*)nwpath->path);
if ( (!(modus & 1)) && nwpath->fn[0])
strcpy(p, nwpath->fn); /* and now fn */
strcpy(p, (char*)nwpath->fn); /* and now fn */
else if ((modus & 2) && (*(p-1) == '/')) *(p-1) = '\0';
if (nw_volumes[volume].options & 1) downstr((uint8*)pp);
return(unixname);
}
static int new_file_handle(void)
{
int rethandle = -1;
FILE_HANDLE *fh=NULL;
while (++rethandle < anz_fhandles) {
FILE_HANDLE *fh=&(file_handles[rethandle]);
if (fh->fd == -1 && !(fh->flags & 4)) { /* empty slot */
rethandle++;
break;
} else fh=NULL;
}
if (fh == NULL) {
if (anz_fhandles < MAX_FILEHANDLES) {
fh=&(file_handles[anz_fhandles]);
rethandle = ++anz_fhandles;
} else return(0); /* no free handle anymore */
}
/* init handle */
fh->fd = -2;
fh->offd = 0L;
fh->tmodi = 0L;
fh->name[0] = '\0';
fh->flags = 0;
fh->f = NULL;
XDPRINTF((5, 0, "new_file_handle=%d, anz_fhandles=%d",
rethandle, anz_fhandles));
return(rethandle);
}
static int free_file_handle(int fhandle)
{
int result=-0x88;
if (fhandle > 0 && (fhandle <= anz_fhandles)) {
FILE_HANDLE *fh=&(file_handles[fhandle-1]);
if (fh->fd > -1) {
if (fh->flags & 2) {
if (fh->f) pclose(fh->f);
fh->f = NULL;
} else close(fh->fd);
if (fh->tmodi > 0L && !(fh->flags & 2)) {
/* now set date and time */
struct utimbuf ut;
ut.actime = ut.modtime = fh->tmodi;
utime(fh->name, &ut);
fh->tmodi = 0L;
}
}
fh->fd = -1;
if (fhandle == anz_fhandles && !(fh->flags & 4)) {
/* was last */
anz_fhandles--;
while (anz_fhandles && file_handles[anz_fhandles-1].fd == -1
&& !(file_handles[anz_fhandles-1].flags & 4) )
anz_fhandles--;
}
result=0;
}
XDPRINTF((5, 0, "free_file_handle=%d, anz_fhandles=%d, result=%d",
fhandle, anz_fhandles, result));
return(result); /* wrong filehandle */
}
static int new_dir_handle(ino_t inode, NW_PATH *nwpath)
/*
@ -152,7 +89,7 @@ static int new_dir_handle(ino_t inode, NW_PATH *nwpath)
int nhandle = 0;
for (rethandle=0; rethandle < anz_dirhandles; rethandle++){
fh=&(dir_handles[rethandle]);
if (fh->f == (DIR*) NULL) {
if (!fh->inode) {
if (!nhandle) nhandle = rethandle+1;
} else if (fh->inode == inode && fh->volume == nwpath->volume){
/* Dieser hat Vorrang */
@ -187,6 +124,10 @@ static int new_dir_handle(ino_t inode, NW_PATH *nwpath)
fh->vol_options = nw_volumes[fh->volume].options;
fh->inode = inode;
fh->timestamp = akttime;
if (fh->vol_options & VOL_OPTION_REMOUNT) {
closedir(fh->f);
fh->f = NULL;
}
} else {
fh->f = (DIR*)NULL;
fh->unixname[0] = '\0';
@ -205,7 +146,8 @@ static int free_dir_handle(int dhandle)
closedir(fh->f);
fh->f = (DIR*)NULL;
}
while (anz_dirhandles && dir_handles[anz_dirhandles-1].f == (DIR*)NULL)
fh->inode = 0;
while (anz_dirhandles && !dir_handles[anz_dirhandles-1].inode)
anz_dirhandles--;
return(0);
}
@ -240,7 +182,7 @@ static char nwpathname[300];
char volname[100];
if (p->volume < 0 || p->volume >= used_nw_volumes) {
sprintf(volname, "<%d=NOT-OK>", (int)p->volume);
} else strcpy(volname, nw_volumes[p->volume].sysname);
} else strcpy(volname, (char*)nw_volumes[p->volume].sysname);
sprintf(nwpathname, "%s:%s%s", volname, p->path, p->fn);
return(nwpathname);
}
@ -475,6 +417,23 @@ static int get_dir_entry(NW_PATH *nwpath,
return(okflag);
}
static DIR *give_dh_f(DIR_HANDLE *dh)
{
if (!dh->f) {
*(dh->kpath) = '\0';
dh->f = opendir(dh->unixname);
}
return(dh->f);
}
static void release_dh_f(DIR_HANDLE *dh)
{
if (dh->f && (dh->vol_options & VOL_OPTION_REMOUNT) ) {
closedir(dh->f);
dh->f = NULL;
}
}
static int get_dh_entry(DIR_HANDLE *dh,
uint8 *search,
int *sequence,
@ -483,8 +442,9 @@ static int get_dh_entry(DIR_HANDLE *dh,
/* returns 1 if OK and 0 if not OK */
{
DIR *f = dh->f;
DIR *f = give_dh_f(dh);
int okflag = 0;
if (f != (DIR*)NULL) {
struct dirent *dirbuff;
uint8 entry[256];
@ -525,16 +485,17 @@ static int get_dh_entry(DIR_HANDLE *dh,
} /* while */
dh->kpath[0] = '\0';
*sequence = (int) telldir(f);
release_dh_f(dh);
} /* if */
return(okflag);
}
void conn_build_path_fn( uint8 *vol,
uint8 *path,
uint8 *fn,
int *has_wild,
uint8 *data,
int len)
uint8 *path,
uint8 *fn,
int *has_wild,
uint8 *data,
int len)
/* is called from build_path */
{
@ -819,111 +780,6 @@ static int get_dir_attrib(NW_DIR_INFO *d, struct stat *stb,
}
int nw_creat_open_file(int dir_handle, uint8 *data, int len,
NW_FILE_INFO *info, int attrib, int access, int creatmode)
/*
* creatmode: 0 = open, 1 = creat, 2 = creatnew
* attrib ??
* access: 0x1=read, 0x2=write
*/
{
int fhandle=new_file_handle();
if (fhandle > 0){
FILE_HANDLE *fh=&(file_handles[fhandle-1]);
NW_PATH nwpath;
int completition = conn_get_kpl_path(&nwpath, dir_handle, data, len, 0);
#ifdef TEST_FNAME
int got_testfn = 0;
if (!nw_debug){
if (strstr(nwpath.fn, TEST_FNAME)){
nw_debug = 99;
got_testfn++;
}
}
#endif
if (completition > -1) {
struct stat stbuff;
completition = -0xff; /* no File Found */
strcpy(fh->name, build_unix_name(&nwpath, 0));
if (get_volume_options(nwpath.volume, 1) & VOL_OPTION_IS_PIPE) {
/* this is a PIPE Dir */
int statr = stat(fh->name, &stbuff);
if (!statr && (stbuff.st_mode & S_IFMT) != S_IFDIR) {
char pipecommand[300];
char *pipeopen = (creatmode || (access & 2)) ? "w" : "r";
char *topipe = "READ";
if (creatmode) topipe = "CREAT";
else if (access & 2) topipe = "WRITE";
sprintf(pipecommand, "%s %s", fh->name, topipe);
fh->f = popen(pipecommand, pipeopen);
fh->fd = (fh->f) ? fileno(fh->f) : -1;
if (fh->fd > -1) {
fh->flags |= 2;
get_file_attrib(info, &stbuff, &nwpath);
return(fhandle);
}
}
} else {
if (creatmode) { /* creat File */
if (creatmode & 0x2) { /* creatnew */
if (!stat(fh->name, &stbuff)) {
XDPRINTF((5,0,"CREAT File exist!! :%s:", fh->name));
fh->fd = -1;
completition = -0x85; /* No Priv */
} else {
XDPRINTF((5,0,"CREAT FILE:%s: Handle=%d", fh->name, fhandle));
fh->fd = creat(fh->name, 0777);
if (fh->fd < 0) completition = -0x84; /* no create Rights */
}
} else {
XDPRINTF((5,0,"CREAT FILE, ever with attrib:0x%x, access:0x%x, fh->name:%s: handle:%d",
attrib, access, fh->name, fhandle));
fh->fd = open(fh->name, O_CREAT|O_TRUNC|O_RDWR, 0777);
if (fh->fd < 0) completition = -0x85; /* no delete /create Rights */
}
if (fh->fd > -1) {
close(fh->fd);
fh->fd = open(fh->name, O_RDWR);
fh->offd = 0L;
stat(fh->name, &stbuff);
}
} else {
int statr = stat(fh->name, &stbuff);
int acm = (access & 2) ? (int) O_RDWR /*|O_CREAT*/ : (int)O_RDONLY;
if ( (!statr && (stbuff.st_mode & S_IFMT) != S_IFDIR)
|| (statr && (acm & O_CREAT))){
XDPRINTF((5,0,"OPEN FILE with attrib:0x%x, access:0x%x, fh->name:%s: fhandle=%d",attrib,access, fh->name, fhandle));
fh->fd = open(fh->name, acm, 0777);
fh->offd = 0L;
if (fh->fd > -1) {
if (statr) stat(fh->name, &stbuff);
} else completition = -0x9a;
}
}
if (fh->fd > -1) {
get_file_attrib(info, &stbuff, &nwpath);
#ifdef TEST_FNAME
if (got_testfn) test_handle = fhandle;
#endif
return(fhandle);
}
} /* else (NOT DEVICE) */
}
XDPRINTF((5,0,"OPEN FILE not OK ! fh->name:%s: fhandle=%d",fh->name, fhandle));
free_file_handle(fhandle);
#ifdef TEST_FNAME
if (got_testfn) {
test_handle = -1;
nw_debug = -99;
}
#endif
return(completition);
} else return(-0x81); /* no more File Handles */
}
static int do_delete_file(NW_PATH *nwpath, FUNC_SEARCH *fs)
{
@ -967,168 +823,6 @@ int nw_chmod_datei(int dir_handle, uint8 *data, int len, int modus)
return(-0x9c); /* wrong path */
}
int nw_close_datei(int fhandle)
{
if (fhandle > 0 && (fhandle <= anz_fhandles)) {
FILE_HANDLE *fh=&(file_handles[fhandle-1]);
if (fh->fd > -1) {
int result = 0;
int result2;
if (fh->flags & 2) {
if (fh->f) {
result=pclose(fh->f);
if (result) result = -1;
}
fh->f = NULL;
} else result=close(fh->fd);
fh->fd = -1;
if (fh->tmodi > 0L && !(fh->flags&2)) {
struct utimbuf ut;
ut.actime = ut.modtime = fh->tmodi;
utime(fh->name, &ut);
fh->tmodi = 0L;
}
#ifdef TEST_FNAME
if (fhandle == test_handle) {
test_handle = -1;
nw_debug = -99;
}
#endif
result2=free_file_handle(fhandle);
return((result == -1) ? -0xff : result2);
} else return(free_file_handle(fhandle));
}
return(-0x88); /* wrong filehandle */
}
int nw_read_datei(int fhandle, uint8 *data, int size, uint32 offset)
{
if (fhandle > 0 && (--fhandle < anz_fhandles)) {
FILE_HANDLE *fh=&(file_handles[fhandle]);
if (fh->fd > -1) {
if (fh->offd != (long)offset)
fh->offd=lseek(fh->fd, offset, SEEK_SET);
if (fh->offd > -1L) {
size = read(fh->fd, data, size);
fh->offd+=(long)size;
} else size = -1;
return(size);
}
}
return(- 0x88); /* wrong filehandle */
}
int nw_seek_datei(int fhandle, int modus)
{
if (fhandle > 0 && (--fhandle < anz_fhandles)) {
FILE_HANDLE *fh=&(file_handles[fhandle]);
if (fh->fd > -1) {
int size=-0xfb;
if (!modus) {
if ( (size=fh->offd=lseek(fh->fd, 0L, SEEK_END)) < 0L)
size = -1;
}
return(size);
}
}
return(-0x88); /* wrong filehandle */
}
int nw_write_datei(int fhandle, uint8 *data, int size, uint32 offset)
{
if (fhandle > 0 && (--fhandle < anz_fhandles)) {
FILE_HANDLE *fh=&(file_handles[fhandle]);
if (fh->fd > -1) {
if (fh->offd != (long)offset)
fh->offd = lseek(fh->fd, offset, SEEK_SET);
if (size) {
if (fh->offd > -1L) {
size = write(fh->fd, data, size);
fh->offd+=(long)size;
} else size = -1;
return(size);
} else { /* strip FILE */
/* TODO: for LINUX */
struct flock flockd;
int result= /* -1 */ 0;
flockd.l_type = 0;
flockd.l_whence = SEEK_SET;
flockd.l_start = offset;
flockd.l_len = 0;
#if HAVE_TLI
result = fcntl(fh->fd, F_FREESP, &flockd);
XDPRINTF((5,0,"File %s is stripped, result=%d", fh->name, result));
#endif
return(result);
}
}
}
return(- 0x88); /* wrong filehandle */
}
int nw_server_copy(int qfhandle, uint32 qoffset,
int zfhandle, uint32 zoffset,
uint32 size)
{
if (qfhandle > 0 && (--qfhandle < anz_fhandles)
&& zfhandle > 0 && (--zfhandle < anz_fhandles) ) {
FILE_HANDLE *fhq=&(file_handles[qfhandle]);
FILE_HANDLE *fhz=&(file_handles[zfhandle]);
int retsize = -1;
if (fhq->fd > -1 && fhz->fd > -1) {
char buff[2048];
int wsize;
if (lseek(fhq->fd, qoffset, SEEK_SET) > -1L &&
lseek(fhz->fd, zoffset, SEEK_SET) > -1L) {
retsize = 0;
while (size && !retsize) {
int xsize = read(fhq->fd, buff, min(size, (uint32)sizeof(buff)));
if (xsize > 0){
if ((wsize =write(fhz->fd, buff, xsize)) != xsize) {
retsize = -0x1; /* out of Disk SPace */
break;
} else {
size -= (uint32)xsize;
retsize += wsize;
}
} else {
if (xsize < 0) retsize=-0x93; /* no read privilegs */
break;
}
}
}
fhq->offd = -1L;
fhz->offd = -1L;
/*
if (!retsize) (retsize=fhz->offd=lseek(fhz->fd, 0L, SEEK_END));
*/
return(retsize);
}
}
return(- 0x88); /* wrong filehandle */
}
int nw_lock_datei(int fhandle, int offset, int size, int do_lock)
{
if (fhandle > 0 && (--fhandle < anz_fhandles)) {
FILE_HANDLE *fh=&(file_handles[fhandle]);
if (fh->fd > -1) {
struct flock flockd;
int result;
flockd.l_type = (do_lock) ? F_WRLCK : F_UNLCK;
flockd.l_whence = SEEK_SET;
flockd.l_start = offset;
flockd.l_len = size;
result = fcntl(fh->fd, F_SETLK, &flockd);
if (!result) return(0);
else return(-0x21); /* LOCK Violation */
}
}
return(-0x88); /* wrong filehandle */
}
int nw_mk_rd_dir(int dir_handle, uint8 *data, int len, int mode)
{
@ -1257,9 +951,9 @@ int nw_init_connect(void)
d++;
}
init_file_module();
if (connect_is_init) {
k = 0;
while (k++ < anz_fhandles) free_file_handle(k);
k = 0;
while (k++ < anz_dirhandles) free_dir_handle(k);
} else connect_is_init++;
@ -1292,7 +986,6 @@ int nw_init_connect(void)
/* first Handle must be known und must not be temp */
/* and has no Drive-Character */
used_dirs = 1;
anz_fhandles = 0;
anz_dirhandles = 0;
return(0);
} else return(-1);
@ -1528,7 +1221,6 @@ int nw_get_vol_number(int dir_handle)
return(result);
}
int nw_get_eff_dir_rights(int dir_handle, uint8 *data, int len, int modus)
/* modus 0=only_dir, 1=dirs and files */
{
@ -1546,18 +1238,27 @@ int nw_get_eff_dir_rights(int dir_handle, uint8 *data, int len, int modus)
return(completition);
}
int nw_set_fdate_time(uint32 fhandle, uint8 *datum, uint8 *zeit)
int nw_creat_open_file(int dir_handle, uint8 *data, int len,
NW_FILE_INFO *info, int attrib, int access,
int creatmode)
/*
* creatmode: 0 = open | 1 = creat | 2 = creatnew & 4 == save handle
* attrib ??
* access: 0x1=read, 0x2=write
*/
{
if (fhandle > 0 && (--fhandle < anz_fhandles) ) {
FILE_HANDLE *fh=&(file_handles[fhandle]);
if (fh->fd > -1) {
fh->tmodi = nw_2_un_time(datum, zeit);
return(0);
}
}
return(-0x88); /* wrong filehandle */
}
NW_PATH nwpath;
int completition = conn_get_kpl_path(&nwpath, dir_handle, data, len, 0);
if (completition > -1) {
struct stat stbuff;
completition=file_creat_open(nwpath.volume, build_unix_name(&nwpath, 0),
&stbuff, attrib, access, creatmode);
if (completition > -1)
get_file_attrib(info, &stbuff, &nwpath);
}
return(completition);
}
static int s_nw_scan_dir_info(int dir_handle,
uint8 *data, int len, uint8 *subnr,
@ -1622,8 +1323,8 @@ static int s_nw_scan_dir_info(int dir_handle,
int nw_scan_dir_info(int dir_handle, uint8 *data, int len, uint8 *subnr,
uint8 *subname, uint8 *subdatetime, uint8 *owner)
{
int k = len;
char *p = data+len;
int k = len;
uint8 *p = data+len;
uint8 dirname[256];
while (k--) {
uint8 c = *--p;
@ -1845,11 +1546,7 @@ static void free_queue_job(int q_id)
if (q_id > 0 && q_id <= anz_jobs) {
INT_QUEUE_JOB **pp=&(queue_jobs[q_id-1]);
uint32 fhandle = (*pp)->fhandle;
if (fhandle > 0) {
FILE_HANDLE *fh=&(file_handles[fhandle-1]);
fh->flags &= (~4);
nw_close_datei(fhandle);
}
if (fhandle > 0) nw_close_datei(fhandle, 1);
if (q_id == anz_jobs) {
xfree(*pp);
--anz_jobs;
@ -1889,12 +1586,7 @@ static int create_queue_file(char *job_file_name,
if (result > -1)
result = nw_creat_open_file(result, job_file_name+1,
(int) *job_file_name,
&fnfo, 0x6, 0x6, 1);
if (result > 0){
FILE_HANDLE *fh=&(file_handles[result-1]);
fh->flags = 4; /* don't reuse after close */
}
&fnfo, 0x6, 0x6, 1 | 4);
XDPRINTF((5,0,"creat queue file bez=`%s` handle=%d",
job_bez, result));
@ -1932,8 +1624,8 @@ int nw_creat_queue(int connection, uint8 *queue_id, uint8 *queue_job,
if (result > -1) {
jo->fhandle = (uint32) result;
U32_TO_BE32(jo->fhandle, jo->q.o.job_file_handle);
U16_TO_BE16(0, jo->q.o.job_file_handle+4);
U16_TO_BE16(0, jo->q.o.job_file_handle);
U32_TO_BE32(jo->fhandle, jo->q.o.job_file_handle+2);
result = 0;
}
jo->q.o.server_station = 0;
@ -1969,8 +1661,7 @@ int nw_creat_queue(int connection, uint8 *queue_id, uint8 *queue_job,
if (result > -1) {
jo->fhandle = (uint32) result;
U16_TO_BE16((uint16)result, jo->q.n.job_file_handle);
U16_TO_BE16(0, jo->q.n.job_file_handle+2);
U32_TO_BE32(jo->fhandle, jo->q.n.job_file_handle);
result = 0;
}
U32_TO_BE32(0, jo->q.n.server_station);
@ -1993,16 +1684,14 @@ int nw_close_file_queue(uint8 *queue_id,
if (jo_id > 0 && jo_id <= anz_jobs){
INT_QUEUE_JOB *jo=queue_jobs[jo_id-1];
int fhandle = (int)jo->fhandle;
char unixname[300];
strmaxcpy(unixname, file_get_unix_name(fhandle), sizeof(unixname)-1);
XDPRINTF((5,0,"nw_close_file_queue fhandle=%d", fhandle));
if (fhandle > 0 && fhandle <= anz_fhandles) {
FILE_HANDLE *fh=&(file_handles[fhandle-1]);
char unixname[300];
if (*unixname) {
char printcommand[256];
FILE *f=NULL;
strmaxcpy(unixname, fh->name, sizeof(unixname)-1);
strmaxcpy(printcommand, prc, prc_len);
fh->flags &= (~4);
nw_close_datei(fhandle);
nw_close_datei(fhandle, 1);
jo->fhandle = 0L;
if (NULL != (f = fopen(unixname, "r"))) {
int is_ok = 0;
@ -2027,7 +1716,7 @@ int nw_close_file_queue(uint8 *queue_id,
}
} else XDPRINTF((1,0,"Cannot open queue-file `%s`", unixname));
} else
XDPRINTF((2,0,"fhandle=%d NOT OK anz_fhandles=%d", fhandle, anz_fhandles));
XDPRINTF((2,0,"fhandle=%d NOT OK !", fhandle));
free_queue_job(jo_id);
}
return(result);

178
connect.h
View File

@ -1,15 +1,6 @@
/* connect.h 21-Jan-96 */
typedef struct {
int fd; /* von System bei Open bzw. Create */
long offd; /* aktueller File Offset */
time_t tmodi; /* modification TIME */
FILE *f; /* for PIPE */
int flags; /* 2 = PIPE */
/* 4 = don't reuse after close */
char name[256]; /* UNIX Dateiname */
} FILE_HANDLE;
/* connect.h 28-Jan-96 */
#ifndef _CONNECT_H_
#define _CONNECT_H_
typedef struct {
DIR *f;
char unixname[256]; /* kompletter unixname */
@ -37,6 +28,95 @@ typedef struct {
uint8 task; /* actual task */
} NW_DIR;
typedef struct {
uint8 name[14]; /* filename in DOS format */
uint8 attrib; /* Attribute */
uint8 ext_attrib; /* File Execute Type */
uint8 size[4]; /* size of file */
uint8 create_date[2];
uint8 acces_date[2];
uint8 modify_date[2];
uint8 modify_time[2];
} NW_FILE_INFO;
typedef struct {
uint8 name[14]; /* dirname */
uint8 attrib;
uint8 ext_attrib;
uint8 create_date[2];
uint8 create_time[2];
uint8 owner_id[4];
uint8 access_right_mask;
uint8 reserved; /* future use */
uint8 next_search[2];
} NW_DIR_INFO;
extern int nw_init_connect(void);
extern int nw_free_handles(int task);
extern int nw_creat_open_file(int dir_handle, uint8 *data, int len,
NW_FILE_INFO *info, int attrib, int access, int mode);
extern int nw_delete_datei(int dir_handle, uint8 *data, int len);
extern int nw_chmod_datei(int dir_handle, uint8 *data, int len, int modus);
extern int mv_file(int qdirhandle, uint8 *q, int qlen,
int zdirhandle, uint8 *z, int zlen);
extern int nw_mk_rd_dir(int dir_handle, uint8 *data, int len, int mode);
extern int nw_search(uint8 *info,
int dirhandle, int searchsequence,
int search_attrib, uint8 *data, int len);
extern int nw_dir_search(uint8 *info,
int dirhandle, int searchsequence,
int search_attrib, uint8 *data, int len);
extern int nw_find_dir_handle( int dir_handle,
uint8 *data, /* zus„tzlicher Pfad */
int len); /* L„nge Pfad */
extern int nw_alloc_dir_handle(
int dir_handle, /* Suche ab Pfad dirhandle */
uint8 *data, /* zus„tzl. Pfad */
int len, /* L„nge DATA */
int driveletter, /* A .. Z normal */
int is_temphandle, /* tempor„res Handle 1 */
/* spez. temp Handle 2 */
int task); /* Prozess Task */
extern int nw_open_dir_handle( int dir_handle,
uint8 *data, /* zus„tzlicher Pfad */
int len, /* L„nge DATA */
int *volume, /* Volume */
int *dir_id, /* „hnlich Filehandle */
int *searchsequence);
extern int nw_free_dir_handle(int dir_handle);
extern int nw_set_dir_handle(int targetdir, int dir_handle,
uint8 *data, int len, int task);
extern int nw_get_directory_path(int dir_handle, uint8 *name);
extern int nw_get_vol_number(int dir_handle);
extern int nw_get_eff_dir_rights(int dir_handle, uint8 *data, int len, int modus);
extern int nw_scan_dir_info(int dir_handle, uint8 *data, int len,
uint8 *subnr, uint8 *subname,
uint8 *subdatetime, uint8 *owner);
#define MAX_NW_DIRS 255
extern NW_DIR dirs[MAX_NW_DIRS];
extern int used_dirs;
@ -64,6 +144,77 @@ extern int fn_match(uint8 *s, uint8 *p, uint8 options);
/* queues */
typedef struct {
uint8 record_in_use[2];
uint8 record_previous[4];
uint8 record_next[4];
uint8 client_connection[4];
uint8 client_task[4];
uint8 client_id[4];
uint8 target_id[4]; /* 0xff, 0xff, 0xff, 0xff */
uint8 target_execute_time[6]; /* all 0xff */
uint8 job_entry_time[6]; /* all zero */
uint8 job_id[4]; /* ?? alles 0 HI-LOW */
uint8 job_typ[2]; /* z.B. Printform HI-LOW */
uint8 job_position[2]; /* ?? alles 0 low-high ? */
uint8 job_control_flags[2]; /* z.B 0x10, 0x00 */
/* 0x80 operator hold flag */
/* 0x40 user hold flag */
/* 0x20 entry open flag */
/* 0x10 service restart flag */
/* 0x08 autostart flag */
uint8 job_file_name[14]; /* len + DOS filename */
uint8 job_file_handle[4];
uint8 server_station[4];
uint8 server_task[4];
uint8 server_id[4];
uint8 job_bez[50]; /* "LPT1 Catch" */
uint8 client_area[152];
} QUEUE_JOB;
typedef struct {
uint8 client_connection;
uint8 client_task;
uint8 client_id[4];
uint8 target_id[4]; /* 0xff, 0xff, 0xff, 0xff */
uint8 target_execute_time[6]; /* all 0xff */
uint8 job_entry_time[6]; /* all zero */
uint8 job_id[2]; /* ?? alles 0 HI-LOW */
uint8 job_typ[2]; /* z.B. Printform HI-LOW */
uint8 job_position; /* zero */
uint8 job_control_flags; /* z.B 0x10 */
/* 0x80 operator hold flag */
/* 0x40 user hold flag */
/* 0x20 entry open flag */
/* 0x10 service restart flag */
/* 0x08 autostart flag */
uint8 job_file_name[14]; /* len + DOS filename */
uint8 job_file_handle[6];
uint8 server_station;
uint8 server_task;
uint8 server_id[4];
uint8 job_bez[50]; /* "LPT1 Catch" */
uint8 client_area[152];
} QUEUE_JOB_OLD; /* before 3.11 */
typedef struct {
uint8 version; /* normal 0x0 */
uint8 tabsize; /* normal 0x8 */
uint8 anz_copies[2]; /* copies 0x0, 0x01 */
uint8 print_flags[2]; /* 0x0, 0xc0 z.B. with banner */
uint8 max_lines[2]; /* 0x0, 0x42 */
uint8 max_chars[2]; /* 0x0, 0x84 */
uint8 form_name[16]; /* "UNKNOWN" */
uint8 reserved[6]; /* all zero */
uint8 banner_user_name[13]; /* "SUPERVISOR" */
uint8 bannner_file_name[13]; /* "LST:" */
uint8 bannner_header_file_name[14]; /* all zero */
uint8 file_path_name[80]; /* all zero */
} QUEUE_PRINT_AREA;
extern int nw_creat_queue(int connection, uint8 *queue_id, uint8 *queue_job,
uint8 *dirname, int dir_nam_len, int old_call);
@ -72,7 +223,6 @@ extern int nw_close_file_queue(uint8 *queue_id,
uint8 *prc, int prc_len);
extern uint16 un_date_2_nw(time_t time, uint8 *d);
extern time_t nw_2_un_time(uint8 *d, uint8 *t);
extern uint16 un_time_2_nw(time_t time, uint8 *d);
@ -80,4 +230,4 @@ extern uint16 un_time_2_nw(time_t time, uint8 *d);
extern void xun_date_2_nw(time_t time, uint8 *d);
extern void xun_time_2_nw(time_t time, uint8 *d);
#endif

View File

@ -1,9 +1,9 @@
/* emutli.c 22-Jan-96 */
/* emutli.c 07-Feb-96 */
/*
* One short try to emulate TLI with SOCKETS.
*/
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -237,30 +237,6 @@ void exit_dev(char *devname, int frame)
del_interface(devname, frame);
}
int get_ipx_addr(ipxAddr_t *addr)
{
int sock = socket(AF_IPX, SOCK_DGRAM, AF_IPX);
int result=-1;
if (sock > -1) {
struct sockaddr_ipx ipxs;
int maxplen=sizeof(struct sockaddr_ipx);
result=0;
memset((char*)&ipxs, 0, sizeof(struct sockaddr_ipx));
ipxs.sipx_family=AF_IPX;
if (bind(sock, (struct sockaddr*)&ipxs, sizeof(struct sockaddr_ipx))==-1){
errorp(0, "EMUTLI:bind", NULL);
result = -1;
} else {
if (getsockname(sock, (struct sockaddr*)&ipxs, &maxplen) == -1){
errorp(0, "EMUTLI:init_ipx:getsockname", NULL);
result = -1;
} else sock2ipxadr(addr, &ipxs);
}
close(sock);
} else errorp(0, "EMUTLI:bind", NULL);
return(result);
}
void ipx_route_add(uint32 dest_net,
uint32 route_net,
uint8 *route_node)
@ -351,7 +327,10 @@ int t_bind(int sock, struct t_bind *a_in, struct t_bind *a_out)
&& a_in->addr.len == sizeof(ipxAddr_t))
ipx2sockadr(&ipxs, (ipxAddr_t*) (a_in->addr.buf));
ipxs.sipx_network = 0L;
ipxs.sipx_network = 0L; /* allways default net */
memset(ipxs.sipx_node, 0, IPX_NODE_SIZE); /* allways default node */
/* Hi Volker :) */
if (bind(sock, (struct sockaddr*)&ipxs, sizeof(struct sockaddr_ipx))==-1) {
errorp(0, "TLI-BIND", "socket Nr:0x%x", (int)GET_BE16(&(ipxs.sipx_port)));
@ -388,7 +367,7 @@ int t_close(int fd)
int poll( struct pollfd *fds, unsigned long nfds, int timeout)
/* z.Z. nur POLL-IN */
/* only POLL-IN */
{
fd_set readfs;
/*

View File

@ -1,4 +1,4 @@
/* emutli.h 11-Sep-95 */
/* emutli.h 30-Jan-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
*
@ -101,7 +101,9 @@ extern void exit_ipx(int full);
extern int init_dev(char *devname, int frame, uint32 network);
extern void exit_dev(char *devname, int frame);
#if 0
extern int get_ipx_addr(ipxAddr_t *addr);
#endif
extern void ipx_route_add(uint32 dest_net,
uint32 route_net,

7
examples/README.dosemu Normal file
View File

@ -0,0 +1,7 @@
If dosemu don't work together with mars_nwe you should apply
the dirty dosemu-patch to the dosemu program.
In 1.3.6? the changing of an existing route over the internal net
is not ignored, but handled as an error (EINVAL, Alan's idea :-( ) .
Therefor actual dosemus can fail when then want to access a external
server.

View File

@ -1,4 +1,6 @@
this kernelpatch for kernels 1.3.56,57,58, ?? makes 3 things.
!! this kernelpatch is not needed for kernel >= 1.3.60 :) !!
this kernelpatch for clean kernels 1.3.56,57,58, pur 59 makes 3 things.
- removes the ipx-send bug. BIG THANKS to Volker Lendecke.
the problem was that sometimes the sendto function hung.

View File

@ -1,16 +1,32 @@
/* config.h: 22-Jan-96 */
/* config.h: 08-Feb-96 */
/* some of this config is needed by make, others by cc */
#define FILENAME_NW_INI "/etc/nwserv.conf" /* full name of ini (conf) file */
#define PATHNAME_PROGS "/sbin" /* path location of progs */
#define PATHNAME_BINDERY "/etc" /* path location of bindery */
#define MAX_CONNECTIONS 5 /* max. Number of Connections */
/* must be < 256 !!! */
#define NETWORK_SERIAL_NMBR 0x44444444L /* Serial Number 4 Byte */
#define NETWORK_APPL_NMBR 0x2222 /* Applikation Number 2 Byte */
#define MAX_NW_VOLS 10 /* max. Volumes */
#define MAX_CONNECTIONS 5 /* max. Number of Connections */
/* must be < 256 !!! */
#define MAX_NW_VOLS 10 /* max. Volumes */
#define IPX_DATA_GR_546 1 /* allow ipx packets > 546+30 Byte */
#define WITH_NAME_SPACE_CALLS 0 /* Namespace Calls are only badly */
/* supported till now. */
/* to enable testing of them this */
/* entry must be changed to '1' and */
/* entry '6' in ini file must be set */
/* to '1', too. */
#define MAX_NW_SERVERS 40 /* max. count of servers */
/* <--------------- next is for linux only -------------------> */
#define INTERNAL_RIP_SAP 1 /* use internal/own rip/sap process */
#define MAX_NET_DEVICES 5 /* max. Netdevices, frames */
#define MAX_NW_ROUTES 50 /* max. networks (internal + external) */
/* this is for very special use of mars_nwe to only act as a router */
#define FILE_SERVER_INACTIV 0 /* 1 = ncpserv will not be startet */
#define MAX_NET_DEVICES 5 /* max. Netdevices, frames */
#define IPX_DATA_GR_546 1 /* allow ipx packets > 546+30 Byte */
#define MAX_NW_ROUTES 50 /* max. networks (internal + external) */
#define MAX_NW_SERVERS 40 /* max. count of servers */

11
examples/dosemu-patch Normal file
View File

@ -0,0 +1,11 @@
--- net/ipxglt.c Thu Feb 8 10:02:54 1996
+++ net/ipxglt.c Thu Feb 8 10:13:21 1996
@@ -59,7 +59,7 @@
}
if(ioctl(sock,SIOCADDRT,(void *)&rt) < 0) {
- if( errno != EEXIST ) {
+ if( errno != EEXIST && errno != EINVAL ) {
close( sock );
return( -2 );
}

View File

@ -1,6 +1,6 @@
#!/bin/sh
# mk.li 16-Nov-95 ###
#
# mk.li 30-Jan-96 ###
# please edit this file !
mk()
{
@ -14,12 +14,46 @@ mk()
chmod 666 $ERRFILE
}
export CC=cc
export CCP="cc -E"
#export CFLAGS="-pipe -O2 -fomit-frame-pointer"
#problems gcc2.5.8 ^^^^^^^^^^^^^^^^^^^^^^^^
export CFLAGS="-pipe"
export HOSTCFLAGS="-DLINUX"
export TMP=/tmp
MAKE=make
TOLOWER='tr "[A-Z]" "[a-z]"'
UNX=`uname -s | $TOLOWER`
case $UNX in
linux)
CC=cc;
CCP="cc -E";
# CFLAGS="-pipe -O2 -fomit-frame-pointer"
# problems gcc2.5.8 ^^^^^^^^^^^^^^^^^^^^^
CFLAGS="-pipe"
HOSTCFLAGS="-DLINUX"
NDBMLIB="-ldbm"
NSLLIB=""
MAKE=make
TMP=/tmp
INSTALL=install
;;
########### USL UNIX ##############
unix_sv)
CC=cc
CCP="gcc -E"
CFLAGS="-pipe"
HOSTCFLAGS=""
NDBMLIB="/usr/ucblib/libucb.a"
NSLLIB="-lnsl"
MAKE=gmake
TMP=/tmp
INSTALL=/usr/ucb/install
;;
*) echo "mk.li: Unknown or not supported OS, probably you must set \$UNX"
;;
esac
export CC
export CCP
export CFLAGS
export HOSTCFLAGS
export NDBMLIB
export NSLLIB
export TMP
export INSTALL
mk $@

View File

@ -1,19 +1,19 @@
# (C)opyright 1993, 1995, Martin Stover, Softwareentwicklung, Marburg
# last change: 22-Jan-96
# last change: 08-Feb-96
# MAR.S NW-Server Emulator
# Einfache Konfiguration, alles ab # ist Kommentar.
# Jeder Eintrag beginnt mit einer Zahl und dann folgt der Inhalt.
# simple configuration, all after # is ignored.
# every entry begins with a number and then the meet follows.
# entry 1 VOLUMES (max. 5) entry 1
# Volumename Volumepath Options (k=lowercase,p=pipe)
# entry 1 VOLUMES (max. volumes depend on your config.h)
# Volumename Volumepath Options (k=lowercase,p=pipe,m=removable)
1 SYS /u3/SYS/ # SYS 1
####################################
# Die folgenden Volumes sind optional.
# the following volumes are optional.
#1 SYS1 /u3/SYS1/ # SYS 2 upshift
#1 TMP /tmp/ k # TMP downshift
#1 CD /cdrom k # CDROM downshift
#1 CD /cdrom km # CDROM downshift/removable
#1 PIPES /u3/pipes kp # pipecommands
# Falls lowercase nicht gesetzt ist, werden GROSSBUCHSTABEN erwartet.
# If lowercase is not set then all filenames are upshift.
@ -30,10 +30,11 @@
#2 MAR1 # Servername
######################################
# next entry for configure mars_nwe to use the internal net
# If you have mars_nwe V > 0.96pl5 and the small ipx-kpatch
# from the examples dir you can use Internal Net and Routing.
# If you have mars_nwe V > 0.96pl5 and a kernel >= 1.3.60
# or the small ipx-kpatch from the examples dir you can use
# internal net and routing.
# INTERNAL NET [NODE]
###3 0x999999 1 # Node default 1
#3 0x999999 1 # Node default 1
######################################
# entry 4: # for DEVICE(S)
# if your ipx is allready up, then entry 4 must be removed.
@ -48,6 +49,9 @@
# some clients are running better, if the server tells
# that it is a 3.11 Server, although many calls
# (namespace services) of a real 3.11 Server are missing yet.
# simple namespace services are implemented for testing
# since V 0.96pl8. To test them, this entry must be set to '1'.
# and config.h must be altered to allow namespace calls.
6 0 # tells server version: 2.15=0, 3.11=1
######################################
# GID and UID for _minimal_ rights
@ -89,7 +93,7 @@
210 10 # 1 .. 600 (default 10) seconds after server really goes down
# # after a down command
#############################
300 0 # > 0 print routing info to file every x broadcasts. ( minuts )
300 0 # > 0 print routing info to file every x broadcasts. ( minutes )
301 /tmp/nw.routes # filename.
302 1 # creat new filename=1, append to file=0
#############################

View File

@ -1,4 +1,6 @@
# makefile.unx 15-Jan-96
#if 0
#makefile.unx 07-Feb-96
#endif
VPATH=..
O=.o
C=.c
@ -6,7 +8,7 @@ C=.c
DEBUG=-DDB
V_H=0
V_L=96
P_L=7
P_L=8
#define D_P_L 1
DISTRIB=mars_nwe
#if D_P_L
@ -53,24 +55,12 @@ $(DESTMAKEFILE): makefile.unx config.h
#endif
PROG1=netinit
PROG1=
PROG2=nwserv
PROG3=nwconn
PROG4=ncpserv
PROG5=nwclient
#ifdef LINUX
EMUTLIOBJ=emutli$(O)
PROG1=
NDBMLIB=-ldbm
NSLLIB=
#else
NDBMLIB=/usr/ucblib/libucb.a
NSLLIB=-lnsl
#endif
PROGS=$(PROG1) $(PROG2) $(PROG3) $(PROG4) $(PROG5)
#include "config.h"
#ifdef FILENAME_NW_INI
M_FILENAME_NW_INI=FILENAME_NW_INI
@ -84,25 +74,43 @@ M_PATHNAME_PROGS=PATHNAME_PROGS
M_PATHNAME_PROGS="."
#endif
#ifndef INTERNAL_RIP_SAP
#define INTERNAL_RIP_SAP 1
#endif
#ifdef LINUX
EMUTLIOBJ=emutli$(O)
# if INTERNAL_RIP_SAP
NWROUTE_O=nwroute$(O)
# else
NWROUTE_O=nwroute1$(O)
# endif
#else
NWROUTE_O=nwroute1$(O)
#endif
PROGS=$(PROG1) $(PROG2) $(PROG3) $(PROG4) $(PROG5)
OBJ1= $(EMUTLIOBJ) net1$(O) tools$(O)
OBJ2= $(OBJ1) nwroute$(O)
OBJ3= $(OBJ1) connect$(O) namspace$(O) nwvolume$(O)
OBJ2= $(OBJ1) $(NWROUTE_O)
OBJ3= $(OBJ1) connect$(O) namspace$(O) nwvolume$(O) nwfile$(O)
OBJ4= $(OBJ1) nwdbm$(O) nwcrypt$(O)
OBJ5= $(OBJ1)
OBJS= net1$(O) tools$(O) connect$(O) nwdbm$(O) nwroute$(O) \
OBJS= net1$(O) tools$(O) connect$(O) nwdbm$(O) $(NWROUTE_O) \
namspace$(O) nwvolume$(O) \
$(PROG2)$(O) $(PROG3)$(O) $(PROG4)$(O) $(PROG5)$(O)
HOBJ3= $(PROG3)$(O) connect$(O) namspace$(O)
HOBJ3= $(PROG3)$(O) connect$(O) namspace$(O) nwvolume$(O) nwfile$(O)
$(PROG1): $(PROG1)$(O) $(OBJ1)
$(CC) -o ../$(PROG1) $(PROG1)$(O) $(OBJ1) $(NSLLIB)
$(PROG2): $(PROG2)$(O) $(OBJ2)
$(CC) -o ../$(PROG2) $(PROG2)$(O) $(OBJ2) $(NSLLIB)
#if 0
#$(CC) -o ../$(PROG2) $(PROG2)$(O) $(OBJ2) $(NDBMLIB) $(NSLLIB)
#endif
$(PROG3): $(PROG3)$(O) $(OBJ3)
$(CC) -o ../$(PROG3) $(PROG3)$(O) $(OBJ3) $(NSLLIB)
@ -113,7 +121,7 @@ $(PROG4): $(PROG4)$(O) $(OBJ4)
$(PROG5): $(PROG5)$(O) $(OBJ5)
$(CC) -o ../$(PROG5) $(PROG5)$(O) $(OBJ5) $(NSLLIB)
$(HOBJ3): namspace.h connect.h nwvolume.h
$(HOBJ3): namspace.h connect.h nwvolume.h nwfile.h
$(OBJS): net.h config.h
$(C)$(O):
@ -123,11 +131,11 @@ $(C)$(O):
n_all: $(PROGS)
n_install_ini:
cd .. && install -m 664 nw.ini $(M_FILENAME_NW_INI) && cd obj
cd .. && $(INSTALL) -m 664 nw.ini $(M_FILENAME_NW_INI) && cd obj
n_install:
cd .. && install -d $(M_PATHNAME_PROGS) && cd obj
cd .. && install $(PROGS) $(M_PATHNAME_PROGS) && cd obj
cd .. && $(INSTALL) -d $(M_PATHNAME_PROGS) && cd obj
cd .. && $(INSTALL) $(PROGS) $(M_PATHNAME_PROGS) && cd obj
@cd .. && (if [ -r $(M_FILENAME_NW_INI) ] ; then \
echo ""; \
echo "********************************************************"; \
@ -138,7 +146,7 @@ echo ""; \
echo "********************************************************"; \
echo ""; \
else \
install -m 664 nw.ini $(M_FILENAME_NW_INI); \
$(INSTALL) -m 664 nw.ini $(M_FILENAME_NW_INI); \
echo ""; \
echo "********************************************************"; \
echo ""; \
@ -175,8 +183,6 @@ n_make_dir: n_clean1
$(DISTRIB).lsm \
$(DISTRIB)/. \
; rm -f $(DISTRIB)/config.h \
; rm -f $(DISTRIB)/namspace.? \
; cp old/namspace.? $(DISTRIB)/. \
; ln -f \
examples/$(STERN) \
$(DISTRIB)/examples/. \

View File

@ -1,16 +1,16 @@
Begin3
Title: mars_nwe
Version: 0.96pl7
Entered-date: 22-Jan-96
Version: 0.96pl8
Entered-date: 08-Feb-96
Description: full novell-server-emulator (src),beta
file-services, bindery-services, printing-services
needs no kernelchanges, usefull for testing ipx
supports file-services, bindery-services,
printing-services, routing-services
Keywords: novell, netware, server, ipx, ncp, tli
Author: mstover@freeway.de (Martin Stover)
Maintained-by: mstover@freeway.de (Martin Stover)
Primary-site: linux01.gwdg.de /pub/ncpfs
120kB mars_nwe-0.96.pl7.tgz
Alternate-site: ftp.uni-duisburg.de /pub/linux/ipxware
Platforms: Linux (1.2.xx, 1.3.32, 1.3.55 tested, others should work)
Platforms: Linux (1.2.xx, 1.3.32, > 1.3.55 tested, others should work)
Copying-policy: GNU
End

View File

@ -1,6 +1,10 @@
/* namspace.c 08-Jan-96 : NameSpace Services, mars_nwe */
/* namspace.c 07-Feb-96 : NameSpace Services, mars_nwe */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
/* !!!!!!!!!!!! NOTE !!!!!!!!!! */
/* Its very dirty till now. */
/* namespace calls should be only activated for testings */
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -20,8 +24,896 @@
#include "net.h"
#include <dirent.h>
#include <utime.h>
#ifndef LINUX
#include <errno.h>
#endif
#include "nwvolume.h"
#include "connect.h"
#include "nwfile.h"
#include "namspace.h"
#if WITH_NAME_SPACE_CALLS
#define NW_PATH /* */
typedef struct {
int volume; /* Volume Number */
int has_wild; /* fn has wildcards */
struct stat statb;
uint8 *fn; /* points to last entry of path */
uint8 path[512]; /* path + fn */
} N_NW_PATH;
typedef struct {
DIR *fdir; /* for dir searches */
uint8 *kpath; /* points one after unixname */
uint8 *unixname; /* is allocates fullname of path */
/* + 257 Byte for filename. */
} DIR_SEARCH_STRUCT;
typedef struct {
uint32 basehandle;
int namespace; /* namespace of this entry */
DIR_SEARCH_STRUCT *dir; /* for dir searches */
N_NW_PATH nwpath;
} DIR_BASE_ENTRY;
#define MAX_DIR_BASE_ENTRIES 300
static DIR_BASE_ENTRY *dir_base[MAX_DIR_BASE_ENTRIES];
static int anz_dbe = 0;
static void init_nwpath(N_NW_PATH *nwpath)
{
nwpath->volume = -1;
nwpath->has_wild = 0;
nwpath->fn = nwpath->path;
*(nwpath->path) = '\0';
}
static char *xnwpath_2_unix(N_NW_PATH *nwpath, int modus,
int allocate_extra)
/*
* returns complete UNIX path
* modus & 1 : ignore fn, (only path)
* modus & 2 : no '/' at end
*
* if allocate_extra > 0, then not the static buffer will be returned
* but a fresh allocated buffer, which must be deallocated later.
*/
{
static char unixname[512]; /* should be big enouugh */
int len;
int volume = nwpath->volume;
char *p, *pp;
if (volume < 0 || volume >= used_nw_volumes) {
fprintf(stderr, "nwpath_2_unix volume=%d not ok\n", volume);
strcpy(unixname, "Z/Z/Z/Z"); /* */
len = strlen(unixname);
} else {
int m = ((modus & 1) && nwpath->fn > nwpath->path) /* last path = fn */
? nwpath->fn - nwpath->path
: strlen((char*)nwpath->path);
len = nw_volumes[volume].unixnamlen;
if (m+len >= sizeof(unixname)) {
fprintf(stderr, "nwpath_2_unix buffer to small, needs %d Byte",
m+len+1);
strcpy(unixname, "Z/Z/Z/Z"); /* */
len = strlen(unixname);
} else {
memcpy(unixname, nw_volumes[volume].unixname, len); /* first UNIXNAME VOLUME */
p = pp = unixname+len;
memcpy(p, nwpath->path, m); /* path or partiell path */
len += m;
p += m;
if ((modus & 2) && *(p-1) == '/' ) *(--p) = '\0';
else *p = '\0';
if (nw_volumes[volume].options & 1) downstr((uint8*)pp);
}
}
if (allocate_extra) {
char *ret=xmalloc(len+allocate_extra+2);
strcpy(ret, unixname);
return(ret);
}
return(unixname);
}
#define nwpath_2_unix(nwpath, modus) xnwpath_2_unix((nwpath), (modus), 0)
static void free_dbe_dir(DIR_BASE_ENTRY *dbe)
{
DIR_SEARCH_STRUCT *d = dbe->dir;
if (NULL != d) {
if (d->fdir) closedir(d->fdir);
xfree(d->unixname);
xfree(dbe->dir);
}
}
static int allocate_dbe_dir(DIR_BASE_ENTRY *dbe)
{
DIR_SEARCH_STRUCT *d;
if (dbe->dir) free_dbe_dir(dbe);
dbe->dir = d = (DIR_SEARCH_STRUCT*) xcmalloc(sizeof(DIR_SEARCH_STRUCT));
d->unixname = (uint8*)xnwpath_2_unix(&(dbe->nwpath), 2, 258);
if (NULL == (d->fdir = opendir(d->unixname))) {
free_dbe_dir(dbe);
return(-0xff);
} else {
d->kpath = d->unixname+strlen(d->unixname);
*(d->kpath) = '/';
*(++d->kpath) = '\0';
return(0);
}
}
static void free_dbe_ptr(DIR_BASE_ENTRY *dbe)
{
if (dbe != (DIR_BASE_ENTRY*)NULL) {
free_dbe_dir(dbe);
xfree(dbe);
}
}
static int base_open_seek_dir(DIR_BASE_ENTRY *dbe, uint32 offset)
{
int result = ((dbe->nwpath.statb.st_mode & S_IFMT) != S_IFDIR) ? -0xff : 0;
if (!result) {
if (NULL == dbe->dir) result=allocate_dbe_dir(dbe);
if (result>-1) seekdir(dbe->dir->fdir, offset);
}
if (result < 0 && NULL != dbe->dir) free_dbe_dir(dbe);
XDPRINTF((3, 0, "base_open_seek_dir offset=%d, result=%d", offset, result));
return(result);
}
static int allocate_dbe(int namespace)
/* returns new allocated dir_base_entry */
{
int j=-1;
DIR_BASE_ENTRY **pdbe=(DIR_BASE_ENTRY**) NULL;
if (namespace) return(-0xff); /* TODO: more namespaces */
while (++j < anz_dbe && NULL != *(pdbe = &(dir_base[j])) ) ;;
if (j == anz_dbe) {
if (anz_dbe == MAX_DIR_BASE_ENTRIES) { /* return(-0xff); */
pdbe = &(dir_base[--j]);
free_dbe_ptr(*pdbe);
} else pdbe = &(dir_base[anz_dbe++]);
}
*pdbe = (DIR_BASE_ENTRY*)xcmalloc(sizeof(DIR_BASE_ENTRY));
(*pdbe)->namespace = namespace;
init_nwpath(&((*pdbe)->nwpath));
return(j);
}
static void free_dbe(int dbase)
{
if (dbase > -1 && dbase < anz_dbe) {
free_dbe_ptr(dir_base[dbase]);
dir_base[dbase] = (DIR_BASE_ENTRY*)NULL;
if (dbase+1 == anz_dbe) {
while (anz_dbe && ((DIR_BASE_ENTRY*)NULL == dir_base[anz_dbe-1]) )
--anz_dbe;
}
}
}
int touch_handle_entry(int dbase)
/* routine touchs this entry and returns the new offset */
{
XDPRINTF((4, 0, "touch_handle_entry entry dbase=%d", dbase));
if (dbase > 2) {
DIR_BASE_ENTRY *dbe=dir_base[dbase];
while (dbase--) dir_base[dbase+1] = dir_base[dbase];
dbase=0;
dir_base[0] = dbe;
}
XDPRINTF((4, 0, "touch_handle_entry return dbase=%d", dbase));
return(dbase);
}
char *debug_nwpath_name(N_NW_PATH *p)
/* for debugging */
{
#ifdef DB
static char nwpathname[512];
char volname[300];
if (nw_get_volume_name(p->volume, volname) < 0)
sprintf(volname, "<%d=NOT-OK>", (int)p->volume);
sprintf(nwpathname, "`%s:%s`,fn=`%s`", volname, p->path, p->fn);
#else
static char nwpathname[2];
nwpathname[0]='\0';
nwpathname[1]='\0';
#endif
return(nwpathname);
}
static int add_hpath_to_nwpath(N_NW_PATH *nwpath,
NW_HPATH *nwp, uint8 *pp_pathes)
/* Routine adds nwp to nwpath */
/* nwpath must be setup correctly before entry */
/* return > -1 if ok */
{
int result = 0;
int k = -1;
uint8 *pp = nwpath->path+strlen(nwpath->path);
while (!result && ++k < nwp->components) {
int len = (int) *(pp_pathes++);
uint8 *p = pp_pathes;
pp_pathes+=len;
if (!k && nwpath->volume == -1) { /* first component is volume */
if ((nwpath->volume=nw_get_volume_number(p, len)) < 0) {
result = nwpath->volume;
goto leave_build_nwpath;
}
} else { /* here is path (+ fn ) */
int i=len;
if (pp > nwpath->path) { /* not the first entry */
*pp='/';
*++pp='\0';
}
while (i--) {
if (*p == 0xae) *pp++ = '.';
else if (*p > 0x60 && *p < 0x7b) {
*pp++ = *p - 0x20; /* all is upshift */
} else if (*p == 0xaa || *p == '*' ) {
*pp++ = '*';
nwpath->has_wild++;
} else if (*p == 0xbf || *p == '?' ) {
*pp++ = '?';
nwpath->has_wild++;
} else if (*p == '/' || *p == '\\') {
*pp++ = '/';
} else if (*p == ':') { /* extract volume */
int vlen = (int) (pp - nwpath->path);
if ((nwpath->volume=nw_get_volume_number(nwpath->path, vlen)) < 0) {
result = nwpath->volume;
goto leave_build_nwpath;
}
pp=nwpath->path;
*pp='\0';
} else *pp++ = *p;
p++;
} /* while */
*pp = '\0';
} /* else */
} /* while */
if (nwpath->volume < 0) result=-0x9c;
leave_build_nwpath:
XDPRINTF((2, 0, "add_hpath_to_nwpath: result=0x%x, nwpath=%s",
result, debug_nwpath_name(nwpath)));
return(result);
}
static uint32 build_base_handle(N_NW_PATH *nwpath, int namespace)
/* returns basehandle of path, or 0 if not exist !! */
{
uint32 basehandle=0L;
if (!stat(nwpath_2_unix(nwpath, 2), &(nwpath->statb))) {
DEV_NAMESPACE_MAP dnm;
dnm.dev = nwpath->statb.st_dev;
dnm.namespace = namespace;
basehandle=nw_vol_inode_to_handle(nwpath->volume,
nwpath->statb.st_ino,
&dnm);
} else {
XDPRINTF((4,0, "build_base_handle failed:`%s`",
debug_nwpath_name(nwpath)));
}
return(basehandle);
}
static int find_base_entry(int volume, uint32 basehandle)
{
int k=-1;
while (++k < anz_dbe) {
DIR_BASE_ENTRY *e=dir_base[k];
if ( (DIR_BASE_ENTRY*)NULL != e
&& basehandle == e->basehandle
&& volume == e->nwpath.volume) return(k);
}
return(-0x9b);
}
static int insert_get_base_entry(N_NW_PATH *nwpath, int dbase,
int namespace, int creatmode)
{
uint32 basehandle = build_base_handle(nwpath, namespace);
if (!basehandle && creatmode) {
int result = 0;
char *unname = nwpath_2_unix(nwpath, 2);
if (creatmode & FILE_ATTR_DIR) {
/* creat dir */
if (mkdir(unname, 0777)) result=-0x84;
} else {
/* creat file */
if ((result = creat(unname, 0777)) > -1) {
close(result);
result = 0;
} else result=-0x84;
}
if (result) return(result);
basehandle = build_base_handle(nwpath, namespace);
}
if (basehandle) {
DIR_BASE_ENTRY *dbe=dir_base[dbase];
int k=-1;
while (++k < anz_dbe) {
DIR_BASE_ENTRY *e=dir_base[k];
if ( (DIR_BASE_ENTRY*)NULL != e
&& basehandle == e->basehandle
&& nwpath->volume == e->nwpath.volume) {
free_dbe(dbase);
return(touch_handle_entry(k));
}
} /* while */
/* now i know that it's a new base entry */
dbe->basehandle = basehandle;
return(touch_handle_entry(dbase));
}
return(-0x9c);
}
static int build_dos_base(NW_HPATH *nwp, uint8 *pathes,
int dbase, int mode, uint8 *rets)
/* routine returns the actual dbe entry offset or */
/* < 0 if error */
/* if mode == 1, then last_path will be ignored and will be put */
/* into the rets variable */
{
DIR_BASE_ENTRY *dbe=dir_base[dbase];
N_NW_PATH *nwpath=&(dbe->nwpath);
int result=0;
if (!nwp->flag) { /* short handle */
int dir_handle = nwp->base[0];
if (dir_handle > 0 && --dir_handle < (int)used_dirs
&& dirs[dir_handle].inode) {
nwpath->volume = dirs[dir_handle].volume;
strcpy(nwpath->path, dirs[dir_handle].path);
result = (nwpath->volume > -1) ? 0 : -0x98;
} else result = -0x9b;
} else if (nwp->flag == 1) { /* basehandle */
uint32 basehandle = GET_32(nwp->base);
int k=-1;
result = -0x9b;
while (++k < anz_dbe) {
if (k != dbase) {
DIR_BASE_ENTRY *e=dir_base[k];
if ( (DIR_BASE_ENTRY*)NULL != e
&& e->nwpath.volume == nwp->volume
&& e->basehandle == basehandle) {
nwpath->volume = e->nwpath.volume;
strcpy(nwpath->path, e->nwpath.path);
result = (nwpath->volume > -1) ? 0 : -0x98;
break;
}
}
}
} else if (nwp->flag != 0xff) result=-0xff;
if (!result) {
if ((result = add_hpath_to_nwpath(nwpath, nwp, pathes)) > -1) {
char *pp=strrchr((char*)nwpath->path, '/');
if (mode) {
if (pp) {
if (rets) strcpy(rets, pp+1);
*(pp)=0;
pp=strrchr((char*)nwpath->path, '/');
} else {
if (rets) strcpy(rets, nwpath->path);
*(nwpath->path) = '\0';
}
}
if (pp) nwpath->fn=(uint8*)pp+1;
result = insert_get_base_entry(nwpath, dbase, NAME_DOS, 0);
}
}
return(result);
}
int nw_generate_dir_path(int namespace,
NW_HPATH *nwp,
uint8 *ns_dir_base,
uint8 *dos_dir_base)
/* returns Volume Number >=0 or errcode < 0 if error */
{
int dbase = allocate_dbe(namespace);
int result = -0xfb;
if (dbase > -1) {
if ((result = build_dos_base(nwp, nwp->pathes, dbase, 0, NULL)) > -1) {
DIR_BASE_ENTRY *dbe=dir_base[result];
U32_TO_32(dbe->basehandle, ns_dir_base); /* LOW - HIGH */
U32_TO_32(dbe->basehandle, dos_dir_base);
XDPRINTF((3, 0, "nw_generate_dir_path path=%s, result=%d, basehandle=0x%x",
debug_nwpath_name(&(dbe->nwpath)), result, dbe->basehandle));
result= dbe->nwpath.volume;
} else free_dbe(dbase);
}
if (result < 0) {
XDPRINTF((3, 0, "nw_generate_dir_path NOT OK dbase=%d, result=%d",
dbase, result));
}
return(result);
}
static int build_dir_info(DIR_BASE_ENTRY *dbe, uint32 infomask, uint8 *p)
{
N_NW_PATH *nwpath=&(dbe->nwpath);
struct stat *stb=&(nwpath->statb);
int result = 76;
memset(p, 0, result);
if (infomask & INFO_MSK_DATA_STREAM_SPACE) {
U32_TO_32(stb->st_size, p);
}
p += 4;
if (infomask & INFO_MSK_ATTRIBUTE_INFO) {
uint32 mask=0L;
if (S_ISDIR(stb->st_mode)) mask |= FILE_ATTR_DIR;
U32_TO_32(mask, p);
p += 4;
U16_TO_16((uint16)(mask & 0xFFFF), p);
p +=2;
} else p+=6;
if (infomask & INFO_MSK_DATA_STREAM_SIZE) {
U32_TO_32(stb->st_size, p);
}
p +=4;
if (infomask & INFO_MSK_TOTAL_DATA_STREAM_SIZE) {
U32_TO_32(stb->st_size, p);
p +=4;
U16_TO_16(0, p);
p +=2;
} else p+=6;
if (infomask & INFO_MSK_CREAT_INFO) {
xun_time_2_nw(stb->st_mtime, p);
p +=2;
xun_date_2_nw(stb->st_mtime, p);
p +=2;
U32_TO_32(1, p);
p +=4;
} else p+=8;
if (infomask & INFO_MSK_MODIFY_INFO) {
xun_time_2_nw(stb->st_mtime, p);
p +=2;
xun_date_2_nw(stb->st_mtime, p);
p +=2;
U32_TO_32(1, p);
p +=4;
xun_date_2_nw(stb->st_atime, p); /* access date */
p +=2;
} else p+=10;
if (infomask & INFO_MSK_ARCHIVE_INFO) {
xun_time_2_nw(0, p);
p +=2;
xun_date_2_nw(0, p);
p +=2;
U32_TO_32(0, p);
p +=4;
} else p+=8;
if (infomask & INFO_MSK_RIGHTS_INFO) {
U16_TO_16(0, p);
}
p +=2;
if (infomask & INFO_MSK_DIR_ENTRY_INFO) {
U32_TO_32(dbe->basehandle, p);
p +=4;
U32_TO_32(dbe->basehandle, p);
p +=4;
U32_TO_32(nwpath->volume, p);
p +=4;
} else p+=12;
if (infomask & INFO_MSK_EXT_ATTRIBUTES) {
U32_TO_32(0, p); /* Ext Attr Data Size */
p +=4;
U32_TO_32(0, p); /* Ext Attr Count */
p +=4;
U32_TO_32(0, p); /* Ext Attr Key Size */
p +=4;
} else p+=12;
if (infomask & INFO_MSK_NAME_SPACE_INFO){
U32_TO_32(0, p); /* Creator of the name space number */
}
p +=4;
/* ---------------------------------------------- */
if (infomask & INFO_MSK_ENTRY_NAME) {
*p = (uint8) strlen(nwpath->fn);
result++;
if (*p) {
memcpy(p+1, nwpath->fn, (int) *p);
result += (int) *p;
}
}
XDPRINTF((3, 0, "build_dir_info:path=%s, result=%d, basehandle=0x%x",
debug_nwpath_name(nwpath), result, dbe->basehandle));
return(result);
}
int nw_optain_file_dir_info(int namespace, NW_HPATH *nwp,
int destnamspace,
int searchattrib, uint32 infomask,
uint8 *responsedata)
/* returns sizeof info_mask
* the sizeof info_mask is NOT related by the infomask.
* But the _valid_ info is.
*/
{
int dbase = allocate_dbe(namespace);
int result = -0xfb;
if (dbase > -1) {
if ((result = build_dos_base(nwp, nwp->pathes, dbase, 0, NULL)) > -1) {
result = build_dir_info(dir_base[result], infomask, responsedata);
} else free_dbe(dbase);
}
if (result < 0) {
XDPRINTF((3, 0, "nw_optain_file_dir_info NOT OK dbase=%d, result=0x%x",
dbase, result));
}
return(result);
}
static int nw_init_search(int namespace,
NW_HPATH *nwp,
uint8 *responsedata)
{
int dbase = allocate_dbe(namespace);
int result = -0xfb;
if (dbase > -1) {
if ((result = build_dos_base(nwp, nwp->pathes, dbase, 0, NULL)) > -1) {
DIR_BASE_ENTRY *dbe=dir_base[result];
result = base_open_seek_dir(dbe, 0L);
if (result > -1) {
*responsedata++ = dbe->nwpath.volume;
U32_TO_32(dbe->basehandle, responsedata);
responsedata+=4;
U32_TO_32(0L, responsedata); /* searchsequenz */
result = 9;
}
XDPRINTF((3, 0, "nw_init_search path=%s, result=%d, basehandle=0x%x",
debug_nwpath_name(&(dbe->nwpath)), result, dbe->basehandle));
} else free_dbe(dbase);
}
if (result < 0) {
XDPRINTF((3, 0, "nw_init_search NOT OK dbase=%d, result=%d",
dbase, result));
}
return(result);
}
int get_add_new_entry(DIR_BASE_ENTRY *qbe, uint8 *path, int creatmode)
{
int dbase = allocate_dbe(qbe->namespace);
if (dbase > -1) {
DIR_BASE_ENTRY *dbe=dir_base[dbase];
N_NW_PATH *nwpath=&(dbe->nwpath);
int result = -0x9c;
nwpath->volume=qbe->nwpath.volume;
strcpy(nwpath->path, qbe->nwpath.path);
nwpath->fn = nwpath->path+strlen(nwpath->path);
if (nwpath->fn > nwpath->path && *(nwpath->fn-1) != '/') {
*(nwpath->fn) = '/';
*(++ nwpath->fn) = '\0';
}
strcpy(nwpath->fn, path);
result = insert_get_base_entry(nwpath, dbase, qbe->namespace, creatmode);
if (result < 0) free_dbe(dbase);
return(result);
}
return(dbase);
}
int nw_search_file_dir(int namespace, int datastream,
uint32 searchattrib, uint32 infomask,
int volume, uint32 basehandle, uint32 sequence,
int len, uint8 *path, uint8 *responsedata)
{
int result = find_base_entry(volume, basehandle);
if (result > -1) {
DIR_BASE_ENTRY *dbe=dir_base[result];
if ((result = base_open_seek_dir(dbe, sequence)) > -1) {
uint8 entry[256];
struct dirent *dirbuff;
struct stat statb;
int dest_entry=-1;
DIR_SEARCH_STRUCT *ds=dbe->dir;
int vol_options = get_volume_options(volume, 0);
strmaxcpy(entry, path, min(255, len));
if (vol_options & VOL_OPTION_DOWNSHIFT) downstr(entry);
XDPRINTF((5,0,"nw_search_file_dir searchpath=%s", entry));
while ((dirbuff = readdir(ds->fdir)) != (struct dirent*)NULL){
if (dirbuff->d_ino) {
uint8 *name=(uint8*)(dirbuff->d_name);
XDPRINTF((10,0,"nw_search_file_dir Name=%s",
name));
if ( (name[0] != '.' && (
(!strcmp(name, entry)) ||
(entry[0] == '*' && entry[1] == '\0')
|| fn_match(name, entry, vol_options)))) {
strcpy(ds->kpath, name);
XDPRINTF((5,0,"nw_search_file_dir Name found=%s unixname=%s",
name, ds->unixname));
if (!stat(ds->unixname, &statb)
&& ( !S_ISDIR(statb.st_mode) ||
(searchattrib & FILE_ATTR_DIR) ) ) {
strcpy(entry, name);
if (vol_options & 1) upstr(entry);
if ((dest_entry = get_add_new_entry(dbe, entry, 0)) > -1)
break;
}
}
} /* if */
} /* while */
*(ds->kpath) = '\0';
if (dest_entry > -1) {
DIR_BASE_ENTRY *dest_dbe=dir_base[dest_entry];
sequence = (uint32) telldir(ds->fdir);
*responsedata = (uint8) volume;
responsedata++;
U32_TO_32(basehandle, responsedata);
responsedata+=4;
U32_TO_32(sequence, responsedata);
responsedata+=4;
*responsedata = (uint8) 0; /* reserved */
responsedata++;
result = 10 +
build_dir_info(dest_dbe,
infomask|INFO_MSK_NAME_SPACE_INFO,
responsedata);
} else result=-0xfe; /* no files matching */
} /* if result */
}
return(result);
}
static int nw_open_creat_file_or_dir(int namespace,
int opencreatmode,
int attrib, uint32 infomask,
uint32 creatattrib,
int access_rights,
NW_HPATH *nwp, uint8 *pathes,
uint8 *responsedata)
{
int dbase = allocate_dbe(namespace);
int result = -0xfb;
if (dbase > -1) {
int exist=-1;
uint8 last_part[258];
*last_part='\0';
if ((result = build_dos_base(nwp, pathes, dbase, 0, NULL)) > -1) {
exist = result;
} else if (opencreatmode & OPC_MODE_CREAT) {
result = build_dos_base(nwp, pathes, dbase, 1, last_part);
if (result > -1)
result = get_add_new_entry(dir_base[result], last_part,
(creatattrib & FILE_ATTR_DIR) ? FILE_ATTR_DIR : 1);
}
if (result > -1) {
DIR_BASE_ENTRY *dbe=dir_base[result];
uint32 fhandle=0L;
int actionresult=0;
if (exist < 0) actionresult |= OPC_ACTION_CREAT;
if (!(creatattrib & FILE_ATTR_DIR)) {
int creatmode=0; /* open */
int attrib=0;
if (opencreatmode & (OPC_MODE_OPEN | OPC_MODE_CREAT) ) {
if (opencreatmode & OPC_MODE_CREAT) {
#if 0
if (exist > -1 && !(opencreatmode & OPC_MODE_REPLACE))
creatmode=2;
else
#endif
creatmode = 1;
}
if ((result = file_creat_open(dbe->nwpath.volume,
nwpath_2_unix(&dbe->nwpath, 2), &(dbe->nwpath.statb),
attrib, access_rights, creatmode)) > -1) {
fhandle = (uint32) result;
actionresult |= OPC_ACTION_OPEN; /* FILE OPEN */
if (exist > -1 && (opencreatmode & OPC_MODE_REPLACE))
actionresult |= OPC_ACTION_REPLACE; /* FILE REPLACED */
}
} else result=-0xff;
} else if (exist > -1) result=-0x84;
if (result > -1) {
U32_TO_BE32(fhandle, responsedata);
responsedata += 4;
*responsedata =(uint8) actionresult;
responsedata++ ;
result = 5 + build_dir_info(dbe,infomask, responsedata);
}
}
}
XDPRINTF((3, 0, "nw_open_creat mode=0x%x, creatattr=0x%x, access=0x%x, attr=0x%x, result=%d",
opencreatmode, creatattrib, access_rights, attrib, result));
return(result);
}
static int nw_delete_file_dir(int namespace, int searchattrib,
NW_HPATH *nwp)
{
int dbase = allocate_dbe(namespace);
int result = -0xfb;
if (dbase > -1) {
if ((result = build_dos_base(nwp, nwp->pathes, dbase, 0, NULL)) > -1) {
DIR_BASE_ENTRY *dbe=dir_base[dbase=result];
uint8 *unname=(uint8*)nwpath_2_unix(&(dbe->nwpath), 2);
if (S_ISDIR(dbe->nwpath.statb.st_mode)) result = rmdir(unname);
else result = unlink(unname);
if (result < 0) {
switch (errno) {
case EEXIST: result=-0xa0; /* dir not empty */
default: result=-0x8a; /* No privilegs */
}
} else {
result = 0;
free_dbe(dbase) ;
}
} else free_dbe(dbase);
}
return(result);
}
int handle_func_0x57(uint8 *p, uint8 *responsedata)
{
int result = -0xfb; /* unknown request */
int ufunc = (int) *p++; /* now p locates at 4 byte boundary */
int namespace = (int) *p; /* for most calls */
XDPRINTF((3, 0, "0x57 call ufunc=0x%x namespace=%d", ufunc, namespace));
switch (ufunc) {
case 0x01 : /* open creat file or subdir */
{
/* NW PATH STRUC */
int opencreatmode = *(p+1);
int attrib = (int) GET_16(p+2); /* LOW-HI */
uint32 infomask = GET_32(p+4); /* LOW-HI */
uint32 creatattrib = GET_32(p+8);
int access_rights = (int) GET_16(p+12); /* LOW-HI */
NW_HPATH nwpathstruct;
memcpy(&nwpathstruct, p+14, sizeof(nwpathstruct));
result = nw_open_creat_file_or_dir(namespace, opencreatmode,
attrib, infomask, creatattrib, access_rights,
&nwpathstruct, p+21, responsedata);
}
break;
case 0x02 : /* Initialize Search */
{
/* NW PATH STRUC */
NW_HPATH *nwpathstruct = (NW_HPATH *) (p+2);
result = nw_init_search(namespace, nwpathstruct, responsedata);
}
break;
case 0x03 : /* Search for File or DIR */
{
/* NW PATH STRUC */
int datastream = *(p+1);
int searchattrib = (int) GET_16(p+2); /* LOW-HI */
uint32 infomask = GET_32(p+4); /* LOW-HI */
int volume = *(p+8);
uint32 basehandle = GET_32(p+9); /* LOW-HI */
uint32 sequence = GET_32(p+13); /* LOW-HI */
int len = *(p+17);
uint8 *path = p+18;
result = nw_search_file_dir(namespace, datastream,
searchattrib, infomask,
volume, basehandle, sequence,
len, path, responsedata);
}
break;
case 0x06 : /* Obtain File or Subdir Info */
{
int destnamspace = (int) p+1;
int searchattrib = (int) GET_16(p+2); /* LOW-HI */
uint32 infomask = GET_32(p+4); /* LOW-HI */
NW_HPATH *nwpathstruct = (NW_HPATH *) (p+8);
result = nw_optain_file_dir_info(namespace, nwpathstruct,
destnamspace,
searchattrib, infomask,
responsedata);
}
break;
case 0x07 : /* Modify File or Dir Info */
{
}
break;
case 0x08 : /* Delete a File or Subdir */
{
int searchattrib = (int) GET_16(p+2); /* LOW-HI */
NW_HPATH *nwpathstruct = (NW_HPATH *) (p+4);
result = nw_delete_file_dir(namespace, searchattrib, nwpathstruct);
}
break;
case 0x09 : /* Set short Dir Handle*/
{
}
break;
case 0x0c : /* alloc short dir Handle */
{
}
break;
case 0x15 : /* Get Path String from short dir new */
{
}
break;
case 0x16 : /* Generate Dir BASE and VolNumber */
{
NW_HPATH *nwpathstruct = (NW_HPATH *) (p+4);
struct OUTPUT {
uint8 ns_dir_base[4]; /* BASEHANDLE */
uint8 dos_dir_base[4]; /* BASEHANDLE */
uint8 volume; /* Volumenumber*/
} *xdata= (struct OUTPUT*)responsedata;
result = nw_generate_dir_path(namespace,
nwpathstruct, xdata->ns_dir_base, xdata->dos_dir_base);
if (result >-1 ) {
xdata->volume = result;
result = sizeof(struct OUTPUT);
}
}
break;
case 0x18 : /* Get Name Spaces Loaded*/
{
int volume=*(p+2);
struct OUTPUT {
uint8 anz_name_spaces;
uint8 name_space_list[1];
} *xdata= (struct OUTPUT*)responsedata;
result=get_volume_options(volume, 0);
if (result >-1) {
xdata->anz_name_spaces = (uint8) 1;
xdata->name_space_list[0] = (uint8) NAME_DOS;
result=xdata->anz_name_spaces+1;
}
}
break;
case 0x1a : /* Get Huge NS Info new*/
{
}
break;
case 0x1c : /* GetFullPathString new*/
{
}
break;
case 0x1d : /* GetEffDirRights new */
{
}
break;
default : result = -0xfb; /* unknown request */
} /* switch */
return(result);
}
#endif

View File

@ -1,6 +1,6 @@
/* namspace.h 08-Jan-96 : NameSpace Services, mars_nwe */
/* namspace.h 07-Feb-96 : NameSpace Services, mars_nwe */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -17,4 +17,51 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#define WITH_NAME_SPACE_CALLS 0
#if WITH_NAME_SPACE_CALLS
#define NAME_DOS 0
#define NAME_MAC 1
#define NAME_NFS 2
#define NAME_FTAM 3
#define NAME_OS2 4
typedef struct {
uint8 volume; /* Volumenumber */
uint8 base[4]; /* Base or short Handle, handle is base[0] !! */
uint8 flag; /* 0=handle, 1=base, 0xff=not path nor handle */
uint8 components; /* nmbrs of pathes, components */
uint8 pathes[1]; /* form len+name */
} NW_HPATH;
#define INFO_MSK_ENTRY_NAME 0x00000001
#define INFO_MSK_DATA_STREAM_SPACE 0x00000002
#define INFO_MSK_ATTRIBUTE_INFO 0x00000004
#define INFO_MSK_DATA_STREAM_SIZE 0x00000008
#define INFO_MSK_TOTAL_DATA_STREAM_SIZE 0x00000010
#define INFO_MSK_EXT_ATTRIBUTES 0x00000020
#define INFO_MSK_ARCHIVE_INFO 0x00000040
#define INFO_MSK_MODIFY_INFO 0x00000080
#define INFO_MSK_CREAT_INFO 0x00000100
#define INFO_MSK_NAME_SPACE_INFO 0x00000200
#define INFO_MSK_DIR_ENTRY_INFO 0x00000400
#define INFO_MSK_RIGHTS_INFO 0x00000800
/* Attributes */
#define FILE_ATTR_NORMAL 0x00000000
#define FILE_ATTR_DIR 0x00000010
#define FILE_ATTR_SHARE 0x00000080
/* OPEN/CREAT Modes */
#define OPC_MODE_OPEN 0x01
#define OPC_MODE_REPLACE 0x02
#define OPC_MODE_CREAT 0x08
/* OPEN/CREAT ACTION Results */
#define OPC_ACTION_OPEN 0x01
#define OPC_ACTION_CREAT 0x02
#define OPC_ACTION_REPLACE 0x04
extern int handle_func_0x57(uint8 *p, uint8 *responsedata);
#endif

View File

@ -1,6 +1,6 @@
/* ncpserv.c */
#define REVISION_DATE "22-Jan-96"
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
#define REVISION_DATE "08-Feb-96"
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -440,9 +440,9 @@ static int handle_fxx(CONNECTION *c, int gelen, int func)
uint8 appl_number[2];
} *xdata = (struct XDATA*) responsedata;
/* serial-number 4-Byte */
U32_TO_BE32(0x44444444, xdata->serial_number);
U32_TO_BE32(NETWORK_SERIAL_NMBR, xdata->serial_number);
/* applikation-number 2-Byte */
U16_TO_BE16(0x2222, xdata->appl_number);
U16_TO_BE16(NETWORK_APPL_NMBR, xdata->appl_number);
data_len = sizeof(struct XDATA);
}
break;
@ -484,6 +484,31 @@ static int handle_fxx(CONNECTION *c, int gelen, int func)
} else completition = (uint8) -result;
} break;
case 0x15 : { /* Get Object Connection List */
uint8 *p = rdata;
int result;
NETOBJ obj;
obj.type = GET_BE16(p);
p+=2;
strmaxcpy((char*)obj.name, (char*)(p+1), (int) *(p));
upstr(obj.name);
result = find_obj_id(&obj, 0);
if (!result){
int k=-1;
int anz = 0;
p = responsedata+1;
while (++k < anz_connect && anz < 255) {
CONNECTION *cn= &connections[k];
if (cn->fd > -1 && cn->object_id == obj.id) {
*p++=(uint8)k+1;
anz++;
}
} /* while */
*responsedata = anz;
data_len = 1 + anz;
} else completition=(uint8)-result;
}
break;
case 0x16 : { /* Get Connection Info, OLD */
struct XDATA {
@ -521,7 +546,12 @@ static int handle_fxx(CONNECTION *c, int gelen, int func)
uint8 *p = c->crypt_key;
uint8 *pp = responsedata;
data_len = k;
while (k--) *pp++ = *p++ = (uint8) rand();
while (k--) *pp++ = *p++ =
#if 0
(uint8) rand();
#else
(uint8) k;
#endif
/* if all here are same (1 or 2) then the resulting key is */
/* 00000000 */
}
@ -623,6 +653,7 @@ static int handle_fxx(CONNECTION *c, int gelen, int func)
NETOBJ obj;
obj.type = GET_BE16(p);
strmaxcpy((char*)obj.name, (char*)(p+3), (int) *(p+2));
upstr(obj.name);
result = find_obj_id(&obj, 0);
if (!result){
U32_TO_BE32(obj.id, xdata->object_id);
@ -666,6 +697,7 @@ static int handle_fxx(CONNECTION *c, int gelen, int func)
NETOBJ obj;
obj.type = GET_BE16(p);
strmaxcpy((char*)obj.name, (char*)(p+3),(int) *(p+2));
upstr(obj.name);
result = find_obj_id(&obj, last_obj_id);
if (!result){
U32_TO_BE32(obj.id, xdata->object_id);
@ -969,7 +1001,8 @@ static int handle_fxx(CONNECTION *c, int gelen, int func)
obj.name, result));
}
break;
#if 0
#ifdef _CHANGE_PASSWD_TESTING_
case 0x4b : { /* keyed change pasword */
uint8 *p = rdata+sizeof(c->crypt_key);
NETOBJ obj;
@ -981,12 +1014,11 @@ static int handle_fxx(CONNECTION *c, int gelen, int func)
p += (*p+1); /* here is now password-type ?? 0x60,0x66 */
if (0 == (result = find_obj_id(&obj, 0)))
/*
result=nw_test_passwd(obj.id, c->crypt_key, rdata);
#if 0
if (result > -1)
*/
result=nw_set_enpasswd(obj.id, p+1);
#endif
if (result< 0) completition = (uint8) -result;
XDPRINTF((1, 0, "Keyed Change PW from OBJECT='%s', result=0x%x",
obj.name, result));
@ -1003,7 +1035,7 @@ static int handle_fxx(CONNECTION *c, int gelen, int func)
XDPRINTF((1, 0, "TODO:Create QUEUE ??"));
} break;
case 0x66 : { /* Read Queue Current Status */
case 0x66 : { /* Read Queue Current Status */
/* !!!!!! TO DO */
NETOBJ obj;
obj.id = GET_BE32(rdata);
@ -1011,6 +1043,17 @@ static int handle_fxx(CONNECTION *c, int gelen, int func)
completition=0xd5; /* no Queue Job */
}break;
case 0x6A : /* Remove Job from Queue OLD */
case 0x80 : { /* Remove Job from Queue NEW */
NETOBJ obj;
uint32 jobnr = (ufunc == 0x6A)
? GET_BE16(rdata+4)
: GET_BE32(rdata+4);
obj.id = GET_BE32(rdata);
XDPRINTF((1, 0, "TODO:Remove Job=%ld from Queue Q=0x%lx", jobnr, obj.id));
completition=0xd5; /* no Queue Job */
}break;
case 0x6B : { /* Get Queue Job List, old */
/* !!!!!! TO DO */
NETOBJ obj;
@ -1028,7 +1071,7 @@ static int handle_fxx(CONNECTION *c, int gelen, int func)
}break;
case 0x68: /* creat queue job and file old */
case 0x79: { /* creat queue job and file */
case 0x79: { /* creat queue job and file new */
uint32 q_id = GET_BE32(rdata);
uint8 *dir_name = rdata+4+280+1;
int result = nw_get_q_dirname(q_id, dir_name);
@ -1054,6 +1097,14 @@ static int handle_fxx(CONNECTION *c, int gelen, int func)
}
break;
case 0x7d : { /* Read Queue Current Status, new */
NETOBJ obj;
obj.id = GET_BE32(rdata);
XDPRINTF((1, 0, "TODO:READ QUEUE STATUS NEW of Q=0x%lx", obj.id));
completition=0xd5; /* no Queue Job */
}break;
case 0xc8 : { /* CHECK CONSOLE PRIVILEGES */
XDPRINTF((1, 0, "TODO: CHECK CONSOLE PRIV"));
/* !!!!!! TODO completition=0xc6 (no rights) */
@ -1065,11 +1116,18 @@ static int handle_fxx(CONNECTION *c, int gelen, int func)
char *revision_date = REVISION_DATE;
char *copyright = "(C)opyright Martin Stover";
int k=strlen(company)+1;
int l;
memset(responsedata, 0, 512);
strcpy(responsedata, company);
k += (1+sprintf(responsedata+k, revision,
_VERS_H_, _VERS_L_ ));
l = 1 + sprintf(responsedata+k, revision,
_VERS_H_, _VERS_L_ );
#if 0
k+=l;
#else
/* BUG in LIB */
k += (1 + strlen(responsedata+k));
#endif
strcpy(responsedata+k, revision_date);
k += (strlen(revision_date)+1);
strcpy(responsedata+k, copyright);
@ -1092,7 +1150,7 @@ static int handle_fxx(CONNECTION *c, int gelen, int func)
int anz_conns = (int) *p++;
uint8 *co = p;
int msglen = (int) *(p+anz_conns);
char *msg = p+anz_conns+1;
char *msg = (char*) p+anz_conns+1;
int k = -1;
if (anz_conns) {
while (++k < anz_conns) {
@ -1138,6 +1196,7 @@ static int handle_fxx(CONNECTION *c, int gelen, int func)
ncpresponse->connection = ncprequest->connection;
ncpresponse->reserved = 0;
ncpresponse->completition = completition;
if (c->message[0]) connect_status |= 0x40;
ncpresponse->connect_status = connect_status;
data_len=write(c->fd, (char*)ncpresponse,
sizeof(NCPRESPONSE) + data_len);
@ -1267,7 +1326,7 @@ static int handle_ctrl(void)
case 0x3333 : /* 'bindery' calls */
if (sizeof(conn) == read(0, (char*)&conn, sizeof(conn))) {
uint8 *buff = xmalloc(conn+10);
uint8 *buff = (uint8*) xmalloc(conn+10);
XDPRINTF((2,0, "0x3333 len=%d", conn));
if (conn == read(0, (char*)buff, conn))
handle_bind_calls(buff);

253
net.h
View File

@ -1,6 +1,6 @@
/* net.h 22-Jan-96 */
/* net.h 08-Feb-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -116,10 +116,21 @@
# define PATHNAME_BINDERY "." /* location of bindery files */
#endif
#ifndef NETWORK_SERIAL_NMBR
# define NETWORK_SERIAL_NMBR 0x44444444L /* Serial Number 4 Byte */
#endif
#ifndef NETWORK_APPL_NMBR
# define NETWORK_APPL_NMBR 0x2222 /* Applikation Number 2 Byte */
#endif
#ifndef IPX_DATA_GR_546
# define IPX_DATA_GR_546 1
#endif
#ifndef WITH_NAME_SPACE_CALLS
# define WITH_NAME_SPACE_CALLS 0
#endif
#ifndef MAX_NW_ROUTES
# define MAX_NW_ROUTES 50
#endif
@ -134,6 +145,27 @@
# define IPX_MAX_DATA 546
#endif
#ifdef LINUX
# ifndef INTERNAL_RIP_SAP
# define INTERNAL_RIP_SAP 1
# endif
# if INTERNAL_RIP_SAP
# ifndef FILE_SERVER_INACTIV
# define FILE_SERVER_INACTIV 0
# endif
# else
# undef FILE_SERVER_INACTIV
# define FILE_SERVER_INACTIV 0
# endif
#else
/* USL has good rip/sap router */
# undef INTERNAL_RIP_SAP
# define INTERNAL_RIP_SAP 0
# undef FILE_SERVER_INACTIV
# define FILE_SERVER_INACTIV 0
#endif
#define MAX_SERVER_NAME 48
typedef union {
@ -178,7 +210,6 @@ typedef union {
uint8 server_hops[2];
} saps;
} sap;
struct S_WDOG { /* Watchdog */
uint8 connid; /* connection ID */
uint8 status; /* STATUS */
@ -238,11 +269,11 @@ typedef union {
char data[IPX_MAX_DATA];
} IPX_DATA;
typedef struct S_SIP SIP;
typedef struct S_SQP SQP;
typedef struct S_SAP SAP;
typedef struct S_SAPS SAPS;
typedef struct S_RIP RIP;
typedef struct S_SIP SIP;
typedef struct S_SQP SQP;
typedef struct S_SAP SAP;
typedef struct S_SAPS SAPS;
typedef struct S_RIP RIP;
typedef struct S_CONFREQ CONFREQ;
typedef struct S_DIAGRESP DIAGRESP;
@ -250,202 +281,30 @@ typedef struct S_NCPRESPONSE NCPRESPONSE;
typedef struct S_NCPREQUEST NCPREQUEST;
/* SOCKETS */
#define SOCK_ROUTE 0x0001 /* Routing Information */
#define SOCK_ECHO 0x0002 /* Echo Protokoll Packet */
#define SOCK_ERROR 0x0003 /* Error Handler Packet */
#define SOCK_NCP 0x0451 /* File Service CORE */
#define SOCK_AUTO 0x0000 /* Autobound Socket */
#define SOCK_ROUTE 0x0001 /* Routing Information */
#define SOCK_ECHO 0x0002 /* Echo Protokoll Packet */
#define SOCK_ERROR 0x0003 /* Error Handler Packet */
#define SOCK_NCP 0x0451 /* File Service CORE */
#define SOCK_SAP 0x0452 /* SAP Service Advertising Packet */
#define SOCK_RIP 0x0453 /* Routing Information Packet */
#define SOCK_NETBIOS 0x0455 /* NET BIOS Packet */
#define SOCK_DIAGNOSE 0x0456 /* Diagnostic Packet */
#define SOCK_NVT 0x8063 /* NVT (Netzerk Virtual Terminal) */
#define SOCK_RIP 0x0453 /* Routing Information Packet */
#define SOCK_NETBIOS 0x0455 /* NET BIOS Packet */
#define SOCK_DIAGNOSE 0x0456 /* Diagnostic Packet */
#define SOCK_NVT 0x8063 /* NVT (Network Virtual Terminal) */
/* PACKET TYPES */
#define PACKT_0 0 /* unknown */
#define PACKT_ROUTE 1 /* Routing Information */
#define PACKT_ECHO 2 /* Echo Packet */
#define PACKT_ERROR 3 /* Error Packet */
#define PACKT_0 0 /* unknown */
#define PACKT_ROUTE 1 /* Routing Information */
#define PACKT_ECHO 2 /* Echo Packet */
#define PACKT_ERROR 3 /* Error Packet */
#define PACKT_EXCH 4 /* Packet Exchange Packet */
#define PACKT_SPX 5 /* SPX Packet */
/* 16 - 31 Experimental */
#define PACKT_CORE 17 /* Core Protokoll (NCP) */
#define FD_NWSERV 3 /* one after stderr */
#define PACKT_SPX 5 /* SPX Packet */
/* 16 - 31 Experimental */
#define PACKT_CORE 17 /* Core Protokoll (NCP) */
#define FD_NWSERV 3 /* one after stderr */
#include "net1.h"
/* connect.c */
typedef struct {
uint8 name[14]; /* filename in DOS format */
uint8 attrib; /* Attribute */
uint8 ext_attrib; /* File Execute Type */
uint8 size[4]; /* size of file */
uint8 create_date[2];
uint8 acces_date[2];
uint8 modify_date[2];
uint8 modify_time[2];
} NW_FILE_INFO;
typedef struct {
uint8 name[14]; /* dirname */
uint8 attrib;
uint8 ext_attrib;
uint8 create_date[2];
uint8 create_time[2];
uint8 owner_id[4];
uint8 access_right_mask;
uint8 reserved; /* future use */
uint8 next_search[2];
} NW_DIR_INFO;
typedef struct {
uint8 record_in_use[2];
uint8 record_previous[4];
uint8 record_next[4];
uint8 client_connection[4];
uint8 client_task[4];
uint8 client_id[4];
uint8 target_id[4]; /* 0xff, 0xff, 0xff, 0xff */
uint8 target_execute_time[6]; /* all 0xff */
uint8 job_entry_time[6]; /* all zero */
uint8 job_id[4]; /* ?? alles 0 HI-LOW */
uint8 job_typ[2]; /* z.B. Printform HI-LOW */
uint8 job_position[2]; /* ?? alles 0 low-high ? */
uint8 job_control_flags[2]; /* z.B 0x10, 0x00 */
/* 0x80 operator hold flag */
/* 0x40 user hold flag */
/* 0x20 entry open flag */
/* 0x10 service restart flag */
/* 0x08 autostart flag */
uint8 job_file_name[14]; /* len + DOS filename */
uint8 job_file_handle[4];
uint8 server_station[4];
uint8 server_task[4];
uint8 server_id[4];
uint8 job_bez[50]; /* "LPT1 Catch" */
uint8 client_area[152];
} QUEUE_JOB;
typedef struct {
uint8 client_connection;
uint8 client_task;
uint8 client_id[4];
uint8 target_id[4]; /* 0xff, 0xff, 0xff, 0xff */
uint8 target_execute_time[6]; /* all 0xff */
uint8 job_entry_time[6]; /* all zero */
uint8 job_id[2]; /* ?? alles 0 HI-LOW */
uint8 job_typ[2]; /* z.B. Printform HI-LOW */
uint8 job_position; /* zero */
uint8 job_control_flags; /* z.B 0x10 */
/* 0x80 operator hold flag */
/* 0x40 user hold flag */
/* 0x20 entry open flag */
/* 0x10 service restart flag */
/* 0x08 autostart flag */
uint8 job_file_name[14]; /* len + DOS filename */
uint8 job_file_handle[6];
uint8 server_station;
uint8 server_task;
uint8 server_id[4];
uint8 job_bez[50]; /* "LPT1 Catch" */
uint8 client_area[152];
} QUEUE_JOB_OLD; /* before 3.11 */
typedef struct {
uint8 version; /* normal 0x0 */
uint8 tabsize; /* normal 0x8 */
uint8 anz_copies[2]; /* copies 0x0, 0x01 */
uint8 print_flags[2]; /* 0x0, 0xc0 z.B. with banner */
uint8 max_lines[2]; /* 0x0, 0x42 */
uint8 max_chars[2]; /* 0x0, 0x84 */
uint8 form_name[16]; /* "UNKNOWN" */
uint8 reserved[6]; /* all zero */
uint8 banner_user_name[13]; /* "SUPERVISOR" */
uint8 bannner_file_name[13]; /* "LST:" */
uint8 bannner_header_file_name[14]; /* all zero */
uint8 file_path_name[80]; /* all zero */
} QUEUE_PRINT_AREA;
extern int nw_init_connect(void);
extern int nw_free_handles(int task);
extern int nw_creat_open_file(int dir_handle, uint8 *data, int len,
NW_FILE_INFO *info, int attrib, int access, int mode);
extern int nw_read_datei(int fhandle, uint8 *data, int size, uint32 offset);
extern int nw_seek_datei(int fhandle, int modus);
extern int nw_write_datei(int fhandle, uint8 *data, int size, uint32 offset);
extern int nw_lock_datei(int fhandle, int offset, int size, int do_lock);
extern int nw_close_datei(int fhandle);
extern int nw_server_copy(int qfhandle, uint32 qoffset,
int zfhandle, uint32 zoffset,
uint32 size);
extern int nw_delete_datei(int dir_handle, uint8 *data, int len);
extern int nw_chmod_datei(int dir_handle, uint8 *data, int len, int modus);
extern int mv_file(int qdirhandle, uint8 *q, int qlen,
int zdirhandle, uint8 *z, int zlen);
extern int nw_mk_rd_dir(int dir_handle, uint8 *data, int len, int mode);
extern int nw_search(uint8 *info,
int dirhandle, int searchsequence,
int search_attrib, uint8 *data, int len);
extern int nw_dir_search(uint8 *info,
int dirhandle, int searchsequence,
int search_attrib, uint8 *data, int len);
extern int nw_find_dir_handle( int dir_handle,
uint8 *data, /* zus„tzlicher Pfad */
int len); /* L„nge Pfad */
extern int nw_alloc_dir_handle(
int dir_handle, /* Suche ab Pfad dirhandle */
uint8 *data, /* zus„tzl. Pfad */
int len, /* L„nge DATA */
int driveletter, /* A .. Z normal */
int is_temphandle, /* tempor„res Handle 1 */
/* spez. temp Handle 2 */
int task); /* Prozess Task */
extern int nw_open_dir_handle( int dir_handle,
uint8 *data, /* zus„tzlicher Pfad */
int len, /* L„nge DATA */
int *volume, /* Volume */
int *dir_id, /* „hnlich Filehandle */
int *searchsequence);
extern int nw_free_dir_handle(int dir_handle);
extern int nw_set_dir_handle(int targetdir, int dir_handle,
uint8 *data, int len, int task);
extern int nw_get_directory_path(int dir_handle, uint8 *name);
extern int nw_get_vol_number(int dir_handle);
extern int nw_get_eff_dir_rights(int dir_handle, uint8 *data, int len, int modus);
extern int nw_set_fdate_time(uint32 fhandle, uint8 *datum, uint8 *zeit);
extern int nw_scan_dir_info(int dir_handle, uint8 *data, int len,
uint8 *subnr, uint8 *subname,
uint8 *subdatetime, uint8 *owner);
#include "tools.h"

308
netinit.c
View File

@ -1,308 +0,0 @@
/* netinit.c 11-Sep-95 */
/* Initialisierung VON IPX u. SPX unter USL 1.1 */
/* 'emuliert' Teil von NPSD */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "net.h"
#include <sys/dlpi.h>
#define NET_DEBUG 1
#define MY_NETWORK 0x10
#if NET_DEBUG
void print_adaptinfo(FILE *fout, ipxAdapterInfo_t *ai, char *s)
{
if (s != NULL)
fprintf(fout, "\n---- %s ----\n", s);
fprintf(fout,
"dl_primitive = %lu \n\
dl_max_sdu = %lu \n\
dl_min_sdu = %lu \n\
dl_addr_length = %lu \n\
dl_mac_type = %lu \n\
dl_reserved = %lu \n\
dl_current_state = %lu \n\
dl_sap_length = %ld \n\
dl_service_mode = %lu \n\
dl_qos_length = %lu \n\
dl_qos_offset = %lu \n\
dl_qos_range_length = %lu \n\
dl_qos_range_offset = %lu \n\
dl_provider_style = %lu \n\
dl_addr_offset = %lu \n\
dl_version = %lu \n\
dl_brdcst_addr_length = %lu \n\
dl_brdcst_addr_offset = %lu \n\
dl_growth = %lu \n",
ai->dl_primitive,
ai->dl_max_sdu,
ai->dl_min_sdu,
ai->dl_addr_length,
ai->dl_mac_type,
ai->dl_reserved,
ai->dl_current_state,
ai->dl_sap_length,
ai->dl_service_mode,
ai->dl_qos_length,
ai->dl_qos_offset,
ai->dl_qos_range_length,
ai->dl_qos_range_offset,
ai->dl_provider_style,
ai->dl_addr_offset,
ai->dl_version,
ai->dl_brdcst_addr_length,
ai->dl_brdcst_addr_offset,
ai->dl_growth);
fflush(fout);
}
void print_netinfo(FILE *fout, netInfo_t *ni, char *s)
{
ipxAdapterInfo_t *ai = &(ni->adapInfo);
if (s != NULL)
fprintf(fout, "\n---- %s ----\n", s);
fprintf(fout, "Lan:%lx, state:%lx, err:%lx, netw:%lx, mux:%lx, node:%x.%x.%x.%x.%x.%x\n",
ni->lan, ni->state, ni->streamError, ni->network,
ni->muxId,
(int)ni->nodeAddress[0],
(int)ni->nodeAddress[1],
(int)ni->nodeAddress[2],
(int)ni->nodeAddress[3],
(int)ni->nodeAddress[4],
(int)ni->nodeAddress[5]);
print_adaptinfo(fout, ai, NULL);
}
#else
#define print_adaptinfo(fout, ai, s)
#define print_netinfo(fout, ni, s)
#endif
int main(int argc, char **argv)
{
int ipx0fd=open("/dev/ipx0", O_RDWR);
if (ipx0fd > -1) {
int lan0fd=open("/dev/lan0", O_RDWR);
if (lan0fd > -1) {
struct strioctl str1, str2, str3, str4;
int ipxfd;
int j = -1;
long max_adapter=0;
netInfo_t netinfo;
long info_req = DL_INFO_REQ;
ipxAdapterInfo_t *ai = &(netinfo.adapInfo);
dl_bind_req_t bind_req;
struct {
dl_bind_ack_t b;
uint8 addr[8]; /* Adresse */
} bind_ack;
int muxid;
int flagsp=0;
int ilen;
struct strbuf cntr1;
#if NET_DEBUG
FILE *fout = fopen("xyz", "w+");
#endif
/* DL_INFO */
cntr1.maxlen = 4;
cntr1.len = 4;
cntr1.buf = (char *)&info_req;
putmsg(lan0fd, &cntr1, NULL, 0);
cntr1.maxlen = sizeof(ipxAdapterInfo_t);
cntr1.len = 0;
cntr1.buf = (char*)ai;
if ((ilen=getmsg(lan0fd, &cntr1, NULL, &flagsp)) > 0) {
char dummy[100];
cntr1.maxlen = sizeof(dummy);
cntr1.len = 0;
cntr1.buf = dummy;
flagsp = 0;
getmsg(lan0fd, &cntr1, NULL, &flagsp);
fprintf(stderr, "DL_INFO getmsg=%d bzw. %d > 0\n", ilen, cntr1.len);
}
print_adaptinfo(fout, ai, "nach DL_INFO");
/* ----------------------------------------------- */
bind_req.dl_primitive = DL_BIND_REQ;
bind_req.dl_sap = 0x8137; /* SAP Type f<>r NetWare */
bind_req.dl_max_conind = 1;
bind_req.dl_service_mode = DL_CLDLS; /* 2 */
bind_req.dl_conn_mgmt = 0;
bind_req.dl_xidtest_flg = 1;
cntr1.maxlen = sizeof(dl_bind_req_t);
cntr1.len = sizeof(dl_bind_req_t);
cntr1.buf = (char*)&bind_req;
putmsg(lan0fd, &cntr1, NULL, 0);
memset(&bind_ack, 0, sizeof(bind_ack));
bind_ack.b.dl_primitive = DL_BIND_REQ;
cntr1.maxlen = sizeof(bind_ack);
cntr1.len = 0;
cntr1.buf = (char*)&bind_ack;
flagsp = 0;
getmsg(lan0fd, &cntr1, NULL, &flagsp);
fprintf(stderr, "BIND ACK:sap 0x%x, addr_len %d, addr_offs %d\n \
addr=0x%x:0x%x:0x%x:0x%x:0x%x:0x%x:0x%x:0x%x\n" ,
bind_ack.b.dl_sap, bind_ack.b.dl_addr_length, bind_ack.b.dl_addr_offset,
(int)bind_ack.addr[0],
(int)bind_ack.addr[1],
(int)bind_ack.addr[2],
(int)bind_ack.addr[3],
(int)bind_ack.addr[4],
(int)bind_ack.addr[5],
(int)bind_ack.addr[6],
(int)bind_ack.addr[7]);
/* DL_INFO */
cntr1.maxlen = 4;
cntr1.len = 4;
cntr1.buf = (char *)&info_req;
putmsg(lan0fd, &cntr1, NULL, 0);
cntr1.maxlen = sizeof(ipxAdapterInfo_t);
cntr1.len = 0;
cntr1.buf = (char*)ai;
if ((ilen=getmsg(lan0fd, &cntr1, NULL, &flagsp)) > 0) {
char dummy[100];
cntr1.maxlen = sizeof(dummy);
cntr1.len = 0;
cntr1.buf = dummy;
flagsp = 0;
getmsg(lan0fd, &cntr1, NULL, &flagsp);
fprintf(stderr, "DL_INFO getmsg=%d bzw. %d > 0\n", ilen, cntr1.len);
}
print_adaptinfo(fout, ai, "nach DL_INFO 2");
/* ----------------------------------------------- */
str1.ic_cmd = IPX_GET_MAX_CONNECTED_LANS;
str1.ic_timout = 0;
str1.ic_len = 4;
str1.ic_dp = (char*)&max_adapter;
ioctl(ipx0fd, I_STR, &str1);
printf("Max Adapter %ld\n", max_adapter);
muxid = ioctl(ipx0fd, I_LINK, lan0fd); /* LINK */
/*-----------------------------------------------*/
/*
str3.ic_cmd = IPX_SET_FRAME_TYPE_8023;
str3.ic_len = 0;
str3.ic_timout = 5;
str3.ic_dp = 0;
ioctl(ipx0fd, I_STR, &str3);
*/
/*
str2.ic_cmd = IPX_SET_FRAME_TYPE_SNAP;
*/
/*
str2.ic_cmd = IPX_SET_FRAME_TYPE_8022;
*/
str2.ic_timout = 0;
str2.ic_len = sizeof(netinfo);
str2.ic_dp = (char*)&netinfo;
netinfo.lan = 0;
netinfo.state = 0;
netinfo.network = MY_NETWORK;
netinfo.muxId = muxid;
netinfo.nodeAddress[0] = bind_ack.addr[0]; /* 0x00 */
netinfo.nodeAddress[1] = bind_ack.addr[1]; /* 0x80 */
netinfo.nodeAddress[2] = bind_ack.addr[2]; /* 0x48 */
netinfo.nodeAddress[3] = bind_ack.addr[3]; /* 0x83 */
netinfo.nodeAddress[4] = bind_ack.addr[4]; /* 0x14 */
netinfo.nodeAddress[5] = bind_ack.addr[5]; /* 0x3f */
/*
ai->dl_primitive = DL_INFO_REQ ;
ioctl(ipx0fd, I_STR, &str2);
print_netinfo(fout, &netinfo, "nach SET_FRAME");
*/
str3.ic_cmd = IPX_SET_LAN_INFO;
str3.ic_len = sizeof(netinfo);
str3.ic_timout = 5;
str3.ic_dp = (char*)&netinfo;
ioctl(ipx0fd, I_STR, &str3);
print_netinfo(fout, &netinfo, "nach IPX_SET_LAN_INFO");
#if 0
if ((ipxfd = open("/dev/ipx", O_RDWR)) > -1){
int spxfd = open("/dev/nspxd", O_RDWR);
if (spxfd > -1){
int pid=-1;
int akt_pid = getpid();
char *progname = "nwserv";
muxid = ioctl(spxfd, I_LINK, ipxfd);
str4.ic_cmd = IPX_SET_SPX;
str4.ic_len = 0;
str4.ic_timout = 5;
str4.ic_dp = (char*) NULL;
ioctl(spxfd, I_STR, &str4);
close(ipxfd);
pid=fork();
if (pid == 0) { /* Child */
close(spxfd);
close(ipx0fd);
close(lan0fd);
execl(progname, progname, (argc > 1) ? *(argv+1) : NULL, NULL);
/* Falls nicht OK Calling Prozess killen */
kill(akt_pid, SIGTERM);
kill(akt_pid, SIGQUIT);
exit (1);
}
if (pid > -1){
pause();
kill(pid, SIGTERM); /* T”chter killen */
kill(pid, SIGQUIT);
} else perror("nwserv not running");
close(spxfd);
} else {
perror("spx not open");
close(ipxfd);
}
} else perror("ipx not open");
#else
if ((ipxfd = open("/dev/ipx", O_RDWR)) > -1){
int pid=-1;
int akt_pid = getpid();
char *progname = "nwserv";
close(ipxfd);
pid=fork();
if (pid == 0) { /* Child */
close(ipx0fd);
close(lan0fd);
execl(progname, progname, (argc > 1) ? *(argv+1) : NULL, NULL);
/* Falls nicht OK Calling Prozess killen */
kill(akt_pid, SIGTERM);
kill(akt_pid, SIGQUIT);
exit (1);
}
if (pid > -1){
pause();
kill(pid, SIGTERM); /* T”chter killen */
kill(pid, SIGQUIT);
} else perror("nwserv not running");
} else perror("ipx not open");
#endif
close(lan0fd);
#if NET_DEBUG
fclose(fout);
#endif
} else perror("lan0 not open");
close(ipx0fd);
} else perror("ipx0 not open");
}

View File

@ -236,6 +236,8 @@ static int do_17_17(void)
return(-1);
}
static int get_network_serial_number(void)
{
uint8 data[] = {0, 1, 0x12};
@ -610,6 +612,17 @@ static void test2(void)
}
}
static int do_5f(void)
{
uint8 data[] = {0x10, 0, 0, 0};
RDATA(data, 0x17, "do_5f");
if (!handle_event()) {
return(0);
}
return(-1);
}
static void teste_reads(void)
{
@ -681,7 +694,7 @@ static void test_wdog(void)
/* --------------------------------------------------------- */
int main(int argc, char **argv)
{
nw_debug = 1; /* dieses Modul dient nur zum Debuggen !! */
init_tools(NWCLIENT);
if (argc != 3) {
fprintf(stderr, "usage: nwclient MY_ADDR SERVER_ADDR\n");
@ -701,6 +714,7 @@ int main(int argc, char **argv)
get_pkt_size();
get_connect();
get_server_time();
do_5f();
file_search_init(NULL, 1, NULL);
get_bindery_access();

View File

@ -1,7 +1,7 @@
/* nwconn.c 13-Jan-96 */
/* nwconn.c 07-Feb-96 */
/* one process / connection */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -21,6 +21,7 @@
#include "net.h"
#include <dirent.h>
#include "nwvolume.h"
#include "nwfile.h"
#include "connect.h"
#include "namspace.h"
@ -165,7 +166,11 @@ static void handle_ncp_serv()
U16_TO_BE16(fsp.fsu_bavail/1000, xdata->avail_blocks);
U16_TO_BE16(fsp.fsu_files, xdata->total_dirs);
U16_TO_BE16(fsp.fsu_ffree, xdata->avail_dirs);
U16_TO_BE16(0, xdata->removable);
if ( get_volume_options(volume, 1) & VOL_OPTION_REMOUNT) {
U16_TO_BE16(1, xdata->removable);
} else {
U16_TO_BE16(0, xdata->removable);
}
}
data_len = sizeof(struct XDATA);
} else completition = (uint8) -result;
@ -383,7 +388,8 @@ static void handle_ncp_serv()
int result = nw_get_vol_number((int)*(p+1));
memset(xdata, 0, sizeof(struct XDATA));
if (result > -1) {
result = nw_get_volume_name(result, xdata->name);
int volume = result;
result = nw_get_volume_name(volume, xdata->name);
if (result > -1) {
struct fs_usage fsp;
if (!nw_get_fs_usage(xdata->name, &fsp)) {
@ -392,7 +398,11 @@ static void handle_ncp_serv()
U16_TO_BE16(fsp.fsu_bavail/1000, xdata->avail_blocks);
U16_TO_BE16(fsp.fsu_files, xdata->total_dirs);
U16_TO_BE16(fsp.fsu_ffree, xdata->avail_dirs);
U16_TO_BE16(0, xdata->removable);
if (get_volume_options(volume, 1) & VOL_OPTION_REMOUNT) {
U16_TO_BE16(1, xdata->removable);
} else {
U16_TO_BE16(0, xdata->removable);
}
}
data_len = sizeof(struct XDATA);
XDPRINTF((5,0,"GIVE VOLUME INFO von :%s:", xdata->name));
@ -569,7 +579,7 @@ static void handle_ncp_serv()
uint8 namlen;
uint8 name[1];
} *xdata = (struct XDATA*) responsedata;
char name[100];
uint8 name[100];
int result = nw_get_volume_name(volume, name);
if (result > -1){
struct fs_usage fsp;
@ -581,7 +591,7 @@ static void handle_ncp_serv()
U32_TO_32(fsp.fsu_files, xdata->total_dirs);
U32_TO_32(fsp.fsu_ffree, xdata->avail_dirs);
}
xdata->namlen = strlen(name);
xdata->namlen = strlen((char*)name);
strmaxcpy(xdata->name, name, xdata->namlen);
data_len = xdata->namlen + 30;
} else completition = (uint8) -result;
@ -599,7 +609,7 @@ static void handle_ncp_serv()
uint8 name[1]; /* Volume Name */
} *xdata = (struct XDATA*) responsedata;
int result = nw_get_vol_number(dir_handle);
char name[100];
uint8 name[100];
if (result > -1)
result = nw_get_volume_name(result, name);
if (result > -1) {
@ -612,7 +622,7 @@ static void handle_ncp_serv()
U32_TO_32(fsp.fsu_files, xdata->total_dirs);
U32_TO_32(fsp.fsu_ffree, xdata->avail_dirs);
}
xdata->namlen = strlen(name);
xdata->namlen = strlen((char*)name);
strmaxcpy(xdata->name, name, xdata->namlen);
data_len = xdata->namlen + 22;
} else completition = (uint8) -result;
@ -770,8 +780,8 @@ static void handle_ncp_serv()
struct INPUT {
uint8 header[7]; /* Requestheader */
uint8 reserve; /* 0x1 */
uint8 fhandle[4]; /* Filehandle */
uint8 ext_fhandle[2]; /* all zero */
uint8 fhandle[4]; /* Filehandle */
uint8 offset[4];
uint8 size[4];
uint8 weisnicht[2]; /* lock timeout ??? */
@ -836,8 +846,8 @@ static void handle_ncp_serv()
struct INPUT {
uint8 header[7]; /* Requestheader */
uint8 reserve;
uint8 fhandle[4]; /* filehandle */
uint8 ext_fhandle[2]; /* all zero */
uint8 fhandle[4]; /* filehandle */
} *input = (struct INPUT *)ncprequest;
uint32 fhandle = GET_BE32(input->fhandle);
XDPRINTF((2,0, "TODO: COMMIT FILE:fhandle=%ld", fhandle));
@ -927,11 +937,11 @@ static void handle_ncp_serv()
struct INPUT {
uint8 header[7]; /* Requestheader */
uint8 reserve;
uint8 fhandle[4]; /* filehandle */
uint8 ext_fhandle[2]; /* all zero */
uint8 fhandle[4]; /* filehandle */
} *input = (struct INPUT *)ncprequest;
uint32 fhandle = GET_BE32(input->fhandle);
completition = (uint8)(-nw_close_datei(fhandle));
completition = (uint8)(-nw_close_datei(fhandle, 0));
if (!completition && fhandle == test_handle) {
do_druck++;
test_handle = -1;
@ -950,8 +960,8 @@ static void handle_ncp_serv()
uint8 data[1]; /* Name */
} *input = (struct INPUT *)ncprequest;
struct OUTPUT {
uint8 fhandle[4]; /* Filehandle */
uint8 extfhandle[2];
uint8 fhandle[4]; /* Filehandle */
uint8 reserved[2]; /* rese. by NOVELL */
NW_FILE_INFO fileinfo;
} *xdata= (struct OUTPUT*)responsedata;
@ -1041,8 +1051,8 @@ static void handle_ncp_serv()
struct INPUT {
uint8 header[7]; /* Requestheader */
uint8 filler;
uint8 ext_filehandle[2]; /* all zero */
uint8 fhandle[4]; /* Dateihandle */
uint8 ext_filehandle[2]; /* ?? alles 0 */
} *input = (struct INPUT *)ncprequest;
struct OUTPUT {
uint8 size[4]; /* Position ??? */
@ -1062,8 +1072,8 @@ static void handle_ncp_serv()
struct INPUT {
uint8 header[7]; /* Requestheader */
uint8 filler;
uint8 ext_fhandle[2]; /* all zero */
uint8 fhandle[4]; /* filehandle */
uint8 reserve[2]; /* alles 0 */
uint8 offset[4]; /* alles 0 */
uint8 max_size[2]; /* zu lesende Bytes */
} *input = (struct INPUT *)ncprequest;
@ -1093,8 +1103,8 @@ static void handle_ncp_serv()
uint8 header[7]; /* Requestheader */
uint8 filler; /* 0 Filler ?? */
uint8 fhandle[4]; /* Dateihandle */
uint8 ext_handle[2];
uint8 fhandle[4]; /* Dateihandle */
uint8 offset[4]; /* SEEK OFFSET */
uint8 size[2]; /* Datasize */
uint8 data[2]; /* Schreibdaten */
@ -1116,15 +1126,15 @@ static void handle_ncp_serv()
case 0x4a : { /* File SERVER COPY */
/* should be OK */
struct INPUT {
uint8 header[7]; /* Requestheader */
uint8 reserved; /* Reserved by Novell */
uint8 qfhandle[4]; /* Quellfile */
uint8 reserve1[2]; /* ext Filehandle */
uint8 zfhandle[4]; /* Zielfile */
uint8 reserve2[2]; /* ext Filehandle */
uint8 qoffset[4]; /* Quellfile Offset */
uint8 zoffset[4]; /* Zielfile Offset */
uint8 size[4]; /* Anzahl */
uint8 header[7]; /* Requestheader */
uint8 reserved; /* Reserved by Novell */
uint8 qext_fhandle[2]; /* ext Filehandle */
uint8 qfhandle[4]; /* Quellfile */
uint8 zext_fhandle[2]; /* ext Filehandle */
uint8 zfhandle[4]; /* Zielfile */
uint8 qoffset[4]; /* SourceFile Offset */
uint8 zoffset[4]; /* DestFile Offset */
uint8 size[4]; /* copysize */
} *input = (struct INPUT *)ncprequest;
int qfhandle = GET_BE32(input->qfhandle);
int zfhandle = GET_BE32(input->zfhandle);
@ -1150,8 +1160,8 @@ static void handle_ncp_serv()
struct INPUT {
uint8 header[7]; /* Requestheader */
uint8 filler;
uint8 reserve[2]; /* ext Filehandle */
uint8 fhandle[4]; /* Dateihandle */
uint8 reserve[2]; /* ext Filehandle ??? */
uint8 zeit[2]; /* time */
uint8 datum[2]; /* date */
} *input = (struct INPUT *)ncprequest;
@ -1177,8 +1187,8 @@ static void handle_ncp_serv()
uint8 data[2]; /* Name */
} *input = (struct INPUT *)ncprequest;
struct OUTPUT {
uint8 ext_fhandle[2]; /* all zero */
uint8 fhandle[4]; /* Dateihandle */
uint8 ext_fhandle[2]; /* z.B 0x0 0x0 */
uint8 reserve2[2]; /* z.B 0x0 0x0 */
NW_FILE_INFO fileinfo;
} *xdata= (struct OUTPUT*)responsedata;
@ -1216,12 +1226,24 @@ static void handle_ncp_serv()
break;
#endif
#ifdef _MAR_TESTS_
case 0x5f : { /* ????????????? UNIX Client */
struct INPUT {
uint8 header[7]; /* Requestheader */
uint8 unknown[4]; /* 0x10, 0,0,0 */
} *input = (struct INPUT *)ncprequest;
completition = 0;
}
break;
#endif
#if 0
case 0x61 : { /* Negotiate Buffer Size, Packetsize new ??? */
/* > 3.11 */
/* similar request as 0x21 */
}
#endif
default : completition = 0xfb; /* unknown request */

View File

@ -951,7 +951,7 @@ int nw_test_passwd(uint32 obj_id, uint8 *vgl_key, uint8 *akt_key)
int nw_set_enpasswd(uint32 obj_id, uint8 *passwd)
{
uint8 *prop_name="PASSWORD";
uint8 *prop_name=(uint8*)"PASSWORD";
if (passwd && *passwd) {
nw_new_create_prop(obj_id, NULL, 0, 0, 0,
prop_name, P_FL_STAT|P_FL_ITEM, 0x44,
@ -968,7 +968,7 @@ int nw_set_passwd(uint32 obj_id, char *password)
uint8 s_uid[4];
U32_TO_BE32(obj_id, s_uid);
shuffle(s_uid, password, strlen(password), passwd);
#if 0
#if 1
XDPRINTF((2,0, "password %s->0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x",
password,
(int)passwd[0],

369
nwfile.c Normal file
View File

@ -0,0 +1,369 @@
/* nwfile.c 23-Jan-96 */
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "net.h"
#include <dirent.h>
#include <utime.h>
#include <sys/errno.h>
#include "nwvolume.h"
#include "nwfile.h"
#include "connect.h"
#define MAX_FILEHANDLES 80
static FILE_HANDLE file_handles[MAX_FILEHANDLES];
static int anz_fhandles=0;
static int new_file_handle(uint8 *unixname)
{
int rethandle = -1;
FILE_HANDLE *fh=NULL;
while (++rethandle < anz_fhandles) {
FILE_HANDLE *fh=&(file_handles[rethandle]);
if (fh->fd == -1 && !(fh->flags & 4)) { /* empty slot */
rethandle++;
break;
} else fh=NULL;
}
if (fh == NULL) {
if (anz_fhandles < MAX_FILEHANDLES) {
fh=&(file_handles[anz_fhandles]);
rethandle = ++anz_fhandles;
} else return(0); /* no free handle anymore */
}
/* init handle */
fh->fd = -2;
fh->offd = 0L;
fh->tmodi = 0L;
strcpy((char*)fh->fname, (char*)unixname);
fh->flags = 0;
fh->f = NULL;
XDPRINTF((5, 0, "new_file_handle=%d, anz_fhandles=%d, fn=%s",
rethandle, anz_fhandles, unixname));
return(rethandle);
}
static int free_file_handle(int fhandle)
{
int result=-0x88;
if (fhandle > 0 && (fhandle <= anz_fhandles)) {
FILE_HANDLE *fh=&(file_handles[fhandle-1]);
if (fh->fd > -1) {
if (fh->flags & 2) {
if (fh->f) pclose(fh->f);
fh->f = NULL;
} else close(fh->fd);
if (fh->tmodi > 0L && !(fh->flags & 2)) {
/* now set date and time */
struct utimbuf ut;
ut.actime = ut.modtime = fh->tmodi;
utime(fh->fname, &ut);
fh->tmodi = 0L;
}
}
fh->fd = -1;
if (fhandle == anz_fhandles && !(fh->flags & 4)) {
/* was last */
anz_fhandles--;
while (anz_fhandles && file_handles[anz_fhandles-1].fd == -1
&& !(file_handles[anz_fhandles-1].flags & 4) )
anz_fhandles--;
}
result=0;
}
XDPRINTF((5, 0, "free_file_handle=%d, anz_fhandles=%d, result=%d",
fhandle, anz_fhandles, result));
return(result); /* wrong filehandle */
}
void init_file_module(void)
{
int k = -1;
while (k++ < anz_fhandles) free_file_handle(k);
anz_fhandles = 0;
}
int file_creat_open(int volume, uint8 *unixname, struct stat *stbuff,
int attrib, int access, int creatmode)
/*
* creatmode: 0 = open | 1 = creat | 2 = creatnew & 4 == save handle
* attrib ??
* access: 0x1=read, 0x2=write
*/
{
int fhandle=new_file_handle(unixname);
if (fhandle > 0){
FILE_HANDLE *fh=&(file_handles[fhandle-1]);
int completition = -0xff; /* no File Found */
if (get_volume_options(volume, 1) & VOL_OPTION_IS_PIPE) {
/* this is a PIPE Dir */
int statr = stat(fh->fname, stbuff);
if (!statr && (stbuff->st_mode & S_IFMT) != S_IFDIR) {
char pipecommand[300];
char *pipeopen = (creatmode || (access & 2)) ? "w" : "r";
char *topipe = "READ";
if (creatmode) topipe = "CREAT";
else if (access & 2) topipe = "WRITE";
sprintf(pipecommand, "%s %s", fh->fname, topipe);
fh->f = popen(pipecommand, pipeopen);
fh->fd = (fh->f) ? fileno(fh->f) : -1;
if (fh->fd > -1) {
fh->flags |= 2;
if (creatmode & 4) fh->flags |= 4;
return(fhandle);
}
}
} else {
if (creatmode) { /* creat File */
if (creatmode & 0x2) { /* creatnew */
if (!stat(fh->fname, stbuff)) {
XDPRINTF((5,0,"CREAT File exist!! :%s:", fh->fname));
fh->fd = -1;
completition = -0x85; /* No Priv */
} else {
XDPRINTF((5,0,"CREAT FILE:%s: Handle=%d", fh->fname, fhandle));
fh->fd = creat(fh->fname, 0777);
if (fh->fd < 0) completition = -0x84; /* no create Rights */
}
} else {
XDPRINTF((5,0,"CREAT FILE, ever with attrib:0x%x, access:0x%x, fh->fname:%s: handle:%d",
attrib, access, fh->fname, fhandle));
fh->fd = open(fh->fname, O_CREAT|O_TRUNC|O_RDWR, 0777);
if (fh->fd < 0) completition = -0x85; /* no delete /create Rights */
}
if (fh->fd > -1) {
close(fh->fd);
fh->fd = open(fh->fname, O_RDWR);
fh->offd = 0L;
stat(fh->fname, stbuff);
}
} else {
int statr = stat(fh->fname, stbuff);
int acm = (access & 2) ? (int) O_RDWR /*|O_CREAT*/ : (int)O_RDONLY;
if ( (!statr && (stbuff->st_mode & S_IFMT) != S_IFDIR)
|| (statr && (acm & O_CREAT))){
XDPRINTF((5,0,"OPEN FILE with attrib:0x%x, access:0x%x, fh->fname:%s: fhandle=%d",attrib,access, fh->fname, fhandle));
fh->fd = open(fh->fname, acm, 0777);
fh->offd = 0L;
if (fh->fd > -1) {
if (statr) stat(fh->fname, stbuff);
} else completition = -0x9a;
}
}
if (fh->fd > -1) {
if (creatmode & 4) fh->flags |= 4;
return(fhandle);
}
} /* else (NOT DEVICE) */
XDPRINTF((5,0,"OPEN FILE not OK ! fh->name:%s: fhandle=%d",fh->fname, fhandle));
free_file_handle(fhandle);
return(completition);
} else return(-0x81); /* no more File Handles */
}
int nw_set_fdate_time(uint32 fhandle, uint8 *datum, uint8 *zeit)
{
if (fhandle > 0 && (--fhandle < anz_fhandles) ) {
FILE_HANDLE *fh=&(file_handles[fhandle]);
if (fh->fd > -1) {
fh->tmodi = nw_2_un_time(datum, zeit);
return(0);
}
}
return(-0x88); /* wrong filehandle */
}
int nw_close_datei(int fhandle, int reset_reuse)
{
XDPRINTF((5, 0, "nw_close_datei handle=%d", fhandle));
if (fhandle > 0 && (fhandle <= anz_fhandles)) {
FILE_HANDLE *fh=&(file_handles[fhandle-1]);
if (reset_reuse) fh->flags &= (~4);
if (fh->fd > -1) {
int result = 0;
int result2;
if (fh->flags & 2) {
if (fh->f) {
result=pclose(fh->f);
if (result) result = -1;
}
fh->f = NULL;
} else result=close(fh->fd);
fh->fd = -1;
if (fh->tmodi > 0L && !(fh->flags&2)) {
struct utimbuf ut;
ut.actime = ut.modtime = fh->tmodi;
utime(fh->fname, &ut);
fh->tmodi = 0L;
}
#ifdef TEST_FNAME
if (fhandle == test_handle) {
test_handle = -1;
nw_debug = -99;
}
#endif
result2=free_file_handle(fhandle);
return((result == -1) ? -0xff : result2);
} else return(free_file_handle(fhandle));
}
return(-0x88); /* wrong filehandle */
}
uint8 *file_get_unix_name(int fhandle)
{
if (fhandle > 0 && (--fhandle < anz_fhandles)) {
return((uint8*)file_handles[fhandle].fname);
}
return(NULL);
}
int nw_read_datei(int fhandle, uint8 *data, int size, uint32 offset)
{
if (fhandle > 0 && (--fhandle < anz_fhandles)) {
FILE_HANDLE *fh=&(file_handles[fhandle]);
if (fh->fd > -1) {
if (fh->offd != (long)offset)
fh->offd=lseek(fh->fd, offset, SEEK_SET);
if (fh->offd > -1L) {
size = read(fh->fd, data, size);
fh->offd+=(long)size;
} else size = -1;
return(size);
}
}
return(- 0x88); /* wrong filehandle */
}
int nw_seek_datei(int fhandle, int modus)
{
if (fhandle > 0 && (--fhandle < anz_fhandles)) {
FILE_HANDLE *fh=&(file_handles[fhandle]);
if (fh->fd > -1) {
int size=-0xfb;
if (!modus) {
if ( (size=fh->offd=lseek(fh->fd, 0L, SEEK_END)) < 0L)
size = -1;
}
return(size);
}
}
return(-0x88); /* wrong filehandle */
}
int nw_write_datei(int fhandle, uint8 *data, int size, uint32 offset)
{
if (fhandle > 0 && (--fhandle < anz_fhandles)) {
FILE_HANDLE *fh=&(file_handles[fhandle]);
if (fh->fd > -1) {
if (fh->offd != (long)offset)
fh->offd = lseek(fh->fd, offset, SEEK_SET);
if (size) {
if (fh->offd > -1L) {
size = write(fh->fd, data, size);
fh->offd+=(long)size;
} else size = -1;
return(size);
} else { /* strip FILE */
/* TODO: for LINUX */
struct flock flockd;
int result= /* -1 */ 0;
flockd.l_type = 0;
flockd.l_whence = SEEK_SET;
flockd.l_start = offset;
flockd.l_len = 0;
#if HAVE_TLI
result = fcntl(fh->fd, F_FREESP, &flockd);
XDPRINTF((5,0,"File %s is stripped, result=%d", fh->fname, result));
#endif
return(result);
}
}
}
return(- 0x88); /* wrong filehandle */
}
int nw_server_copy(int qfhandle, uint32 qoffset,
int zfhandle, uint32 zoffset,
uint32 size)
{
if (qfhandle > 0 && (--qfhandle < anz_fhandles)
&& zfhandle > 0 && (--zfhandle < anz_fhandles) ) {
FILE_HANDLE *fhq=&(file_handles[qfhandle]);
FILE_HANDLE *fhz=&(file_handles[zfhandle]);
int retsize = -1;
if (fhq->fd > -1 && fhz->fd > -1) {
char buff[2048];
int wsize;
if (lseek(fhq->fd, qoffset, SEEK_SET) > -1L &&
lseek(fhz->fd, zoffset, SEEK_SET) > -1L) {
retsize = 0;
while (size && !retsize) {
int xsize = read(fhq->fd, buff, min(size, (uint32)sizeof(buff)));
if (xsize > 0){
if ((wsize =write(fhz->fd, buff, xsize)) != xsize) {
retsize = -0x1; /* out of Disk SPace */
break;
} else {
size -= (uint32)xsize;
retsize += wsize;
}
} else {
if (xsize < 0) retsize=-0x93; /* no read privilegs */
break;
}
}
}
fhq->offd = -1L;
fhz->offd = -1L;
/*
if (!retsize) (retsize=fhz->offd=lseek(fhz->fd, 0L, SEEK_END));
*/
return(retsize);
}
}
return(- 0x88); /* wrong filehandle */
}
int nw_lock_datei(int fhandle, int offset, int size, int do_lock)
{
if (fhandle > 0 && (--fhandle < anz_fhandles)) {
FILE_HANDLE *fh=&(file_handles[fhandle]);
if (fh->fd > -1) {
struct flock flockd;
int result;
flockd.l_type = (do_lock) ? F_WRLCK : F_UNLCK;
flockd.l_whence = SEEK_SET;
flockd.l_start = offset;
flockd.l_len = size;
result = fcntl(fh->fd, F_SETLK, &flockd);
if (!result) return(0);
else return(-0x21); /* LOCK Violation */
}
}
return(-0x88); /* wrong filehandle */
}

38
nwfile.h Normal file
View File

@ -0,0 +1,38 @@
/* nwfile.h 23-Jan-96 */
#ifndef _NWFILE_H_
#define _NWFILE_H_
typedef struct {
int fd; /* filehandle from system open/creat */
long offd; /* aktuell file offset */
time_t tmodi; /* modification TIME */
FILE *f; /* for PIPE */
int flags; /* 2 = PIPE */
/* 4 = don't reuse after close */
char fname[256]; /* UNIX filename */
} FILE_HANDLE;
extern void init_file_module(void);
extern int file_creat_open(int volume, uint8 *unixname,
struct stat *stbuff,
int attrib, int access, int creatmode);
extern int nw_set_fdate_time(uint32 fhandle, uint8 *datum, uint8 *zeit);
extern int nw_close_datei(int fhandle, int reset_reuse);
extern uint8 *file_get_unix_name(int fhandle);
extern int nw_read_datei(int fhandle, uint8 *data, int size, uint32 offset);
extern int nw_seek_datei(int fhandle, int modus);
extern int nw_write_datei(int fhandle, uint8 *data, int size, uint32 offset);
extern int nw_server_copy(int qfhandle, uint32 qoffset,
int zfhandle, uint32 zoffset,
uint32 size);
extern int nw_lock_datei(int fhandle, int offset, int size, int do_lock);
#endif

View File

@ -1,4 +1,4 @@
/* nwroute.c 14-Jan-96 */
/* nwroute.c 08-Feb-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
@ -190,9 +190,12 @@ void insert_delete_server(uint8 *name, /* Server Name */
nr->hops = 0xffff;
} else if (do_delete) {
nr=nw_servers[k];
#if !FILE_SERVER_INACTIV
if (!IPXCMPNODE(nr->addr.node, my_server_adr.node) ||
!IPXCMPNET (nr->addr.net, my_server_adr.net) ) {
if (nr->typ == 4) ins_del_bind_net_addr(nr->name, NULL);
!IPXCMPNET (nr->addr.net, my_server_adr.net) )
#endif
{
ins_del_bind_net_addr(nr->name, nr->typ, NULL);
xfree(nr->name);
memset(nr, 0, sizeof(NW_SERVERS));
}
@ -200,13 +203,15 @@ void insert_delete_server(uint8 *name, /* Server Name */
} else nr=nw_servers[k];
/* here now i perhaps must change the entry */
if (nr->hops > 16 || memcmp(&(nr->addr), addr, sizeof(ipxAddr_t))) {
ins_del_bind_net_addr(nr->name, addr);
ins_del_bind_net_addr(nr->name, nr->typ, addr);
memcpy(&(nr->addr), addr, sizeof(ipxAddr_t));
#if !FILE_SERVER_INACTIV
if (IPXCMPNODE(from_addr->node, my_server_adr.node) &&
IPXCMPNET (from_addr->net, my_server_adr.net)
&& GET_BE16(from_addr->sock) == SOCK_SAP) {
hops = 0;
}
#endif
}
if (hops <= nr->hops && 0 != (net = GET_BE32(from_addr->net)) ) {
nr->net = net;
@ -384,6 +389,48 @@ void handle_rip(int fd, int ipx_pack_typ,
}
/* <========================= SAP ============================> */
void send_server_response(int respond_typ,
int styp, ipxAddr_t *to_addr)
/* respond_typ 2 = general, 4 = nearest service respond */
{
IPX_DATA ipx_data;
int j=-1;
int tics=99;
int hops=15;
int entry = -1;
memset(&ipx_data, 0, sizeof(ipx_data.sip));
while (++j < anz_servers) {
NW_SERVERS *nw=nw_servers[j];
if (nw->typ == styp && nw->name && *(nw->name)) {
int xtics=999;
if (nw->net != internal_net) {
NW_NET_DEVICE *nd=find_netdevice(nw->net);
if (nd) xtics = nd->ticks;
} else xtics =0;
if (xtics < tics || (xtics == tics && nw->hops <= hops)) {
tics = xtics;
hops = nw->hops;
entry = j;
}
}
}
if (entry > -1) {
NW_SERVERS *nw=nw_servers[entry];
strcpy((char*)ipx_data.sip.server_name, nw->name);
memcpy(&ipx_data.sip.server_adr, &nw->addr, sizeof(ipxAddr_t));
XDPRINTF((4, 0, "NEAREST SERVER=%s, typ=0x%x, tics=%d, hops=%d",
nw->name, styp, tics, hops));
U16_TO_BE16(respond_typ, ipx_data.sip.response_type);
U16_TO_BE16(styp, ipx_data.sip.server_type);
U16_TO_BE16(hops, ipx_data.sip.intermediate_networks);
send_ipx_data(sockfd[SAP_SLOT],
4, /* this is the official packet typ for SAP's */
sizeof(ipx_data.sip),
(char *)&(ipx_data.sip),
to_addr, "Nearest Server Response");
}
}
static void send_sap_broadcast(int mode)
/* mode=0, standard broadcast */
/* mode=1, first trie */
@ -448,9 +495,20 @@ void send_sap_rip_broadcast(int mode)
/* mode=1, first trie */
/* mode=2, shutdown */
{
send_sap_broadcast(mode);
send_rip_broadcast(mode);
if (!mode) {
static int flipflop=0;
if (mode) {
send_sap_broadcast(mode);
send_rip_broadcast(mode);
} else {
if (flipflop) {
send_rip_broadcast(mode);
flipflop=0;
} else {
send_sap_broadcast(mode);
flipflop=1;
}
}
if (!mode && flipflop) { /* jedes 2. mal */
FILE *f= open_route_info_fn();
if (f) {
int k=-1;

172
nwroute1.c Normal file
View File

@ -0,0 +1,172 @@
/* nwroute1.c 08-Feb-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "net.h"
#include "nwserv.h"
/* this should be removed one time if there is a good */
/* sapdaemon <-> nwserv handling */
typedef struct {
uint8 *name; /* Server Name */
int typ; /* Server Typ */
ipxAddr_t addr; /* Server Addr */
} NW_SERVERS;
static int anz_servers=0;
static NW_SERVERS *nw_servers[MAX_NW_SERVERS];
void insert_delete_server(uint8 *name, /* Server Name */
int styp, /* Server Typ */
ipxAddr_t *addr, /* Server Addr */
ipxAddr_t *from_addr,
int hops,
int do_delete, /* delete = 1 */
int flags)
{
int k=-1;
int freeslot=-1;
uint32 net;
uint8 sname[MAX_SERVER_NAME+2];
NW_SERVERS *nr=NULL;
strmaxcpy(sname, name, MAX_SERVER_NAME);
upstr(sname);
XDPRINTF((3, 0, "%s %s %s,0x%04x",
visable_ipx_adr(addr),
(do_delete) ? "DEL" : "INS", sname, (int) styp));
k=-1;
if (!*sname) return;
while (++k < anz_servers && (nw_servers[k]->typ != styp ||
!nw_servers[k]->name || strcmp((char*)nw_servers[k]->name, (char*)sname)) ) {
if (freeslot < 0 && !nw_servers[k]->typ) freeslot=k;
}
if (k == anz_servers) { /* server not found */
if (do_delete) return; /* nothing to delete */
if (freeslot < 0) {
if (anz_servers == MAX_NW_SERVERS) {
XDPRINTF((1, 0, "too many servers=%d, increase MAX_NW_SERVERS in config.h", anz_servers));
return;
}
nw_servers[k] = (NW_SERVERS*)xcmalloc(sizeof(NW_SERVERS));
anz_servers++;
} else k=freeslot;
nr = nw_servers[k];
new_str(nr->name, sname);
nr->typ = styp;
memset(&(nr->addr), 0, sizeof(ipxAddr_t));
} else if (do_delete) {
nr=nw_servers[k];
if (!IPXCMPNODE(nr->addr.node, my_server_adr.node) ||
!IPXCMPNET (nr->addr.net, my_server_adr.net) ) {
ins_del_bind_net_addr(nr->name, nr->typ, NULL);
xfree(nr->name);
memset(nr, 0, sizeof(NW_SERVERS));
}
return;
} else nr=nw_servers[k];
/* here now i perhaps must change the entry */
if (memcmp(&(nr->addr), addr, sizeof(ipxAddr_t))) {
ins_del_bind_net_addr(nr->name, nr->typ, addr);
memcpy(&(nr->addr), addr, sizeof(ipxAddr_t));
}
}
void rip_for_net(uint32 net)
{
;
}
void handle_rip(int fd, int ipx_pack_typ,
int data_len, IPX_DATA *ipxdata,
ipxAddr_t *from_addr)
{
;
}
void send_server_response(int respond_typ,
int styp, ipxAddr_t *to_addr)
{
;; /* dummy */
}
void get_servers(void)
{
#if 1
SQP sqp;
ipxAddr_t wild;
memset(&wild, 0, sizeof(ipxAddr_t));
#ifdef xxxLINUX
U32_TO_BE32(internal_net, wild.net);
memcpy(wild.node, my_server_adr.node, IPX_NODE_SIZE);
#else
memset(wild.node, 0xFF, IPX_NODE_SIZE);
#endif
U16_TO_BE16(SOCK_SAP, wild.sock);
U16_TO_BE16(1, sqp.query_type);
U16_TO_BE16(4, sqp.server_type);
send_ipx_data(sockfd[SAP_SLOT], 17, sizeof(SQP),
(char*)&sqp, &wild, "SERVER Query");
#endif
}
void send_sap_rip_broadcast(int mode)
/* mode=0, standard broadcast */
/* mode=1, first trie */
/* mode=2, shutdown */
{
IPX_DATA ipx_data;
ipxAddr_t wild;
memset(&wild, 0, sizeof(ipxAddr_t));
#ifdef xxxLINUX
U32_TO_BE32(internal_net, wild.net);
memcpy(wild.node, my_server_adr.node, IPX_NODE_SIZE);
#else
memset(wild.node, 0xFF, IPX_NODE_SIZE);
#endif
U16_TO_BE16(SOCK_SAP, wild.sock);
memset(&ipx_data, 0, sizeof(ipx_data.sip));
strcpy((char *)ipx_data.sip.server_name, my_nwname);
memcpy(&ipx_data.sip.server_adr, &my_server_adr, sizeof(ipxAddr_t));
U16_TO_BE16(SOCK_NCP, ipx_data.sip.server_adr.sock);
U16_TO_BE16(2, ipx_data.sip.response_type);
U16_TO_BE16(4, ipx_data.sip.server_type);
U16_TO_BE16(mode == 2 ? 16 : 0, ipx_data.sip.intermediate_networks);
send_ipx_data(sockfd[SAP_SLOT],
4, /* this is the official packet typ for SAP's */
sizeof(ipx_data.sip),
(char *)&(ipx_data.sip),
&wild, "SIP Broadcast");
if (!mode) get_servers();
if (mode == 1) {
U16_TO_BE16(SOCK_SAP, wild.sock);
memset(&ipx_data, 0, sizeof(ipx_data.sip));
strcpy((char *)ipx_data.sip.server_name, my_nwname);
memcpy(&ipx_data.sip.server_adr, &my_server_adr, sizeof(ipxAddr_t));
U16_TO_BE16(SOCK_NCP, ipx_data.sip.server_adr.sock);
U16_TO_BE16(2, ipx_data.sip.response_type);
U16_TO_BE16(4, ipx_data.sip.server_type);
U16_TO_BE16(mode == 2 ? 16 : 0, ipx_data.sip.intermediate_networks);
}
}
int dont_send_wdog(ipxAddr_t *addr)
/* returns != 0 if tics are to high for wdogs */
{
return(0);
}

221
nwserv.c
View File

@ -1,5 +1,5 @@
/* nwserv.c 14-Jan-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
/* nwserv.c 08-Feb-96 */
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -30,24 +30,38 @@ int wdogs_till_tics = 0; /* send wdogs to all */
int anz_net_devices=0;
NW_NET_DEVICE *net_devices[MAX_NET_DEVICES];
uint16 ipx_sock_nummern[]={
#ifdef WDOG_SLOT
0, /* auto sock */
uint16 ipx_sock_nummern[]={ SOCK_AUTO /* WDOG */
#if INTERNAL_RIP_SAP
,SOCK_SAP
#else
,SOCK_AUTO
#endif
SOCK_SAP,
SOCK_RIP,
SOCK_ROUTE,
SOCK_DIAGNOSE
#ifdef RIP_SLOT
,SOCK_RIP
#endif
#ifdef ROUTE_SLOT
,SOCK_ROUTE
#endif
#ifdef DIAG_SLOT
,SOCK_DIAGNOSE
#endif
#ifdef ECHO_SLOT
, SOCK_ECHO
,SOCK_ECHO
#endif
#ifdef ERROR_SLOT
, SOCK_ERROR
,SOCK_ERROR
#endif
};
#define NEEDED_SOCKETS (sizeof(ipx_sock_nummern) / sizeof(uint16))
#define NEEDED_POLLS (NEEDED_SOCKETS+1)
#if FILE_SERVER_INACTIV
# define NEEDED_POLLS (NEEDED_SOCKETS)
#else
# define NEEDED_POLLS (NEEDED_SOCKETS+1)
#endif
static uint16 sock_nummern [NEEDED_SOCKETS];
@ -69,7 +83,7 @@ static time_t server_down_stamp = 0;
static int server_goes_down_secs = 10;
static int save_ipx_routes = 0;
#if !FILE_SERVER_INACTIV
static void write_to_ncpserv(int what, int connection,
char *data, int data_size)
{
@ -100,8 +114,15 @@ static void write_to_ncpserv(int what, int connection,
default : break;
}
}
#else
static void write_to_ncpserv(int what, int connection,
char *data, int data_size)
{
;; /* dummy */
}
#endif
void ins_del_bind_net_addr(char *name, ipxAddr_t *adr)
void ins_del_bind_net_addr(uint8 *name, int styp, ipxAddr_t *adr)
{
uint8 buf[1024];
uint8 *p = buf;
@ -109,9 +130,9 @@ void ins_del_bind_net_addr(char *name, ipxAddr_t *adr)
if (NULL != adr) { /* insert */
*p=0x01;
p+=2; len+=2;
U16_TO_BE16(0x4, p);
U16_TO_BE16(styp, p);
p+=2; len+=2;
*p = strlen(name);
*p = strlen((char*)name);
strmaxcpy(p+1, name, *p);
len += (*p+1); p+=(*p + 1);
memcpy(p, adr, sizeof(ipxAddr_t));
@ -119,31 +140,33 @@ void ins_del_bind_net_addr(char *name, ipxAddr_t *adr)
} else { /* delete */
*p=0x02;
p+=2; len+=2;
U16_TO_BE16(0x4, p);
U16_TO_BE16(styp, p);
p+=2; len+=2;
*p = strlen(name);
*p = strlen((char*)name);
strmaxcpy(p+1, name, *p);
len += (*p+1); p+=(*p + 1);
}
write_to_ncpserv(0x3333, 0, buf, len);
write_to_ncpserv(0x3333, 0, (char *)buf, len);
}
static int open_ipx_socket(uint16 sock_nr, int nr, int open_mode)
{
int ipx_fd=t_open("/dev/ipx", open_mode, NULL);
struct t_bind bind;
struct t_bind bind;
if (ipx_fd < 0) {
t_error("t_open !Ok");
return(-1);
}
memset(&my_server_adr, 0, sizeof(ipxAddr_t));
U16_TO_BE16(sock_nr, my_server_adr.sock); /* actual read socket */
bind.addr.len = sizeof(ipxAddr_t);
bind.addr.maxlen = sizeof(ipxAddr_t);
bind.addr.buf = (char*)&my_server_adr;
bind.qlen = 0; /* ever */
if (t_bind(ipx_fd, &bind, &bind) < 0){
char sxx[200];
sprintf(sxx,"NWSERV:t_bind !OK in open_ipx_socket, sock=%d", sock_nr);
sprintf(sxx,"NWSERV:t_bind !OK in open_ipx_socket, sock=0x%x", (int) sock_nr);
t_error(sxx);
t_close(ipx_fd);
return(-1);
@ -155,11 +178,13 @@ static int open_ipx_socket(uint16 sock_nr, int nr, int open_mode)
static int start_ncpserv(char *nwname, ipxAddr_t *addr)
{
#if !FILE_SERVER_INACTIV
int fds_out[2];
int fds_in[2];
int pid;
if (pipe(fds_out) < 0 || pipe(fds_in) < 0) return(-1);
switch (pid=fork()) {
case 0 : { /* new Process */
char *progname="ncpserv";
@ -192,6 +217,7 @@ static int start_ncpserv(char *nwname, ipxAddr_t *addr)
fds_in[1] = -1;
fd_ncpserv_in = fds_in[0];
pid_ncpserv = pid;
#endif
return(0); /* OK */
}
@ -237,7 +263,7 @@ static void send_wdog_packet(ipxAddr_t *addr, int conn, int what)
modify_wdog_conn(conn, 0);
XDPRINTF((2,0, "No wdog to %s", visable_ipx_adr(addr)));
} else
send_ipx_data(sockfd[WDOG_SLOT], 17, 2, data, addr, "WDOG");
send_ipx_data(sockfd[WDOG_SLOT], 17, 2, (char*)data, addr, "WDOG");
}
static void send_bcast_packet(ipxAddr_t *addr, int conn, int signature)
@ -249,7 +275,7 @@ static void send_bcast_packet(ipxAddr_t *addr, int conn, int signature)
* '!' = broadcast waiting inform
* '@' = sft_iii server change over inform.
*/
send_ipx_data(sockfd[WDOG_SLOT], 17, 2, data, addr, "BCAST");
send_ipx_data(sockfd[WDOG_SLOT], 17, 2, (char*)data, addr, "BCAST");
}
typedef struct {
@ -347,28 +373,6 @@ static void send_bcasts(int conn)
}
}
static void send_server_respons(int fd, uint8 ipx_pack_typ,
int respond_typ, int server_typ,
ipxAddr_t *to_addr)
{
IPX_DATA ipx_data;
memset(&ipx_data, 0, sizeof(ipx_data.sip));
strcpy(ipx_data.sip.server_name, my_nwname);
memcpy(&ipx_data.sip.server_adr, &my_server_adr, sizeof(ipxAddr_t));
U16_TO_BE16(SOCK_NCP, ipx_data.sip.server_adr.sock);
/* NCP SOCKET verwenden */
U16_TO_BE16(respond_typ, ipx_data.sip.response_type);
U16_TO_BE16(server_typ, ipx_data.sip.server_type);
U16_TO_BE16(0, ipx_data.sip.intermediate_networks);
send_ipx_data(fd, ipx_pack_typ,
sizeof(ipx_data.sip),
(char *)&(ipx_data.sip),
to_addr, "Server Response");
}
void get_server_data(char *name,
ipxAddr_t *adr,
ipxAddr_t *from_addr)
@ -392,19 +396,15 @@ static void handle_sap(int fd,
{
int query_type = GET_BE16(ipxdata->sqp.query_type);
int server_type = GET_BE16(ipxdata->sqp.server_type);
if (query_type == 3) {
XDPRINTF((2,0,"SAP NEAREST SERVER request typ=%d von %s",
server_type, visable_ipx_adr(from_addr)));
if (server_type == 4) {
/* Get Nearest File Server */
send_server_respons(fd, ipx_pack_typ, 4, server_type, from_addr);
}
/* Get Nearest File Server */
send_server_response(4, server_type, from_addr);
} else if (query_type == 1) { /* general Request */
XDPRINTF((2,0, "SAP GENERAL request server_type =%d", server_type));
if (server_type == 4) {
/* Get General File Server Request */
send_server_respons(fd, ipx_pack_typ, 4, server_type, from_addr);
}
send_server_response(2, server_type, from_addr);
} else if (query_type == 2 || query_type == 4) {
/* periodic general or shutdown response (2)
* or nearests Service Response (4)
@ -421,17 +421,16 @@ static void handle_sap(int fd,
XDPRINTF((2,0, "TYP=%2d,hops=%2d, Addr=%s, Name=%s", type, hops,
visable_ipx_adr(ad), name));
if (type == 4) /* && strcmp(name, my_nwname)) */ { /* from Fileserver */
if (type == 4) { /* from Fileserver */
if (16 == hops) {
/* shutdown */
XDPRINTF((2,0, "SERVER %s IS GOING DOWN", name));
insert_delete_server(name, type, NULL, NULL, 16, 1, 0);
} else {
get_server_data(name, ad, from_addr);
get_server_data((char*)name, ad, from_addr);
insert_delete_server(name, type, ad, from_addr, hops, 0, 0);
}
}
p+=sizeof(SAPS);
} /* while */
} else {
@ -470,6 +469,7 @@ static void handle_sap(int fd,
#endif
#ifdef DIAG_SLOT
static void response_ipx_diag(int fd, int ipx_pack_typ,
ipxAddr_t *to_addr)
{
@ -523,6 +523,7 @@ static void handle_diag(int fd, int ipx_pack_typ,
(int)ipx_pack_typ, data_len, count));
response_ipx_diag(fd, ipx_pack_typ, from_addr);
}
#endif
static void handle_event(int fd, uint16 socknr, int slot)
{
@ -565,6 +566,7 @@ static void handle_event(int fd, uint16 socknr, int slot)
if (server_down_stamp) return; /* no more interests */
#if INTERNAL_RIP_SAP
if ( IPXCMPNODE(source_adr.node, my_server_adr.node) &&
IPXCMPNET (source_adr.net, my_server_adr.net)) {
@ -579,11 +581,17 @@ static void handle_event(int fd, uint16 socknr, int slot)
/* it also can be Packets from DOSEMU OR ncpfs on this machine */
XDPRINTF((2,0,"Packet from OWN maschine:sock=0x%x", source_sock));
}
#endif
switch (socknr) {
case SOCK_SAP : handle_sap( fd, (int) ipx_pack_typ, ud.udata.len, &ipx_data_buff, &source_adr); break;
case SOCK_RIP : handle_rip( fd, (int) ipx_pack_typ, ud.udata.len, &ipx_data_buff, &source_adr); break;
case SOCK_DIAGNOSE : handle_diag(fd, (int) ipx_pack_typ, ud.udata.len, &ipx_data_buff, &source_adr); break;
switch (slot) {
case SAP_SLOT : handle_sap( fd, (int) ipx_pack_typ, ud.udata.len, &ipx_data_buff, &source_adr); break;
#ifdef RIP_SLOT
case RIP_SLOT : handle_rip( fd, (int) ipx_pack_typ, ud.udata.len, &ipx_data_buff, &source_adr); break;
#endif
#ifdef DIAG_SLOT
case DIAG_SLOT : handle_diag(fd, (int) ipx_pack_typ, ud.udata.len, &ipx_data_buff, &source_adr); break;
#endif
default :
if (WDOG_SLOT == slot) { /* this is a watchdog packet */
@ -610,6 +618,54 @@ static void handle_event(int fd, uint16 socknr, int slot)
}
}
#if 0
static int get_ipx_addr(ipxAddr_t *addr)
{
int fd=t_open("/dev/ipx", O_RDWR, NULL);
struct t_optmgmt optb;
int result = -1;
if (fd < 0) {
t_error("t_open !Ok");
return(-1);
}
optb.opt.maxlen = optb.opt.len = sizeof(ipxAddr_t);
optb.opt.buf = (char*)addr;
optb.flags = 0;
result = t_optmgmt(fd, &optb, &optb);
if (result < 0) t_error("t_optmgmt !Ok");
else result=0;
t_close(fd);
return(result);
}
#else
static int get_ipx_addr(ipxAddr_t *addr)
{
int fd=t_open("/dev/ipx", O_RDWR, NULL);
struct t_bind bind;
int result = -1;
if (fd < 0) {
t_error("t_open !Ok");
return(-1);
}
bind.addr.len = sizeof(ipxAddr_t);
bind.addr.maxlen = sizeof(ipxAddr_t);
bind.addr.buf = (char*)addr;
bind.qlen = 0; /* ever */
memset(addr, 0, sizeof(ipxAddr_t));
if (t_bind(fd, &bind, &bind) < 0)
t_error("tbind:get_ipx_addr");
else {
result=0;
t_unbind(fd);
}
t_close(fd);
return(result);
}
#endif
static void get_ini(int full)
{
FILE *f = open_nw_ini();
@ -617,7 +673,7 @@ static void get_ini(int full)
uint32 node = 1; /* default 1 */
if (full) {
gethostname(my_nwname, 48);
upstr(my_nwname);
upstr((uint8*)my_nwname);
}
if (f){
char buff[500];
@ -635,7 +691,7 @@ static void get_ini(int full)
case 2 : if (full) {
strncpy(my_nwname, inhalt, 48);
my_nwname[47] = '\0';
upstr(my_nwname);
upstr((uint8*)my_nwname);
}
break;
@ -650,6 +706,7 @@ static void get_ini(int full)
}
break;
#if INTERNAL_RIP_SAP
case 4 :
if (full) {
if (anz_net_devices < MAX_NET_DEVICES &&
@ -682,7 +739,7 @@ static void get_ini(int full)
}
}
break;
#ifdef LINUX
case 5 : save_ipx_routes=atoi(inhalt);
break;
#endif
@ -700,7 +757,7 @@ static void get_ini(int full)
case 300 : print_route_tac=atoi(inhalt);
break;
case 301 : new_str(pr_route_info_fn, inhalt);
case 301 : new_str(pr_route_info_fn, (uint8*)inhalt);
break;
case 302 : print_route_mode=atoi(inhalt);
@ -721,6 +778,7 @@ static void get_ini(int full)
if (!print_route_tac) xfree(pr_route_info_fn);
if (full) {
#ifdef LINUX
# if INTERNAL_RIP_SAP
init_ipx(internal_net, node, ipxdebug);
for (k=0; k < anz_net_devices; k++){
NW_NET_DEVICE *nd=net_devices[k];
@ -736,7 +794,9 @@ static void get_ini(int full)
nd->devname, frname, nd->net));
init_dev(nd->devname, nd->frame, nd->net);
}
# endif
#endif
if (!get_ipx_addr(&my_server_adr)) {
internal_net = GET_BE32(my_server_adr.net);
} else exit(1);
@ -781,6 +841,7 @@ static void close_all(void)
}
#ifdef LINUX
# if INTERNAL_RIP_SAP
if (!save_ipx_routes) {
for (j=0; j<anz_net_devices;j++) {
NW_NET_DEVICE *nd=net_devices[j];
@ -790,8 +851,8 @@ static void close_all(void)
}
}
exit_ipx(!save_ipx_routes);
# endif
#endif
}
static void down_server(void)
@ -818,6 +879,7 @@ static void sig_quit(int rsig)
{
signal(rsig, SIG_IGN);
signal(SIGHUP, SIG_IGN); /* don't want it anymore */
XDPRINTF((2, 0, "Got Signal=%d", rsig));
fl_get_int=2;
}
@ -874,18 +936,25 @@ int main(int argc, char **argv)
polls[j].fd = -1;
}
}
U16_TO_BE16(SOCK_NCP, my_server_adr.sock);
if (!start_ncpserv(my_nwname, &my_server_adr)) {
ipxAddr_t server_adr_sap;
/* now do polling */
time_t broadtime;
time(&broadtime);
set_sigs();
polls[NEEDED_SOCKETS].fd = fd_ncpserv_in;
memcpy(&server_adr_sap, &my_server_adr, sizeof(ipxAddr_t));
U16_TO_BE16(SOCK_SAP, server_adr_sap.sock);
insert_delete_server(my_nwname, 0x4, &my_server_adr, &server_adr_sap, 0, 0, 0);
#if !FILE_SERVER_INACTIV
{
ipxAddr_t server_adr_sap;
polls[NEEDED_SOCKETS].fd = fd_ncpserv_in;
U16_TO_BE16(SOCK_NCP, my_server_adr.sock);
memcpy(&server_adr_sap, &my_server_adr, sizeof(ipxAddr_t));
U16_TO_BE16(SOCK_SAP, server_adr_sap.sock);
insert_delete_server((uint8*)my_nwname, 0x4,
&my_server_adr, &server_adr_sap, 0, 0, 0);
}
#endif
while (1) {
int anz_poll = poll(polls, NEEDED_POLLS, broadsecs);
time(&akttime_stamp);
@ -968,12 +1037,18 @@ int main(int argc, char **argv)
if (server_down_stamp) {
if (akttime_stamp - server_down_stamp > server_goes_down_secs) break;
} else {
if (akttime_stamp - broadtime > (broadsecs / 1000)) { /* ca. 60 seconds */
if (akttime_stamp - broadtime > (broadsecs / 1000)) { /* ca. 30 seconds */
send_sap_rip_broadcast((broadsecs<3000) ? 1 :0); /* firsttime broadcast */
if (broadsecs < 32000) {
if (broadsecs < 30000) {
rip_for_net(MAX_U32);
get_servers();
broadsecs *= 2;
if (broadsecs > 30000)
#if INTERNAL_RIP_SAP
broadsecs = 30000; /* every 30 sec. */
#else
broadsecs = 60000; /* every 60 sec. */
#endif
}
send_wdogs();
broadtime = akttime_stamp;

View File

@ -1,4 +1,4 @@
/* nwserv.h 14-Jan-96 */
/* nwserv.h 30-Jan-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
@ -36,19 +36,25 @@ extern int anz_net_devices;
extern NW_NET_DEVICE *net_devices[];
/* <======== SOCKETS =========> */
#define WDOG_SLOT 0 /* Watchdog send + recv */
#define SAP_SLOT 1
#define RIP_SLOT (SAP_SLOT +1)
#define ROUTE_SLOT (RIP_SLOT +1)
#define DIAG_SLOT (ROUTE_SLOT +1)
#if 0
#define ECHO_SLOT (DIAG_SLOT +1)
#define ERR_SLOT (ECHO_SLOT +1)
#define WDOG_SLOT 0 /* Watchdog send + recv */
#define SAP_SLOT 1 /* SAP wellkwon or dynamic */
#if INTERNAL_RIP_SAP
# define RIP_SLOT (SAP_SLOT +1)
# if 0
# define ROUTE_SLOT (RIP_SLOT +1)
# define DIAG_SLOT (ROUTE_SLOT +1)
# define ECHO_SLOT (DIAG_SLOT +1)
# define ERR_SLOT (ECHO_SLOT +1)
# endif
#endif
extern int sockfd[];
extern void ins_del_bind_net_addr(char *name, ipxAddr_t *adr);
extern void ins_del_bind_net_addr(uint8 *name, int styp, ipxAddr_t *adr);
extern void send_server_response(int respond_typ,
int styp, ipxAddr_t *to_addr);
extern void send_sap_rip_broadcast(int mode);
extern void rip_for_net(uint32 net);
extern void get_servers(void);

View File

@ -1,4 +1,4 @@
/* nwvolume.c 15-Jan-96 */
/* nwvolume.c 07-Feb-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
@ -20,6 +20,12 @@
#include <dirent.h>
#include <sys/vfs.h>
#ifndef LINUX
#include <sys/statvfs.h>
#define statfs statvfs
#endif
#include <utime.h>
#include "nwvolume.h"
@ -74,6 +80,9 @@ void nw_init_volumes(FILE *f)
case 'p' : nw_volumes[used_nw_volumes].options
|= VOL_OPTION_IS_PIPE; break;
case 'm' : nw_volumes[used_nw_volumes].options
|= VOL_OPTION_REMOUNT; break;
default : break;
}
}
@ -181,7 +190,7 @@ int nw_get_volume_name(int volnr, uint8 *volname)
if (volnr < MAX_NW_VOLS) result=0;
}
if (nw_debug > 4) {
char xvolname[10];
uint8 xvolname[10];
if (!volname) {
volname = xvolname;
*volname = '\0';
@ -220,10 +229,10 @@ static int get_fs_usage(char *path, struct fs_usage *fsp)
return(0);
}
int nw_get_fs_usage(char *volname, struct fs_usage *fsu)
int nw_get_fs_usage(uint8 *volname, struct fs_usage *fsu)
/* returns 0 if OK, else errocode < 0 */
{
int volnr = nw_get_volume_number(volname, strlen(volname));
int volnr = nw_get_volume_number(volname, strlen((char*)volname));
return((volnr>-1 && !get_fs_usage(nw_volumes[volnr].unixname, fsu)) ? 0 : -1);
}

View File

@ -1,4 +1,4 @@
/* nwvolume.h 15-Jan-96 */
/* nwvolume.h 07-Feb-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
@ -15,6 +15,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _NWVOLUME_H_
#define _NWVOLUME_H_
#define MAX_DEV_NAMESPACE_MAPS 256
@ -31,16 +33,16 @@ typedef struct {
typedef struct {
uint8 *sysname; /* VOL_NAME */
uint8 *unixname; /* UNIX-Verzeichnis */
uint8 *unixname; /* UNIX-DIR */
int unixnamlen; /* len of unixname */
DEV_NAMESPACE_MAP *dev_namespace_maps[MAX_DEV_NAMESPACE_MAPS];
int maps_count; /* count of dev_namespace_maps */
uint8 options; /* *_1_* alles in Kleinbuchstaben */
uint8 options; /* *_1_* all is lowercase */
} NW_VOL;
#define VOL_OPTION_DOWNSHIFT 1
#define VOL_OPTION_IS_PIPE 2 /* Volume has only pipes */
#define VOL_OPTION_IS_PIPE 2 /* Volume has only pipes */
#define VOL_OPTION_REMOUNT 4 /* Volume can be remounted (cdroms) */
/* stolen from GNU-fileutils */
/* Space usage statistics for a filesystem. Blocks are 512-byte. */
@ -58,7 +60,7 @@ extern int used_nw_volumes;
extern void nw_init_volumes(FILE *f);
extern int nw_get_volume_number(uint8 *volname, int namelen);
extern int nw_get_volume_name(int volnr, uint8 *volname);
extern int nw_get_fs_usage(char *volname, struct fs_usage *fsu);
extern int nw_get_fs_usage(uint8 *volname, struct fs_usage *fsu);
extern int get_volume_options(int volnr, int mode);
extern uint32 nw_vol_inode_to_handle(int volume, ino_t inode,
@ -66,3 +68,4 @@ extern uint32 nw_vol_inode_to_handle(int volume, ino_t inode,
extern ino_t nw_vol_handle_to_inode(int volume, uint32 handle,
DEV_NAMESPACE_MAP *dnm);
#endif

24
tools.c
View File

@ -19,6 +19,13 @@
#include "net.h"
#include <stdarg.h>
#ifndef LINUX
#include <errno.h>
extern int _sys_nerr;
extern char _sys_errlist[];
#endif
int nw_debug=0;
FILE *logfile=stdout;
@ -27,7 +34,8 @@ static char *modnames[] =
{ "???????",
"NWSERV ",
"NCPSERV",
"NWCONN " };
"NWCONN ",
"NWCLIEN" };
static char *get_modstr(void)
{
@ -59,9 +67,9 @@ void x_x_xfree(char **p)
}
}
int strmaxcpy(char *dest, char *source, int len)
int strmaxcpy(uint8 *dest, uint8 *source, int len)
{
int slen = (source != (char *)NULL) ? min(len, strlen(source)) : 0;
int slen = (source != (uint8 *)NULL) ? min(len, strlen((char*)source)) : 0;
if (slen) memcpy(dest, source, slen);
dest[slen] = '\0';
return(slen);
@ -69,7 +77,7 @@ int strmaxcpy(char *dest, char *source, int len)
int x_x_xnewstr(uint8 **p, uint8 *s)
{
int len = (s == NULL) ? 0 : strlen(s);
int len = (s == NULL) ? 0 : strlen((char*)s);
if (*p != (uint8 *)NULL) free((char*)*p);
*p = (uint8*)xmalloc(len+1);
if (len) strcpy((char*)(*p), (char*)s);
@ -87,6 +95,7 @@ void dprintf(char *p, ...)
va_end(ap);
fprintf(logfile, "\n");
fflush(logfile);
fflush(logfile);
}
}
@ -159,11 +168,11 @@ int get_ini_entry(FILE *f, int entry, char *str, int strsize)
if (len > se+1 && se > 0 && se < 4 && ppi){
char sx[10];
int fentry;
strmaxcpy(sx, buff, se);
strmaxcpy((uint8*)sx, (uint8*)buff, se);
fentry = atoi(sx);
if (fentry > 0 && ((!entry) || entry == fentry)) {
if (ppe) *(ppe+1) = '\0';
strmaxcpy(str, ppi, strsize-1);
strmaxcpy((uint8*)str, (uint8*)ppi, strsize-1);
if (do_open) fclose(f);
return(fentry);
}
@ -194,6 +203,7 @@ void get_ini_debug(int module)
* 1 = nwserv
* 2 = ncpserv
* 3 = nwconn
* 4 = nwclient
*/
{
int debug = get_ini_int(100+module);
@ -222,7 +232,7 @@ void init_tools(int module)
while (0 != (what=get_ini_entry(f, 0, buff, sizeof(buff)))) { /* daemonize */
if (200 == what) dodaemon = atoi(buff);
else if (201 == what) {
strmaxcpy(logfilename, buff, sizeof(logfilename)-1);
strmaxcpy((uint8*)logfilename, (uint8*)buff, sizeof(logfilename)-1);
withlog++;
} else if (202 == what) {
new_log = atoi(buff);

View File

@ -1,4 +1,4 @@
/* tools.h : 15-Jan-96 */
/* tools.h : 28-Jan-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
*
@ -21,6 +21,7 @@
#define NWSERV 1
#define NCPSERV 2
#define NWCONN 3
#define NWCLIENT 4
extern FILE *logfile;
extern void x_x_xfree(char **p);
@ -31,7 +32,7 @@ extern int x_x_xnewstr(uint8 **p, uint8 *s);
extern char *xmalloc(uint size);
extern char *xcmalloc(uint size);
extern int strmaxcpy(char *dest, char *source, int len);
extern int strmaxcpy(uint8 *dest, uint8 *source, int len);
extern void dprintf(char *p, ...);
extern void xdprintf(int dlevel, int mode, char *p, ...);
extern void errorp(int mode, char *what, char *p, ...);
@ -52,8 +53,10 @@ extern int nw_debug;
#ifdef DB
# define DPRINTF(x) dprintf x
# define XDPRINTF(x) xdprintf x
# define D() XDPRINTF((3, 0, "Z: %d" , __LINE__));
#else
# define DPRINTF(x) /* */
# define XDPRINTF(x) /* */
# define D() /* */
#endif