home *** CD-ROM | disk | FTP | other *** search
- ;; types of interfaces
- CONF_GENERIC = 1 ;; interface that requires no special config data
-
- CONF_ROUTE = 10 ;; static route configuration data
- CONF_BOOTP = 20 ;; Bootp configration data (forwarding host)
- CONF_ADMIN = 21 ;; administrative data (admin host)
- CONF_SYSLOG = 22 ;; host to send syslog messages to
-
-
- ;;************************************************************************
- ;; CONFIG reads in the configuration data from p?.cfg, and configures
- ;; all the router objects. If it is not successful it jumps to 'fail'.
- ;; 'dlog' is the Disk logger object to log errors to
- ;;
- CONFIG MACRO fail, dlog
- local config_failed, open_failed, read_failed, done
-
- .DATA
- config_data DW 64 dup (0)
-
- .CODE
- TIMER_DEFINE %mytimer
-
- CONFIG_OPEN_DATA open_failed, 64
-
- irp idx,<1,2,3,4,5,6,7,8> ;; config the ethernets
- CONF_DEFINE_ARP idx, dlog, fail, read_failed, config_failed
- endm
-
- RIP_DEFINE %myrip
-
- IP_DEFINE %myip
-
- ;; All ethernet types have to be defined at this point so we can
- ;; now register them with the packet drivers.
-
- irp idx,<1,2,3,4,5,6,7,8> ;; config the packet drivers
- CONF_DEFINE_PKT idx, dlog, fail
- endm
-
- CONF_DEFINE_ROUTE %myrip, dlog, fail, read_failed, config_failed
-
- ICMP_DEFINE %myicmp
-
- UDP_DEFINE %myudp
-
- CONF_DEFINE_BOOTP %mybootp, dlog, fail, read_failed, config_failed
-
- CONF_DEFINE_SYSLOG %mylog, dlog, fail, read_failed, config_failed
- jmp done
-
- open_failed:
- DLOG_PRINT dlog, <Could not open config file>
- jmp fail
- read_failed:
- DLOG_PRINT dlog, <Error reading config file>
- jmp fail
- config_failed:
- DLOG_PRINT dlog, <Config file corrupt or out of sync>
- jmp fail
- done:
- ENDM
-
- ;;**************************************************************************
- CONF_DEFINE_PKT MACRO name, dlog, fail
- local around, pktfail
- .errb <name>
- .errb <dlog>
- .errb <fail>
-
- ifdef pkt_&name&_declared
- PKT_DEFINE name, pktfail
- jmp around
- pktfail:
- DLOG_PRINT dlog, <No packet driver for interface name !?>
- jmp fail
- around:
- endif
-
- ENDM
-
-
-
- ;;**************************************************************************
- ;; If the ARP DL_IP 'name' object exists, then CONF_DECLARE_ARP defines
- ;; the flag that will tell the configuration program that configuration
- ;; information for a ARP DL_IP object is needed.
- ;;
- CONF_DECLARE_ARP MACRO name
- .errb <name>
-
- ifdef arp_&name&_declared
- DB CONF_GENERIC, 3 ;; type and version
- endif
- ifdef pps_&name&_declared
- DB CONF_GENERIC, 3 ;; type and version
- endif
- ENDM
-
- ;;**************************************************************************
- ;; If the ARP object 'name' exists CONF_DEFINE_ARP reads in the configuration
- ;; data and initializes the ARP object.
- ;;
- CONF_DEFINE_ARP MACRO name, dlog, fail, read_failed, config_failed
- .errb <config_failed>
-
- ifdef eth_&name&_declared
- ETH_DEFINE name
- endif
-
- ifdef arp_&name&_declared
-
- mov DX, offset config_data
- CONFIG_GET_DATA_in_DX_const_DX_BP_SI_DI 4, read_failed
- cmp word ptr config_data, (CONF_GENERIC)+256*3 ;; type generic, version 3
- jnz config_failed
-
- CONFIG_GET_DATA_in_DX_const_DX_BP_SI_DI 18, read_failed
-
- mov AX, word ptr config_data+12
- mov word ptr dl_ip_&name&_flags, AX
- mov AX, word ptr config_data+14
- mov word ptr dl_ip_&name&_metric, AX
- mov AX, word ptr config_data+16
- mov word ptr dl_ip_&name&_id, AX
-
- ARP_DEFINE name, config_data, (config_data+4), (config_data+8)
- endif
- ifdef pps_&name&_declared
-
- mov DX, offset config_data
- CONFIG_GET_DATA_in_DX_const_DX_BP_SI_DI 4, read_failed
- cmp word ptr config_data, (CONF_GENERIC)+256*3 ;; type generic, version 3
- jnz config_failed
-
- CONFIG_GET_DATA_in_DX_const_DX_BP_SI_DI 18, read_failed
-
- mov AX, word ptr config_data+12
- mov word ptr dl_ip_&name&_flags, AX
- mov AX, word ptr config_data+14
- mov word ptr dl_ip_&name&_metric, AX
- mov AX, word ptr config_data+16
- mov word ptr dl_ip_&name&_id, AX
-
- PP_DEFINE name, config_data, (config_data+4), (config_data+8)
- endif
- ENDM
-
-
- ;;**************************************************************************
- ;; CONF_DEFINE_ROUTE reads in the routing information on the disk and
- ;; initializes the static routes.
- ;;
- CONF_DEFINE_ROUTE MACRO rip, dlog, fail, read_failed, config_failed
- local route_loop, route_done
- .errb <config_failed>
-
- mov DX, offset config_data
- CONFIG_GET_DATA_in_DX_const_DX_BP_SI_DI 4, read_failed
- cmp word ptr config_data, (CONF_ROUTE)+256*2 ;; type rip, version 2
- jnz config_failed
-
- CONFIG_GET_DATA_in_DX_const_DX_BP_SI_DI 2, read_failed
- mov CX, config_data
- cmp CX, 1200
- ja config_failed
-
- mov AX, DS
- mov ES, AX
- mov DI, offset config_data+8
-
- route_loop:
- or CX, CX
- jz route_done
-
- mov SI, CX ;; save CX without changing stack
- mov DX, offset config_data
- CONFIG_GET_DATA_in_DX_const_DX_BP_SI_DI 16, read_failed
- push SI ;; save CX on the stack
-
- mov SI, offset config_data
- mov DX, offset config_data+4
- mov CX, word ptr config_data+12
- mov AX, word ptr config_data+14
- ROUTE_ADD_in_AX_CX_DX_SI_DI_ES_const_DI_ES rip
- pop CX
- dec CX
- jmp route_loop
- route_done:
- ENDM
-
-
- ;;**************************************************************************
- ;; CONF_DEFINE_BOOTP reads in the bootp information on the disk and initializes
- ;; the BOOTP object
- ;;
- CONF_DEFINE_BOOTP MACRO mybootp, dlog, fail, read_failed, config_failed
- .errb <config_failed>
-
- mov DX, offset config_data
- CONFIG_GET_DATA_in_DX_const_DX_BP_SI_DI 4, read_failed
- cmp word ptr config_data, (CONF_BOOTP)+256*1 ;; type bootp, version 1
- jnz config_failed
-
- CONFIG_GET_DATA_in_DX_const_DX_BP_SI_DI 4, read_failed
-
- BOOTP_DEFINE mybootp, config_data
- ENDM
-
-
- ;;**************************************************************************
- ;; CONF_DEFINE_SYSLOG reads in the bootp information on the disk and initializes
- ;; the BOOTP object
- ;;
- CONF_DEFINE_SYSLOG MACRO mylog, dlog, fail, read_failed, config_failed
- .errb <config_failed>
-
- mov DX, offset config_data
- CONFIG_GET_DATA_in_DX_const_DX_BP_SI_DI 4, read_failed
- cmp word ptr config_data, (CONF_SYSLOG)+256*1 ;; type syslog, version 1
- jnz config_failed
-
- CONFIG_GET_DATA_in_DX_const_DX_BP_SI_DI 8, read_failed
-
- mov AX, word ptr config_data+4
- mov BX, word ptr config_data+6
- LOG_DEFINE_in_AX_BX mylog, config_data
- ENDM
-
-
- ;;**************************************************************************
- ;; CONFIG_OPEN_DATA opens 'p?.cfg' for reading. It enforces a limit
- ;; on a read of 'max_size'. If the open fails it jumps to 'fail'
- ;;
- CONFIG_OPEN_DATA MACRO fail, max_size
- .errb <max_size>
-
- .DATA
- config_file db 'p', '0'+num_dls, '.cfg', 0
- config_handle dw ?
- config_max_size = max_size
-
- .CODE
- mov DX, offset config_file
- mov AH, 3DH ;; open the file
- mov AL, 0 ;; open for reading
- int 21H
- jc fail
- mov config_handle, AX ;; save handle
- ENDM
-
-
- ;;**************************************************************************
- ;; CONFIG_GET_DATA reads in the next 'len' bytes from the file open with
- ;; CONFIG_OPEN_DATA. It puts the info in the buffer DX:DS. If there
- ;; is a error it jumps to 'fail'
- ;;
- CONFIG_GET_DATA_in_DX_const_DX_BP_SI_DI MACRO len, fail
- .errb <fail>
-
- if len gt config_max_size
- .err ;; length to big!!
- endif
-
- mov CX, len
- CONFIG_GET_DATA_in_CX_DX_const_CX_DX_BP_SI_DI fail
- ENDM
-
- ;;**************************************************************************
- ;; CONFIG_GET_DATA reads in the next 'CX' bytes from the file open with
- ;; CONFIG_OPEN_DATA. It puts the info in the buffer DX:DS. If there
- ;; is a error it jumps to 'fail'
- ;;
- CONFIG_GET_DATA_in_CX_DX_const_CX_DX_BP_SI_DI MACRO fail
- .errb <fail>
-
- mov AH, 3FH ;; Read a block
- mov BX, config_handle
- int 21H ;; read the ip info
- jc fail
- cmp AX, CX
- jnz fail
- ENDM
-
-