#
#       Copyright (c) 1995, 1996, Sun Microsystems, Inc.
#
# This software is provided by Sun ``AS IS'' and any express or implied
# warranties, including, but not limited to, the implied warranties of
# merchantability and fitness for a particular purpose are disclaimed.
# In no event shall Sun Microsystems be liable for any direct, indirect,
# incidental, special, exemplary, or consequential damages.
#
# This software is not a product, and is provided for evaluation purposes
# only.
#
# This software may not be resold without the express permission of
# Sun Microsystems.
#
# Feedback on this tool may be sent to packet-shell-owner@sunroof.eng.sun.com.
#
# Packet Shell
#
# @(#)syscall.proto	1.4
#

set pkt_length 1600

proc psizeof {pkt lyr} {
	set siz [plen $pkt $lyr]
	return $siz
}

#
# palloc initializes the packet length or if the packet already exists 
# it increases the length of the packet buffer and puts the new structure
# information in the packet buffer after the end of the original buffer.
#


proc palloc {pkt layer size align} {
	global pkt_length
	if {[catch "plen $pkt" msg] == 0} {
		palign $pkt $align
		pinit $layer temp_pkt $pkt_length $size
		pcopy $pkt/end temp_pkt
		pfree temp_pkt
	} else {
		pinit $layer $pkt $pkt_length $size
	}
	return 0
}

proc palign {pkt align} {
	set align_req [expr [plen $pkt] + ($align - 1) & ~($align - 1)]
	if {$align_req > [plen $pkt]} {
		plen $pkt $align_len
	}
}

set protocolInfo(syscall)  "Syscall Protocol (Used for passing ioctl commands)"


