/*
 *            Copyright (c) 1998-2003 by NETsilicon Inc.
 *
 *  This software is copyrighted by and is the sole property of 
 *  NETsilicon.  All rights, title, ownership, or other interests
 *  in the software remain the property of NETsilicon.  This
 *  software may only be used in accordance with the corresponding
 *  license agreement.  Any unauthorized use, duplication, transmission,  
 *  distribution, or disclosure of this software is expressly forbidden.
 *
 *  This Copyright notice may not be removed or modified without prior
 *  written consent of NETsilicon.
 *
 *  NETsilicon, reserves the right to modify this software
 *  without notice.
 *
 *  NETsilicon
 *  411 Waverley Oaks Road                  USA 781.647.1234
 *  Suite 304                               http://www.netsilicon.com
 *  Waltham, MA 02452                       AmericaSales@netsilicon.com
 *
 *************************************************************************/
/*
 * Edit History
 *
 * Date			Initials			Change Description
 *
 * 07/12/04		JZW					Removed function PPPSetModemAutoAnswerRings. This 
 *                                  function has been replaced by PPPSetModemAutoAnswer
 */


#ifndef __PPP_API_H
#define __PPP_API_H

#ifdef __cplusplus
extern "C"
{
#endif

/**
 * NET+OS PPP API error return code definitions
 *
 * @external
 * @category PPP
 * @since 6.0
 * @name PPP_CODES   "PPP Error Codes"
 *
 * @param	SUCCESS                         0
 * @param 	ERROR                          -1 
 * @param	UNIT_OUT_OF_RANGE               1
 * @param	MODEM_MISMATCH			2
 * @param	PPP_NOT_UP                      3
 * @param	TOO_MANY_RINGS                  4
 * @param	OPEN_PORT_ERROR                 5
 * @param	SET_BAUD_ERROR                  6
 * @param	PORT_NOT_OPEN                   7
 * @param	INIT_MODEM_ERROR                8
 * @param	CLOSE_PORT_ERROR                9
 * @param	DIAL_ERROR                      10
 * @param	ADD_ROUTE_ERROR                 11
 * @param	ADD_USR_PWD_ERROR               12
 * @param	DIAL_STRING_TOO_LONG            13
 * @param	INIT_STRING_TOO_LONG            14
 * @param 	NO_USERNAME                     15
 * @param 	NO_PASSWORD                     16
 * @param 	NO_HOSTNAME                     17
 * @param 	NO_SECRET                       18
 * @param 	NULL_POINTER_ERROR              19
 * @param 	MODEM_NOT_ASSIGNED              20
 * @param 	SYSTEM_RESOURCE_ERROR           21
 * @param 	INVALID_AUTHENTICATION          22
 * @param 	INVALID_CONNECTION_MODE         23
 * @param 	INVALID_IP_PARAMETERS           24
 * @param 	DELETE_ROUTE_ERROR              25
 * @param 	GET_ADDRESS_ERROR               26
 * @param 	LCP_SET_OPTIONS_ERROR           27
 * @param 	IPCP_SET_OPTIONS_ERROR          28
 * @param 	DEL_USR_ERROR                   29
 * @param 	SET_AUTH_INFO_ERROR             30
 * @param   SET_ADDRESS_ERROR               31
 */

#define	SUCCESS                         0
#define ERROR                          -1 
#define	UNIT_OUT_OF_RANGE               1
#define	MODEM_MISMATCH                  2
#define	PPP_NOT_UP                      3
#define	TOO_MANY_RINGS                  4
#define	OPEN_PORT_ERROR                 5
#define	SET_BAUD_ERROR                  6
#define	PORT_NOT_OPEN                   7
#define	INIT_MODEM_ERROR                8
#define	CLOSE_PORT_ERROR                9
#define	DIAL_ERROR                      10
#define	ADD_ROUTE_ERROR                 11
#define	ADD_USR_PWD_ERROR               12
#define	DIAL_STRING_TOO_LONG            13
#define	INIT_STRING_TOO_LONG            14
#define NO_USERNAME                     15
#define NO_PASSWORD                     16
#define NO_HOSTNAME                     17
#define NO_SECRET                       18
#define NULL_POINTER_ERROR              19
#define MODEM_NOT_ASSIGNED              20
#define SYSTEM_RESOURCE_ERROR           21
#define INVALID_AUTHENTICATION          22
#define INVALID_CONNECTION_MODE         23
#define INVALID_IP_PARAMETERS           24
#define DELETE_ROUTE_ERROR              25
#define GET_ADDRESS_ERROR               26
#define LCP_SET_OPTIONS_ERROR           27
#define IPCP_SET_OPTIONS_ERROR          28
#define DEL_USR_ERROR                   29
#define SET_AUTH_INFO_ERROR             30
#define SET_ADDRESS_ERROR               31

/**
 * PPP CommPorts
 *
 *
 * PPP_COMPORT1 is COM1 otherwise known as "/com/0" 
 * PPP_COMPORT2 is COM2 otherwise known as "/com/1" 
 *
 * @external
 * @category PPP
 * @since 6.0
 * @name PPP_COMPORTS    "PPP Serial Ports"
 *
 * @param PPP_COMPORT1            0
 * @param PPP_COMPORT2            1
 */
#define PPP_COMPORT1            0
#define PPP_COMPORT2            1

/* Adds a routing entry to the IP stack's routing table */
int PPPAddRoute(unsigned long destination, unsigned long mask, unsigned long gateway, int commPort);

/* Checks the status of the PPP link on PPP interface #unit */
int PPPCheckLink(unsigned int commPort);

/* Hangs up the phone line connected to serial port #unit and resets the modem 
 * Closes serial port #unit and terminates all communications between the serial
 * port and the modem */

int PPPModemClose(unsigned int commPort);

/* Opens and initializes serial port #unit to the specified baud rate and initializes the modem */
int PPPModemInit(unsigned int commPort, unsigned int mode, unsigned int baud, char * init_string);

/* Closes serial port #unit */
int PPPSerialClose(unsigned int commPort);

/**
 * Opens and initializes serial port #unit to the specified baud rate
 *
 * @external
 * @category PPP
 * @since 6.0
 * @name PPP_OPERATION_MODES    "PPP Connection Activation Modes"
 * 
 * @param PASSIVE_CONNECTION_MODE     1
 * @param ACTIVE_CONNECTION_MODE      2
 */
#define PASSIVE_CONNECTION_MODE     1
#define ACTIVE_CONNECTION_MODE      2
int PPPSerialInit(unsigned int commPort, unsigned int mode, unsigned int baud);

/**
 * Sets PPP interface #unit to require CHAP or PAP authentication
 *
 * @external
 * @category PPP
 * @since 6.0
 * @name PPP_INTERFACE    "PPP Authentication Options"
 *
 * @param REQUIRE_PAP              1
 * @param REQUIRE_CHAP             2
 * @param ACCEPT_PAP               4
 * @param ACCEPT_CHAP              8
 * @param PAP_AUTHENTICATION       REQUIRE_PAP
 * @param CHAP_AUTHENTICATION      REQUIRE_CHAP 
 */

#define REQUIRE_PAP              1
#define REQUIRE_CHAP             2
#define ACCEPT_PAP               4
#define ACCEPT_CHAP              8
#define PAP_AUTHENTICATION       REQUIRE_PAP
#define CHAP_AUTHENTICATION      REQUIRE_CHAP

/* Deprecated */
int PPPSetAuthentication(unsigned int commPort, char * papname, char * pappassword, char * chapname, char * chapsecret, int authentication);

/* Sets the PPP interface for authentication using the CHAP or PAP protocols.
   Also sets the specified PPP interface's PAP username / password and CHAP ID / secret-key pairs. */
int PPPSetAuth(unsigned int commPort, char * papname, char * pappassword, char * chapname, char * chapsecret, int authentication);

/* Same as PPPSetAuth, but with device name to be used by PPPoE */ 
int PPPDeviceSetAuth(char *devname, char * papname, char * pappassword, char * chapname, char * chapsecret, int authentication);

/**
 * Configures PPP interface #unit as a direct serial or modem connection
 *
 * @external
 * @category PPP
 * @since 6.0
 * @name PPP_MODES    "PPP Connection Type"
 *
 * @param PPP_DIRECT_SERIAL_MODE      0
 * @param PPP_MODEM_MODE              1
 */

#define PPP_DIRECT_SERIAL_MODE      0
#define PPP_MODEM_MODE              1

int PPPCreateDevice (unsigned int commPort, unsigned int mode, unsigned int ipAddress,unsigned int subnetMask);



/* Sets the ring count before the modem answers an incoming call */
int PPPSetModemAutoAnswer(unsigned int commPort, unsigned int auto_answer_rings);

/* Deprecated */
int PPPSetModemDialString(char * dial_string);

/* Set modem dial string */
int PPPSetModemDialStr(unsigned int commPort, char * dial_string);

/* When using PPP as a dial in server, use this function to specify the IP */
/* address PPP interface #unit assigns to the dial-up client through IPCP  */
int PPPSetPeerAddr(unsigned int commPort, unsigned long IPaddr);

/**
 * Enables or disables Van Jacobson Compression (or IP header compression).  By default, VJ Compression is enabled
 *
 * @external
 * @category PPP
 * @since 6.0
 * @name PPP_VJ_COMPRESSION    "PPP Van Jacobson Compression"
 *
 * @param DISABLE_VJ_COMPRESSION  0
 * @param ENABLE_VJ_COMPRESSION   1
 */

#define DISABLE_VJ_COMPRESSION  0
#define ENABLE_VJ_COMPRESSION   1
int PPPSetVJ(unsigned int commPort, int require_VJ);


/*  Gets Server assigned IP address  */

int PPPGetPeerAssignedAddress (unsigned int commPort, unsigned long *ipAddress);


/* Delete a routing table entry */

int PPPDelRoute(unsigned long destination, unsigned long mask) ;

#ifdef __cplusplus
}
#endif

#endif
