/*
 *  Copyright (C) 1987
 *  Louis A. Mamakos  WA3YMH
 *  All rights reserved.
 *
 *  This code may not be redistributed, sold, included on any collection of
 *  software which is sold.  Use of this software is restricted to inclusion
 *  in the KA9Q TCP/IP software package for use on a Commodore-Amiga system.
 *  Commercial use is prohibited.  Only educational and Amateur Packet Radio
 *  use is allowed.
 */

#ifndef	EXEC_SEMAPHORES_H
#include <exec/semaphores.h>
#endif


struct InternetBase {
	struct Library lib;

	/* use AttemptSemaphore()/ObtainSemaphore()/ReleaseSemaphore() */
	struct SignalSemaphore ib_lock;

	/* add any user visible variables here */
	struct List	ib_Units;
} *InternetBase;


struct IOINETReq {
	struct	Message	io_Message;
	struct	Device	*io_Device;	/* device node pointer */
	struct INET_Unit	*io_Unit;		/* unit (driver private) */
	UWORD	io_Command;		/* device command */
	UBYTE	io_Flags;
	BYTE	io_Error;
	ULONG	io_Actual;
	ULONG	io_Length;
	APTR	io_Data;
	ULONG	io_Offset;
	union {
		struct TCP_state_u {
			UBYTE	io_u_OldState;	/* old TCP state */
			UBYTE	io_u_State;	/* new tcp state */
		} io_TCP_State_u;
		/* add more members of union here (protocol specific) */
	} io_INET_u;
	struct	socket io_lsocket;	/* local socket address */
	struct	socket io_fsocket;	/* remote socket address */

/* parameters used on OpenDevice() only */
#define	io_TCP_Window	io_Length
#define	io_INET_TOS	io_Actual

/* define easier to use names for members of protocol specific status union */
#define	io_OldState	io_INET_u.io_TCP_State_u.io_u_OldState
#define io_State	io_INET_u.io_TCP_State_u.io_u_State

};


struct INET_Unit {
	struct	Node iu_Unit;		/* list thread */
	struct	List iu_Input;		/* queue of read requests */
	struct	List iu_Output;		/* queue of write reqeusts */
	struct	IOINETReq *iu_Act_Input;/* current active input request */
	struct	IOINETReq *iu_Act_Output;/* current active output request */
	void	*iu_ccb;		/* generic control block 
					   (TCP/UDP protocol specific) */
	ULONG	iu_user;		/* user supplied "cookie" */
	ULONG	iu_type;		/* type of connection (UDP/TCP..) */
};

#define IN_VERSION	1
#define IN_REVISION	0

#define INET_UNIT_RAW	0L
#define	INET_UNIT_TCP	1L
#define	INET_UNIT_UDP	2L
