home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1999 March B
/
SCO_CASTOR4RRT.iso
/
nwnet
/
root
/
usr
/
lib
/
netcfg
/
bin
/
ipxBE
/
ipxBE~
Wrap
Text File
|
1998-08-19
|
16KB
|
617 lines
#!/bin/tcl
#
# Copyright (C) 1997, The Santa Cruz Operation, Inc.
# All Rights Reserved.
#
# The information in this file is provided for the exclusive use of
# the licensees of The Santa Cruz Operation, Inc. Such users have the
# right to use, modify, and incorporate this code into other products
# for purposes authorized by the license agreement provided they include
# this notice and the associated copyright notice with any such product.
# The information in this file is provided "AS IS" without warranty.
#
#ident "@(#)ipxBE 1.6"
#
# This is the netconfig prompter "back-end" for SCO IPX/SPX.
#
#cmdtrace on [ open /tmp/ipxBE.log a+ ]
set NCFG_DIR /usr/lib/netcfg
set IPX_TMPDIR /usr/lib/ipxrt/tmp
set IPX_NEWCFG $IPX_TMPDIR/config
set NWIP off
set AUTO_DISCO_OK 0
set TCP tcp
source $NCFG_DIR/bin/ipx.fn
loadlibindex /usr/lib/sysadm.tlib
# main MAIN Main
#
# NOTE: arguments are:
# <script name> <netconfig state> <adapter> <framing type list> <interface>
global ncfgState NETWORK_MEDIA configList adapter interfaceType \
dbgInit dbgParse dbgFile
set configList {}
set dbgInit 1
set dbgParse 0
set dbgFile "/tmp/ipxBE.dbg"
# Set up the debugging output (if required).
#
if {$dbgInit || $dbgParse} then {
if {[set dbgfd [open $dbgFile w]] == -1} then {
# Open failed, turn off debugging.
#
set dbgInit 0
set dbgParse 0
}
}
# Determine and record the "netconfig state", as indicated by the invoking
# netconfig script.
#
set ncfgState [lindex $argv 0]
# Record the adapter being configured over.
#
set adapter [lindex $argv 1]
if [ cequal $adapter "/dev/${TCP}" ] {
set adapter /dev/nwip
}
# Set the framing type variable. This is expected to be a
# list of valid framing types or UNKNOWN.
#
set NETWORK_MEDIA [lindex $argv 2]
# Set the interface type variable. This is expected to be one of: LLI, DLPI,
# or UNKNOWN.
#
set interfaceType [lindex $argv 3]
fcntl $dbgfd NOBUF 1
if {$dbgInit} {
puts $dbgfd "netconfig state: '$ncfgState', Media type: '$NETWORK_MEDIA', adapter: '$adapter', interface: '$interfaceType'"
}
# Ensure all replies to the prompter are flushed immediately.
#
fcntl stdout NOBUF 1
switch $ncfgState {
INITIAL_INIT -
INIT {
set lanNumber [ GetFreeLanNumber ]
}
LIST -
RECONF {
#
# if more than one lan is configured over a
# NIC this will select the one with the lowest
# lanNumber
#
set lanNumber [ FindIpxLanNumber adapter $adapter ]
if { $lanNumber == 0 } {
# echo \
# "ipxBE: Attempting to access ipx configuration over adapter $adapter. This is not configured " >&3
exit 3
}
}
}
set LAN_NETWORK [GetNwcmParam lan_${lanNumber}_network]
set RIP_AGE_INT [GetNwcmParam lan_${lanNumber}_rip_ageout_intervals]
set FRAME_TYPE [GetNwcmParam lan_${lanNumber}_frame_type]
set SERVER_NAME [GetNwcmParam server_name]
set AUTO_DISCOVERY [GetNwcmParam ipx_auto_discovery]
set INTERNAL_NN [GetNwcmParam ipx_internal_network]
set ROUTER_TYPE [GetNwcmParam router_type]
set MAX_SPX_CON [GetNwcmParam spx_max_connections]
set MAX_SPX_SOC [GetNwcmParam spx_max_sockets]
set IPX_START [GetNwcmParam ipx_start_at_boot]
set SPX_START [GetNwcmParam spx]
if [ cequal $adapter /dev/nwip ] {
set NWIP on
set NWIP_DOMAIN [GetNwcmParam nwip_domain]
set NWIP_SYNC [GetNwcmParam nwip_db_sync_interval]
set NWIP_PORT [GetNwcmParam nwip_port]
set NSQ_BC [GetNwcmParam nwip_nsq_broadcast]
set NWIP_DSS [GetNwcmParam nwip_preferred_dss]
set NWIP_SVR [GetNwcmParam nwip_nearest_server]
}
#
# Depending upon state, set parameters to sensible values
#
switch $ncfgState {
INITIAL_INIT -
INIT {
#
# try and ensure a sensible server name gets set
#
if { [ cequal $SERVER_NAME "" ] } {
set SERVER_NAME [exec uname -n ]
}
#
# verify that a suitable packet type has been
# provided - the default provided by nwcm is
# ethernet which is not reasonable for an fddi or
# token-ring card
#
set fr $FRAME_TYPE
set media [ ctoken fr _ ]
switch $NETWORK_MEDIA {
ETHER {
if { ! [ cequal $media "ETHERNET" ] } {
set FRAME_TYPE ETHERNET_802.2
}
}
TOKEN {
if { ! [ cequal $media "TOKEN-RING" ] } {
set FRAME_TYPE TOKEN-RING
}
}
FDDI {
if { ! [ cequal $media "FDDI" ] } {
set FRAME_TYPE FDDI
}
}
}
#
# now try and figure out an external number
# and frame type via nwdiscover.
# XXX
# This can only be done if the device node
# has been added and idbuild -M performed on the
# device.
#
AutoDiscover $adapter
}
LIST {
}
RECONF {
#
# if more than one lan is configured over a
# NIC this will select the one with the lowest
# lanNumber
#
# if you're modifying and the network address is still 0
# then run nwdiscover as you could be running over a nic
# which required a reboot before it could be accessed
#
if [ cequal $LAN_NETWORK "0x0" ] {
AutoDiscover $adapter
}
}
}
switch $ncfgState {
INIT {
# set an internal number if
# 1: its not the first ipx lan (its obligatory then)
# 2: its the first lan and the user wants one - you can't
# figure that bit out until you get to the questions
#
if [ cequal $INTERNAL_NN "0x0" ] {
random seed [ getclock ]
set INTERNAL_NN [ format "0x%8.8X" [ random 2147483647 ] ]
}
# Auto discovery with 2 lans is not a good idea.
set AUTO_DISCO_OK 0
set AUTO_DISCOVERY off
}
INITIAL_INIT {
set AUTO_DISCO_OK 1
}
RECONF {
if { [ IpxNumLan ] == 1 } {
set AUTO_DISCO_OK 1
} else {
set AUTO_DISCO_OK 0
set AUTO_DISCOVERY off
}
}
LIST {
set AUTO_DISCO_OK 1
}
}
# Parse the commands from the prompter; perform appropriate actions for each
# command.
#
# Assumptions:
# - all commands are actually upper case
# - all commands follow the established syntax
#
while { [ gets stdin line ] != -1 } {
set REQUEST [ lindex $line 0 ]
set ARG1 [ lindex $line 1 ]
set ARG2 [ lindex $line 2 ]
switch $REQUEST {
LIST {
switch $ARG1 {
BASIC {
if [ cequal $NWIP on ] {
echo "\
{ LAN_NETWORK \"External network number\" LABEL \"Enter the external IPX network number for this network\" } \
{ FRAME_TYPE \"Frame type\" LIST \"Select the frame type for this network\" } \
{ ADVANCED_INTF \"Advanced interface options\" NEWSCREEN \"\" } \
{ GLOBAL_IPX \"Global IPX/SPX options\" NEWSCREEN \"\" } \
{ NWIP \"NetWare/IP options\" NEWSCREEN \"\" } \
"
} else {
echo "\
{ LAN_NETWORK \"External network number\" LABEL \"Enter the external IPX network number for this network\" } \
{ FRAME_TYPE \"Frame type\" LIST \"Select the frame type for this network\" } \
{ ADVANCED_INTF \"Advanced interface options\" NEWSCREEN \"\" } \
{ GLOBAL_IPX \"Global IPX/SPX options\" NEWSCREEN \"\" } \
"
}
}
ADVANCED_INTF {
echo "\
{ RIP_AGE_INT \"rip ageout interval\" LABEL \"Enter the rip ageout interval in seconds\"} \
"
}
GLOBAL_IPX {
echo "\
{ INTERNAL_NN \"Internal network number\" LABEL \"Enter the internal IPX number for this machine\" } \
{ SERVER_NAME \"Server name\" LABEL \"Enter the netware server name\" } \
{ MAX_SPX_CON \"Maximum SPX connections\" LABEL \"Enter the maximum number of SPX connections allowed on this machine\" } \
{ MAX_SPX_SOC \"Maximum SPX sockets\" LABEL \"Enter the maximum number of SPX sockets allowed on this machine\" } \
{ ROUTER_TYPE \"Router type\" RADIO \"Enter the router type for this machine\" } \
{ AUTO_DISCOVERY \"Auto discovery \" RADIO \"IPX automatic network discovery at boot\" } \
{ IPX_START \"IPX start at boot ?\" RADIO \"Do you want IPX to start at boot ?\" } \
{ SPX_START \"SPX start with ipx?\" RADIO \"Do you want SPX to start when ipx starts ?\" } \
"
}
NWIP {
echo "\
{ NWIP_DOMAIN \"NetWare/IP domain\" LABEL \"The NWIP domain which this machine belongs to\" } \
{ NWIP_SYNC \"NWIP database sync interval\" LABEL \"Time in seconds for the synchronisation of the SAP/RIP database with the DSS\" } \
{ NWIP_PORT \"NWIP UDP port\" LABEL \"The UDP port NWIP will use for communicating with the DSS\" } \
{ NSQ_BC \"NWIP broadcasts to find DSS\" RADIO \"If on, the system will broadcast to the local subnet to find the nearest DSS\" } \
{ NWIP_DSS \"NWIP preferred DSS list\" LABEL \"Comma separated list of IP address for preferred DSS servers\" } \
{ NWIP_SVR \"NetWare/IP server list\" LABEL \"Comma separated list of IP addresses of nearest NetWare/IP servers\" } \
"
}
default {
echo "ipxBE: Unknown argument to LIST" >&3
exit 1
}
}
}
CURRENT {
switch $ARG1 {
BASIC {
echo "\
{ LAN_NETWORK 1 \"$LAN_NETWORK\" } \
{ FRAME_TYPE 1 \"$FRAME_TYPE\" } \
"
}
ADVANCED_INTF {
echo " \
{ RIP_AGE_INT 1 \"$RIP_AGE_INT\" } \
"
}
GLOBAL_IPX {
if { $AUTO_DISCO_OK } {
echo " \
{ SERVER_NAME 1 \"$SERVER_NAME\" } \
{ INTERNAL_NN 1 \"$INTERNAL_NN\" } \
{ MAX_SPX_CON 1 \"$MAX_SPX_CON\" } \
{ MAX_SPX_SOC 1 \"$MAX_SPX_SOC\" } \
{ IPX_START 1 \"$IPX_START\" } \
{ SPX_START 1 \"$SPX_START\" } \
{ ROUTER_TYPE 1 \"$ROUTER_TYPE\" } \
{ AUTO_DISCOVERY 1 \"$AUTO_DISCOVERY\" } \
"
} else {
echo " \
{ SERVER_NAME 1 \"$SERVER_NAME\" } \
{ INTERNAL_NN 1 \"$INTERNAL_NN\" } \
{ MAX_SPX_CON 1 \"$MAX_SPX_CON\" } \
{ MAX_SPX_SOC 1 \"$MAX_SPX_SOC\" } \
{ IPX_START 1 \"$IPX_START\" } \
{ SPX_START 1 \"$SPX_START\" } \
{ ROUTER_TYPE 1 \"$ROUTER_TYPE\" } \
{ AUTO_DISCOVERY 0 \"$AUTO_DISCOVERY\" } \
"
}
}
NWIP {
echo " \
{ NWIP_DOMAIN 1 \"$NWIP_DOMAIN\" } \
{ NWIP_SYNC 1 \"$NWIP_SYNC\" } \
{ NWIP_PORT 1 \"$NWIP_PORT\" } \
{ NSQ_BC 1 \"$NSQ_BC\" } \
{ NWIP_DSS 1 \"$NWIP_DSS\" } \
{ NWIP_SVR 1 \"$NWIP_SVR\" } \
"
}
default {
echo "BE: Unknown argument to CURRENT" >&3
exit 1
}
}
}
VALUES {
switch $ARG1 {
IPX_START -
SPX_START -
NSQ_BC -
AUTO_DISCOVERY {
echo "on off"
}
FRAME_TYPE {
switch $NETWORK_MEDIA {
ETHER {
echo "ETHERNET_802.2 \
ETHERNET_II \
ETHERNET_802.3 \
ETHERNET_SNAP"
}
TOKEN {
echo "TOKEN-RING \
TOKEN-RING_SNAP"
}
FDDI {
echo "FDDI \
FDDI_SNAP"
}
default {
echo "ETHERNET_II \
ETHERNET_802.2 \
ETHERNET_802.3 \
ETHERNET_SNAP \
FDDI \
FDDI_SNAP \
TOKEN-RING \
TOKEN-RING_SNAP"
}
}
}
ROUTER_TYPE {
echo "FULL CLIENT"
}
default {
echo "BE: Unknown argument to VALUES" >&3
exit 1
}
}
}
SET {
switch $ARG1 {
LAN_NETWORK {
if [IsValidNwcmParam lan_${lanNumber}_network $ARG2] {
set LAN_NETWORK $ARG2
echo "OK"
} else {
#
# don't try and check for == 0x0
# it may fail if the number is too large
#
if { [ cequal $ARG2 "0x0" ] } {
set LAN_NETWORK $ARG2
echo "OK internal network turned off"
} else {
echo "ERROR invalid external network number"
}
}
}
FRAME_TYPE {
if [IsValidNwcmParam lan_${lanNumber}_frame_type $ARG2 ] {
set FRAME_TYPE $ARG2
echo "OK"
} else {
echo "ERROR invalid frame type"
}
}
SERVER_NAME {
if [IsValidNwcmParam server_name $ARG2 ] {
set SERVER_NAME $ARG2
echo "OK"
} else {
echo "ERROR invalid server name"
}
}
AUTO_DISCOVERY {
set AUTO_DISCOVERY $ARG2
echo "OK"
}
INTERNAL_NN {
if [IsValidNwcmParam ipx_internal_network $ARG2 ] {
set INTERNAL_NN $ARG2
echo "OK"
} else {
echo "ERROR invalid internal network number"
}
}
ROUTER_TYPE {
set ROUTER_TYPE $ARG2
echo "OK"
}
MAX_SPX_CON {
if [IsValidNwcmParam spx_max_connections $ARG2 ] {
set MAX_SPX_CON $ARG2
echo "OK"
} else {
echo "ERROR maximum number of SPX connections"
}
}
MAX_SPX_SOC {
if [IsValidNwcmParam spx_max_sockets $ARG2 ] {
set MAX_SPX_SOC $ARG2
echo "OK"
} else {
echo "ERROR maximum number of SPX sockets"
}
}
IPX_START {
set IPX_START $ARG2
echo "OK"
}
SPX_START {
set SPX_START $ARG2
echo "OK"
}
RIP_AGE_INT {
if [IsValidNwcmParam \
lan_${lanNumber}_rip_ageout_intervals $ARG2 ] {
set RIP_AGE_INT $ARG2
echo "OK"
} else {
echo "ERROR invalid RIP ageout interval"
}
}
NWIP_DOMAIN {
if [IsValidNwcmParam nwip_domain $ARG2 ] {
set NWIP_DOMAIN $ARG2
echo "OK"
} else {
echo "ERROR illegal nwip domain name"
}
}
NWIP_SYNC {
if [IsValidNwcmParam nwip_db_sync_interval $ARG2 ] {
set NWIP_SYNC $ARG2
echo "OK"
} else {
echo "ERROR invalid nwip database sync interval"
}
}
NWIP_PORT {
if [IsValidNwcmParam nwip_port $ARG2 ] {
set NWIP_PORT $ARG2
echo "OK"
} else {
echo "ERROR illegal nwip port number"
}
}
NSQ_BC {
set NSQ_BC $ARG2
echo "OK"
}
NWIP_DSS {
if [IsValidNwcmParam nwip_preferred_dss $ARG2 ] {
set NWIP_DSS $ARG2
echo "OK"
} else {
echo "ERROR illegal DSS IP address list"
}
}
NWIP_SVR {
if [IsValidNwcmParam nwip_nearest_server $ARG2 ] {
set NWIP_SVR $ARG2
echo "OK"
} else {
echo "ERROR illegal server IP address list"
}
}
default {
echo "ipxBE: Unknown argument to SET" >&3
exit 1
}
}
}
PAGEINIT {
switch $ARG1 {
BASIC {
echo "{IPX/SPX Protocol Configuration} {} {NET_ipxspx} {ipxN.config.html} {OK}"
}
ADVANCED_INTF {
echo "{Advanced IPX/SPX Interface Configuration} {} {NET_ipxspx} {ipxN.advconfig.html} {OK}"
}
GLOBAL_IPX {
echo "{Global IPX/SPX Configuration} {} {NET_ipxspx} {ipxN.glconfig.html} {OK}"
}
NWIP {
echo "{NetWare/IP Configuration} {} {NET_ipxspx} {ipxN.nwip.html} {OK}"
}
default {
echo "ipxBE: Unknown argument to PAGEINIT" >&3
exit 1
}
}
}
USER_DONE {
# user is done
# save all information for main netcfg script
if { [set config_fd [open $IPX_NEWCFG w]] == -1} {
echo "ERROR cannot open file $IPX_NEWCFG for writing"
exit 1
}
puts $config_fd lan_${lanNumber}_network=$LAN_NETWORK
puts $config_fd lan_${lanNumber}_rip_ageout_intervals=$RIP_AGE_INT
puts $config_fd lan_${lanNumber}_frame_type=$FRAME_TYPE
puts $config_fd server_name=$SERVER_NAME
puts $config_fd ipx_auto_discovery=$AUTO_DISCOVERY
puts $config_fd ipx_internal_network=$INTERNAL_NN
puts $config_fd router_type=$ROUTER_TYPE
puts $config_fd spx_max_connections=$MAX_SPX_CON
puts $config_fd spx_max_sockets=$MAX_SPX_SOC
puts $config_fd ipx_start_at_boot=$IPX_START
puts $config_fd spx=$SPX_START
if [ cequal $NWIP on ] {
puts $config_fd lan_${lanNumber}_adapter=/dev/nwip
puts $config_fd nwip_domain=$NWIP_DOMAIN
puts $config_fd nwip_db_sync_interval=$NWIP_SYNC
puts $config_fd nwip_port=$NWIP_PORT
puts $config_fd nwip_nsq_broadcast=$NSQ_BC
puts $config_fd nwip_preferred_dss=$NWIP_DSS
puts $config_fd nwip_nearest_server=$NWIP_SVR
} else {
puts $config_fd lan_${lanNumber}_adapter=$adapter
}
switch $NETWORK_MEDIA {
ETHER {
puts $config_fd \
lan_${lanNumber}_adapter_type=ETHERNET_DLPI
}
TOKEN-RING {
puts $config_fd \
lan_${lanNumber}_adapter_type=TOKEN-RING_DLPI
}
FDDI {
puts $config_fd \
lan_${lanNumber}_adapter_type=FDDI_DLPI
}
}
close $config_fd
echo "OK"
}
default {
echo "ipxBE: Unknown request <$line>" >&3
exit 1
}
}
}