/****************************************************************************
*
* (C) 2000 by BECK IPC GmbH
*
*  BECK IPC GmbH
*  Garbenheimerstr. 38
*  D-35578 Wetzlar
*
*  Phone : (49)-6441-905-240
*  Fax   : (49)-6441-905-245
*
* ---------------------------------------------------------------------------
* Module        : IPC@CHIP SC12 API: PKTDRV.H
* Function      : Headerfile
                  Packet driver interface enables access to the ethernet of SC12
*                 Required memory model: Large
*
* Author        : Bartat
* Date          : 10.10.00
* ---------------------------------------------------------------------------

$Header: PKTDRV.H, 7, 16.01.2002 11:45:05, Christoph Stoidner$

$Log:
 7    IPC@CHIP  1.6         16.01.2002 11:45:05  Christoph Stoidner add starteam
      directives
 6    IPC@CHIP  1.5         16.01.2002 11:04:49  Christoph Stoidner add some
      comments

 5    IPC@CHIP  1.4         14.12.2001 12:15:49  Markus Bartat   added
      set_rcv_mode functions
 4    IPC@CHIP  1.3         17.09.2001 11:19:41  Markus Bartat   added new
      functions for wildcard and multicast api calls
 3    IPC@CHIP  1.2         19.06.2001 13:35:06  Markus Bartat   start: Added
      comments to the c functions
 2    IPC@CHIP  1.1         15.02.2001 15:16:52  Christoph Stoidner
 1    IPC@CHIP  1.0         14.02.2001 16:09:33  Christoph Stoidner
$

* History       :
*
*  Vx.yy                 Author  Changes
*
*             10.10.00   mb      Create
*             12.09.01   mb       added multicast and wildcard_access  functions
*             06.12.01   mb       added set_rcv_mode functions
/**************************************************************************/
#ifndef _PKT_DRV_H_
#define _PKT_DRV_H_

/**************************************************************************/
//   				DEFINES
/**************************************************************************/
#ifdef _MSC_VER /* If Microsoft C Compiler is used, define new FP_SEG and FP_OFF Macro */
	#ifdef FP_SEG
  		#undef FP_SEG
	#endif
	#define FP_SEG(ptr)    ((unsigned int)(((unsigned long)ptr)>>16))

	#ifdef FP_OFF
  		#undef FP_OFF
	#endif
	#define FP_OFF(ptr)    ((unsigned int)(((unsigned long)ptr)&0xFFFF))
#endif


#define PKTVECT  0xAE

//frame size
#define SIZE_ETH_HEADER    (int)14
#define ETH_MIN            (int)64
#define ETH_MAX            (int)1500




/* Packet driver error return codes */
#define	NO_ERROR	0
#define	BAD_HANDLE	1	/* invalid handle number */
#define	BAD_TYPE	5	/* bad packet type specified */
#define	NO_SPACE	9	/* operation failed because of insufficient space */
#define	TYPE_INUSE	10	/* the type had previously been accessed, and not released */
#define	BAD_COMMAND	11	/* the command was out of range, or not	implemented */
#define	CANT_SEND	12	/* the packet couldn't be sent (usually	hardware error) */


/* Packet driver function call numbers */
#define	DRIVER_INFO		1
#define	ACCESS_TYPE		2
#define	RELEASE_TYPE	        3
#define	SEND_PKT		4
#define	GET_ADDRESS		6
#define SET_RCVMODE     20
#define GET_RCVMODE     21
#define	SET_MULTICAST	22     /*set/add multicast mac address*/
#define	DEL_MULTICAST	39     /*remove multicast mac address*/
#define INSTALL_WILDCARD 40


/************************************************************************/
//       	       typedefinitions
/************************************************************************/

//ethernet frame
typedef struct tag_ethernet_packet_format
{
    unsigned char	dest[6];
    unsigned char	src[6];
    unsigned int	type;
    unsigned char	data[1500];
}Eth_Packet;


typedef union union_eth
{
    Eth_Packet     packstruc;
    unsigned char  packet[sizeof(Eth_Packet)];
}Ethernet_Packet;




//driver info
typedef struct tag_driver_info
{
   unsigned char basic;
   unsigned char _class;
   unsigned char number;
   unsigned int type;
   unsigned int version;
}Driver_Info;




typedef void (far *fpFktPtr)();




/************************************************************************/
//prototypes
/************************************************************************/
unsigned char PktDriver_Installed(void);
unsigned char Get_Driver_Info(Driver_Info * drv_info );
unsigned char Get_Eth_Address(unsigned char *buffer, unsigned int len);
unsigned char Send_Packet(unsigned char * buffer, unsigned int len);
unsigned int Set_Access_Type(Driver_Info * drv_info, fpFktPtr Receiver, int * pkt_type, int *handle);
unsigned int Release_Type(unsigned int handle);
unsigned int Set_Multicast(unsigned char * mac_addr, int set);
unsigned int Set_WildcardAccess_Type(Driver_Info * drv_info, fpFktPtr Receiver, int * pkt_type, int *handle);
unsigned int Get_Receive_Mode(unsigned char * error);
unsigned int Set_Receive_Mode(unsigned int mode,unsigned char * error);
/************************************************************************/
#endif
/************************************************************************/
//end pktdrv.h
/************************************************************************/
