#ident	"@(#)cmd-inet:common/cmd/cmd-inet/etc/strcf	1.3.9.6"
#ident	"$Header: $"

#
#	STREAMware TCP
#	Copyright 1987, 1993 Lachman Technology, Inc.
#	All Rights Reserved.
#

#
#	Copyright (c) 1982, 1986, 1988
#	The Regents of the University of California
#	All Rights Reserved.
#	Portions of this document are derived from
#	software developed by the University of
#	California, Berkeley, and its contributors.
#

#
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# 		PROPRIETARY NOTICE (Combined)
# 
# This source code is unpublished proprietary information
# constituting, or derived under license from AT&T's UNIX(r) System V.
# In addition, portions of such source code were derived from Berkeley
# 4.3 BSD under license from the Regents of the University of
# California.
# 
# 
# 
# 		Copyright Notice 
# 
# Notice of copyright on this source code product does not indicate 
# publication.
# 
# 	(c) 1986,1987,1988.1989  Sun Microsystems, Inc
# 	(c) 1983,1984,1985,1986,1987,1988,1989,1990  AT&T.
# 	(c) 1990,1991  UNIX System Laboratories, Inc.
# 	          All rights reserved.
#  
#

#
#	Copyright 1987, 1988 Lachman Associates, Incorporated (LAI)
#	All Rights Reserved.
#
#	The copyright above and this notice must be preserved in all
#	copies of this source code.  The copyright above does not
#	evidence any actual or intended publication of this source
#	code.
#
#	This is unpublished proprietary trade secret source code of
#	Lachman Associates.  This source code may not be copied,
#	disclosed, distributed, demonstrated or licensed except as
#	expressly authorized by Lachman Associates.
#
#	System V STREAMS TCP was jointly developed by Lachman
#	Associates and Convergent Technologies.
#
#
# tp - configure transport provider (i.e. tcp, udp, icmp)
# usage: tp devname
#
tp {
	p = open $1
	ip = open /dev/ip
	new_link p ip
}

#
# iplinkint - link interface to ip
# usage: iplinkint fd_of_ip fd_of_dev ifname sap
#
# NOTE: If app is needed on this stream, it must be pushed before
# iplinkint is called.
#
iplinkint {
	bind $2 $4
	muxid = new_link $1 $2
	sifname $1 muxid $3
}

#
# iplinkint_subs - link interface to ip
# usage: iplinkint_subs fd_of_ip fd_of_dev ifname sap subs_sap
#
# NOTE: If app is needed on this stream, it must be pushed before
# iplinkint_subs is called.
#
iplinkint_subs {
	bind $2 $4 $5
	muxid = new_link $1 $2
	sifname $1 muxid $3
}

#
# arplinkint - link interface to arp
# usage: arplinkint fd_of_arp fd_of_dev ifname sap
#
arplinkint {
	bind $2 $4
	muxid = new_link $1 $2
	sifname $1 muxid $3
}

#
# arplinkint_subs - link interface to arp
# usage: arplinkint_subs fd_of_arp fd_of_dev ifname sap subs_sap
#
arplinkint_subs {
	bind $2 $4 $5
	muxid = new_link $1 $2
	sifname $1 muxid $3
}

#
# linkint - link interface to ip or arp
# usage: linkint top bottom ifname
#
# THIS SCRIPT IS FOR COMPATIBILITY ONLY - see iplinkint or arplinkint
#
linkint {
	x = link $1 $2
	sifname $1 x $3
}

#
# aplinkint - like linkint, but app is pushed on dev
# usage: aplinkint top bottom ifname
#
# THIS SCRIPT IS FOR COMPATIBILITY ONLY - see iplinkint, arplinkint 
# iplinkint_subs, arplinkint_subs and push
#
aplinkint {
	push $2 app
	linkint $1 $2 $3
}

#
# uenet - configure ethernet-type interface for cloning driver using
#         unit select
# usage: uenet ip-fd devname ifprefix unit
#
uenet {
	ifname = strcat $3 $4
	dev = open $2
	unitsel dev $4
	push dev app
	iplinkint $1 dev ifname 0x800
	dev = open $2
	unitsel dev $4
	arp = open /dev/arp
	arplinkint arp dev ifname 0x806
}

#
# denet - configure ethernet-type interface for cloning driver using
#         DL_ATTACH
# usage: denet ip-fd devname ifprefix unit
#
denet {
	ifname = strcat $3 $4
	dev = open $2
	dlattach dev $4
	push dev app
	iplinkint $1 dev ifname 0x800
	dev = open $2
	dlattach dev $4
	arp = open /dev/arp
	arplinkint arp dev ifname 0x806
}

#
# cenet - configure ethernet-type interface for cloning driver with
#         one major per interface
# usage: cenet ip-fd devprefix ifprefix unit
#
cenet {
	devname = strcat $2 $4
	ifname = strcat $3 $4
	dev = open devname
	push dev app
	iplinkint $1 dev ifname 0x800
	dev = open devname
	arp = open /dev/arp
	arplinkint arp dev ifname 0x806
}

#
# senet - configure ethernet-type interface for non-cloning driver
# usage: senet ip-fd ipdevname arpdevname ifname
#
senet {
	dev = open $2
	push dev app
	iplinkint $1 dev $4 0x800
	dev = open $3
	arp = open /dev/arp
	arplinkint arp dev $4 0x806
}

#
# senetc - configure ethernet-type interface for non-cloning driver
#         using convergence module
# usage: senetc ip-fd convergence ipdevname arpdevname ifname
#
senetc {
	dev = open $3
	push dev $2
	push dev app
	iplinkint $1 dev $5 0x800
	dev = open $4
	push dev $2
	arp = open /dev/arp
	arplinkint arp dev $5 0x806
}

#
# loopback - configure loopback device
# usage: loopback compat_ip_reserved ifname
#
loopback {
	ip = open /dev/ip
	dev = open /dev/loop
	iplinkint ip dev $2 0x800
}

#
# slip - configure slip interface
# usage: slip unit
#
slip {
	ip = open /dev/ip
	s = open /dev/slip
	ifname = strcat sl $1
	unitsel s $1
	iplinkint $1 s ifname 0x800
}

#
# boot - boot time configuration
#
boot {
	#
	# queue params
	#
	initqp /dev/ip muxrq 40960 64386 rq 8192 40960
	initqp /dev/tcp muxrq 8192 40960
	initqp /dev/udp hdrq 32768 64512
	#
	# transport
	#
	tp /dev/tcp
	tp /dev/udp
	tp /dev/icmp
	tp /dev/rawip

# interfaces are added to the /etc/confnet.d/inet/interface file
# from scripts under /etc/confnet.d
#	DO NOT ADD PROVIDERS NOT HERE!!  Even if slink gets them,
#	ifconfig will not.
}

# usage: add_loop compat_ip_reserved devicename  interfacename
#	  We will assume that boot{} has already run and
#	  we will open /dev/ip ourselves and link up underneath it.
add_loop {
	ip = open /dev/ip
	dev = open $2
	iplinkint ip dev $3 0x800
}

#
# add_interface_SNAP - configure ethernet-type interface for cloning driver
#	with one major per interface.  Similar to cenet except we are given
#	arguments that are allready concatinated with a major device number
#	(such as emd0).  We assume that boot{} has already run.  We will use
#	iplinkint to bind the device to the SNAP SAP for ip and link devpath
#	under IP, and will open devpath, and use arplinkint to bind it to
#	the SNAP SAP for arp and link it under arp.
# usage: add_interface compat_ip_reserved devpath ifname
#
add_interface_SNAP {
	ip = open /dev/ip
	dev = open $2
	push dev app
	iplinkint_subs ip dev $3 0xaa 0x800
	dev = open $2
	arp = open /dev/arp
	arplinkint_subs arp dev $3 0xaa 0x806
}

#
# add_interface - configure ethernet-type interface for cloning driver with
#         one major per interface.  Similar to cenet except we are given
#	  arguments that are allready concatinated with major device
#	  number (such as emd0).
#	  We will also assume that boot{} has already run and
#	  we will open /dev/ip ourselves and link up underneath it.
# usage: add_interface compat_ip_reserved devpath ifname
#
add_interface {
	ip = open /dev/ip
	dev = open $2
	push dev app
	iplinkint ip dev $3 0x800
	dev = open $2
	arp = open /dev/arp
	arplinkint arp dev $3 0x806
}

# usage: add_ppp compat_ip_reserved devicename interfacename
#         We will assume that boot{} has already run and
#         we will open /dev/ip ourselves and link up underneath it.
add_ppp {
	ip = open /dev/ip
	dev = open $2
	iplinkint ip dev $3 0x800
}
