/****************************************************************************
*
* (C) 1999 by BECK IPC GmbH
*
*  BECK IPC GmbH
*  Garbenheimerstr. 38
*  D-35578 Wetzlar
*
*  Phone : (49)-6441-905-240
*  Fax   : (49)-6441-905-245
*
* ---------------------------------------------------------------------------
* Module        : TCPIPAPI.H
* Function      : Constants and datastructures for access to
*                 the Socketinterface
*                 Recommended memory model for applications: LARGE
*
*
* Author        : Bartat
* Date          : 05.10.99
* ---------------------------------------------------------------------------
* History       :


$Header: TCPIPAPI.H, 26, 07.05.2002 14:50:52, Markus Bartat$

$Log:
 26   IPC@CHIP  1.25        07.05.2002 14:50:52  Markus Bartat   added
      C-function for TCPAPI call 0x22 Get_tcp-socket_state
 25   IPC@CHIP  1.24        05.04.2002 15:00:06  Christoph Stoidner Add
      SetSockOpt options (MAX_RT->connect/send timeout; MAX_REXMIT->maximal send
      retries).
 24   IPC@CHIP  1.23        01.03.2002 18:49:26  Markus Bartat   added functions
      for API calls 0x45,0x44,0x55
 23   IPC@CHIP  1.22        26.02.2002 18:45:52  Christoph Stoidner Add
      PPPSetPPPOption
 22   IPC@CHIP  1.21        30.01.2002 12:52:07  Markus Bartat   added extendend
      dhcp_stat function 0x73
 21   IPC@CHIP  1.20        16.01.2002 11:45:07  Christoph Stoidner add starteam
      directives
 20   IPC@CHIP  1.19        14.01.2002 13:33:37  Christoph Stoidner add new
      functions (Set/get Idle timeout: 0x79)
 19   IPC@CHIP  1.18        14.01.2002 13:19:06  Christoph Stoidner add new
      functions
 18   IPC@CHIP  1.17        14.12.2001 11:55:08  Markus Bartat   Added C
      functions and define for TCPIP API calls 0x90-0x92
 17   IPC@CHIP  1.16        20.11.2001 13:03:31  Markus Bartat   added comments
      to the ppp client init struct
 16   IPC@CHIP  1.15        15.11.2001 12:02:43  Markus Bartat   added comment
      header
 15   IPC@CHIP  1.14        15.11.2001 12:02:42  Markus Bartat   added comment
      header
 14   IPC@CHIP  1.13        15.11.2001 12:02:42  Markus Bartat   added comment
      header
 13   IPC@CHIP  1.12        08.11.2001 18:54:18  Markus Bartat   modified
      documentation
 12   IPC@CHIP  1.11        08.11.2001 18:49:03  Markus Bartat   added comments
      to the PPPclient_Init structure
 11   IPC@CHIP  1.10        17.09.2001 12:40:23  Markus Bartat   added tcpip api
      call 0x67
 10   IPC@CHIP  1.9         21.06.2001 13:53:32  Markus Bartat   added tcpip api
      call 0x19
 9    IPC@CHIP  1.8         08.06.2001 15:42:38  Christoph Stoidner Add SockOpt
      #define NODELAY
 8    IPC@CHIP  1.7         01.06.2001 12:20:29  Markus Bartat   added new
      functions
 7    IPC@CHIP  1.6         31.05.2001 16:19:04  Christoph Stoidner
 6    IPC@CHIP  1.5         31.05.2001 14:27:48  Christoph Stoidner
 5    IPC@CHIP  1.4         29.05.2001 16:04:20  Markus Bartat   added aPI call
      0x60 Get access to internal snmp variables
 4    IPC@CHIP  1.3         15.05.2001 11:20:49  Markus Bartat   überarbeitet
      von Ali Senol
 3    IPC@CHIP  1.2         14.05.2001 12:54:28  Markus Bartat   added constant
      TCP_NODELAY
 2    IPC@CHIP  1.1         12.04.2001 14:03:09  Markus Bartat   bugfix at
      pingclient structure (dummy counter)
 1    IPC@CHIP  1.0         14.02.2001 16:09:59  Christoph Stoidner
$


*
*  Vx.yy        Author  Changes
*
*                 mb    Create
*                 mb    added tcpinterface
*                 mb    add ppp client API calls
*                 mb    add ppp server API calls
*                 mb    SC12 TCPIP system calls (ip config, DHCP, statistics, IP_TOS)
*                 mb    changed API constants from dec. to hex. (value is the same)
*                 mb    modify struct packet count
*                 mb    add get and set sockopt calls
*                 mb    add ping api calls
*                 mb    add memory information call
*                 mb    modified(rename) members of ppp structures for using PAP and CHAP auth method
*                 mb    add routing calls
*                 mb    add blocking mode call for a sockets
*                 mb    !! important: modified PPPclient_Init structure: set max length of user and password string
*                       to 50 character
*                 mb    add typedefs snmp mib structures
*                 mb    add telnet and ftp login functions
                  mb    add register callback function and socket eventflags
                  mb    add get telnet state function
                  mb    add comments to the PPPclient_init structure, because of changes at BIOS 1.02B
                  mb    add igmp functions numbers 0x90 - 0x92
                  mb    added typedef struct UserEthDhcp_entry
                  mb    added new function PPP_GET_DNSIP 0x44 and pppsetoptions 0x45,0x55
                  mb     added TCP API function 0x22, get state of tcp socket
*****************************************************************************************************/
#ifndef _TCPIP_API_H__
#define _TCPIP_API_H__
/*****************************************************************************/
/*****************************************************************************/
/*
 * BSD Structure Definitions
 */
/*****************************************************************************/
struct sockaddr
{
	unsigned char  sa_len;      /* Total Length */
	unsigned char  sa_family;   /* Address Family AF_xxx */
	char    sa_data[14]; /* up to 14 bytes of protocol specific address */
};


struct in_addr
{
	unsigned long s_addr; /* 32bit netis/hostid address in network byte order */
};

struct sockaddr_in
{
	short           sin_family; /* AF_INET */
	unsigned int    sin_port;   /* 16bit Port Number in network byte order */
	struct  in_addr sin_addr;   /* 32bit netid/hostid in network byte order */
	char            sin_zero[8];/* unused */
};

/*****************************************************************************/
struct recv_params
{
   char                   *   bufferPtr;
   int                        bufferLength;
   int                        flags;            /*Blocking or  dontwait*/
   struct sockaddr        *   fromPtr;          /* only needed for UDP */
   int                    *   fromlengthPtr;    /* only needed for UDP */
   unsigned long              timeout;          /*timeout milliseconds*/
};

struct send_params
{

   char                   *   bufferPtr;
   int                        bufferLength;
   int                        flags;            /*Blocking or  dontwait*/
   struct sockaddr        *   toPtr;            /* only needed for UDP */
   int                    *   tolengthPtr;      /* only needed for UDP */

};

/*****************************************************************************/
//Set and get socket options structure
/*****************************************************************************/


typedef struct tag_setsockopt{

    int protocol_level;            /*protocol level ip level,tcp level or socket level*/
    int optionName;                /*options name*/
    const char * optionValue;      /* pointer to the option value*/
    int optionLength;              /* length of option value*/

}SetSocketOption;


typedef struct tag_getsockopt{

    int protocol_level;            /*protocol level ip level,tcp level or socket level*/
    int optionName;                /*options name*/
    char       * optionValue;      /* pointer to the option value buffer, where Value can befilled in by the API call */
    int        * optionLength;     /* length of option value buffer*/

}GetSocketOption;

/*****************************************************************************/
//PPP server config information structure
/*****************************************************************************/
typedef struct tag_pppipcfg_data
{
     char IP[16];
     char RemIP[16];
     char Netmask[16];
     char Gateway[16];
     unsigned int  comport;     /* 0==EXT, 1==COM of the SC12*/
     unsigned int  auth;        /* 0==No auth, 1==PAP authentication, 2:CHAP*/
     unsigned int  modem;       /* 0==Nullmodem, 1==usage of modem*/
     unsigned int  flow;
     long          baud;
}PPP_IPCfg_Data;



/*****************************************************************************/
//PPP client structures
/*****************************************************************************/

#define PPP_MAX_DIAL 7


typedef struct tag_pppdial
{
      char  * modemcmd;     //modem command string
      char  * modemans;     //modem answer  string
      int   timeout;        //seconds
      int   retries;
      char  expect_send;
      /*flag:
        expect = 0: pppclient sends modemcmd and expects modemanswer
        expect = 1: pppclient expects modemanswer and sends modemcmd
      */
}PPPDial;


typedef struct tag_pppclie_hangup
{
      char    *modemcmdmode;                 //switch modem into command mode e.g. +++
      int     delay;                         //delay time after switching in seconds
      PPPDial pppdial[PPP_MAX_DIAL];     //modem commands and answer for hangups
}PPP_ModemHangup;




typedef struct tag_ppp_client
{
   /************************************************************************************/
   //user PPP config data
   /************************************************************************************/

   int  port;                     //serial port (0:EXT 1:COM)
   
   int  auth;                     // 0: no authentication
                                  // 1:PAP  Client must send username and password for PAP authentication to the peer
                                  // 2:CHAP Client must send username and password for CHAP authentication to the peer
                                  // 3:PAP  Client expects PAP username and password  from the peer
                                  // 4:CHAP Client expects CHAP username and password from the peer

   int  modem;                    //modem usage (0:nullmodem 1:analogue modem)
   int  flow;                     //serial flow control (0: none, 1:XON/XOFF, 2:RTS/CTS)
   long baud;                     //serial baudrate
   unsigned long idletimeout;     //closing ppp after idle time seconds (0: no closing after idle time)

   char username[50];             //username, if auth <=4 and !=0
   char password[50];             //password, if auth <=4 and !=0

   void * dptr;                   //dummy ptr

   /************************************************************************************/
   //filled in after successful API call: IP cfg data given from server
   /************************************************************************************/
   char PPPClieipAddrStr[16];     //If this IP is set to "0.0.0.0" client expect IP form the peer, IP is filled in after sucessful connection
                                  //If this IP is set to a string != "0.0.0.0" client wants to use this IP during the ppp session
   char PPPClieRemipAddrStr[16];  //If RemoteIP is set to "0.0.0.0" client allow the peer to use its own IP during the PPP session
                                  //the RemoteIP is filled in after sucessful  connection
                                  //If RemoteIP is set to a string != "0.0.0.0" client wants to configure the remote peer with this IP



   char PPPClienetMaskStr[16];
   char PPPClieipGatewayStr[16];



   /************************************************************************************/
   //modem parameters
   /************************************************************************************/
   PPPDial          pppdial[PPP_MAX_DIAL];       // modem/dial entries
   PPP_ModemHangup  modem_hangup;                    //modem hangup commands




   unsigned int    break_modem;     /*
                                       flag for breaking SC12 <-> modem control communication, dialing, waiting for connect,..
                                       setting break_modem to 1, interrupts current modem communication between
                                       SC12 and the modem at a pppclient open or close call, 
                                       The pppclient read this flag and breaks the modem dialing, or waiting.
                                       This flag could be set from another task, to interrupt the dialing.
                                       If a ppp link  is established, it doesn't break the session.
                                       Don't forget to set this flag to zero after breaking
                                     */

}PPPClient_Init;

/*****************************************************************************/
//PPP Option
/*****************************************************************************/
typedef struct tag_ppp_option
{
   int         protocolLevel;
   int         remoteLocalFlag;
   int         optionName;
   const char *optionValuePtr;
   int         optionLength;
} PPP_Option;

/*****************************************************************************/
//TCPIP statistics  structure (needed by function TCPIP_STATISTISTICS 0x74)
/*****************************************************************************/
typedef struct tag_cnt_packet{
      /*recv counter*/
      unsigned int  * cnt_all_packets;   //count all incoming ethernet packets
      unsigned int  * cnt_ip_packets;    //count incoming IP packets
      unsigned int  * cnt_arp_packets;   //count incoming ARP packets
      unsigned int  * cnt_tcp_packets;   //count incoming TCP packets
      unsigned int  * cnt_udp_packets;   //count incoming UDP packets
      unsigned int  * cnt_icmp_packets;  //count incoming ICMP packets
      /*send counter*/
      unsigned int  * cnt_all_sended_packets; //count all sended ethernet packets
      unsigned int  * cnt_ip_sended_packets;//count all sended ip packets
      unsigned int  * cnt_arp_sended_packets; //count all sended arp packets
      unsigned int  * cnt_tcp_sended_packets; //count all sended tcp packets
      unsigned int  * cnt_udp_sended_packets; //count all sended udp packets
      unsigned int  * cnt_icmp_sended_packets;//count all sended icmp packets
      /*chksum error  counter on incoming packets*/
      unsigned int  * cnt_ip_chksum_errs;//count all chksum errors on incoming ip packets
      unsigned int  * cnt_udp_chksum_errs;//count all chksum errors on incoming udp packets
      unsigned int  * cnt_tcp_chksum_errs;//count all chksum errors on incoming tcp packets
      unsigned int  * cnt_eth_errs;//count all ethernet error, CRC, FAE and FIFO overrun
}Packet_Count;


/*****************************************************************************/
//Ping API
/*****************************************************************************/

typedef struct tag_ping_command
{
int    sd;                //socket descriptor, filled by PING_OPEN
char *  remoteHostNamePtr; //remote ip
int     pingInterval;      //seconds
int     pingDataLength;    //max. 1024 Bytes
unsigned long count;       //number of pings to send
unsigned char pingstate;   //pin socket state, 1: open 0: closed

//statistics, filled by ping command
unsigned long transmitted; //sended ping requests
unsigned long received;    //received replies
unsigned int lastsenderr;  //last send error
unsigned int lastrcverr;   //last receive error
unsigned long maxRtt;      //Max round trip time, rounded off to 100ms steps
unsigned long minRtt;      //Minimum round trip time in milliseconds, (100 ms steps)
unsigned long lastRtt;     //round trip time (100 ms steps) of the last ping request/reply
}Ping;



/*****************************************************************************/
//Routing
/*****************************************************************************/
typedef struct tag_route_entry
{
     unsigned long destIPAddress;  //The IP address to add the route for
     unsigned long destNetmask;    //The netmask for the route
     unsigned long gateway;        //IP address of the gateway of the route
     int hops;                     //Number or routers between this host and route
}Route_Entry;
/*********************************************************************************/
/*
   SNMP MIB structures: Only available at BIOS version which contains SNMP MIB variables.
   Note: We don't have a SNMP agent inside of the BIOS but
   if an user is able to implement an own snmp agent at the IPC@Chip based at the
   TCPIP API, he needs access to TCPIP internal variables of these defined structures
*/
/********************************************************************************/
typedef struct tagIfMib     /*interface, only ethernet is supported*/
{
    long          ifIndex;        /* index of this interface  1 for ethernet, currently only ethernet*/
    char          ifDescr[32];    /* description of interface */
    long          ifType;         /* network device type  */
    long          ifMtu;          /* maximum transfer unit */
    unsigned long ifSpeed;        /* bandwidth in bits/sec    */
    unsigned char ifPhysAddress[11];  /* interface's address */
    unsigned char PhysAddrLen;    /* length of physAddr: 6 */
    long          ifAdminStatus;  /* desired state of interface, not supported */
    long          ifOperStatus;   /* current operational status, not supported  */
    //counters
    unsigned long   devLastChange;       /* value of sysUpTime when current state entered */
    unsigned long   devInOctets;         /* number of octets received on interface */
    unsigned long   devInUcastPkts;      /* number of unicast packets delivered */
    unsigned long   devInMulticastPkts;  /* number of multicast packets delivered, not supported */
    unsigned long   devInBroadcastPkts;  /*broadcasts delivered */
    unsigned long   devInDiscards;       /* number of broadcasts */
    unsigned long   devInErrors;         /* number of packets containing errors */
    unsigned long   devInUnknownProtos;  /* number of packets with unknown protocol */
    unsigned long   devOutOctets;        /* number of octets transmitted */
    unsigned long   devOutUcastPkts;     /* number of unicast packets sent */
    unsigned long   devOutMulticastPkts; /* number of multicast packets sent */
    unsigned long   devOutBroadcastPkts; /*broadcasts sent */
    unsigned long   devOutDiscards;      /* number of packets discarded with no error */
    unsigned long   devOutErrors;        /* number of pkts discarded with an error */
    unsigned long   devOutQLen;          /* number of packets in output queue */
}IfMib;


typedef struct tagIpMib
{
    long                ipForwarding;      /* 1: enabled  */
    long                ipDefaultTTL;      /* default TTL for pkts originating here */
    unsigned long       ipInReceives;      /* IP packets received from interfaces */
    unsigned long       ipInHdrErrors;     /* Pkts discarded due to header errors */
    unsigned long       ipInAddrErrors;    /* Pkts discarded due to bad address */
    unsigned long       ipForwDatagrams;   /* Pkts forwarded through this entity */
    unsigned long       ipInUnknownProtos; /* Local-addressed pkts w/unknown proto */
    unsigned long       ipInDiscards;      /* Error-free packets discarded */
    unsigned long       ipInDelivers;      /* Datagrams delivered to upper level */
    unsigned long       ipOutRequests;     /* IP datagrams originating locally */
    unsigned long       ipOutDiscards;     /* Error-free output IP pkts discarded */
    unsigned long       ipOutNoRoutes;     /* IP pkts discarded due to no route */
    long                ipReasmTimeout;    /* Seconds fragment is held awaiting reassembly */
    unsigned long       ipReasmReqds;      /* Fragments needing reassembly (here) */
    unsigned long       ipReasmOKs;        /* Number of fragments reassembled */
    unsigned long       ipReasmFails;      /* Number of failures in IP reassembly */
    unsigned long       ipFragOKs;         /* Number of datagrams fragmented here */
    unsigned long       ipFragFails;       /* Pkts unable to be fragmented here */
    unsigned long       ipFragCreates;     /* Number of IP fragments created here */
    unsigned long       ipRoutingDiscards;
} IpMib;


typedef struct tagIcmpMib
{
    unsigned long       icmpInMsgs;          /* Total of ICMP msgs received */
    unsigned long       icmpInErrors;        /* Total of ICMP msgs received with errors */
    unsigned long       icmpInDestUnreachs;
    unsigned long       icmpInTimeExcds;
    unsigned long       icmpInParmProbs;
    unsigned long       icmpInSrcQuenchs;
    unsigned long       icmpInRedirects;
    unsigned long       icmpInEchos;
    unsigned long       icmpInEchoReps;
    unsigned long       icmpInTimestamps;
    unsigned long       icmpInTimestampReps;
    unsigned long       icmpInAddrMasks;
    unsigned long       icmpInAddrMaskReps;
    unsigned long       icmpOutMsgs;
    unsigned long       icmpOutErrors;
    unsigned long       icmpOutDestUnreachs;
    unsigned long       icmpOutTimeExcds;
    unsigned long       icmpOutParmProbs;
    unsigned long       icmpOutSrcQuenchs;
    unsigned long       icmpOutRedirects;
    unsigned long       icmpOutEchos;
    unsigned long       icmpOutEchoReps;
    unsigned long       icmpOutTimestamps;
    unsigned long       icmpOutTimestampReps;
    unsigned long       icmpOutAddrMasks;
    unsigned long       icmpOutAddrMaskReps;
} IcmpMib;


typedef struct tagTcpMib
{
    long                tcpRtoAlgorithm;  /* retransmission timeout algorithm */
    long                tcpRtoMin;        /* minimum retransmission timeout (mS) */
    long                tcpRtoMax;        /* maximum retransmission timeout (mS) */
    long                tcpMaxConn;       /* maximum tcp connections possible */
    unsigned long       tcpActiveOpens;   /* number of SYN-SENT -> CLOSED transitions */
    unsigned long       tcpPassiveOpens;  /* number of SYN-RCVD -> LISTEN transitions */
    unsigned long       tcpAttemptFails;  /*(SYN-SENT,SYN-RCVD)->CLOSED or SYN-RCVD->LISTEN*/
    unsigned long       tcpEstabResets;   /* (ESTABLISHED,CLOSE-WAIT) -> CLOSED */
    unsigned long       tcpCurrEstab;     /* number in ESTABLISHED or CLOSE-WAIT state */
    unsigned long       tcpInSegs;        /* number of segments received */
    unsigned long       tcpOutSegs;       /* number of segments sent */
    unsigned long       tcpRetransSegs;   /* number of retransmitted segments */
    unsigned long       tcpInErrs;        /* number of received errors */
    unsigned long       tcpOutRsts;       /* number of transmitted resets */
} TcpMib;


typedef struct tagUdpMib
{
    unsigned long       udpInDatagrams; /* UDP datagrams delivered to users */
    unsigned long       udpNoPorts;     /* UDP datagrams to port with no listener */
    unsigned long       udpInErrors;    /* UDP datagrams unable to be delivered */
    unsigned long       udpOutDatagrams;/* UDP datagrams sent from this entity */
}UdpMib;

typedef struct tag_atEntry
{
    long           IfIndex;          /* interface on which this entry maps */
    unsigned char  PhysAddress[11];  /* physical address of destination */
    unsigned char  PhysAddressLen;   /* length of atPhysAddress */
    unsigned long  NetAddress;       /* IP address of physical address */
}atEntry;



typedef struct tag_UserDhcpEthEntry
{
    unsigned long   BootSIpAddress;      //BOOT Server (TFTP server), not supported
    unsigned long   Dns1ServerIpAddress; // Domain name server
    unsigned long   Dns2ServerIpAddress; // Second domain name server
    unsigned long   Yiaddr;              // Our (leased) IP address
    unsigned long   NetMask;             // Our subnet mask
    unsigned long   DefRouter;           // Default router
    unsigned long   DhcpServerId;        // DHCP selected server IP address
    unsigned long   internal1;           // Internal use only
    unsigned long   internal2;           // Internal use only
    unsigned long   DhcpLeaseTime;       // DHCP Address lease time in milliseconds
    unsigned long   internal3;           // internal use only
    unsigned long   internal4;           // internal use only
    unsigned char   DomainName[64];      // Domain name
    unsigned char   BootSname[64];       // TFTP server name, not used
    unsigned char   BootFileName[128];   // Boot file name (for TFTP download), not supported
    unsigned short  BootFileSize;        // Boot file size in 512 Bytes blocks (for TFTP download), not supported
    unsigned short  internal5;           // internal use only
}UserEthDhcp_Entry;


/*****************************************************************************/
//BSD Socket defines
/*****************************************************************************/

#define AF_INET  2
#define PF_INET  AF_INET

#define SOCK_STREAM     1       /* stream socket   , TCP*/
#define SOCK_DGRAM      2       /* datagram socket , UDP*/

/*****************************************************************************/
#define MSG_BLOCKING          0x0000  /*this message should be blocking */
#define MSG_TIMEOUT           0x0001  /*wake up from recv after we have timed out*/
#define MSG_DONTWAIT          0x0080  /* this message should be nonblocking */

/*****************************************************************************/
//API defines
/*****************************************************************************/

#define API_OPENSOCKET        0x01
#define API_CLOSESOCKET       0x02
#define API_BIND              0x03  /*assign an address to an unnamed socket,port*/
#define API_CONNECT           0x04  /* TCP client only, connect  */
#define API_RECVFROM          0x05  /* UDP recvfrom */
#define API_SENDTO            0x06  /* UDP sendto*/
#define API_HTONS             0x07
#define API_INETADDR          0x08
#define API_SLEEP             0x09
#define API_MALLOC            0x0A
#define API_FREE              0x0B
#define API_GETRCV_BYTES      0x0C
#define API_ACCEPT            0x0D  /* TCP server only  */
#define API_LISTEN            0x0E  /* TCP server only  */
#define API_SEND              0x0F  /* TCP  only  */
#define API_RECV              0x10  /* TCP  only  */
#define API_INETTOASCII       0x11
#define API_RESETCONNECTION   0x12  /* TCP  only  */
#define API_SETLINGER         0x13  /* TCP  only  */
#define API_SETREUSE          0x14  /* TCP server only */
#define API_SETIPTOS          0x15  /* set Type Of Service for a socket */
#define API_SETSOCKOPT        0x16  /* set socket options*/
#define API_GETSOCKOPT        0x17  /* get socket options*/
#define API_SETBLOCKINGMODE   0x18  /* set a socket in blocking or non blocking mode*/
#define API_REGISTERCALLBACK  0x19  /* register call back function on socket events*/
#define API_GET_SOCKETERROR   0x21  /* Get the last socket error */
#define API_GET_TCP_STATE     0x22  /* Only at @Chip-RTOS versions with SNMP support, get tcp state socket state*/

#define PPPCLIENT_INSTALLED   0x40
#define PPPCLIENT_OPEN        0x41
#define PPPCLIENT_CLOSE       0x42
#define PPPCLIENT_GET_STATUS  0x43
#define PPPCLIE_GET_DNSIP     0x44   /*Get DNS ip negotiated by the remote PPP server */
#define PPPCLIENT_SET_OPTIONS 0x45


//PPP server API calls
#define PPPSERVER_INSTALLED   0x50
#define PPPSERVER_SUSPEND     0x51
#define PPPSERVER_ACTIVATE    0x52
#define PPPSERVER_GET_STATUS  0x53
#define PPPSERVER_GET_CFG     0x54
#define PPPSERVER_SET_OPTIONS 0x55






//snmp
/*  Only available a BIOS versions, which includes SNMP access:
    Accesssing the tcpip internal snmp mibs
    Note: The IPC@Chip BIOS doesn't have a SNMP agent inside, but
    if an user is able to implement an own agent based at the TCPIP API,
    he needs access to the TCPIP internal snmp mib structures (defined above)
*/
#define  API_SNMP_GET           0x60



#define  API_FTP_GET_LOGIN          0x65   /*get addresses of FTP server login counters*/
#define  API_TELNET_GET_LOGIN       0x66   /*get addresses of Telnet server login counters*/
#define  API_GET_TELNET_STATE       0x67    /*get state of Telnet server 1:active, 0:closed*/





//Get list of installed servers and devices
#define GET_INSTALLED_SERVERS   0x70

//Reconfigure ethernet interface
#define  REINIT_ETHERNET        0x71

//DHCP usage
#define  DHCP_USE               0x72
#define  DHCP_STAT              0x73
#define  TCPIP_STATISTICS       0x74

//Ping API
#define  PING_OPEN              0x75
#define  PING_CLOSE             0x76
#define  PING_STATISTICS        0x77

//memory
#define  GET_MEMORY_INFO        0x78

#define  SET_SERVER_IDLE_TIMEOUT 0x79




//Routing
#define  ADD_DEFAULT_GATEWAY    0x80
#define  DEL_DEFAULT_GATEWAY    0x81
#define  GET_DEFAULT_GATEWAY    0x82
#define  ADD_STATIC_ROUTE       0x83
#define  DEL_STATIC_ROUTE       0x84


//IGMP
#define  ADD_IGMP_MEMBERSHIP       0x90
#define  DROP_IGMP_MEMBERSHIP      0x91
#define  MCASTIP_TO_MACADDR        0x92



/*****************************************************************************/
//Socket options
/*****************************************************************************/
//protocol levels
#define IP_PROTOIP_LEVEL        0       /* ip level     */
#define IP_PROTOTCP_LEVEL       6       /* tcp level    */
#define SOCKET_LEVEL        0x7fff      /* socket level */

//ip level options
#define IPO_TTL               0x0001    /* IP Time to live, default 64 seconds*/
#define IPO_TOS               0x0002    /*IP type of service , default 0*/

//tcp level options
#define TCP_NODELAY         0x0001  /* Disable/enable the nagle algorithm*/
#define TCP_NOPUSH          0x0004  /* Delay sending until a full segment is buffered*/
#define TCP_SLOW_START      0x0200  /* Disable/enable TCP slow start algorithm*/


#define TCP_KEEPALIVE       0x4001  /* Set idle time,before sending keepalive probes, default 7200 seconds*/
#define TCP_DELAY_ACK       0x4002  /* Set the TCP delay ack time in millseconds*/
#define TCP_KEEPALIVE_INTV  0x4004  /* Set keep alive interval probes (default 75 seconds) */
#define TCP_KEEPALIVE_CNT   0x4005  /* Set max. number of keep alive probes, before tcp gives up, default 12*/
#define TCP_FINWT2TIME      0x4006  /* Set the max. amount of time TCP will wait for the remote side to close, after it initiate a close*/
#define TCP_2MSLTIME        0x4007  /* Set the max. amount of time TCP will wait in the TIME WAIT state, once it has initiated a close*/
#define TCP_MAXRT           0x0010  /* Set the TCP/IP Timeout, OptionLength: 2 Bytes (INT) */
#define TCP_MAXREXMIT       0x4003  /* Set the Maximal TCP/IP Send retries, OptionLength: 2 Bytes (INT) */


//socket level options
#define SO_REUSEADDR       0x0004      /* allow local address reuse ,default 0 disable*/
#define SO_KEEPALIVE       0x0008      /* keep connections alive, default  0 disable*/
#define SO_SNDBUF          0x1001      /* send buffer size, default TCP 4096, UDP 2048 bytes */
#define SO_RCVBUF          0x1002      /* receive buffer size,default TCP 4096, UDP 2048 bytes */




/*****************************************************************************/
////socket call back function and event flags, TCP sockets only!!
/*****************************************************************************/

#define CB_CONNECT_COMPLT            0x0001   /*connection complete*/
#define CB_ACCEPT                    0x0002   /*remote has establ. a connection to our listening server*/
#define CB_RECV                      0x0004   /*incoming data arrived*/
#define CB_SEND_COMPLT               0x0010   /*sending of data has been acked by the peer*/
#define CB_REMOTE_CLOSE              0x0020   /*peer has shutdown the connection*/
#define CB_SOCKET_ERROR              0x0040   /*an error occured on the connection*/
#define CB_RESET                     0x0080   /*peer has sent a rest on the connection*/
#define CB_CLOSE_COMPLT              0x0100   /*close has been completed*/


/*****************************************************************************/
//PPP options
/*****************************************************************************/

//PPP Protocol levels
#define PPP_LCP_PROTOCOL      0x21c0
#define PPP_IPCP_PROTOCOL     0x2180

#define PPP_OPTION_WANT       0
#define PPP_OPTION_ALLOW      1


//PPP Protocol options

//LCP
#define PPP_LCP_ACCM           2
#define PPP_LCP_PROTO_COMP     7
#define PPP_LCP_ADDRCTRL_COMP  8

//IPCP
#define PPP_IPCP_COMP_PROTOCOL  2     /*VJ TCPIP Header compression*/
#define PPP_IPCP_DNS_PRI       29     /*Primary   DNS server IP*/
#define PPP_IPCP_DNS_SEC       31     /*Secondary DNS server IP*/




/*****************************************************************************/
//Errorcodes
/*****************************************************************************/
#define API_NOT_SUPPORTED       -2
#define API_ERROR               -1
#define API_ENOERROR             0

//PPP server states
#define PPPS_UNDEFINED      -1    /* Undefined, should not happen*/
#define PPPS_NOT_STARTED     0    /* PPP server was not started*/
#define PPPS_DISABLED        1    /* Server started, but disabled */
#define PPPS_ENABLED         2    /* Server enabled, not connected*/
#define PPPS_LNKUP           3    /* Connection established*/
#define PPPS_MODEMCLOSING    4    /* Server hangs up modem*/
#define PPPS_MODEMINIT       5    /* Server tries init modem*/



//PPP client states
#define PPP_NOTAVAIL    -1     /*Client is not running*/
#define PPP_LNKDOWN     0      /*Link is down*/
#define PPP_LNKWILLOPEN 1      /*open link in progress*/
#define PPP_LNKUP       2      /*Link is established*/



//PPP client errorcodes
#define PPP_INV_COMPORT  -1    /* invalid comport specified,
                                  this errorCode also occurs, if
                                  the pppclient is interrupted while dialing
                                  (e.g. user break with setting the flag modem_break
                                  at the struct pppclient_init
                                  or another modem error
                                */
#define PPP_INUSE        -2    /* ppp client already in use     */
#define PPP_INV_USER     -3    /* invalid user or password      */
#define PPP_OPEN_FAIL    -4    /* connection failed             */
#define PPP_INV_DEV      -5    /* pppclient interface not found */
#define PPP_IPCFG_FAIL   -6
#define PPP_CONNECT_FAIL -7


/*****************************************************************************/
#endif _TCPIP_API_H__
/*****************************************************************************/
//end tcpipapi.h
/***************************************************************************/
