mars_nwe-0.96.pl06

This commit is contained in:
Mario Fetka 2011-11-13 00:38:55 +01:00
parent 42aa23ed0b
commit 164365d514
15 changed files with 388 additions and 211 deletions

View File

@ -52,4 +52,10 @@ Erste 'oeffentliche' Version
geschrieben. geschrieben.
- SAP Responses gehen nun immer ueber den SAP Socket. - SAP Responses gehen nun immer ueber den SAP Socket.
- Routing Bereich (SAP's) erweitert. - Routing Bereich (SAP's) erweitert.
- SAP Broadcasts haben nun Packettyp '4'.
- Volume Info's (Volume Size usw.) korrigiert.
- Nun auch neue Konstante MAX_NW_SERVERS in config.h
- Routing and Server Tabelle (Info) kann nun in Datei ausgegeben werden.
- Es kann nun gesteuert werden (nw.ini:310), dass wdogs zu einer
connection nur gesendet werden, falls der client ueber eine device
net < angebbarer anzahl tics ist. (z.B. fuer IPX ueber ISDN)

View File

@ -1,4 +1,4 @@
/* connect.c 02-Jan-96 */ /* connect.c 13-Jan-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany /* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -698,7 +698,7 @@ static int build_verz_name(NW_PATH *nwpath, /* gets complete path */
while (*xp++ == '.' && completition > -1) { while (*xp++ == '.' && completition > -1) {
p1--; /* steht nun auf letztem Zeichen '/' od. ':' */ p1--; /* steht nun auf letztem Zeichen '/' od. ':' */
if (p1 < panf) completition = -0x9c ; if (p1 < panf) completition = -0x9c ;
/* Falscher Pfad, denn weiter zurueck gehts nicht */ /* wrong path, don't can go back any more */
else { else {
while (p1 > panf && *(--p1) != '/');; while (p1 > panf && *(--p1) != '/');;
if (p1 == panf) *p1='\0'; if (p1 == panf) *p1='\0';
@ -1081,7 +1081,7 @@ int nw_server_copy(int qfhandle, uint32 qoffset,
return(retsize); return(retsize);
} }
} }
return(- 0x88); /* Falscher Filehandle */ return(- 0x88); /* wrong filehandle */
} }
@ -1374,7 +1374,7 @@ int nw_search(uint8 *info,
} }
return(searchsequence); return(searchsequence);
} else return(-0xff); /* not found */ } else return(-0xff); /* not found */
} else return(completition); /* Falscher Pfad */ } else return(completition); /* wrong path */
} }
int nw_dir_search(uint8 *info, int nw_dir_search(uint8 *info,
@ -1468,7 +1468,7 @@ int nw_free_dir_handle(int dir_handle)
{ {
if (dir_handle && --dir_handle < (int)used_dirs) { if (dir_handle && --dir_handle < (int)used_dirs) {
NW_DIR *d=&(dirs[dir_handle]); NW_DIR *d=&(dirs[dir_handle]);
if (!d->inode) return(-0x9b); /* Falscher Handle */ if (!d->inode) return(-0x9b); /* wrong handle */
else { else {
d->inode = 0; d->inode = 0;
xfree(d->path); xfree(d->path);
@ -1500,7 +1500,7 @@ int nw_get_directory_path(int dir_handle, uint8 *name)
name[0] = '\0'; name[0] = '\0';
if (dir_handle > 0 && --dir_handle < (int)used_dirs) { if (dir_handle > 0 && --dir_handle < (int)used_dirs) {
int volume = dirs[dir_handle].volume; int volume = dirs[dir_handle].volume;
if (volume < used_vols){ if (volume > -1 && volume < used_vols){
result=sprintf((char*)name, "%s:%s", vols[volume].sysname, dirs[dir_handle].path); result=sprintf((char*)name, "%s:%s", vols[volume].sysname, dirs[dir_handle].path);
if (name[result-1] == '/') name[--result] = '\0'; if (name[result-1] == '/') name[--result] = '\0';
} else result = -0x98; } else result = -0x98;
@ -1512,10 +1512,10 @@ int nw_get_directory_path(int dir_handle, uint8 *name)
int nw_get_vol_number(int dir_handle) int nw_get_vol_number(int dir_handle)
/* Get Volume Nummmer with Handle */ /* Get Volume Nummmer with Handle */
{ {
int result = -0x9b; /* Falsches Handle */ int result = -0x9b; /* wrong handle */
if (dir_handle > 0 && --dir_handle < (int)used_dirs) { if (dir_handle > 0 && --dir_handle < (int)used_dirs) {
result = dirs[dir_handle].volume; result = dirs[dir_handle].volume;
if (result >= used_vols) result = -0x98; /* Falsches Volume */ if (result < 0 || result >= used_vols) result = -0x98; /* wrong volume */
} }
XDPRINTF((5,0,"nw_get_vol_number:0x%x: von Handle=%d", result, dir_handle+1)); XDPRINTF((5,0,"nw_get_vol_number:0x%x: von Handle=%d", result, dir_handle+1));
return(result); return(result);
@ -1543,12 +1543,24 @@ int nw_get_volume_number(uint8 *volname, int namelen)
int nw_get_volume_name(int volnr, uint8 *volname) int nw_get_volume_name(int volnr, uint8 *volname)
/* returns < 0 if error, else len of volname */ /* returns < 0 if error, else len of volname */
{ {
int result = -0x98; /* Volume not exist */; int result = -0x98; /* Volume not exist */;
if (volnr < used_vols) { if (volnr < used_vols) {
strcpy(volname, vols[volnr].sysname); if (volname != NULL) {
result = strlen(volname); strcpy(volname, vols[volnr].sysname);
} else volname[0] = '\0'; result = strlen(volname);
XDPRINTF((5,0,"GET_VOLUME_NAME von:%d = %s: ,result=0x%x", volnr, volname, result)); } else result= strlen(vols[volnr].sysname);
} else {
if (NULL != volname) *volname = '\0';
if (volnr < MAX_NW_VOLS) result=0;
}
if (nw_debug > 4) {
char xvolname[10];
if (!volname) {
volname = xvolname;
*volname = '\0';
}
XDPRINTF((5,0,"GET_VOLUME_NAME von:%d = %s: ,result=0x%x", volnr, volname, result));
}
return(result); return(result);
} }
@ -1675,7 +1687,7 @@ int nw_get_vol_info(int volnr)
/* returns >= 0 if OK, else errocode < 0 */ /* returns >= 0 if OK, else errocode < 0 */
{ {
int result = -0x98; /* Volume not exist */; int result = -0x98; /* Volume not exist */;
if (volnr < used_vols) { if (volnr > -1 && volnr < used_vols) {
result =0; result =0;
} }
XDPRINTF((5,0,"NW_GET_VOL_INFO von VOLNR:%d, result=0x%x", volnr, result)); XDPRINTF((5,0,"NW_GET_VOL_INFO von VOLNR:%d, result=0x%x", volnr, result));

View File

@ -1,4 +1,4 @@
/* config.h: 03-Jan-96 */ /* config.h: 14-Jan-96 */
/* some of this config is needed by make, others by cc */ /* 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 FILENAME_NW_INI "/etc/nwserv.conf" /* full name of ini (conf) file */
#define PATHNAME_PROGS "/sbin" /* path location of progs */ #define PATHNAME_PROGS "/sbin" /* path location of progs */
@ -13,5 +13,4 @@
#define IPX_DATA_GR_546 1 /* allow ipx packets > 546+30 Byte */ #define IPX_DATA_GR_546 1 /* allow ipx packets > 546+30 Byte */
#define MAX_NW_ROUTES 50 /* max. networks (internal + external) */ #define MAX_NW_ROUTES 50 /* max. networks (internal + external) */
#define MAX_NW_SERVERS 40 /* max. count of servers */

View File

@ -1,5 +1,5 @@
# (C)opyright 1993, 1995, Martin Stover, Softwareentwicklung, Marburg # (C)opyright 1993, 1995, Martin Stover, Softwareentwicklung, Marburg
# last change: 20-Dec-95 # last change: 14-Jan-96
# MAR.S NW-Server Emulator # MAR.S NW-Server Emulator
# Einfache Konfiguration, alles ab # ist Kommentar. # Einfache Konfiguration, alles ab # ist Kommentar.
# Jeder Eintrag beginnt mit einer Zahl und dann folgt der Inhalt. # Jeder Eintrag beginnt mit einer Zahl und dann folgt der Inhalt.
@ -86,5 +86,13 @@
############################# #############################
210 10 # 1 .. 600 (default 10) seconds after server really goes down 210 10 # 1 .. 600 (default 10) seconds after server really goes down
# # after a down command # # after a down command
#############################
300 0 # > 0 print routing info to file every x broadcasts. ( minuts )
301 /tmp/nw.routes # filename.
302 1 # creat new filename=1, append to file=0
#############################
310 7 # send wdog's only to device net < x tics.
# 0 = allways send wdogs. < 0 = never send wdogs

View File

@ -1,4 +1,4 @@
# makefile.unx 09-Jan-96 # makefile.unx 12-Jan-96
VPATH=.. VPATH=..
O=.o O=.o
C=.c C=.c
@ -6,7 +6,7 @@ C=.c
DEBUG=-DDB DEBUG=-DDB
V_H=0 V_H=0
V_L=96 V_L=96
P_L=5 P_L=6
#define D_P_L 1 #define D_P_L 1
DISTRIB=mars_nwe DISTRIB=mars_nwe
#if D_P_L #if D_P_L

View File

@ -1,7 +1,7 @@
Begin3 Begin3
Title: mars_nwe Title: mars_nwe
Version: 0.96pl4 Version: 0.96pl6
Entered-date: 09-Jan-96 Entered-date: 14-Jan-96
Description: full novell-server-emulator (src),beta Description: full novell-server-emulator (src),beta
file-services, bindery-services, printing-services file-services, bindery-services, printing-services
needs no kernelchanges, usefull for testing ipx needs no kernelchanges, usefull for testing ipx

View File

@ -1,5 +1,5 @@
/* ncpserv.c */ /* ncpserv.c */
#define REVISION_DATE "09-Jan-96" #define REVISION_DATE "14-Jan-96"
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany /* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify

10
net.h
View File

@ -61,13 +61,17 @@
*( (uint8*) (b) ) = *( ((uint8*) (&a)) +1); \ *( (uint8*) (b) ) = *( ((uint8*) (&a)) +1); \
*( ((uint8*) (b)) +1) = *( (uint8*) (&a)); } *( ((uint8*) (b)) +1) = *( (uint8*) (&a)); }
#define U32_TO_BE32(u, ar) { uint32 a= (u); uint8 *b= ((uint8*)(ar))+3; \ #define U32_TO_BE32(u, ar) { uint32 a= (u); uint8 *b= ((uint8*)(ar))+3; \
*b-- = (uint8)a; a >>= 8; \ *b-- = (uint8)a; a >>= 8; \
*b-- = (uint8)a; a >>= 8; \ *b-- = (uint8)a; a >>= 8; \
*b-- = (uint8)a; a >>= 8; \ *b-- = (uint8)a; a >>= 8; \
*b = (uint8)a; } *b = (uint8)a; }
#define GET_BE16(b) ( (int) *(((uint8*)(b))+1) \ #define U16_TO_16(u, b) { uint16 a=(u); memcpy(b, &a, 2); }
#define U32_TO_32(u, b) { uint32 a=(u); memcpy(b, &a, 4); }
#define GET_BE16(b) ( (int) *(((uint8*)(b))+1) \
| ( ( (int) *( (uint8*)(b) ) << 8) ) ) | ( ( (int) *( (uint8*)(b) ) << 8) ) )
#define GET_BE32(b) ( (uint32) *(((uint8*)(b))+3) \ #define GET_BE32(b) ( (uint32) *(((uint8*)(b))+3) \
@ -112,6 +116,10 @@
# define MAX_NW_ROUTES 50 # define MAX_NW_ROUTES 50
#endif #endif
#ifndef MAX_NW_SERVERS
# define MAX_NW_SERVERS MAX_NW_ROUTES
#endif
#if IPX_DATA_GR_546 #if IPX_DATA_GR_546
# define IPX_MAX_DATA 1058 # define IPX_MAX_DATA 1058
#else #else

16
net1.c
View File

@ -1,4 +1,4 @@
/* net1.c, 09-Jan-96 */ /* net1.c, 14-Jan-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany /* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
* *
@ -39,17 +39,23 @@ void print_t_info(struct t_info *t)
} }
#endif #endif
char *visable_ipx_adr(ipxAddr_t *p) char *xvisable_ipx_adr(ipxAddr_t *p, int modus)
{ {
static char str[200]; static char str[200];
if (p) if (p) {
if (!modus) {
sprintf(str,"net=%x:%x:%x:%x, node=%x:%x:%x:%x:%x:%x, sock=%02x:%02x", sprintf(str,"net=%x:%x:%x:%x, node=%x:%x:%x:%x:%x:%x, sock=%02x:%02x",
(int)p->net[0], (int)p->net[1], (int)p->net[2], (int)p->net[3], (int)p->net[0], (int)p->net[1], (int)p->net[2], (int)p->net[3],
(int)p->node[0], (int)p->node[1], (int)p->node[2], (int)p->node[3], (int)p->node[0], (int)p->node[1], (int)p->node[2], (int)p->node[3],
(int)p->node[4], (int)p->node[5], (int)p->sock[0], (int)p->sock[1]); (int)p->node[4], (int)p->node[5], (int)p->sock[0], (int)p->sock[1]);
else } else if (modus== 1) {
sprintf(str,"%02X:%02X:%02X:%02X,%02x:%02x:%02x:%02x:%02x:%02x,%02x:%02x",
(int)p->net[0], (int)p->net[1], (int)p->net[2], (int)p->net[3],
(int)p->node[0], (int)p->node[1], (int)p->node[2], (int)p->node[3],
(int)p->node[4], (int)p->node[5], (int)p->sock[0], (int)p->sock[1]);
} else strcpy(str, "??");
} else
strcpy(str, "net=UNKOWN(NULLPOINTER)"); strcpy(str, "net=UNKOWN(NULLPOINTER)");
return(str); return(str);
} }

6
net1.h
View File

@ -1,4 +1,4 @@
/* net1.h 11-Sep-95 */ /* net1.h 14-Jan-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany /* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
* *
@ -23,7 +23,9 @@ extern void print_t_info(struct t_info *t);
extern void print_ud_data(struct t_unitdata *ud); extern void print_ud_data(struct t_unitdata *ud);
#endif #endif
extern char *visable_ipx_adr(ipxAddr_t *p); extern char *xvisable_ipx_adr(ipxAddr_t *p, int modus);
#define visable_ipx_adr(adr) xvisable_ipx_adr((adr), 0)
extern void print_ipx_addr(ipxAddr_t *p); extern void print_ipx_addr(ipxAddr_t *p);
extern void print_ipx_data(IPX_DATA *p); extern void print_ipx_data(IPX_DATA *p);
extern void print_sip_data(SIP *sip); extern void print_sip_data(SIP *sip);

View File

@ -1,4 +1,4 @@
/* nwconn.c 09-Jan-96 */ /* nwconn.c 13-Jan-96 */
/* one process / connection */ /* one process / connection */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany /* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
@ -159,9 +159,9 @@ static void handle_ncp_serv()
if ((result = nw_get_volume_name(volume, xdata->name))>-1){ if ((result = nw_get_volume_name(volume, xdata->name))>-1){
struct fs_usage fsp; struct fs_usage fsp;
if (!nw_get_fs_usage(xdata->name, &fsp)) { if (!nw_get_fs_usage(xdata->name, &fsp)) {
U16_TO_BE16(38, xdata->sec_per_block); /* hard coded */ U16_TO_BE16(1000, xdata->sec_per_block); /* hard coded */
U16_TO_BE16(fsp.fsu_blocks, xdata->total_blocks); U16_TO_BE16(fsp.fsu_blocks/1000, xdata->total_blocks);
U16_TO_BE16(fsp.fsu_bavail, xdata->avail_blocks); U16_TO_BE16(fsp.fsu_bavail/1000, xdata->avail_blocks);
U16_TO_BE16(fsp.fsu_files, xdata->total_dirs); U16_TO_BE16(fsp.fsu_files, xdata->total_dirs);
U16_TO_BE16(fsp.fsu_ffree, xdata->avail_dirs); U16_TO_BE16(fsp.fsu_ffree, xdata->avail_dirs);
U16_TO_BE16(0, xdata->removable); U16_TO_BE16(0, xdata->removable);
@ -371,8 +371,7 @@ static void handle_ncp_serv()
} else if (*p == 0x15){ /* liefert Volume Information */ } else if (*p == 0x15){ /* liefert Volume Information */
/******** Get Volume Info with Handle ****/ /******** Get Volume Info with Handle ****/
struct XDATA { struct XDATA {
uint8 reserve1; uint8 sectors[2];
uint8 len;
uint8 total_blocks[2]; uint8 total_blocks[2];
uint8 avail_blocks[2]; uint8 avail_blocks[2];
uint8 total_dirs[2]; /* anz dirs */ uint8 total_dirs[2]; /* anz dirs */
@ -387,9 +386,9 @@ static void handle_ncp_serv()
if (result > -1) { if (result > -1) {
struct fs_usage fsp; struct fs_usage fsp;
if (!nw_get_fs_usage(xdata->name, &fsp)) { if (!nw_get_fs_usage(xdata->name, &fsp)) {
xdata->len = 8; /* blocks entries */ U16_TO_BE16(1000, xdata->sectors);
U16_TO_BE16(fsp.fsu_blocks, xdata->total_blocks); U16_TO_BE16(fsp.fsu_blocks/1000, xdata->total_blocks);
U16_TO_BE16(fsp.fsu_bavail, xdata->avail_blocks); U16_TO_BE16(fsp.fsu_bavail/1000, xdata->avail_blocks);
U16_TO_BE16(fsp.fsu_files, xdata->total_dirs); U16_TO_BE16(fsp.fsu_files, xdata->total_dirs);
U16_TO_BE16(fsp.fsu_ffree, xdata->avail_dirs); U16_TO_BE16(fsp.fsu_ffree, xdata->avail_dirs);
U16_TO_BE16(0, xdata->removable); U16_TO_BE16(0, xdata->removable);
@ -459,7 +458,8 @@ static void handle_ncp_serv()
input->dir_handle); input->dir_handle);
if (result > -1) data_len = result; if (result > -1) data_len = result;
else completition = (uint8) (-result); else completition = (uint8) (-result);
} else if (*p == 0x20){ /* scan volume user disk restrictions */ } else if (*p == 0x20){
/* scan volume user disk restrictions */
uint8 volnr = *(p+1); uint8 volnr = *(p+1);
uint32 sequenz = GET_BE32(p+2); uint32 sequenz = GET_BE32(p+2);
struct XDATA { struct XDATA {
@ -468,8 +468,11 @@ static void handle_ncp_serv()
uint8 id[4]; uint8 id[4];
uint8 restriction[4]; uint8 restriction[4];
} *xdata = (struct XDATA*) responsedata; } *xdata = (struct XDATA*) responsedata;
xdata->entries = 0x0; int result = nw_get_volume_name(volnr, NULL);
data_len = (8 * xdata->entries) + 1; if (result > -1) {
xdata->entries = 0x0;
data_len = (8 * xdata->entries) + 1;
} else completition = (uint8) (-result);
} else if (*p == 0x21) { } else if (*p == 0x21) {
/* change Vol restrictions for Obj */ /* change Vol restrictions for Obj */
uint8 volnr = *(p+1); uint8 volnr = *(p+1);
@ -554,7 +557,7 @@ static void handle_ncp_serv()
/* ncpfs need this call */ /* ncpfs need this call */
int volume = (int) *(p+1); int volume = (int) *(p+1);
struct XDATA { struct XDATA {
uint8 total_blocks[4]; uint8 total_blocks[4]; /* LOW-HI !! */
uint8 avail_blocks[4]; uint8 avail_blocks[4];
uint8 purgeable_blocks[4]; uint8 purgeable_blocks[4];
uint8 not_purgeable_blocks[4]; uint8 not_purgeable_blocks[4];
@ -571,11 +574,11 @@ static void handle_ncp_serv()
struct fs_usage fsp; struct fs_usage fsp;
memset(xdata, 0, sizeof(struct XDATA)); memset(xdata, 0, sizeof(struct XDATA));
if (!nw_get_fs_usage(name, &fsp)) { if (!nw_get_fs_usage(name, &fsp)) {
xdata->sec_per_block = 38; /* hard coded */ xdata->sec_per_block = 1; /* hard coded */
U32_TO_BE32(fsp.fsu_blocks, xdata->total_blocks); U32_TO_32(fsp.fsu_blocks, xdata->total_blocks);
U32_TO_BE32(fsp.fsu_bavail, xdata->avail_blocks); U32_TO_32(fsp.fsu_bavail, xdata->avail_blocks);
U32_TO_BE32(fsp.fsu_files, xdata->total_dirs); U32_TO_32(fsp.fsu_files, xdata->total_dirs);
U32_TO_BE32(fsp.fsu_ffree, xdata->avail_dirs); U32_TO_32(fsp.fsu_ffree, xdata->avail_dirs);
} }
xdata->namlen = strlen(name); xdata->namlen = strlen(name);
strmaxcpy(xdata->name, name, xdata->namlen); strmaxcpy(xdata->name, name, xdata->namlen);
@ -602,11 +605,11 @@ static void handle_ncp_serv()
struct fs_usage fsp; struct fs_usage fsp;
memset(xdata, 0, sizeof(struct XDATA)); memset(xdata, 0, sizeof(struct XDATA));
if (!nw_get_fs_usage(name, &fsp)) { if (!nw_get_fs_usage(name, &fsp)) {
xdata->sec_per_block = 38; /* hard coded */ xdata->sec_per_block = 1; /* hard coded */
U32_TO_BE32(fsp.fsu_blocks, xdata->total_blocks); U32_TO_32(fsp.fsu_blocks, xdata->total_blocks);
U32_TO_BE32(fsp.fsu_bavail, xdata->avail_blocks); U32_TO_32(fsp.fsu_bavail, xdata->avail_blocks);
U32_TO_BE32(fsp.fsu_files, xdata->total_dirs); U32_TO_32(fsp.fsu_files, xdata->total_dirs);
U32_TO_BE32(fsp.fsu_ffree, xdata->avail_dirs); U32_TO_32(fsp.fsu_ffree, xdata->avail_dirs);
} }
xdata->namlen = strlen(name); xdata->namlen = strlen(name);
strmaxcpy(xdata->name, name, xdata->namlen); strmaxcpy(xdata->name, name, xdata->namlen);

68
nwdbm.c
View File

@ -1,4 +1,4 @@
/* nwdbm.c 08-Jan-96 data base for mars_nwe */ /* nwdbm.c 13-Jan-96 data base for mars_nwe */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany /* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -951,39 +951,46 @@ int nw_test_passwd(uint32 obj_id, uint8 *vgl_key, uint8 *akt_key)
int nw_set_enpasswd(uint32 obj_id, uint8 *passwd) int nw_set_enpasswd(uint32 obj_id, uint8 *passwd)
{ {
nw_new_create_prop(obj_id, NULL, 0, 0, 0, uint8 *prop_name="PASSWORD";
"PASSWORD", P_FL_STAT|P_FL_ITEM, 0x44, if (passwd && *passwd) {
passwd, 16); nw_new_create_prop(obj_id, NULL, 0, 0, 0,
prop_name, P_FL_STAT|P_FL_ITEM, 0x44,
passwd, 16);
} else
(void)loc_delete_property(obj_id, prop_name, 0);
return(0); return(0);
} }
int nw_set_passwd(uint32 obj_id, char *password) int nw_set_passwd(uint32 obj_id, char *password)
{ {
uint8 passwd[200]; if (password && *password) {
uint8 s_uid[4]; uint8 passwd[200];
U32_TO_BE32(obj_id, s_uid); uint8 s_uid[4];
shuffle(s_uid, password, strlen(password), passwd); U32_TO_BE32(obj_id, s_uid);
shuffle(s_uid, password, strlen(password), passwd);
#if 0 #if 0
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", 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, password,
(int)passwd[0], (int)passwd[0],
(int)passwd[1], (int)passwd[1],
(int)passwd[2], (int)passwd[2],
(int)passwd[3], (int)passwd[3],
(int)passwd[4], (int)passwd[4],
(int)passwd[5], (int)passwd[5],
(int)passwd[6], (int)passwd[6],
(int)passwd[7], (int)passwd[7],
(int)passwd[8], (int)passwd[8],
(int)passwd[9], (int)passwd[9],
(int)passwd[10], (int)passwd[10],
(int)passwd[11], (int)passwd[11],
(int)passwd[12], (int)passwd[12],
(int)passwd[13], (int)passwd[13],
(int)passwd[14], (int)passwd[14],
(int)passwd[15])); (int)passwd[15]));
#endif #endif
return(nw_set_enpasswd(obj_id, passwd)); return(nw_set_enpasswd(obj_id, passwd));
} else
return(nw_set_enpasswd(obj_id, NULL));
} }
int prop_add_new_member(uint32 obj_id, int prop_id, uint32 member_id) int prop_add_new_member(uint32 obj_id, int prop_id, uint32 member_id)
@ -1085,7 +1092,10 @@ static void add_user(uint32 u_id, uint32 g_id,
"UNIX_USER", P_FL_ITEM, 0x33, "UNIX_USER", P_FL_ITEM, 0x33,
(char*)unname, strlen(unname)); (char*)unname, strlen(unname));
if (password && *password) nw_set_passwd(u_id, password); if (password && *password) {
if (*password == '-') *password='\0';
nw_set_passwd(u_id, password);
}
} }
void nw_fill_standard(char *servername, ipxAddr_t *adr) void nw_fill_standard(char *servername, ipxAddr_t *adr)
@ -1214,7 +1224,7 @@ void nw_init_dbm(char *servername, ipxAddr_t *adr)
} }
} }
dbmclose(); dbmclose();
while (anz--) loc_delete_property(objs[anz], (char*)NULL, props[anz]); /* Nun l”schen */ while (anz--) loc_delete_property(objs[anz], (char*)NULL, props[anz]); /* now delete */
nw_fill_standard(servername, adr); nw_fill_standard(servername, adr);
} }

145
nwroute.c
View File

@ -1,4 +1,4 @@
/* nwroute.c 11-Jan-96 */ /* nwroute.c 14-Jan-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany /* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -32,16 +32,16 @@ static int anz_routes=0;
static NW_ROUTES *nw_routes[MAX_NW_ROUTES]; static NW_ROUTES *nw_routes[MAX_NW_ROUTES];
typedef struct { typedef struct {
uint8 *name; uint8 *name; /* Server Name */
int typ; int typ; /* Server Typ */
ipxAddr_t addr; ipxAddr_t addr; /* Server Addr */
int net; /* routing over NET */ uint32 net; /* routing over NET */
int hops; int hops;
int flags; int flags;
} NW_SERVERS; } NW_SERVERS;
static int anz_servers=0; static int anz_servers=0;
static NW_SERVERS *nw_servers[MAX_NW_ROUTES]; static NW_SERVERS *nw_servers[MAX_NW_SERVERS];
static void insert_delete_net(uint32 destnet, static void insert_delete_net(uint32 destnet,
uint32 rnet, /* routernet */ uint32 rnet, /* routernet */
@ -116,9 +116,35 @@ static void insert_delete_net(uint32 destnet,
} }
} }
void insert_delete_server(uint8 *name,
int styp, NW_NET_DEVICE *find_netdevice(uint32 network)
ipxAddr_t *addr, /* return the device over which the network is routed, I hope */
{
uint32 net=network;
int l=2;
XDPRINTF((3, 0, "find_netdevice of network=%lX", net));
while (l--) {
int k=-1;
while (++k < anz_net_devices) {
NW_NET_DEVICE *nd=net_devices[k];
if (nd->net == net) {
XDPRINTF((3, 0, "found netdevive %s, frame=%d, ticks=%d",
nd->devname, nd->frame, nd->ticks));
return(nd);
}
}
if (!l) return(NULL);
k=-1;
while (++k < anz_routes && nw_routes[k]->net != network);;
if (k < anz_routes) net=nw_routes[k]->rnet;
else return(NULL);
}
return(NULL);
}
void insert_delete_server(uint8 *name, /* Server Name */
int styp, /* Server Typ */
ipxAddr_t *addr, /* Server Addr */
ipxAddr_t *from_addr, ipxAddr_t *from_addr,
int hops, int hops,
int do_delete, /* delete = 1 */ int do_delete, /* delete = 1 */
@ -141,7 +167,7 @@ void insert_delete_server(uint8 *name,
while (++k < anz_servers && (nw_servers[k]->typ != styp || while (++k < anz_servers && (nw_servers[k]->typ != styp ||
!nw_servers[k]->name || strcmp(nw_servers[k]->name, sname)) ) { !nw_servers[k]->name || strcmp(nw_servers[k]->name, sname)) ) {
if (nw_servers[k]->name) { if (nw_servers[k]->name) {
XDPRINTF((3,0, "Server %s = typ=0x%04x", XDPRINTF((10,0, "Server %s = typ=0x%04x",
nw_servers[k]->name, nw_servers[k]->typ)); nw_servers[k]->name, nw_servers[k]->typ));
} }
if (freeslot < 0 && !nw_servers[k]->typ) freeslot=k; if (freeslot < 0 && !nw_servers[k]->typ) freeslot=k;
@ -151,8 +177,8 @@ void insert_delete_server(uint8 *name,
if (do_delete) return; /* nothing to delete */ if (do_delete) return; /* nothing to delete */
if (freeslot < 0) { if (freeslot < 0) {
if (anz_servers == MAX_NW_ROUTES) { if (anz_servers == MAX_NW_SERVERS) {
XDPRINTF((1, 0, "too many servers=%d, increase MAX_NW_ROUTES in config.h", anz_servers)); XDPRINTF((1, 0, "too many servers=%d, increase MAX_NW_SERVERS in config.h", anz_servers));
return; return;
} }
nw_servers[k] = (NW_SERVERS*)xcmalloc(sizeof(NW_SERVERS)); nw_servers[k] = (NW_SERVERS*)xcmalloc(sizeof(NW_SERVERS));
@ -164,9 +190,12 @@ void insert_delete_server(uint8 *name,
nr->hops = 0xffff; nr->hops = 0xffff;
} else if (do_delete) { } else if (do_delete) {
nr=nw_servers[k]; nr=nw_servers[k];
if (nr->typ == 4) ins_del_bind_net_addr(nr->name, NULL); if (!IPXCMPNODE(nr->addr.node, my_server_adr.node) ||
xfree(nr->name); !IPXCMPNET (nr->addr.net, my_server_adr.net) ) {
memset(nr, 0, sizeof(NW_SERVERS)); if (nr->typ == 4) ins_del_bind_net_addr(nr->name, NULL);
xfree(nr->name);
memset(nr, 0, sizeof(NW_SERVERS));
}
return; return;
} else nr=nw_servers[k]; } else nr=nw_servers[k];
/* here now i perhaps must change the entry */ /* here now i perhaps must change the entry */
@ -284,7 +313,7 @@ static void send_rip_buff(ipxAddr_t *from_addr)
} }
} }
void send_rip_broadcast(int mode) static void send_rip_broadcast(int mode)
/* mode=0, standard broadcast */ /* mode=0, standard broadcast */
/* mode=1, first trie */ /* mode=1, first trie */
/* mode=2, shutdown */ /* mode=2, shutdown */
@ -355,7 +384,7 @@ void handle_rip(int fd, int ipx_pack_typ,
} }
/* <========================= SAP ============================> */ /* <========================= SAP ============================> */
void send_sap_broadcast(int mode) static void send_sap_broadcast(int mode)
/* mode=0, standard broadcast */ /* mode=0, standard broadcast */
/* mode=1, first trie */ /* mode=1, first trie */
/* mode=2, shutdown */ /* mode=2, shutdown */
@ -363,7 +392,8 @@ void send_sap_broadcast(int mode)
int k=-1; int k=-1;
while (++k < anz_net_devices) { while (++k < anz_net_devices) {
NW_NET_DEVICE *nd=net_devices[k]; NW_NET_DEVICE *nd=net_devices[k];
if (nd->ticks < 7 || mode) { /* isdn devices should not get SAP broadcasts everytime */ if (nd->ticks < 7 || mode) {
/* isdn devices should not get SAP broadcasts everytime */
IPX_DATA ipx_data; IPX_DATA ipx_data;
ipxAddr_t wild; ipxAddr_t wild;
int j=-1; int j=-1;
@ -373,7 +403,8 @@ void send_sap_broadcast(int mode)
U16_TO_BE16(SOCK_SAP, wild.sock); U16_TO_BE16(SOCK_SAP, wild.sock);
while (++j < anz_servers) { while (++j < anz_servers) {
NW_SERVERS *nw=nw_servers[j]; NW_SERVERS *nw=nw_servers[j];
if (!nw->typ || (nw->net == nd->net && nw->hops)) continue; /* no SAP to this NET */ if (!nw->typ || (nw->net == nd->net && nw->hops)
|| (mode == 2 && nw->hops) ) continue; /* no SAP to this NET */
memset(&ipx_data, 0, sizeof(ipx_data.sip)); memset(&ipx_data, 0, sizeof(ipx_data.sip));
strcpy(ipx_data.sip.server_name, nw->name); strcpy(ipx_data.sip.server_name, nw->name);
memcpy(&ipx_data.sip.server_adr, &(nw->addr), sizeof(ipxAddr_t)); memcpy(&ipx_data.sip.server_adr, &(nw->addr), sizeof(ipxAddr_t));
@ -383,12 +414,12 @@ void send_sap_broadcast(int mode)
U16_TO_BE16(16, ipx_data.sip.intermediate_networks); U16_TO_BE16(16, ipx_data.sip.intermediate_networks);
} else { } else {
U16_TO_BE16(nw->hops+1, ipx_data.sip.intermediate_networks); U16_TO_BE16(nw->hops+1, ipx_data.sip.intermediate_networks);
/* I hope hops are ok here */
XDPRINTF((3, 0, "SEND SIP %s,0x%04x, hops=%d", XDPRINTF((3, 0, "SEND SIP %s,0x%04x, hops=%d",
nw->name, nw->typ, nw->hops+1)); nw->name, nw->typ, nw->hops+1));
/* I hope 1 is ok here */
} }
send_ipx_data(sockfd[SAP_SLOT], send_ipx_data(sockfd[SAP_SLOT],
0, 4, /* this is the official packet typ for SAP's */
sizeof(ipx_data.sip), sizeof(ipx_data.sip),
(char *)&(ipx_data.sip), (char *)&(ipx_data.sip),
&wild, "SIP Broadcast"); &wild, "SIP Broadcast");
@ -397,6 +428,60 @@ void send_sap_broadcast(int mode)
} }
} }
static FILE *open_route_info_fn(void)
{
static int tacs=0;
FILE *f=NULL;
if (print_route_tac > 0) {
if (!tacs) {
if (NULL != (f=fopen(pr_route_info_fn,
(print_route_mode) ? "w" : "a"))) {
tacs = print_route_tac-1;
} else print_route_tac=0;
} else tacs--;
}
return(f);
}
void send_sap_rip_broadcast(int mode)
/* mode=0, standard broadcast */
/* mode=1, first trie */
/* mode=2, shutdown */
{
send_sap_broadcast(mode);
send_rip_broadcast(mode);
if (!mode) {
FILE *f= open_route_info_fn();
if (f) {
int k=-1;
fprintf(f, "<--------- Routing Table ---------->\n");
fprintf(f, "%8s Hops Tics %9s Router Node\n", "Network", "RouterNet");
while (++k < anz_routes) {
NW_ROUTES *nr = nw_routes[k];
if (nr->net) {
fprintf(f, "%08lX %4d %4d %08lX %02x:%02x:%02x:%02x:%02x:%02x\n",
nr->net, nr->hops, nr->ticks, nr->rnet,
(int)nr->rnode[0], (int)nr->rnode[1], (int)nr->rnode[2],
(int)nr->rnode[3], (int)nr->rnode[4], (int)nr->rnode[5]);
}
}
k=-1;
fprintf(f, "<--------- Server Table ---------->\n");
fprintf(f, "%-20s %4s %9s Hops Server-Address\n","Name", "Typ", "RouterNet");
while (++k < anz_servers) {
NW_SERVERS *ns = nw_servers[k];
if (ns->typ) {
char sname[50];
strmaxcpy(sname, ns->name, 20);
fprintf(f, "%-20s %4d %08lX %4d %s\n", sname, ns->typ,
ns->net, ns->hops, xvisable_ipx_adr(&(ns->addr), 1));
}
} /* while */
fclose(f);
}
}
}
static void query_sap_on_net(uint32 net) static void query_sap_on_net(uint32 net)
/* searches for the next server on this network */ /* searches for the next server on this network */
{ {
@ -409,7 +494,7 @@ static void query_sap_on_net(uint32 net)
U16_TO_BE16(3, sqp.query_type); U16_TO_BE16(3, sqp.query_type);
U16_TO_BE16(4, sqp.server_type); U16_TO_BE16(4, sqp.server_type);
send_ipx_data(sockfd[SAP_SLOT], 17, sizeof(SQP), send_ipx_data(sockfd[SAP_SLOT], 17, sizeof(SQP),
(char*)&sqp, &wild, "SERVER Query"); (char*)&sqp, &wild, "SERVER Query");
} }
void get_servers(void) void get_servers(void)
@ -417,10 +502,20 @@ void get_servers(void)
int k=-1; int k=-1;
while (++k < anz_net_devices) { while (++k < anz_net_devices) {
NW_NET_DEVICE *nd=net_devices[k]; NW_NET_DEVICE *nd=net_devices[k];
if (nd->ticks < 7) query_sap_on_net(nd->net); /* only fast routes */ if (nd->ticks < 7) query_sap_on_net(nd->net); /* only fast routes */
} }
if (!anz_net_devices) if (!anz_net_devices) query_sap_on_net(internal_net);
query_sap_on_net(internal_net);
} }
int dont_send_wdog(ipxAddr_t *addr)
/* returns != 0 if tics are to high for wdogs */
{
NW_NET_DEVICE *nd;
if (!wdogs_till_tics) return(0); /* ever send wdogs */
else if (wdogs_till_tics < 0) return(1); /* never send wdogs */
if (NULL != (nd=find_netdevice(GET_BE32(addr->net))))
return((nd->ticks < wdogs_till_tics) ? 0 : 1);
return(0);
}

215
nwserv.c
View File

@ -1,4 +1,4 @@
/* nwserv.c 09-Jan-96 */ /* nwserv.c 14-Jan-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany /* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -19,29 +19,32 @@
#include "net.h" #include "net.h"
#include "nwserv.h" #include "nwserv.h"
uint32 internal_net = 0x0L; /* NETWORKNUMMER INTERN (SERVER) */ uint32 internal_net = 0x0L; /* NETWORKNUMMER INTERN (SERVER) */
ipxAddr_t my_server_adr; /* Address of this server */ ipxAddr_t my_server_adr; /* Address of this server */
char my_nwname[50]; /* Name of this server */ char my_nwname[50]; /* Name of this server */
int print_route_tac = 0; /* every x broadcasts print it */
int print_route_mode = 0; /* append */
char *pr_route_info_fn = NULL; /* filename */
int wdogs_till_tics = 0; /* send wdogs to all */
/* <========== DEVICES ==========> */ /* <========== DEVICES ==========> */
int anz_net_devices=0; int anz_net_devices=0;
NW_NET_DEVICE *net_devices[MAX_NET_DEVICES]; NW_NET_DEVICE *net_devices[MAX_NET_DEVICES];
uint16 ipx_sock_nummern[]={ uint16 ipx_sock_nummern[]={
#ifdef WDOG_SLOT #ifdef WDOG_SLOT
0, /* auto sock */ 0, /* auto sock */
#endif #endif
SOCK_SAP, SOCK_SAP,
SOCK_RIP, SOCK_RIP,
SOCK_ROUTE, SOCK_ROUTE,
SOCK_DIAGNOSE SOCK_DIAGNOSE
#ifdef ECHO_SLOT #ifdef ECHO_SLOT
, SOCK_ECHO , SOCK_ECHO
#endif #endif
#ifdef ERROR_SLOT #ifdef ERROR_SLOT
, SOCK_ERROR , SOCK_ERROR
#endif #endif
}; };
#define NEEDED_SOCKETS (sizeof(ipx_sock_nummern) / sizeof(uint16)) #define NEEDED_SOCKETS (sizeof(ipx_sock_nummern) / sizeof(uint16))
#define NEEDED_POLLS (NEEDED_SOCKETS+1) #define NEEDED_POLLS (NEEDED_SOCKETS+1)
@ -55,16 +58,16 @@ static uint16 spx_diag_socket; /* SPX DIAGNOSE SOCKET */
static ipxAddr_t nw386_adr; /* Address of NW-TEST Server */ static ipxAddr_t nw386_adr; /* Address of NW-TEST Server */
static int nw386_found = 0; static int nw386_found = 0;
static int client_mode = 0; static int client_mode = 0;
static int ipxdebug = 0; static int ipxdebug = 0;
static int pid_ncpserv = -1; static int pid_ncpserv = -1;
static int fd_ncpserv_out = -1; /* ctrl-pipe out to ncpserv */ static int fd_ncpserv_out = -1; /* ctrl-pipe out to ncpserv */
static int fd_ncpserv_in = -1; /* ctrl-pipe in from ncpserv */ static int fd_ncpserv_in = -1; /* ctrl-pipe in from ncpserv */
static time_t akttime_stamp = 0; static time_t akttime_stamp = 0;
static int broadsecs = 2048; static int broadsecs = 2048;
static time_t server_down_stamp = 0; static time_t server_down_stamp = 0;
static int server_goes_down_secs = 10; static int server_goes_down_secs = 10;
static int save_ipx_routes = 0; static int save_ipx_routes = 0;
static void write_to_ncpserv(int what, int connection, static void write_to_ncpserv(int what, int connection,
@ -159,30 +162,30 @@ static int start_ncpserv(char *nwname, ipxAddr_t *addr)
switch (pid=fork()) { switch (pid=fork()) {
case 0 : { /* new Process */ case 0 : { /* new Process */
char *progname="ncpserv"; char *progname="ncpserv";
char addrstr[100]; char addrstr[100];
char pathname[300]; char pathname[300];
int j = FD_NWSERV; int j = FD_NWSERV;
close(fds_out[1]); /* no need to write */ close(fds_out[1]); /* no need to write */
dup2(fds_out[0], 0); /* becommes stdin */ dup2(fds_out[0], 0); /* becommes stdin */
close(fds_out[0]); /* no longer needed */ close(fds_out[0]); /* no longer needed */
close(fds_in[0]); /* no need to read */ close(fds_in[0]); /* no need to read */
dup2(fds_in[1], FD_NWSERV); /* becommes fd FD_NWSERV */ dup2(fds_in[1], FD_NWSERV); /* becommes fd FD_NWSERV */
close(fds_in[1]); /* no longer needed */ close(fds_in[1]); /* no longer needed */
while (j++ < 100) close(j); /* close all > 4 */ while (j++ < 100) close(j); /* close all > 4 */
ipx_addr_to_adr(addrstr, addr); ipx_addr_to_adr(addrstr, addr);
execl(get_exec_path(pathname, progname), progname, execl(get_exec_path(pathname, progname), progname,
nwname, addrstr, NULL); nwname, addrstr, NULL);
exit(1); exit(1);
} }
break; break;
case -1: close(fds_out[0]); case -1: close(fds_out[0]);
close(fds_out[1]); close(fds_out[1]);
close(fds_in[0]); close(fds_in[0]);
close(fds_in[1]); close(fds_in[1]);
return(-1); /* error */ return(-1); /* error */
} }
fds_out[0] = -1; fds_out[0] = -1;
fd_ncpserv_out = fds_out[1]; fd_ncpserv_out = fds_out[1];
@ -196,16 +199,16 @@ static int start_nwclient(void)
{ {
switch (fork()){ switch (fork()){
case 0 : { /* new Process */ case 0 : { /* new Process */
char *progname="nwclient"; char *progname="nwclient";
char pathname[300]; char pathname[300];
char my_addrstr[100]; char my_addrstr[100];
char serv_addrstr[100]; char serv_addrstr[100];
ipx_addr_to_adr(my_addrstr, &my_server_adr); ipx_addr_to_adr(my_addrstr, &my_server_adr);
ipx_addr_to_adr(serv_addrstr, &nw386_adr); ipx_addr_to_adr(serv_addrstr, &nw386_adr);
execl(get_exec_path(pathname, progname), progname, execl(get_exec_path(pathname, progname), progname,
my_addrstr, serv_addrstr, NULL); my_addrstr, serv_addrstr, NULL);
} }
exit(1); exit(1);
case -1: return(-1); /* error */ case -1: return(-1); /* error */
} }
@ -223,13 +226,18 @@ static int start_nwclient(void)
# define MAX_WDOG_TRIES 11 /* Standardtries */ # define MAX_WDOG_TRIES 11 /* Standardtries */
#endif #endif
static void modify_wdog_conn(int conn, int mode);
static void send_wdog_packet(ipxAddr_t *addr, int conn, int what) static void send_wdog_packet(ipxAddr_t *addr, int conn, int what)
{ {
uint8 data[2]; uint8 data[2];
data[0] = (uint8) conn; data[0] = (uint8) conn;
data[1] = (uint8) what; data[1] = (uint8) what;
send_ipx_data(sockfd[WDOG_SLOT], 17, 2, data, addr, "WDOG"); if (what == '?' && dont_send_wdog(addr)) {
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");
} }
static void send_bcast_packet(ipxAddr_t *addr, int conn, int signature) static void send_bcast_packet(ipxAddr_t *addr, int conn, int signature)
@ -288,7 +296,7 @@ static void modify_wdog_conn(int conn, int mode)
break; break;
default : c->counter = 0; /* reset */ default : c->counter = 0; /* reset */
break; break;
} /* switch */ } /* switch */
} else if (mode == 99) { /* remove */ } else if (mode == 99) { /* remove */
memset(c, 0, sizeof(CONN)); memset(c, 0, sizeof(CONN));
@ -341,8 +349,8 @@ static void send_bcasts(int conn)
static void send_server_respons(int fd, uint8 ipx_pack_typ, static void send_server_respons(int fd, uint8 ipx_pack_typ,
int respond_typ, int server_typ, int respond_typ, int server_typ,
ipxAddr_t *to_addr) ipxAddr_t *to_addr)
{ {
IPX_DATA ipx_data; IPX_DATA ipx_data;
memset(&ipx_data, 0, sizeof(ipx_data.sip)); memset(&ipx_data, 0, sizeof(ipx_data.sip));
@ -356,9 +364,9 @@ static void send_server_respons(int fd, uint8 ipx_pack_typ,
U16_TO_BE16(server_typ, ipx_data.sip.server_type); U16_TO_BE16(server_typ, ipx_data.sip.server_type);
U16_TO_BE16(0, ipx_data.sip.intermediate_networks); U16_TO_BE16(0, ipx_data.sip.intermediate_networks);
send_ipx_data(fd, ipx_pack_typ, send_ipx_data(fd, ipx_pack_typ,
sizeof(ipx_data.sip), sizeof(ipx_data.sip),
(char *)&(ipx_data.sip), (char *)&(ipx_data.sip),
to_addr, "Server Response"); to_addr, "Server Response");
} }
void get_server_data(char *name, void get_server_data(char *name,
@ -377,10 +385,10 @@ void get_server_data(char *name,
} }
static void handle_sap(int fd, static void handle_sap(int fd,
int ipx_pack_typ, int ipx_pack_typ,
int data_len, int data_len,
IPX_DATA *ipxdata, IPX_DATA *ipxdata,
ipxAddr_t *from_addr) ipxAddr_t *from_addr)
{ {
int query_type = GET_BE16(ipxdata->sqp.query_type); int query_type = GET_BE16(ipxdata->sqp.query_type);
int server_type = GET_BE16(ipxdata->sqp.server_type); int server_type = GET_BE16(ipxdata->sqp.server_type);
@ -463,7 +471,7 @@ static void handle_sap(int fd,
static void response_ipx_diag(int fd, int ipx_pack_typ, static void response_ipx_diag(int fd, int ipx_pack_typ,
ipxAddr_t *to_addr) ipxAddr_t *to_addr)
{ {
IPX_DATA ipxdata; IPX_DATA ipxdata;
DIAGRESP *dia = &ipxdata.diaresp; DIAGRESP *dia = &ipxdata.diaresp;
@ -490,14 +498,14 @@ static void response_ipx_diag(int fd, int ipx_pack_typ,
memcpy(p, my_server_adr.node, IPX_NODE_SIZE); memcpy(p, my_server_adr.node, IPX_NODE_SIZE);
datalen += IPX_NODE_SIZE; datalen += IPX_NODE_SIZE;
send_ipx_data(fd, ipx_pack_typ, send_ipx_data(fd, ipx_pack_typ,
datalen, datalen,
(char*)&ipxdata, (char*)&ipxdata,
to_addr, "DIAG Response"); to_addr, "DIAG Response");
} }
static void handle_diag(int fd, int ipx_pack_typ, static void handle_diag(int fd, int ipx_pack_typ,
int data_len, IPX_DATA *ipxdata, int data_len, IPX_DATA *ipxdata,
ipxAddr_t *from_addr) ipxAddr_t *from_addr)
/* should handle CONFIGURATION REQUESTS one time */ /* should handle CONFIGURATION REQUESTS one time */
{ {
CONFREQ *conf = &(ipxdata->confreq); CONFREQ *conf = &(ipxdata->confreq);
@ -512,7 +520,7 @@ static void handle_diag(int fd, int ipx_pack_typ,
exnodes += IPX_NODE_SIZE; exnodes += IPX_NODE_SIZE;
} }
XDPRINTF((2,0,"DIAG Request, ipx_pack_typ %d, data_len %d, count %d", XDPRINTF((2,0,"DIAG Request, ipx_pack_typ %d, data_len %d, count %d",
(int)ipx_pack_typ, data_len, count)); (int)ipx_pack_typ, data_len, count));
response_ipx_diag(fd, ipx_pack_typ, from_addr); response_ipx_diag(fd, ipx_pack_typ, from_addr);
} }
@ -597,8 +605,8 @@ static void handle_event(int fd, uint16 socknr, int slot)
/* /*
print_ud_data(&ud); print_ud_data(&ud);
*/ */
} }
break; break;
} }
} }
@ -676,7 +684,7 @@ static void get_ini(int full)
break; break;
#ifdef LINUX #ifdef LINUX
case 5 : save_ipx_routes=atoi(inhalt); case 5 : save_ipx_routes=atoi(inhalt);
break; break;
#endif #endif
case 104 : /* nwclient */ case 104 : /* nwclient */
if (client_mode && atoi(inhalt)) if (client_mode && atoi(inhalt))
@ -689,6 +697,18 @@ static void get_ini(int full)
server_goes_down_secs = 10; server_goes_down_secs = 10;
break; break;
case 300 : print_route_tac=atoi(inhalt);
break;
case 301 : new_str(pr_route_info_fn, inhalt);
break;
case 302 : print_route_mode=atoi(inhalt);
break;
case 310 : wdogs_till_tics=atoi(inhalt);
break;
default : break; default : break;
} /* switch */ } /* switch */
} /* if */ } /* if */
@ -696,6 +716,9 @@ static void get_ini(int full)
fclose(f); fclose(f);
} }
if (client_mode < 2) client_mode=0; if (client_mode < 2) client_mode=0;
if (print_route_tac && !pr_route_info_fn && !*pr_route_info_fn)
print_route_tac = 0;
if (!print_route_tac) xfree(pr_route_info_fn);
if (full) { if (full) {
#ifdef LINUX #ifdef LINUX
init_ipx(internal_net, node, ipxdebug); init_ipx(internal_net, node, ipxdebug);
@ -730,8 +753,7 @@ static void get_ini(int full)
static void send_down_broadcast(void) static void send_down_broadcast(void)
{ {
send_sap_broadcast(2); send_sap_rip_broadcast(2);
send_rip_broadcast(2); /* shutdown rip */
} }
static void close_all(void) static void close_all(void)
@ -840,8 +862,8 @@ int main(int argc, char **argv)
int fd = open_ipx_socket(ipx_sock_nummern[j], j, O_RDWR); int fd = open_ipx_socket(ipx_sock_nummern[j], j, O_RDWR);
if (fd < 0) { if (fd < 0) {
while (j--) { while (j--) {
t_unbind(sockfd[j]); t_unbind(sockfd[j]);
t_close(sockfd[j]); t_close(sockfd[j]);
} }
return(1); return(1);
} else { } else {
@ -855,11 +877,15 @@ int main(int argc, char **argv)
U16_TO_BE16(SOCK_NCP, my_server_adr.sock); U16_TO_BE16(SOCK_NCP, my_server_adr.sock);
if (!start_ncpserv(my_nwname, &my_server_adr)) { if (!start_ncpserv(my_nwname, &my_server_adr)) {
/* Jetzt POLLEN */ ipxAddr_t server_adr_sap;
/* now do polling */
time_t broadtime; time_t broadtime;
time(&broadtime); time(&broadtime);
set_sigs(); set_sigs();
polls[NEEDED_SOCKETS].fd = fd_ncpserv_in; 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);
while (1) { while (1) {
int anz_poll = poll(polls, NEEDED_POLLS, broadsecs); int anz_poll = poll(polls, NEEDED_POLLS, broadsecs);
time(&akttime_stamp); time(&akttime_stamp);
@ -868,19 +894,19 @@ int main(int argc, char **argv)
else if (fl_get_int == 2) down_server(); else if (fl_get_int == 2) down_server();
} }
if (anz_poll > 0) { /* i have to work */ if (anz_poll > 0) { /* i have to work */
struct pollfd *p = &polls[0]; struct pollfd *p = &polls[0];
j = -1; j = -1;
while (++j < NEEDED_POLLS) { while (++j < NEEDED_POLLS) {
if (p->revents){ if (p->revents){
if (j < NEEDED_SOCKETS) { /* socket */ if (j < NEEDED_SOCKETS) { /* socket */
XDPRINTF((99, 0,"POLL %d, SOCKET %x", p->revents, sock_nummern[j])); XDPRINTF((99, 0,"POLL %d, SOCKET %x", p->revents, sock_nummern[j]));
if (p->revents & ~POLLIN) if (p->revents & ~POLLIN)
errorp(0, "STREAM error", "revents=0x%x", p->revents ); errorp(0, "STREAM error", "revents=0x%x", p->revents );
else handle_event(p->fd, sock_nummern[j], j); else handle_event(p->fd, sock_nummern[j], j);
} else { /* fd_ncpserv_in */ } else { /* fd_ncpserv_in */
XDPRINTF((2, 0, "POLL %d, fh=%d", p->revents, p->fd)); XDPRINTF((2, 0, "POLL %d, fh=%d", p->revents, p->fd));
if (p->revents & ~POLLIN) if (p->revents & ~POLLIN)
errorp(0, "STREAM error", "revents=0x%x", p->revents ); errorp(0, "STREAM error", "revents=0x%x", p->revents );
else { else {
if (p->fd == fd_ncpserv_in) { if (p->fd == fd_ncpserv_in) {
int what; int what;
@ -889,7 +915,7 @@ int main(int argc, char **argv)
ipxAddr_t adr; ipxAddr_t adr;
if (sizeof(int) == read(fd_ncpserv_in, if (sizeof(int) == read(fd_ncpserv_in,
(char*)&what, sizeof(int))) { (char*)&what, sizeof(int))) {
XDPRINTF((2, 0, "GOT ncpserv_in what=0x%x", what)); XDPRINTF((2, 0, "GOT ncpserv_in what=0x%x", what));
switch (what) { switch (what) {
case 0x2222 : /* insert wdog connection */ case 0x2222 : /* insert wdog connection */
if (sizeof(int) == read(fd_ncpserv_in, if (sizeof(int) == read(fd_ncpserv_in,
@ -904,7 +930,7 @@ int main(int argc, char **argv)
case 0x4444 : /* reset wdog connection = 0 */ case 0x4444 : /* reset wdog connection = 0 */
/* force test wdog conn 1 = 1 */ /* force test wdog conn 1 = 1 */
/* force test wdog conn 2 = 2 */ /* force test wdog conn 2 = 2 */
/* remove wdog = 99 */ /* remove wdog = 99 */
if (sizeof(int) == read(fd_ncpserv_in, if (sizeof(int) == read(fd_ncpserv_in,
(char*)&conn, sizeof(int)) (char*)&conn, sizeof(int))
&& sizeof(int) == read(fd_ncpserv_in, && sizeof(int) == read(fd_ncpserv_in,
@ -932,10 +958,10 @@ int main(int argc, char **argv)
} }
} }
} }
if (! --anz_poll) break; if (! --anz_poll) break;
} /* if */ } /* if */
p++; p++;
} /* while */ } /* while */
} else { } else {
XDPRINTF((99,0,"POLLING ...")); XDPRINTF((99,0,"POLLING ..."));
} }
@ -943,8 +969,7 @@ int main(int argc, char **argv)
if (akttime_stamp - server_down_stamp > server_goes_down_secs) break; if (akttime_stamp - server_down_stamp > server_goes_down_secs) break;
} else { } else {
if (akttime_stamp - broadtime > (broadsecs / 1000)) { /* ca. 60 seconds */ if (akttime_stamp - broadtime > (broadsecs / 1000)) { /* ca. 60 seconds */
send_sap_broadcast(broadsecs<3000); /* firsttime broadcast */ send_sap_rip_broadcast((broadsecs<3000) ? 1 :0); /* firsttime broadcast */
send_rip_broadcast(broadsecs<3000); /* firsttime broadcast */
if (broadsecs < 32000) { if (broadsecs < 32000) {
rip_for_net(MAX_U32); rip_for_net(MAX_U32);
get_servers(); get_servers();

View File

@ -1,4 +1,4 @@
/* nwserv.h 11-Jan-96 */ /* nwserv.h 14-Jan-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany /* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -16,10 +16,13 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
extern uint32 internal_net; /* NETWORKNUMMER INTERN (SERVER) */ extern uint32 internal_net; /* NETWORKNUMMER INTERN (SERVER) */
extern ipxAddr_t my_server_adr; /* Address of this server */ extern ipxAddr_t my_server_adr; /* Address of this server */
extern char my_nwname[50]; /* Name of this server */ extern char my_nwname[50]; /* Name of this server */
extern int print_route_tac; /* every x broadcasts print it */
extern int print_route_mode; /* append */
extern char *pr_route_info_fn; /* filename */
extern int wdogs_till_tics;
typedef struct { typedef struct {
char *devname; /* "eth0" or "isdnX" */ char *devname; /* "eth0" or "isdnX" */
@ -46,8 +49,7 @@ extern NW_NET_DEVICE *net_devices[];
extern int sockfd[]; extern int sockfd[];
extern void ins_del_bind_net_addr(char *name, ipxAddr_t *adr); extern void ins_del_bind_net_addr(char *name, ipxAddr_t *adr);
extern void send_rip_broadcast(int mode); extern void send_sap_rip_broadcast(int mode);
extern void send_sap_broadcast(int mode);
extern void rip_for_net(uint32 net); extern void rip_for_net(uint32 net);
extern void get_servers(void); extern void get_servers(void);
@ -64,4 +66,5 @@ extern void insert_delete_server(uint8 *name,
int do_delete, /* delete = 1 */ int do_delete, /* delete = 1 */
int flags); int flags);
extern int dont_send_wdog(ipxAddr_t *addr);