RemkoEB
asked on
Converting C headers to delphi
I have 2 headers of the Cisco VPN Client API which I'd like to convert to Delphi. I tried to do this myself but I'm getting stuck (I don't know c).
Below my code so far and the original headers. Who can help?
unit VPNAPI;
interface
uses Windows, WinSock;
{$IFNDEF VPNAPI_H}
{$DEFINE VPNAPI_H}
const
DLL_EXPORT_NAME = __declspec(dllexport);
VPNAPI_VERSION = $00010000;
VPN_OK:LongWord = 0;
VPN_ERROR:LongWord = -1;
VPN_ERROR_BAD_PARAM::LongW ord = -2;
VPN_ERROR_NOT_A_PROFILE: :LongWord = -3;
VPN_ERROR_IPC_FAILURE: = -4;
VPN_ERROR_OUT_OF_MEMORY:Lo ngWord = -5;
VPN_ERROR_SERVICE_NOT_RUNN ING:LongWo rd = -6;
VPN_ERROR_SERVICE_SHUTTING _DOWN:Long Word = -7;
VPN_ERROR_NOT_CONNECTED:Lo ngWord = -8;
VPN_ERROR_ALREADY_CONNECTI NG:LongWor d = -9;
VPN_ERROR_ALREADY_CONNECTE D:LongWord = -10;
VPN_ERROR_CONNECT_ABORTED: LongWord = -11;
VPN_ERROR_NO_PPPTOOL:LongW ord = -12;
VPN_ERROR_DRIVER_FAIL:Long Word = -13;
VPN_ERROR_NO_MORE_BACKUPS: LongWord = -14;
VPN_ERROR_PPP_FAIL:LongWor d = -15;
VPN_ERROR_CTCP_FAIL:LongWo rd = -16;
VPN_ERROR_IKE_FAIL:LongWor d = -17;
VPN_ERROR_HOSTNAME_LOOKUP_ FAIL:LongW ord = -18;
VPN_ERROR_USER_CANCELLED_A UTH:LongWo rd = -19;
VPN_ERROR_SA_EXPIRED:LongW ord = -20;
VPN_ERROR_PEER_NOT_RESPOND ING:LongWo rd = -21;
VPN_ERROR_LOAD_BALANCING:L ongWord = -22;
VPN_ERROR_IKE_NEG_FAILED:L ongWord = -23;
VPN_ERROR_DUPLICATE_EXISTS :LongWord = -25;
VPN_ERROR_NO_CLIENT_EXTENS IONS:LongW ord = -26;
VPN_ERROR_USER_AUTH_FAILED :LongWord = -27;
VPN_ERROR_FIREWALL_NO_LONG ER_RUNNING :LongWord = -28;
VPN_ERROR_UNABLE_TO_CONFIG URE_FIREWA LL:LongWor d = -29;
VPN_ERROR_UPDATE_CERT_FAIL ED:LongWor d = -30;
VPN_ERROR_ADDRESS_CHANGE:L ongWord = -31;
VPN_ERROR_AUTH_PHASE_ERROR :LongWord = -32;
VPN_ERROR_BY_ERROR:LongWor d = -33;
VPN_ERROR_BY_ADMIN_COMMAND :LongWord = -34;
VPN_ERROR_BY_EXPIRED_LIFTI ME:LongWor d = -35;
VPN_ERROR_SERVER_SHUTDOWN: LongWord = -36;
VPN_ERROR_SERVER_IN_FLAMES :LongWord = -37;
VPN_ERROR_MAX_CONNECT_TIME :LongWord = -38;
VPN_ERROR_IDLE_TIMEOUT:Lon gWord = -39;
VPN_ERROR_SERVER_REBOOT:Lo ngWord = -40;
VPN_ERROR_PHASE2_PROPOSAL_ MISMATCH:L ongWord = -41;
VPN_ERROR_FIREWALL_MISMATC H:LongWord = -42;
VPN_ERROR_CERT_EXPIRED:Lon gWord = -43;
VPN_ERROR_PLATFORM_VERSION _MISMATCH: LongWord = -44;
VPN_ERROR_ZONE_FIREWALL_SE RVER_FAIL: LongWord = -45;
VPN_ERROR_NO_ERROR:LongWor d = -46;
VPN_ERROR_DEL_REASON_UNSPE CIFIED:Lon gWord = -47;
VPN_ERROR_AUTOUPDATE_SHUTD OWN:LongWo rd = -48;
VPN_MSGTYPE_AUTH = (1<<1);
VPN_MSGTYPE_STATE_CHANGE = (1<<2);
VPN_MSGTYPE_MASK = (VPN_MSGTYPE_AUTH | VPN_MSGTYPE_STATE_CHANGE);
VPN_AUTH_MESSAGE = (1<<0);
VPN_AUTH_USERNAME = (1<<1);
VPN_AUTH_PASSWORD = (1<<2);
VPN_AUTH_PASSCODE = (1<<3);
VPN_AUTH_ANSWER = (1<<4);
VPN_AUTH_NEXTPIN = (1<<5);
VPN_AUTH_NEXTPASSWORD = (1<<6);
VPN_AUTH_DOMAIN = (1<<7);
VPN_AUTH_PIN = (1<<8);
VPN_AUTH_TOKENCODE = (1<<9);
VPN_AUTH_MASK = (VPN_AUTH_MESSAGE, VPN_AUTH_USERNAME, VPN_AUTH_PASSWORD, VPN_AUTH_PASSCODE, VPN_AUTH_ANSWER, VPN_AUTH_NEXTPIN, VPN_AUTH_NEXT_PASSWORD , VPN_AUTH_DOMAIN, VPN_AUTH_PIN , VPN_AUTH_TOKENCODE);
VPN_STATGROUP_COUNTERS = (1<<0);
VPN_STATGROUP_TUNNEL_INFO = (1<<1);
VPN_STATGROUP_ROUTES = (1<<2);
VPN_STATGROUP_PROFILE = (1<<3);
VPN_STATGROUP_MASK = (VPN_STATGROUP_COUNTERS, VPN_STATGROUP_TUNNEL_INFO, VPN_STATGROUP_ROUTES, VPN_STATGROUP_PROFILE);
VPN_OPT_SILENT_DISCONNECT = (1<<0);
VPN_OPT_MASK = (VPN_OPT_SILENT_DISCONNECT );
type
vpn_error_t = INT32_T;
vpn_state_t = (VPN_MIN_STATE, VPN_STATE_IDLE, VPN_STATE_WAIT_PPP, VPN_STATE_WAIT_CTCP, VPN_STATE_WAIT_PHASE1, VPN_STATE_WAIT_AUTH, VPN_STATE_WAIT_MODECFG, VPN_STATE_WAIT_PHASE2, VPN_STATE_CONNECTED, VPN_MAX_STATE);
vpn_crypto_t = (VPN_MIN_CRYPTO_ALG, VPN_CRYPTO_DES, VPN_CRYPTO_3DES, VPN_CRYPTO_NULL, VPN_CRYPTO_AES, VPN_MAX_CRYPTO_ALG);
vpn_compress_t =(VPN_MIN_COMPRESS_ALG, VPN_COMPRESS_NONE, VPN_COMPRESS_LZS, VPN_MAX_COMPRESS_ALG);
vpn_nat_mode_t = (VPN_MIN_NAT_MODE, VPN_NAT_NONE, VPN_NAT_IPSEC_OVER_UDP, VPN_NAT_IPSEC_OVER_CTCP, VPN_MAX_NAT_MODE);
vpn_channel_t = Pointer;
vpn_stats_t = Pointer;
vpn_auth_t = Pointer;
type
vpn_route = record
network: VPN_IP_ADDR_T;
mask: VPN_IP_ADDR_T;
bytes: UINT32_T;
haskeys: UINT16_T;
reserved: Array[0..2-1] of UINT32_T;
end {vpn_route};
type
vpn_routes = record
num_routes: UINT32_T;
reserved: Array[0..2-1] of UINT32_T;
routes: Array[0..-1] of VPN_ROUTE;
end {vpn_routes};
{///! IPSec traffic statistics }
type
vpn_counters = packed record
time_connected: LongWord;
total_bytes: LongWord;
bytes_sent: LongWord;
bytes_recieved: LongWord;
packets_transformed: LongWord;
packets_encrypted: LongWord;
packets_decrypted: LongWord;
packets_bypassed: LongWord;
packets_discarded: LongWord;
reserved[2]:LongWord;
end {vpn_counters};
{///! basic information about a VPN tunnel }
type
vpn_tunnel_info = record
{///! address of client on the internal network }
internal_addr: VPN_IP_ADDR_T;
{///! address of currently connected headend }
peer_addr: VPN_IP_ADDR_T;
{///! non-zero if the exclude local lan feature is enabled }
local_lan_enabled: UINT8_T;
{///! nat pass through mode }
nat_mode: VPN_NAT_MODE_T;
{///! UDP or TCP port number used for nat passthrough }
nat_port: UINT16_T;
{///! encryption algorithm used for securing IPSec traffic }
crypto_algorithm: VPN_CRYPTO_T;
{///! encryption key length, in bytes }
crypto_key_length: UINT16_T;
{///! hash algorithm used for securing IPSec traffic }
hash_algorithm: VPN_HASH_T;
{///! IP compression algorithm }
compress_algorithm: VPN_COMPRESS_T;
reserved: Array[0..2-1] of UINT32_T;
end {vpn_tunnel_info};
{///! }
type
vpn_connect_error = record
error: VPN_ERROR_T;
is_remote: UINT32_T;
delete_reason: PChar;
reserved: Array[0..2-1] of UINT32_T;
end {vpn_connect_error};
{+//@}*/ }
{$IFNDEF VPN_API_DATATYPES_ONLY}
{+//* }
{-* \defgroup callbacks Callback Functions }
{= }
{+//@{*/ }
{///! callback for vpn_connect() results }
{+//! }
{-* \param error error code from the vpn_connect() attempt. }
{-* \param banner is a user displayable string that contains the login }
{-* banner that the headend's administrator requires all users to }
{-* acknowledge before connecting. }
{= }
type
(*vpn_connect_cb) (const vpn_connect_error*, const char*banner); = void;
}: ///! CALLBACK FOR VPN_DISCONNECT() RESULT;
{+//! }
{-* \param error error code from the vpn_disconnect() attempt }
{= }
error): TYPEDEF VOID (*VPN_DISCONNECT_CB) (VPN_ERROR_T;
{///! state transition callback }
{+//! }
{-* \param state new state of the vpn connection. }
{-* \param peer address of current headend. This may change during a }
{-* connection attempt due to load balancing or backup servers. }
{-* \param error when a state change happens because a connection }
{-* attempt failed, this value will indicate the reason for the }
{-* failure }
{= }
state, const vpn_ip_addr_t* peer, const struct vpn_connect_error* ): TYPEDEF VOID (*VPN_STATE_CHANGE_CB) (VPN_STATE_T;
{///! callback for vpn_get_stats() results }
{+//! }
{-* \param error error code from the vpn_get_stats() attempt. }
{-* \param statgroups bitmask of VPN_STATGROUPS_ flags indicating which }
{-* portions of the stats are available. }
{-* \param stats handle used for accessing the various stats structures. }
{-* This variable may be used only inside of this callback function. }
{= }
error, uint32_t stats_groups, vpn_stats_t stats): TYPEDEF VOID (*VPN_STATS_CB) (VPN_ERROR_T;
{///! callback for authentication }
{+//! }
{-* \param auth handle for accessing authentication attributes. }
{-* This variable may be used until vpn_auth_respond() or }
{-* vpn_auth_abort() is called, or vpn_auth_stop_cb() is }
{-* recieved. }
{-* \param auth_attrs bitmask of VPN_AUTH flags indicating which }
{-* authentication attributes were requested by the headend }
{-* \param allowed_save_attrs bitmask of VPN_AUTH flags indicating which }
{-* authentication can be saved in the profile. See the save_attrs }
{-* argument to vpn_auth_respond() }
{-* \param profile_name }
{= }
auth, uint32_t auth_attrs, uint32_t allowed_save_attrs, const char*profile_name): TYPEDEF VOID (*VPN_AUTH_CB) (VPN_AUTH_T;
{///! callback to cancel authentication }
{+//! }
{-* This callback is called to cancel any in-progress user authentication. }
{-* All authentication user interfaces should be closed, and any state }
{-* related to the authentication attempt should be destroyed. }
{= }
(void): TYPEDEF VOID (*VPN_AUTH_STOP_CB);
{///! structure for passing callback functions to the vpnapi }
{+//! }
{= }
{///! vpn_connect() callback }
fp_connect: VPN_CONNECT_CB;
{///! vpn_disconnect() callback }
fp_disconnect: VPN_DISCONNECT_CB;
{///! state change callback }
fp_state_change: VPN_STATE_CHANGE_CB;
{///! vpn_get_stats() callback }
fp_stats: VPN_STATS_CB;
{///! authentication callback }
fp_auth: VPN_AUTH_CB;
{///! authentication stop callback }
fp_auth_stop: VPN_AUTH_STOP_CB;
end {vpn_connect_error};
{+//@}*/ }
{+//! }
{-* \defgroup global Global Initialization Functions }
{= }
{+//@{*/ }
{///! must be called before any other api functions are called. }
{+//! }
{-* \param version On input this should be set to VPNAPI_VERSION. }
{-* On output it will be set to the version number supported in }
{-* the shared library. }
{= }
var
vpn_api_init: function(version: PUINT32_T): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! call when done issuing api calls }
var
vpn_api_destroy: function: DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{+//@}*/ }
{+//! }
{-* \defgroup channel_functions Communications Channel Functions }
{-* types of messages that client wants to send/recieve }
{= }
{+//@{*/ }
{///! initialize a communications channel to the VPN service component }
{+//! }
{-\param channel will be set by this function }
{-\param msgtypes should be set to some of flags above. On return, it will }
{-be set to the VPN_MSGTYPEs that can actually be sent. }
{-\param callbacks should be initialized with pointers to the callback }
{-funcitons you want to use }
{= }
var
vpn_channel_init: function(var channel: VPN_CHANNEL_T;
var msgtypes: UINT32_T;
const callbacks: PVPN_CALLBACK_TABLE): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! destroy the communictations channel }
{+//! }
{-\param channel will be destroyed by this function. }
{= }
var
vpn_channel_destroy: function(channel: VPN_CHANNEL_T): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! retreives a OS-level descriptor for the channel. }
{+//! This descriptor should only be used to initialize an event loop, either }
{-* with select(), WaitForMultipleObjects() or similar functions }
{-* \param channel }
{-* \returns a socket descriptor }
{= }
var
vpn_channel_get_socket: function(channel: VPN_CHANNEL_T): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! event handling function }
{+//! call this function when the socket from vpn_channel_get_socket() becomes }
{-* readable. All calls to callback functions will be made from within }
{-* this function. }
{-* \param channel }
{= }
var
vpn_channel_event: function(channel: VPN_CHANNEL_T): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! simplified event handling function }
{+//! this function implements a simple event loop, which calls }
{-* vpn_channel_event(). }
{-* }
{-* this function. }
{-* \param channel }
{-* \param max_wait maximum time to wait for events. }
{= }
var
vpn_process_events: function(channel: VPN_CHANNEL_T;
max_wait: Word): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! retrieve msgtypes flags that were set in call to vpn_channel_init() }
{+//! }
{-* \param channel }
{-* \returns a bitmask of VPN_MSGTYPES }
{= }
var
vpn_channel_get_msgtypes: function(channel: VPN_CHANNEL_T): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{+//@}*/ }
{+//* }
{-* \defgroup command_functions Command functions }
{-* types of messages that client wants to send/recieve }
{= }
{+//@{*/ }
{///! try to connect using a given profile. }
{+//! }
{-* \param channel the channel to use for sending the command }
{-* \param profile the name of the profile }
{-* \param group_name the name of the profile. May be NULL if the }
{-* group name is saved in the profile }
{-* \param password is the group password or the certificate password, }
{-* depending on the setting of AuthType value in the profile. }
{-* may be NULL if the group password is saved in the profile. }
{-* \param option_flags bitmask of VPN_OPT_* flags. }
{-* }
{-* Calling this function will cause fp_connect to be called when the }
{-* connection attempt suceeds. Additionally, fp_stats will be called }
{-* for state changes during the connection attempt and fp_auth/fp_auth_stop }
{-* will be called to handle authentication. }
{= }
var
vpn_connect: function(channel: VPN_CHANNEL_T;
const profile: PChar;
const group_name: PChar;
const password: PChar;
option_flags: UINT32_T): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! used to return users response to the banner given in vpn_connect_cb() }
{+//! }
{-* \param channel }
{-* \param banner_accepted TRUE if the user agrees to the banner, }
{-* FALSE if the user disagrees. }
{= }
var
vpn_acknowledge_banner: function(channel: VPN_CHANNEL_T;
banner_accepted: Integer): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! disconnect the vpn tunnel. }
{+//! causes fp_disconnect to be called with the result of the disconnect }
{-* attempt. No VPN_MSGTYPE flag is needed to send. }
{= }
var
vpn_disconnect: function(channel: VPN_CHANNEL_T): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! request statistics to be sent }
{+//! causes fp_statistics to be called. no mstype needed to send. }
{-* \param channel }
{-* \param stats_groups flags describing which statistics to send. }
{-* use VPN_STATGROUP flags }
{= }
var
vpn_get_stats: function(channel: VPN_CHANNEL_T;
stats_groups: UINT32_T): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! Reset byte and packet counts in the statistics }
{+//! no mstype needed to send. }
{-* \param channel }
{= }
var
vpn_reset_stats: function(channel: VPN_CHANNEL_T): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! reply to a fp_auth callback. }
{+//! }
{-* This function is called to pass back authentication attributes }
{-* to the headend. msgtype VPN_MSGTYPE_AUTH is needed to send. }
{-* \param channel }
{-* \param auth }
{-* \param save_attrs a bitmask of VPN_AUTH flags indicating which }
{-* attributes should be saved in the profile. Attributes }
{-* that were not set in the allowed_save_attrs argument }
{-* to vpn_auth_cb will be ignored. }
{= }
var
vpn_auth_respond: function(channel: VPN_CHANNEL_T;
auth: VPN_AUTH_T;
save_attrs: UINT32_T): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! negative reply to a fp_auth callback. }
{+//! }
{-* This function is called to cancel an authentication attempt. }
{-* msgtype VPN_MSGTYPE_AUTH is needed to send. }
{-* \param channel }
{-* \param auth }
{= }
var
vpn_auth_abort: function(channel: VPN_CHANNEL_T;
auth: VPN_AUTH_T): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{+//@}*/ }
{+//* }
{-* \defgroup stats_functions Statistics Functions }
{-* Functions for accessing components of vpn_stats_t. These functions }
{-* should only be used inside of your vpn_stats_cb. The memory }
{-* returned by these functions is only valid in your vpn_stats_cb }
{-* function. If need to use the data returned outside of this function, }
{-* you should make a copy of the data. }
{= }
{+//@{*/ }
{///! returns list of local networks excluded from the VPN tunnel }
type
const vpn_routes*vpn_stats_get_l ocal_lan_r outes(vpn_ stats_t stats); = DLL_EXPORT_NAME;
}: ///! RETURNS LIST OF NETWORKS INCLUDED IN THE VPN TUNNEL;
stats): DLL_EXPORT_NAME CONST VPN_ROUTES*VPN_STATS_GET_S ECURE_ROUT ES(VPN_STA TS_T;
{///! returns basic information about the VPN tunnel }
stats): DLL_EXPORT_NAME CONST VPN_TUNNEL_INFO*VPN_STATS_ GET_TUNNEL _INFO(VPN_ STATS_T;
{///! returns traffic information about the VPN tunnel }
stats): DLL_EXPORT_NAME CONST VPN_COUNTERS*VPN_STATS_GET _COUNTERS( VPN_STATS_ T;
{///! returns the name of the profile used for the current VPN tunnel }
stats): DLL_EXPORT_NAME CONST CHAR*VPN_STATS_GET_PROFILE _NAME(VPN_ STATS_T;
{+//@}*/ }
{+//* }
{-* \defgroup auth_functions Authentication Functions }
{-* Functions for accessing components of vpn_auth_t. These functions }
{-* should only be used inside of your vpn_stats_cb }
{= }
{+//@{*/ }
{+//! }
{-\param auth authentication handle passed to vpn_auth_cb }
{-\param auth_attr the authentication attribute to get }
{= }
auth, uint32_t auth_attr): DLL_EXPORT_NAME CONST CHAR*VPN_AUTH_GET_ATTRIBUT E(VPN_AUTH _T;
{+//! }
{-\param auth authentication handle passed to vpn_auth_cb }
{-\param auth_attr the authentication attribute to set }
{-\param value new value for the attribute. }
{= }
auth, uint32_t auth_attr, const char*value): DLL_EXPORT_NAME VPN_ERROR_T VPN_AUTH_SET_ATTRIBUTE(VPN _AUTH_T;
{$IFDEF _WIN32}
vpn_get_service_start_even t(void): DLL_EXPORT_NAME HANDLE;
{$ENDIF}
{$ENDIF //VPN_API_DATATYPES_ONLY}
{+//@}*/ }
{$IFDEF _MSC_VER}
{+// re-enable warning: }
{-nonstandard extension used: zero-sized array in struct/union }
{= }
{ #pragma warning( default: 4200 ) }
{$ENDIF}
{$IFDEF __cplusplus}
{///*INDENT-OFF* }
end {};
{$ENDIF}
{$ENDIF // VPNAPI_H}
var
DLLLoaded: Boolean { is DLL (dynamically) loaded already? }
{$IFDEF WIN32} = False; {$ENDIF}
implementation
var
SaveExit: pointer;
DLLHandle: THandle;
{$IFNDEF MSDOS}
ErrorMode: Integer;
{$ENDIF}
procedure NewExit; far;
begin
ExitProc := SaveExit;
FreeLibrary(DLLHandle)
end {NewExit};
procedure LoadDLL;
begin
if DLLLoaded then Exit;
{$IFNDEF MSDOS}
ErrorMode := SetErrorMode($8000{SEM_NoO penFileErr orBox});
{$ENDIF}
DLLHandle := LoadLibrary('VPNAPI.DLL');
if DLLHandle >= 32 then
begin
DLLLoaded := True;
SaveExit := ExitProc;
ExitProc := @NewExit;
@vpn_api_init := GetProcAddress(DLLHandle,' vpn_api_in it');
{$IFDEF WIN32}
Assert(@vpn_api_init <> nil);
{$ENDIF}
@vpn_api_destroy := GetProcAddress(DLLHandle,' vpn_api_de stroy');
{$IFDEF WIN32}
Assert(@vpn_api_destroy <> nil);
{$ENDIF}
@vpn_channel_init := GetProcAddress(DLLHandle,' vpn_channe l_init');
{$IFDEF WIN32}
Assert(@vpn_channel_init <> nil);
{$ENDIF}
@vpn_channel_destroy := GetProcAddress(DLLHandle,' vpn_channe l_destroy' );
{$IFDEF WIN32}
Assert(@vpn_channel_destro y <> nil);
{$ENDIF}
@vpn_channel_get_socket := GetProcAddress(DLLHandle,' vpn_channe l_get_sock et');
{$IFDEF WIN32}
Assert(@vpn_channel_get_so cket <> nil);
{$ENDIF}
@vpn_channel_event := GetProcAddress(DLLHandle,' vpn_channe l_event');
{$IFDEF WIN32}
Assert(@vpn_channel_event <> nil);
{$ENDIF}
@vpn_process_events := GetProcAddress(DLLHandle,' vpn_proces s_events') ;
{$IFDEF WIN32}
Assert(@vpn_process_events <> nil);
{$ENDIF}
@vpn_channel_get_msgtypes := GetProcAddress(DLLHandle,' vpn_channe l_get_msgt ypes');
{$IFDEF WIN32}
Assert(@vpn_channel_get_ms gtypes <> nil);
{$ENDIF}
@vpn_connect := GetProcAddress(DLLHandle,' vpn_connec t');
{$IFDEF WIN32}
Assert(@vpn_connect <> nil);
{$ENDIF}
@vpn_acknowledge_banner := GetProcAddress(DLLHandle,' vpn_acknow ledge_bann er');
{$IFDEF WIN32}
Assert(@vpn_acknowledge_ba nner <> nil);
{$ENDIF}
@vpn_disconnect := GetProcAddress(DLLHandle,' vpn_discon nect');
{$IFDEF WIN32}
Assert(@vpn_disconnect <> nil);
{$ENDIF}
@vpn_get_stats := GetProcAddress(DLLHandle,' vpn_get_st ats');
{$IFDEF WIN32}
Assert(@vpn_get_stats <> nil);
{$ENDIF}
@vpn_reset_stats := GetProcAddress(DLLHandle,' vpn_reset_ stats');
{$IFDEF WIN32}
Assert(@vpn_reset_stats <> nil);
{$ENDIF}
@vpn_auth_respond := GetProcAddress(DLLHandle,' vpn_auth_r espond');
{$IFDEF WIN32}
Assert(@vpn_auth_respond <> nil);
{$ENDIF}
@vpn_auth_abort := GetProcAddress(DLLHandle,' vpn_auth_a bort');
{$IFDEF WIN32}
Assert(@vpn_auth_abort <> nil);
{$ENDIF}
end
else
begin
DLLLoaded := False;
{ Error: VPNAPI.DLL could not be loaded !! }
end;
{$IFNDEF MSDOS}
SetErrorMode(ErrorMode)
{$ENDIF}
end {LoadDLL};
begin
LoadDLL;
end.
Here are the header files:
vpnapi.h:
/*
note: the comments in this header file are used for automatic
documentation generation using doxygen (www.doxygen.org)
*/
#ifndef VPNAPI_H
#define VPNAPI_H
#ifdef __cplusplus
// *INDENT-OFF*
extern "C"
{
// *INDENT-ON*
#endif
#ifdef _WIN32
#include "windows_stdint.h"
#include <winsock.h>
#else
#include <inttypes.h>
#include <sys/types.h>
#include <netinet/in.h>
#endif
#ifdef _MSC_VER
/* disable warning:
nonstandard extension used: zero-sized array in struct/union
*/
#pragma warning( disable : 4200 )
#endif
#ifdef _WIN32
#define DLL_EXPORT_NAME __declspec(dllexport)
#else
typedef int SOCKET;
#define DLL_EXPORT_NAME
#endif
//! API version number
#define VPNAPI_VERSION 0x00010000
/**
* \defgroup constants Constants
*/
/*@{*/
/**
* \defgroup error_codes Error Codes
*/
/*@{*/
//! not an error
#define VPN_OK (0L)
#define VPN_ERROR (-1L)
//error codes are all preliminary and will be added/delete as
//the API is implemented.
//! input parameter has bad value
#define VPN_ERROR_BAD_PARAM (-2L)
//! profile name doesn't match an existing profile
#define VPN_ERROR_NOT_A_PROFILE (-3L)
//! interprocess communcation subsystem failed
#define VPN_ERROR_IPC_FAILURE (-4L)
//! unable to allocate memory
#define VPN_ERROR_OUT_OF_MEMORY (-5L)
//! cisco vpn service is not running
#define VPN_ERROR_SERVICE_NOT_RUNN ING (-6L)
//! cisco vpn service is shutting down
#define VPN_ERROR_SERVICE_SHUTTING _DOWN (-7L)
//! no vpn connection exists
#define VPN_ERROR_NOT_CONNECTED (-8L)
//! vpn is attempting connect
#define VPN_ERROR_ALREADY_CONNECTI NG (-9L)
//! vpn connection already exists
#define VPN_ERROR_ALREADY_CONNECTE D (-10L)
//! vpn connection aborted by user command
#define VPN_ERROR_CONNECT_ABORTED (-11L)
//! ppptool.exe could not be found (windows only)
#define VPN_ERROR_NO_PPPTOOL (-12L)
//! vpn driver failure
#define VPN_ERROR_DRIVER_FAIL (-13L)
//! all backup servers were unreachable
#define VPN_ERROR_NO_MORE_BACKUPS (-14L)
//! cannot bring up a ppp connection (windows only)
#define VPN_ERROR_PPP_FAIL (-15L)
//! cTCP layer failure
#define VPN_ERROR_CTCP_FAIL (-16L)
//! local IKE failure
#define VPN_ERROR_IKE_FAIL (-17L)
//! gethostbyname() failed
#define VPN_ERROR_HOSTNAME_LOOKUP_ FAIL (-18L)
//! user cancelled authentication
#define VPN_ERROR_USER_CANCELLED_A UTH (-19L)
//! IKE security association expired
#define VPN_ERROR_SA_EXPIRED (-20L)
//! could not contact remote peer
#define VPN_ERROR_PEER_NOT_RESPOND ING (-21L)
//! moving to a different headedend in a load balancing group
#define VPN_ERROR_LOAD_BALANCING (-22L)
//! IKE negotiation failed
#define VPN_ERROR_IKE_NEG_FAILED (-23L)
//! duplicate IKE SA already exists
#define VPN_ERROR_DUPLICATE_EXISTS (-25L)
//! headend does not support unity extentions to IKE
#define VPN_ERROR_NO_CLIENT_EXTENS IONS (-26L)
//! authentication failed
#define VPN_ERROR_USER_AUTH_FAILED (-27L)
//! firewall was not detected
#define VPN_ERROR_FIREWALL_NO_LONG ER_RUNNING (-28L)
//! firewall couldn't be configured to match headend policy
#define VPN_ERROR_UNABLE_TO_CONFIG URE_FIREWA LL (-29L)
//! could not update peer certificate
#define VPN_ERROR_UPDATE_CERT_FAIL ED (-30L)
//! client system DHCP address changed
#define VPN_ERROR_ADDRESS_CHANGE (-31L)
//! authentication phase failed
#define VPN_ERROR_AUTH_PHASE_ERROR (-32L)
//! connection closed by remote error
#define VPN_ERROR_BY_ERROR (-33L)
//! connection closed by remote admininstrator command
#define VPN_ERROR_BY_ADMIN_COMMAND (-34L)
//! remote SA expired
#define VPN_ERROR_BY_EXPIRED_LIFTI ME (-35L)
//! remote server is shutting down
#define VPN_ERROR_SERVER_SHUTDOWN (-36L)
//! remote server is on fire!
#define VPN_ERROR_SERVER_IN_FLAMES (-37L)
//! maximum connection time reached
#define VPN_ERROR_MAX_CONNECT_TIME (-38L)
//! maximum idle time reache
#define VPN_ERROR_IDLE_TIMEOUT (-39L)
//! remote server is rebooting
#define VPN_ERROR_SERVER_REBOOT (-40L)
//! IKE phase 2 negotation failed
#define VPN_ERROR_PHASE2_PROPOSAL_ MISMATCH (-41L)
//! client firewall policy not accepted by server
#define VPN_ERROR_FIREWALL_MISMATC H (-42L)
//! client certificate expired
#define VPN_ERROR_CERT_EXPIRED (-43L)
//! client platform version not allowed
#define VPN_ERROR_PLATFORM_VERSION _MISMATCH (-44L)
//! remote server cannot contact zone firewall server
#define VPN_ERROR_ZONE_FIREWALL_SE RVER_FAIL (-45L)
//! remote server closed connection, but won't say why
#define VPN_ERROR_NO_ERROR (-46L)
//! remote server closed connection, but didn't send a reson
#define VPN_ERROR_DEL_REASON_UNSPE CIFIED (-47L)
//! autoupdate needs to make the tunnel shutdown
#define VPN_ERROR_AUTOUPDATE_SHUTD OWN (-48L)
/*@}*/
/**
* \defgroup MSGTYPEs Message Types
* types of messages that client wants to send/recieve. These flags serve
* 2 purposes:
* 1. Requesting the right to perform an operation, such as initiating
* a vpn tunnel.
* 2. Enabling certain different types of messages from the VPN service.
*/
//! receive authentication messages.
/*! only 1 channel can do this at a time
* causes fp_auth and fp_auth_stop callbacks to be active.
*/
#define VPN_MSGTYPE_AUTH (1<<1)
//! receive state change updates.
/*! causes fp_state_change callback to be called whenever client state changes.
* Any number of channels can retrieve state change messages at once.
*/
#define VPN_MSGTYPE_STATE_CHANGE (1<<2)
//! mask of all valid MSGTYPE bits
#define VPN_MSGTYPE_MASK (VPN_MSGTYPE_AUTH | VPN_MSGTYPE_STATE_CHANGE)
/**
* \defgroup authattrs Authentication Attributes
*/
/*@{*/
//! instructions from headend to be displayed to the user.
#define VPN_AUTH_MESSAGE (1<<0)
//! Prompt: Username:
#define VPN_AUTH_USERNAME (1<<1)
//! Prompt: Password:
#define VPN_AUTH_PASSWORD (1<<2)
//! Prompt: Passcode:
#define VPN_AUTH_PASSCODE (1<<3)
//! Prompt: Response:
#define VPN_AUTH_ANSWER (1<<4)
//! Prompt: New PIN: & Confirm PIN:
#define VPN_AUTH_NEXTPIN (1<<5)
//! Prompt: New Password: & Confirm Password:
#define VPN_AUTH_NEXTPASSWORD (1<<6)
//! Prompt: Domain:
#define VPN_AUTH_DOMAIN (1<<7)
//! Prompt: PIN:
#define VPN_AUTH_PIN (1<<8)
//! Prompt: Next Cardcode:
#define VPN_AUTH_TOKENCODE (1<<9)
#define VPN_AUTH_MASK (VPN_AUTH_MESSAGE | VPN_AUTH_USERNAME | \
VPN_AUTH_PASSWORD | VPN_AUTH_PASSCODE | \
VPN_AUTH_ANSWER | VPN_AUTH_NEXTPIN | \
VPN_AUTH_NEXT_PASSWORD | VPN_AUTH_DOMAIN \ \
VPN_AUTH_PIN | VPN_AUTH_TOKENCODE)
/*@}*/
/**
* \defgroup STATGROUPs Statistic Groups
*/
/*@{*/
//! causes struct vpn_counters to be included in returned stats
#define VPN_STATGROUP_COUNTERS (1L<<0)
//! causes struct vpn_tunnel_info to be included in returned stats
#define VPN_STATGROUP_TUNNEL_INFO (1L<<1)
//! causes split tunnel, secured, and local lan routes to be returned
#define VPN_STATGROUP_ROUTES (1L<<2)
//! causes the connected profile name to be returned
#define VPN_STATGROUP_PROFILE (1L<<3)
//! mask of all possible statgroups
#define VPN_STATGROUP_MASK (VPN_STATGROUP_COUNTERS | \
VPN_STATGROUP_TUNNEL_INFO | \
VPN_STATGROUP_ROUTES | \
VPN_STATGROUP_PROFILE)
/*@}*/
/**
* \defgroup OPTIONs Connect Options
*/
/*@{*/
//! disable shutdown messages from the cisco GUI
#define VPN_OPT_SILENT_DISCONNECT (1L<<0)
#define VPN_OPT_MASK (VPN_OPT_SILENT_DISCONNECT )
/*@}*/
/*@}*/
/**
* \defgroup types Data Types and Structures
*/
/*@{*/
//! return type for most functions
typedef int32_t vpn_error_t;
//! Possible states for a VPN connection.
typedef enum
{
VPN_MIN_STATE = -1,
//! VPN is not connected.
VPN_STATE_IDLE,
//! Waiting for PPP connection to come up.
VPN_STATE_WAIT_PPP,
//! Waiting for cTCP handshake to complete.
VPN_STATE_WAIT_CTCP,
//! Waiting for IKE Phase 1 to complete.
VPN_STATE_WAIT_PHASE1,
//! Waiting for authentication to complete.
VPN_STATE_WAIT_AUTH,
//! Waiting for MODE-CFG to complete.
VPN_STATE_WAIT_MODECFG,
//! Waiting for IKE Phase 2 to complete.
VPN_STATE_WAIT_PHASE2,
//! VPN is Connected.
VPN_STATE_CONNECTED,
VPN_MAX_STATE,
} vpn_state_t;
//! IPSec encryption algorithms
typedef enum
{
VPN_MIN_CRYPTO_ALG = 0,
//! DES
VPN_CRYPTO_DES,
//! 3DES
VPN_CRYPTO_3DES,
//! No Encryption
VPN_CRYPTO_NULL,
//! AES
VPN_CRYPTO_AES,
VPN_MAX_CRYPTO_ALG
} vpn_crypto_t;
//! IPSec authentication algorithms
typedef enum
{
VPN_MIN_HASH = 0,
//! HMAC-MD5
VPN_HASH_MD5,
//! HMAC-SHA
VPN_HASH_SHA,
VPN_MAX_HASH
} vpn_hash_t;
//! IP Compression algorithms
typedef enum
{
VPN_MIN_COMPRESS_ALG = 0,
//! No IP Compression
VPN_COMPRESS_NONE,
//! LZS
VPN_COMPRESS_LZS,
VPN_MAX_COMPRESS_ALG,
} vpn_compress_t;
//! NAT pass-through algorithms
typedef enum
{
VPN_MIN_NAT_MODE = 0,
//! Normal IPSec
VPN_NAT_NONE,
//! IPSec over UDP
VPN_NAT_IPSEC_OVER_UDP,
//! IPSec over cTCP
VPN_NAT_IPSEC_OVER_CTCP,
VPN_MAX_NAT_MODE
} vpn_nat_mode_t;
//! opaque representation of a communications channel with the VPN service
/*!
* This datatype is used to issue commands and receive data from the
* VPN service. It is intialized by calling vpn_channel_init() and
* destroyed by calling vpn_channel_destroy()
*/
typedef void *vpn_channel_t;
//! opaque representation VPN connection statistics
/*!
* This datastructure is accessed by the functions whose
* names begin with "vpn_stats"
*/
typedef void *vpn_stats_t;
//! opaque representation VPN authentication information
/*!
* This datastructure is accessed by the functions whose
* names begin with "vpn_auth"
*/
typedef void *vpn_auth_t;
//! datastructure represinting an IP address
/*! this datatype is set up so that ipv6 support can be added without
breaking binary compatibility. Also, the padding in struct ipv4 causes
an IPv4 address stored into this structure to be in a format understood
IPv6 address parsing routines.
*/
typedef union
{
struct
{
uint32_t pad[3];
//! IP address in network order
struct in_addr addr;
} ipv4;
#ifdef NOT_IMPLEMENTED
struct
{
struct in6_addr addr;
} ipv6;
#endif /* */
} vpn_ip_addr_t;
//! datastructure representing a route (secured or unsecured)
struct vpn_route
{
//! network portion of the address. (eg. 192.168.0.0)
vpn_ip_addr_t network;
//! netmask portion of the address. (eg. 255.255.255.0)
vpn_ip_addr_t mask;
//! bytes sent and received using this route.
uint32_t bytes;
//! is traffic secured?
uint16_t haskeys;
uint32_t reserved[2];
};
//! a set of routes.
struct vpn_routes
{
//! number of entries in the routes array
uint32_t num_routes;
uint32_t reserved[2];
//! contains num_routes vpn_route structures
struct vpn_route routes[];
};
//! IPSec traffic statistics
struct vpn_counters
{
//! number of seconds connected
uint32_t time_connected;
//! total bytes sent/received
uint32_t total_bytes;
//!
uint32_t bytes_sent;
//!
uint32_t bytes_recieved;
//! number of valid IPSec packets recieved
uint32_t packets_transformed;
//! number of packets successfully encrypted
uint32_t packets_encrypted;
//! number of packets successfully decrypted
uint32_t packets_decrypted;
//! number of packets sent without encryption
uint32_t packets_bypassed;
//! number of packets deleted by IPSec
uint32_t packets_discarded;
uint32_t reserved[2];
};
//! basic information about a VPN tunnel
struct vpn_tunnel_info
{
//! address of client on the internal network
vpn_ip_addr_t internal_addr;
//! address of currently connected headend
vpn_ip_addr_t peer_addr;
//! non-zero if the exclude local lan feature is enabled
uint8_t local_lan_enabled;
//! nat pass through mode
vpn_nat_mode_t nat_mode;
//! UDP or TCP port number used for nat passthrough
uint16_t nat_port;
//! encryption algorithm used for securing IPSec traffic
vpn_crypto_t crypto_algorithm;
//! encryption key length, in bytes
uint16_t crypto_key_length;
//! hash algorithm used for securing IPSec traffic
vpn_hash_t hash_algorithm;
//! IP compression algorithm
vpn_compress_t compress_algorithm;
uint32_t reserved[2];
};
//!
struct vpn_connect_error
{
vpn_error_t error;
uint32_t is_remote;
char * delete_reason;
uint32_t reserved[2];
};
/*@}*/
#ifndef VPN_API_DATATYPES_ONLY
/**
* \defgroup callbacks Callback Functions
*/
/*@{*/
//! callback for vpn_connect() results
/*!
* \param error error code from the vpn_connect() attempt.
* \param banner is a user displayable string that contains the login
* banner that the headend's administrator requires all users to
* acknowledge before connecting.
*/
typedef void (*vpn_connect_cb) (const struct vpn_connect_error *,
const char *banner);
//! callback for vpn_disconnect() result
/*!
* \param error error code from the vpn_disconnect() attempt
*/
typedef void (*vpn_disconnect_cb) (vpn_error_t error);
//! state transition callback
/*!
* \param state new state of the vpn connection.
* \param peer address of current headend. This may change during a
* connection attempt due to load balancing or backup servers.
* \param error when a state change happens because a connection
* attempt failed, this value will indicate the reason for the
* failure
*/
typedef void (*vpn_state_change_cb) (vpn_state_t state,
const vpn_ip_addr_t * peer,
const struct vpn_connect_error*);
//! callback for vpn_get_stats() results
/*!
* \param error error code from the vpn_get_stats() attempt.
* \param statgroups bitmask of VPN_STATGROUPS_ flags indicating which
* portions of the stats are available.
* \param stats handle used for accessing the various stats structures.
* This variable may be used only inside of this callback function.
*/
typedef void (*vpn_stats_cb) (vpn_error_t error, uint32_t stats_groups,
vpn_stats_t stats);
//! callback for authentication
/*!
* \param auth handle for accessing authentication attributes.
* This variable may be used until vpn_auth_respond() or
* vpn_auth_abort() is called, or vpn_auth_stop_cb() is
* recieved.
* \param auth_attrs bitmask of VPN_AUTH flags indicating which
* authentication attributes were requested by the headend
* \param allowed_save_attrs bitmask of VPN_AUTH flags indicating which
* authentication can be saved in the profile. See the save_attrs
* argument to vpn_auth_respond()
* \param profile_name
*/
typedef void (*vpn_auth_cb) (vpn_auth_t auth, uint32_t auth_attrs,
uint32_t allowed_save_attrs,
const char *profile_name);
//! callback to cancel authentication
/*!
* This callback is called to cancel any in-progress user authentication.
* All authentication user interfaces should be closed, and any state
* related to the authentication attempt should be destroyed.
*/
typedef void (*vpn_auth_stop_cb) (void);
//! structure for passing callback functions to the vpnapi
/*!
*/
struct vpn_callback_table
{
//! vpn_connect() callback
vpn_connect_cb fp_connect;
//! vpn_disconnect() callback
vpn_disconnect_cb fp_disconnect;
//! state change callback
vpn_state_change_cb fp_state_change;
//! vpn_get_stats() callback
vpn_stats_cb fp_stats;
//! authentication callback
vpn_auth_cb fp_auth;
//! authentication stop callback
vpn_auth_stop_cb fp_auth_stop;
};
/*@}*/
/*!
* \defgroup global Global Initialization Functions
*/
/*@{*/
//! must be called before any other api functions are called.
/*!
* \param version On input this should be set to VPNAPI_VERSION.
* On output it will be set to the version number supported in
* the shared library.
*/
DLL_EXPORT_NAME vpn_error_t vpn_api_init(uint32_t * version);
//! call when done issuing api calls
DLL_EXPORT_NAME vpn_error_t vpn_api_destroy(void);
/*@}*/
/*!
* \defgroup channel_functions Communications Channel Functions
* types of messages that client wants to send/recieve
*/
/*@{*/
//! initialize a communications channel to the VPN service component
/*!
\param channel will be set by this function
\param msgtypes should be set to some of flags above. On return, it will
be set to the VPN_MSGTYPEs that can actually be sent.
\param callbacks should be initialized with pointers to the callback
funcitons you want to use
*/
DLL_EXPORT_NAME vpn_error_t vpn_channel_init(vpn_chann el_t * channel,
uint32_t * msgtypes,
const struct
vpn_callback_table *callbacks);
//! destroy the communictations channel
/*!
\param channel will be destroyed by this function.
*/
DLL_EXPORT_NAME vpn_error_t vpn_channel_destroy(vpn_ch annel_t channel);
//! retreives a OS-level descriptor for the channel.
/*! This descriptor should only be used to initialize an event loop, either
* with select(), WaitForMultipleObjects() or similar functions
* \param channel
* \returns a socket descriptor
*/
DLL_EXPORT_NAME SOCKET vpn_channel_get_socket(vpn _channel_t channel);
//! event handling function
/*! call this function when the socket from vpn_channel_get_socket() becomes
* readable. All calls to callback functions will be made from within
* this function.
* \param channel
*/
DLL_EXPORT_NAME vpn_error_t vpn_channel_event(vpn_chan nel_t channel);
//! simplified event handling function
/*! this function implements a simple event loop, which calls
* vpn_channel_event().
*
* this function.
* \param channel
* \param max_wait maximum time to wait for events.
*/
DLL_EXPORT_NAME vpn_error_t vpn_process_events(vpn_cha nnel_t channel, unsigned int max_wait);
//! retrieve msgtypes flags that were set in call to vpn_channel_init()
/*!
* \param channel
* \returns a bitmask of VPN_MSGTYPES
*/
DLL_EXPORT_NAME uint32_t vpn_channel_get_msgtypes(v pn_channel _t channel);
/*@}*/
/**
* \defgroup command_functions Command functions
* types of messages that client wants to send/recieve
*/
/*@{*/
//! try to connect using a given profile.
/*!
* \param channel the channel to use for sending the command
* \param profile the name of the profile
* \param group_name the name of the profile. May be NULL if the
* group name is saved in the profile
* \param password is the group password or the certificate password,
* depending on the setting of AuthType value in the profile.
* may be NULL if the group password is saved in the profile.
* \param option_flags bitmask of VPN_OPT_* flags.
*
* Calling this function will cause fp_connect to be called when the
* connection attempt suceeds. Additionally, fp_stats will be called
* for state changes during the connection attempt and fp_auth/fp_auth_stop
* will be called to handle authentication.
*/
DLL_EXPORT_NAME vpn_error_t vpn_connect(vpn_channel_t channel,
const char *profile,
const char *group_name,
const char *password,
uint32_t option_flags);
//! used to return users response to the banner given in vpn_connect_cb()
/*!
* \param channel
* \param banner_accepted TRUE if the user agrees to the banner,
* FALSE if the user disagrees.
*/
DLL_EXPORT_NAME vpn_error_t vpn_acknowledge_banner(vpn _channel_t channel,
int banner_accepted);
//! disconnect the vpn tunnel.
/*! causes fp_disconnect to be called with the result of the disconnect
* attempt. No VPN_MSGTYPE flag is needed to send.
*/
DLL_EXPORT_NAME vpn_error_t vpn_disconnect(vpn_channel _t channel);
//! request statistics to be sent
/*! causes fp_statistics to be called. no mstype needed to send.
* \param channel
* \param stats_groups flags describing which statistics to send.
* use VPN_STATGROUP flags
*/
DLL_EXPORT_NAME vpn_error_t vpn_get_stats(vpn_channel_ t channel,
uint32_t stats_groups);
//! Reset byte and packet counts in the statistics
/*! no mstype needed to send.
* \param channel
*/
DLL_EXPORT_NAME vpn_error_t vpn_reset_stats(vpn_channe l_t channel);
//! reply to a fp_auth callback.
/*!
* This function is called to pass back authentication attributes
* to the headend. msgtype VPN_MSGTYPE_AUTH is needed to send.
* \param channel
* \param auth
* \param save_attrs a bitmask of VPN_AUTH flags indicating which
* attributes should be saved in the profile. Attributes
* that were not set in the allowed_save_attrs argument
* to vpn_auth_cb will be ignored.
*/
DLL_EXPORT_NAME vpn_error_t vpn_auth_respond(vpn_chann el_t channel,
vpn_auth_t auth,
uint32_t save_attrs);
//! negative reply to a fp_auth callback.
/*!
* This function is called to cancel an authentication attempt.
* msgtype VPN_MSGTYPE_AUTH is needed to send.
* \param channel
* \param auth
*/
DLL_EXPORT_NAME vpn_error_t vpn_auth_abort(vpn_channel _t channel,
vpn_auth_t auth);
/*@}*/
/**
* \defgroup stats_functions Statistics Functions
* Functions for accessing components of vpn_stats_t. These functions
* should only be used inside of your vpn_stats_cb. The memory
* returned by these functions is only valid in your vpn_stats_cb
* function. If need to use the data returned outside of this function,
* you should make a copy of the data.
*/
/*@{*/
//! returns list of local networks excluded from the VPN tunnel
DLL_EXPORT_NAME const struct vpn_routes
*vpn_stats_get_local_lan_r outes(vpn_ stats_t stats);
//! returns list of networks included in the VPN tunnel
DLL_EXPORT_NAME const struct vpn_routes
*vpn_stats_get_secure_rout es(vpn_sta ts_t stats);
//! returns basic information about the VPN tunnel
DLL_EXPORT_NAME const struct vpn_tunnel_info
*vpn_stats_get_tunnel_info (vpn_stats _t stats);
//! returns traffic information about the VPN tunnel
DLL_EXPORT_NAME const struct vpn_counters
*vpn_stats_get_counters(vp n_stats_t stats);
//! returns the name of the profile used for the current VPN tunnel
DLL_EXPORT_NAME const char *vpn_stats_get_profile_nam e(vpn_stat s_t stats);
/*@}*/
/**
* \defgroup auth_functions Authentication Functions
* Functions for accessing components of vpn_auth_t. These functions
* should only be used inside of your vpn_stats_cb
*/
/*@{*/
/*!
\param auth authentication handle passed to vpn_auth_cb
\param auth_attr the authentication attribute to get
*/
DLL_EXPORT_NAME const char *vpn_auth_get_attribute(vp n_auth_t auth,
uint32_t auth_attr);
/*!
\param auth authentication handle passed to vpn_auth_cb
\param auth_attr the authentication attribute to set
\param value new value for the attribute.
*/
DLL_EXPORT_NAME vpn_error_t vpn_auth_set_attribute(vpn _auth_t auth,
uint32_t auth_attr,
const char *value);
#ifdef _WIN32
DLL_EXPORT_NAME HANDLE vpn_get_service_start_even t(void);
#endif
#endif //VPN_API_DATATYPES_ONLY
/*@}*/
#ifdef _MSC_VER
/* re-enable warning:
nonstandard extension used: zero-sized array in struct/union
*/
#pragma warning( default: 4200 )
#endif
#ifdef __cplusplus
// *INDENT-OFF*
}
// *INDENT-ON*
#endif
#endif // VPNAPI_H
windows_stdint.h:
#ifndef WINDOWS_STDINT_H
#define WINDOWS_STDINT_H
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed long int32_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned long uint32_t;
#endif //WINDOWS_STDINT_H
Below my code so far and the original headers. Who can help?
unit VPNAPI;
interface
uses Windows, WinSock;
{$IFNDEF VPNAPI_H}
{$DEFINE VPNAPI_H}
const
DLL_EXPORT_NAME = __declspec(dllexport);
VPNAPI_VERSION = $00010000;
VPN_OK:LongWord = 0;
VPN_ERROR:LongWord = -1;
VPN_ERROR_BAD_PARAM::LongW
VPN_ERROR_NOT_A_PROFILE: :LongWord = -3;
VPN_ERROR_IPC_FAILURE: = -4;
VPN_ERROR_OUT_OF_MEMORY:Lo
VPN_ERROR_SERVICE_NOT_RUNN
VPN_ERROR_SERVICE_SHUTTING
VPN_ERROR_NOT_CONNECTED:Lo
VPN_ERROR_ALREADY_CONNECTI
VPN_ERROR_ALREADY_CONNECTE
VPN_ERROR_CONNECT_ABORTED:
VPN_ERROR_NO_PPPTOOL:LongW
VPN_ERROR_DRIVER_FAIL:Long
VPN_ERROR_NO_MORE_BACKUPS:
VPN_ERROR_PPP_FAIL:LongWor
VPN_ERROR_CTCP_FAIL:LongWo
VPN_ERROR_IKE_FAIL:LongWor
VPN_ERROR_HOSTNAME_LOOKUP_
VPN_ERROR_USER_CANCELLED_A
VPN_ERROR_SA_EXPIRED:LongW
VPN_ERROR_PEER_NOT_RESPOND
VPN_ERROR_LOAD_BALANCING:L
VPN_ERROR_IKE_NEG_FAILED:L
VPN_ERROR_DUPLICATE_EXISTS
VPN_ERROR_NO_CLIENT_EXTENS
VPN_ERROR_USER_AUTH_FAILED
VPN_ERROR_FIREWALL_NO_LONG
VPN_ERROR_UNABLE_TO_CONFIG
VPN_ERROR_UPDATE_CERT_FAIL
VPN_ERROR_ADDRESS_CHANGE:L
VPN_ERROR_AUTH_PHASE_ERROR
VPN_ERROR_BY_ERROR:LongWor
VPN_ERROR_BY_ADMIN_COMMAND
VPN_ERROR_BY_EXPIRED_LIFTI
VPN_ERROR_SERVER_SHUTDOWN:
VPN_ERROR_SERVER_IN_FLAMES
VPN_ERROR_MAX_CONNECT_TIME
VPN_ERROR_IDLE_TIMEOUT:Lon
VPN_ERROR_SERVER_REBOOT:Lo
VPN_ERROR_PHASE2_PROPOSAL_
VPN_ERROR_FIREWALL_MISMATC
VPN_ERROR_CERT_EXPIRED:Lon
VPN_ERROR_PLATFORM_VERSION
VPN_ERROR_ZONE_FIREWALL_SE
VPN_ERROR_NO_ERROR:LongWor
VPN_ERROR_DEL_REASON_UNSPE
VPN_ERROR_AUTOUPDATE_SHUTD
VPN_MSGTYPE_AUTH = (1<<1);
VPN_MSGTYPE_STATE_CHANGE = (1<<2);
VPN_MSGTYPE_MASK = (VPN_MSGTYPE_AUTH | VPN_MSGTYPE_STATE_CHANGE);
VPN_AUTH_MESSAGE = (1<<0);
VPN_AUTH_USERNAME = (1<<1);
VPN_AUTH_PASSWORD = (1<<2);
VPN_AUTH_PASSCODE = (1<<3);
VPN_AUTH_ANSWER = (1<<4);
VPN_AUTH_NEXTPIN = (1<<5);
VPN_AUTH_NEXTPASSWORD = (1<<6);
VPN_AUTH_DOMAIN = (1<<7);
VPN_AUTH_PIN = (1<<8);
VPN_AUTH_TOKENCODE = (1<<9);
VPN_AUTH_MASK = (VPN_AUTH_MESSAGE, VPN_AUTH_USERNAME, VPN_AUTH_PASSWORD, VPN_AUTH_PASSCODE, VPN_AUTH_ANSWER, VPN_AUTH_NEXTPIN, VPN_AUTH_NEXT_PASSWORD , VPN_AUTH_DOMAIN, VPN_AUTH_PIN , VPN_AUTH_TOKENCODE);
VPN_STATGROUP_COUNTERS = (1<<0);
VPN_STATGROUP_TUNNEL_INFO = (1<<1);
VPN_STATGROUP_ROUTES = (1<<2);
VPN_STATGROUP_PROFILE = (1<<3);
VPN_STATGROUP_MASK = (VPN_STATGROUP_COUNTERS, VPN_STATGROUP_TUNNEL_INFO,
VPN_OPT_SILENT_DISCONNECT = (1<<0);
VPN_OPT_MASK = (VPN_OPT_SILENT_DISCONNECT
type
vpn_error_t = INT32_T;
vpn_state_t = (VPN_MIN_STATE, VPN_STATE_IDLE, VPN_STATE_WAIT_PPP, VPN_STATE_WAIT_CTCP, VPN_STATE_WAIT_PHASE1, VPN_STATE_WAIT_AUTH, VPN_STATE_WAIT_MODECFG, VPN_STATE_WAIT_PHASE2, VPN_STATE_CONNECTED, VPN_MAX_STATE);
vpn_crypto_t = (VPN_MIN_CRYPTO_ALG, VPN_CRYPTO_DES, VPN_CRYPTO_3DES, VPN_CRYPTO_NULL, VPN_CRYPTO_AES, VPN_MAX_CRYPTO_ALG);
vpn_compress_t =(VPN_MIN_COMPRESS_ALG, VPN_COMPRESS_NONE, VPN_COMPRESS_LZS, VPN_MAX_COMPRESS_ALG);
vpn_nat_mode_t = (VPN_MIN_NAT_MODE, VPN_NAT_NONE, VPN_NAT_IPSEC_OVER_UDP, VPN_NAT_IPSEC_OVER_CTCP, VPN_MAX_NAT_MODE);
vpn_channel_t = Pointer;
vpn_stats_t = Pointer;
vpn_auth_t = Pointer;
type
vpn_route = record
network: VPN_IP_ADDR_T;
mask: VPN_IP_ADDR_T;
bytes: UINT32_T;
haskeys: UINT16_T;
reserved: Array[0..2-1] of UINT32_T;
end {vpn_route};
type
vpn_routes = record
num_routes: UINT32_T;
reserved: Array[0..2-1] of UINT32_T;
routes: Array[0..-1] of VPN_ROUTE;
end {vpn_routes};
{///! IPSec traffic statistics }
type
vpn_counters = packed record
time_connected: LongWord;
total_bytes: LongWord;
bytes_sent: LongWord;
bytes_recieved: LongWord;
packets_transformed: LongWord;
packets_encrypted: LongWord;
packets_decrypted: LongWord;
packets_bypassed: LongWord;
packets_discarded: LongWord;
reserved[2]:LongWord;
end {vpn_counters};
{///! basic information about a VPN tunnel }
type
vpn_tunnel_info = record
{///! address of client on the internal network }
internal_addr: VPN_IP_ADDR_T;
{///! address of currently connected headend }
peer_addr: VPN_IP_ADDR_T;
{///! non-zero if the exclude local lan feature is enabled }
local_lan_enabled: UINT8_T;
{///! nat pass through mode }
nat_mode: VPN_NAT_MODE_T;
{///! UDP or TCP port number used for nat passthrough }
nat_port: UINT16_T;
{///! encryption algorithm used for securing IPSec traffic }
crypto_algorithm: VPN_CRYPTO_T;
{///! encryption key length, in bytes }
crypto_key_length: UINT16_T;
{///! hash algorithm used for securing IPSec traffic }
hash_algorithm: VPN_HASH_T;
{///! IP compression algorithm }
compress_algorithm: VPN_COMPRESS_T;
reserved: Array[0..2-1] of UINT32_T;
end {vpn_tunnel_info};
{///! }
type
vpn_connect_error = record
error: VPN_ERROR_T;
is_remote: UINT32_T;
delete_reason: PChar;
reserved: Array[0..2-1] of UINT32_T;
end {vpn_connect_error};
{+//@}*/ }
{$IFNDEF VPN_API_DATATYPES_ONLY}
{+//* }
{-* \defgroup callbacks Callback Functions }
{= }
{+//@{*/ }
{///! callback for vpn_connect() results }
{+//! }
{-* \param error error code from the vpn_connect() attempt. }
{-* \param banner is a user displayable string that contains the login }
{-* banner that the headend's administrator requires all users to }
{-* acknowledge before connecting. }
{= }
type
(*vpn_connect_cb) (const vpn_connect_error*, const char*banner); = void;
}: ///! CALLBACK FOR VPN_DISCONNECT() RESULT;
{+//! }
{-* \param error error code from the vpn_disconnect() attempt }
{= }
error): TYPEDEF VOID (*VPN_DISCONNECT_CB) (VPN_ERROR_T;
{///! state transition callback }
{+//! }
{-* \param state new state of the vpn connection. }
{-* \param peer address of current headend. This may change during a }
{-* connection attempt due to load balancing or backup servers. }
{-* \param error when a state change happens because a connection }
{-* attempt failed, this value will indicate the reason for the }
{-* failure }
{= }
state, const vpn_ip_addr_t* peer, const struct vpn_connect_error* ): TYPEDEF VOID (*VPN_STATE_CHANGE_CB) (VPN_STATE_T;
{///! callback for vpn_get_stats() results }
{+//! }
{-* \param error error code from the vpn_get_stats() attempt. }
{-* \param statgroups bitmask of VPN_STATGROUPS_ flags indicating which }
{-* portions of the stats are available. }
{-* \param stats handle used for accessing the various stats structures. }
{-* This variable may be used only inside of this callback function. }
{= }
error, uint32_t stats_groups, vpn_stats_t stats): TYPEDEF VOID (*VPN_STATS_CB) (VPN_ERROR_T;
{///! callback for authentication }
{+//! }
{-* \param auth handle for accessing authentication attributes. }
{-* This variable may be used until vpn_auth_respond() or }
{-* vpn_auth_abort() is called, or vpn_auth_stop_cb() is }
{-* recieved. }
{-* \param auth_attrs bitmask of VPN_AUTH flags indicating which }
{-* authentication attributes were requested by the headend }
{-* \param allowed_save_attrs bitmask of VPN_AUTH flags indicating which }
{-* authentication can be saved in the profile. See the save_attrs }
{-* argument to vpn_auth_respond() }
{-* \param profile_name }
{= }
auth, uint32_t auth_attrs, uint32_t allowed_save_attrs, const char*profile_name): TYPEDEF VOID (*VPN_AUTH_CB) (VPN_AUTH_T;
{///! callback to cancel authentication }
{+//! }
{-* This callback is called to cancel any in-progress user authentication. }
{-* All authentication user interfaces should be closed, and any state }
{-* related to the authentication attempt should be destroyed. }
{= }
(void): TYPEDEF VOID (*VPN_AUTH_STOP_CB);
{///! structure for passing callback functions to the vpnapi }
{+//! }
{= }
{///! vpn_connect() callback }
fp_connect: VPN_CONNECT_CB;
{///! vpn_disconnect() callback }
fp_disconnect: VPN_DISCONNECT_CB;
{///! state change callback }
fp_state_change: VPN_STATE_CHANGE_CB;
{///! vpn_get_stats() callback }
fp_stats: VPN_STATS_CB;
{///! authentication callback }
fp_auth: VPN_AUTH_CB;
{///! authentication stop callback }
fp_auth_stop: VPN_AUTH_STOP_CB;
end {vpn_connect_error};
{+//@}*/ }
{+//! }
{-* \defgroup global Global Initialization Functions }
{= }
{+//@{*/ }
{///! must be called before any other api functions are called. }
{+//! }
{-* \param version On input this should be set to VPNAPI_VERSION. }
{-* On output it will be set to the version number supported in }
{-* the shared library. }
{= }
var
vpn_api_init: function(version: PUINT32_T): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! call when done issuing api calls }
var
vpn_api_destroy: function: DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{+//@}*/ }
{+//! }
{-* \defgroup channel_functions Communications Channel Functions }
{-* types of messages that client wants to send/recieve }
{= }
{+//@{*/ }
{///! initialize a communications channel to the VPN service component }
{+//! }
{-\param channel will be set by this function }
{-\param msgtypes should be set to some of flags above. On return, it will }
{-be set to the VPN_MSGTYPEs that can actually be sent. }
{-\param callbacks should be initialized with pointers to the callback }
{-funcitons you want to use }
{= }
var
vpn_channel_init: function(var channel: VPN_CHANNEL_T;
var msgtypes: UINT32_T;
const callbacks: PVPN_CALLBACK_TABLE): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! destroy the communictations channel }
{+//! }
{-\param channel will be destroyed by this function. }
{= }
var
vpn_channel_destroy: function(channel: VPN_CHANNEL_T): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! retreives a OS-level descriptor for the channel. }
{+//! This descriptor should only be used to initialize an event loop, either }
{-* with select(), WaitForMultipleObjects() or similar functions }
{-* \param channel }
{-* \returns a socket descriptor }
{= }
var
vpn_channel_get_socket: function(channel: VPN_CHANNEL_T): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! event handling function }
{+//! call this function when the socket from vpn_channel_get_socket() becomes }
{-* readable. All calls to callback functions will be made from within }
{-* this function. }
{-* \param channel }
{= }
var
vpn_channel_event: function(channel: VPN_CHANNEL_T): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! simplified event handling function }
{+//! this function implements a simple event loop, which calls }
{-* vpn_channel_event(). }
{-* }
{-* this function. }
{-* \param channel }
{-* \param max_wait maximum time to wait for events. }
{= }
var
vpn_process_events: function(channel: VPN_CHANNEL_T;
max_wait: Word): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! retrieve msgtypes flags that were set in call to vpn_channel_init() }
{+//! }
{-* \param channel }
{-* \returns a bitmask of VPN_MSGTYPES }
{= }
var
vpn_channel_get_msgtypes: function(channel: VPN_CHANNEL_T): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{+//@}*/ }
{+//* }
{-* \defgroup command_functions Command functions }
{-* types of messages that client wants to send/recieve }
{= }
{+//@{*/ }
{///! try to connect using a given profile. }
{+//! }
{-* \param channel the channel to use for sending the command }
{-* \param profile the name of the profile }
{-* \param group_name the name of the profile. May be NULL if the }
{-* group name is saved in the profile }
{-* \param password is the group password or the certificate password, }
{-* depending on the setting of AuthType value in the profile. }
{-* may be NULL if the group password is saved in the profile. }
{-* \param option_flags bitmask of VPN_OPT_* flags. }
{-* }
{-* Calling this function will cause fp_connect to be called when the }
{-* connection attempt suceeds. Additionally, fp_stats will be called }
{-* for state changes during the connection attempt and fp_auth/fp_auth_stop }
{-* will be called to handle authentication. }
{= }
var
vpn_connect: function(channel: VPN_CHANNEL_T;
const profile: PChar;
const group_name: PChar;
const password: PChar;
option_flags: UINT32_T): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! used to return users response to the banner given in vpn_connect_cb() }
{+//! }
{-* \param channel }
{-* \param banner_accepted TRUE if the user agrees to the banner, }
{-* FALSE if the user disagrees. }
{= }
var
vpn_acknowledge_banner: function(channel: VPN_CHANNEL_T;
banner_accepted: Integer): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! disconnect the vpn tunnel. }
{+//! causes fp_disconnect to be called with the result of the disconnect }
{-* attempt. No VPN_MSGTYPE flag is needed to send. }
{= }
var
vpn_disconnect: function(channel: VPN_CHANNEL_T): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! request statistics to be sent }
{+//! causes fp_statistics to be called. no mstype needed to send. }
{-* \param channel }
{-* \param stats_groups flags describing which statistics to send. }
{-* use VPN_STATGROUP flags }
{= }
var
vpn_get_stats: function(channel: VPN_CHANNEL_T;
stats_groups: UINT32_T): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! Reset byte and packet counts in the statistics }
{+//! no mstype needed to send. }
{-* \param channel }
{= }
var
vpn_reset_stats: function(channel: VPN_CHANNEL_T): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! reply to a fp_auth callback. }
{+//! }
{-* This function is called to pass back authentication attributes }
{-* to the headend. msgtype VPN_MSGTYPE_AUTH is needed to send. }
{-* \param channel }
{-* \param auth }
{-* \param save_attrs a bitmask of VPN_AUTH flags indicating which }
{-* attributes should be saved in the profile. Attributes }
{-* that were not set in the allowed_save_attrs argument }
{-* to vpn_auth_cb will be ignored. }
{= }
var
vpn_auth_respond: function(channel: VPN_CHANNEL_T;
auth: VPN_AUTH_T;
save_attrs: UINT32_T): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{///! negative reply to a fp_auth callback. }
{+//! }
{-* This function is called to cancel an authentication attempt. }
{-* msgtype VPN_MSGTYPE_AUTH is needed to send. }
{-* \param channel }
{-* \param auth }
{= }
var
vpn_auth_abort: function(channel: VPN_CHANNEL_T;
auth: VPN_AUTH_T): DLL_EXPORT_NAME cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{+//@}*/ }
{+//* }
{-* \defgroup stats_functions Statistics Functions }
{-* Functions for accessing components of vpn_stats_t. These functions }
{-* should only be used inside of your vpn_stats_cb. The memory }
{-* returned by these functions is only valid in your vpn_stats_cb }
{-* function. If need to use the data returned outside of this function, }
{-* you should make a copy of the data. }
{= }
{+//@{*/ }
{///! returns list of local networks excluded from the VPN tunnel }
type
const vpn_routes*vpn_stats_get_l
}: ///! RETURNS LIST OF NETWORKS INCLUDED IN THE VPN TUNNEL;
stats): DLL_EXPORT_NAME CONST VPN_ROUTES*VPN_STATS_GET_S
{///! returns basic information about the VPN tunnel }
stats): DLL_EXPORT_NAME CONST VPN_TUNNEL_INFO*VPN_STATS_
{///! returns traffic information about the VPN tunnel }
stats): DLL_EXPORT_NAME CONST VPN_COUNTERS*VPN_STATS_GET
{///! returns the name of the profile used for the current VPN tunnel }
stats): DLL_EXPORT_NAME CONST CHAR*VPN_STATS_GET_PROFILE
{+//@}*/ }
{+//* }
{-* \defgroup auth_functions Authentication Functions }
{-* Functions for accessing components of vpn_auth_t. These functions }
{-* should only be used inside of your vpn_stats_cb }
{= }
{+//@{*/ }
{+//! }
{-\param auth authentication handle passed to vpn_auth_cb }
{-\param auth_attr the authentication attribute to get }
{= }
auth, uint32_t auth_attr): DLL_EXPORT_NAME CONST CHAR*VPN_AUTH_GET_ATTRIBUT
{+//! }
{-\param auth authentication handle passed to vpn_auth_cb }
{-\param auth_attr the authentication attribute to set }
{-\param value new value for the attribute. }
{= }
auth, uint32_t auth_attr, const char*value): DLL_EXPORT_NAME VPN_ERROR_T VPN_AUTH_SET_ATTRIBUTE(VPN
{$IFDEF _WIN32}
vpn_get_service_start_even
{$ENDIF}
{$ENDIF //VPN_API_DATATYPES_ONLY}
{+//@}*/ }
{$IFDEF _MSC_VER}
{+// re-enable warning: }
{-nonstandard extension used: zero-sized array in struct/union }
{= }
{ #pragma warning( default: 4200 ) }
{$ENDIF}
{$IFDEF __cplusplus}
{///*INDENT-OFF* }
end {};
{$ENDIF}
{$ENDIF // VPNAPI_H}
var
DLLLoaded: Boolean { is DLL (dynamically) loaded already? }
{$IFDEF WIN32} = False; {$ENDIF}
implementation
var
SaveExit: pointer;
DLLHandle: THandle;
{$IFNDEF MSDOS}
ErrorMode: Integer;
{$ENDIF}
procedure NewExit; far;
begin
ExitProc := SaveExit;
FreeLibrary(DLLHandle)
end {NewExit};
procedure LoadDLL;
begin
if DLLLoaded then Exit;
{$IFNDEF MSDOS}
ErrorMode := SetErrorMode($8000{SEM_NoO
{$ENDIF}
DLLHandle := LoadLibrary('VPNAPI.DLL');
if DLLHandle >= 32 then
begin
DLLLoaded := True;
SaveExit := ExitProc;
ExitProc := @NewExit;
@vpn_api_init := GetProcAddress(DLLHandle,'
{$IFDEF WIN32}
Assert(@vpn_api_init <> nil);
{$ENDIF}
@vpn_api_destroy := GetProcAddress(DLLHandle,'
{$IFDEF WIN32}
Assert(@vpn_api_destroy <> nil);
{$ENDIF}
@vpn_channel_init := GetProcAddress(DLLHandle,'
{$IFDEF WIN32}
Assert(@vpn_channel_init <> nil);
{$ENDIF}
@vpn_channel_destroy := GetProcAddress(DLLHandle,'
{$IFDEF WIN32}
Assert(@vpn_channel_destro
{$ENDIF}
@vpn_channel_get_socket := GetProcAddress(DLLHandle,'
{$IFDEF WIN32}
Assert(@vpn_channel_get_so
{$ENDIF}
@vpn_channel_event := GetProcAddress(DLLHandle,'
{$IFDEF WIN32}
Assert(@vpn_channel_event <> nil);
{$ENDIF}
@vpn_process_events := GetProcAddress(DLLHandle,'
{$IFDEF WIN32}
Assert(@vpn_process_events
{$ENDIF}
@vpn_channel_get_msgtypes := GetProcAddress(DLLHandle,'
{$IFDEF WIN32}
Assert(@vpn_channel_get_ms
{$ENDIF}
@vpn_connect := GetProcAddress(DLLHandle,'
{$IFDEF WIN32}
Assert(@vpn_connect <> nil);
{$ENDIF}
@vpn_acknowledge_banner := GetProcAddress(DLLHandle,'
{$IFDEF WIN32}
Assert(@vpn_acknowledge_ba
{$ENDIF}
@vpn_disconnect := GetProcAddress(DLLHandle,'
{$IFDEF WIN32}
Assert(@vpn_disconnect <> nil);
{$ENDIF}
@vpn_get_stats := GetProcAddress(DLLHandle,'
{$IFDEF WIN32}
Assert(@vpn_get_stats <> nil);
{$ENDIF}
@vpn_reset_stats := GetProcAddress(DLLHandle,'
{$IFDEF WIN32}
Assert(@vpn_reset_stats <> nil);
{$ENDIF}
@vpn_auth_respond := GetProcAddress(DLLHandle,'
{$IFDEF WIN32}
Assert(@vpn_auth_respond <> nil);
{$ENDIF}
@vpn_auth_abort := GetProcAddress(DLLHandle,'
{$IFDEF WIN32}
Assert(@vpn_auth_abort <> nil);
{$ENDIF}
end
else
begin
DLLLoaded := False;
{ Error: VPNAPI.DLL could not be loaded !! }
end;
{$IFNDEF MSDOS}
SetErrorMode(ErrorMode)
{$ENDIF}
end {LoadDLL};
begin
LoadDLL;
end.
Here are the header files:
vpnapi.h:
/*
note: the comments in this header file are used for automatic
documentation generation using doxygen (www.doxygen.org)
*/
#ifndef VPNAPI_H
#define VPNAPI_H
#ifdef __cplusplus
// *INDENT-OFF*
extern "C"
{
// *INDENT-ON*
#endif
#ifdef _WIN32
#include "windows_stdint.h"
#include <winsock.h>
#else
#include <inttypes.h>
#include <sys/types.h>
#include <netinet/in.h>
#endif
#ifdef _MSC_VER
/* disable warning:
nonstandard extension used: zero-sized array in struct/union
*/
#pragma warning( disable : 4200 )
#endif
#ifdef _WIN32
#define DLL_EXPORT_NAME __declspec(dllexport)
#else
typedef int SOCKET;
#define DLL_EXPORT_NAME
#endif
//! API version number
#define VPNAPI_VERSION 0x00010000
/**
* \defgroup constants Constants
*/
/*@{*/
/**
* \defgroup error_codes Error Codes
*/
/*@{*/
//! not an error
#define VPN_OK (0L)
#define VPN_ERROR (-1L)
//error codes are all preliminary and will be added/delete as
//the API is implemented.
//! input parameter has bad value
#define VPN_ERROR_BAD_PARAM (-2L)
//! profile name doesn't match an existing profile
#define VPN_ERROR_NOT_A_PROFILE (-3L)
//! interprocess communcation subsystem failed
#define VPN_ERROR_IPC_FAILURE (-4L)
//! unable to allocate memory
#define VPN_ERROR_OUT_OF_MEMORY (-5L)
//! cisco vpn service is not running
#define VPN_ERROR_SERVICE_NOT_RUNN
//! cisco vpn service is shutting down
#define VPN_ERROR_SERVICE_SHUTTING
//! no vpn connection exists
#define VPN_ERROR_NOT_CONNECTED (-8L)
//! vpn is attempting connect
#define VPN_ERROR_ALREADY_CONNECTI
//! vpn connection already exists
#define VPN_ERROR_ALREADY_CONNECTE
//! vpn connection aborted by user command
#define VPN_ERROR_CONNECT_ABORTED (-11L)
//! ppptool.exe could not be found (windows only)
#define VPN_ERROR_NO_PPPTOOL (-12L)
//! vpn driver failure
#define VPN_ERROR_DRIVER_FAIL (-13L)
//! all backup servers were unreachable
#define VPN_ERROR_NO_MORE_BACKUPS (-14L)
//! cannot bring up a ppp connection (windows only)
#define VPN_ERROR_PPP_FAIL (-15L)
//! cTCP layer failure
#define VPN_ERROR_CTCP_FAIL (-16L)
//! local IKE failure
#define VPN_ERROR_IKE_FAIL (-17L)
//! gethostbyname() failed
#define VPN_ERROR_HOSTNAME_LOOKUP_
//! user cancelled authentication
#define VPN_ERROR_USER_CANCELLED_A
//! IKE security association expired
#define VPN_ERROR_SA_EXPIRED (-20L)
//! could not contact remote peer
#define VPN_ERROR_PEER_NOT_RESPOND
//! moving to a different headedend in a load balancing group
#define VPN_ERROR_LOAD_BALANCING (-22L)
//! IKE negotiation failed
#define VPN_ERROR_IKE_NEG_FAILED (-23L)
//! duplicate IKE SA already exists
#define VPN_ERROR_DUPLICATE_EXISTS
//! headend does not support unity extentions to IKE
#define VPN_ERROR_NO_CLIENT_EXTENS
//! authentication failed
#define VPN_ERROR_USER_AUTH_FAILED
//! firewall was not detected
#define VPN_ERROR_FIREWALL_NO_LONG
//! firewall couldn't be configured to match headend policy
#define VPN_ERROR_UNABLE_TO_CONFIG
//! could not update peer certificate
#define VPN_ERROR_UPDATE_CERT_FAIL
//! client system DHCP address changed
#define VPN_ERROR_ADDRESS_CHANGE (-31L)
//! authentication phase failed
#define VPN_ERROR_AUTH_PHASE_ERROR
//! connection closed by remote error
#define VPN_ERROR_BY_ERROR (-33L)
//! connection closed by remote admininstrator command
#define VPN_ERROR_BY_ADMIN_COMMAND
//! remote SA expired
#define VPN_ERROR_BY_EXPIRED_LIFTI
//! remote server is shutting down
#define VPN_ERROR_SERVER_SHUTDOWN (-36L)
//! remote server is on fire!
#define VPN_ERROR_SERVER_IN_FLAMES
//! maximum connection time reached
#define VPN_ERROR_MAX_CONNECT_TIME
//! maximum idle time reache
#define VPN_ERROR_IDLE_TIMEOUT (-39L)
//! remote server is rebooting
#define VPN_ERROR_SERVER_REBOOT (-40L)
//! IKE phase 2 negotation failed
#define VPN_ERROR_PHASE2_PROPOSAL_
//! client firewall policy not accepted by server
#define VPN_ERROR_FIREWALL_MISMATC
//! client certificate expired
#define VPN_ERROR_CERT_EXPIRED (-43L)
//! client platform version not allowed
#define VPN_ERROR_PLATFORM_VERSION
//! remote server cannot contact zone firewall server
#define VPN_ERROR_ZONE_FIREWALL_SE
//! remote server closed connection, but won't say why
#define VPN_ERROR_NO_ERROR (-46L)
//! remote server closed connection, but didn't send a reson
#define VPN_ERROR_DEL_REASON_UNSPE
//! autoupdate needs to make the tunnel shutdown
#define VPN_ERROR_AUTOUPDATE_SHUTD
/*@}*/
/**
* \defgroup MSGTYPEs Message Types
* types of messages that client wants to send/recieve. These flags serve
* 2 purposes:
* 1. Requesting the right to perform an operation, such as initiating
* a vpn tunnel.
* 2. Enabling certain different types of messages from the VPN service.
*/
//! receive authentication messages.
/*! only 1 channel can do this at a time
* causes fp_auth and fp_auth_stop callbacks to be active.
*/
#define VPN_MSGTYPE_AUTH (1<<1)
//! receive state change updates.
/*! causes fp_state_change callback to be called whenever client state changes.
* Any number of channels can retrieve state change messages at once.
*/
#define VPN_MSGTYPE_STATE_CHANGE (1<<2)
//! mask of all valid MSGTYPE bits
#define VPN_MSGTYPE_MASK (VPN_MSGTYPE_AUTH | VPN_MSGTYPE_STATE_CHANGE)
/**
* \defgroup authattrs Authentication Attributes
*/
/*@{*/
//! instructions from headend to be displayed to the user.
#define VPN_AUTH_MESSAGE (1<<0)
//! Prompt: Username:
#define VPN_AUTH_USERNAME (1<<1)
//! Prompt: Password:
#define VPN_AUTH_PASSWORD (1<<2)
//! Prompt: Passcode:
#define VPN_AUTH_PASSCODE (1<<3)
//! Prompt: Response:
#define VPN_AUTH_ANSWER (1<<4)
//! Prompt: New PIN: & Confirm PIN:
#define VPN_AUTH_NEXTPIN (1<<5)
//! Prompt: New Password: & Confirm Password:
#define VPN_AUTH_NEXTPASSWORD (1<<6)
//! Prompt: Domain:
#define VPN_AUTH_DOMAIN (1<<7)
//! Prompt: PIN:
#define VPN_AUTH_PIN (1<<8)
//! Prompt: Next Cardcode:
#define VPN_AUTH_TOKENCODE (1<<9)
#define VPN_AUTH_MASK (VPN_AUTH_MESSAGE | VPN_AUTH_USERNAME | \
VPN_AUTH_PASSWORD | VPN_AUTH_PASSCODE | \
VPN_AUTH_ANSWER | VPN_AUTH_NEXTPIN | \
VPN_AUTH_NEXT_PASSWORD | VPN_AUTH_DOMAIN \ \
VPN_AUTH_PIN | VPN_AUTH_TOKENCODE)
/*@}*/
/**
* \defgroup STATGROUPs Statistic Groups
*/
/*@{*/
//! causes struct vpn_counters to be included in returned stats
#define VPN_STATGROUP_COUNTERS (1L<<0)
//! causes struct vpn_tunnel_info to be included in returned stats
#define VPN_STATGROUP_TUNNEL_INFO (1L<<1)
//! causes split tunnel, secured, and local lan routes to be returned
#define VPN_STATGROUP_ROUTES (1L<<2)
//! causes the connected profile name to be returned
#define VPN_STATGROUP_PROFILE (1L<<3)
//! mask of all possible statgroups
#define VPN_STATGROUP_MASK (VPN_STATGROUP_COUNTERS | \
VPN_STATGROUP_TUNNEL_INFO | \
VPN_STATGROUP_ROUTES | \
VPN_STATGROUP_PROFILE)
/*@}*/
/**
* \defgroup OPTIONs Connect Options
*/
/*@{*/
//! disable shutdown messages from the cisco GUI
#define VPN_OPT_SILENT_DISCONNECT (1L<<0)
#define VPN_OPT_MASK (VPN_OPT_SILENT_DISCONNECT
/*@}*/
/*@}*/
/**
* \defgroup types Data Types and Structures
*/
/*@{*/
//! return type for most functions
typedef int32_t vpn_error_t;
//! Possible states for a VPN connection.
typedef enum
{
VPN_MIN_STATE = -1,
//! VPN is not connected.
VPN_STATE_IDLE,
//! Waiting for PPP connection to come up.
VPN_STATE_WAIT_PPP,
//! Waiting for cTCP handshake to complete.
VPN_STATE_WAIT_CTCP,
//! Waiting for IKE Phase 1 to complete.
VPN_STATE_WAIT_PHASE1,
//! Waiting for authentication to complete.
VPN_STATE_WAIT_AUTH,
//! Waiting for MODE-CFG to complete.
VPN_STATE_WAIT_MODECFG,
//! Waiting for IKE Phase 2 to complete.
VPN_STATE_WAIT_PHASE2,
//! VPN is Connected.
VPN_STATE_CONNECTED,
VPN_MAX_STATE,
} vpn_state_t;
//! IPSec encryption algorithms
typedef enum
{
VPN_MIN_CRYPTO_ALG = 0,
//! DES
VPN_CRYPTO_DES,
//! 3DES
VPN_CRYPTO_3DES,
//! No Encryption
VPN_CRYPTO_NULL,
//! AES
VPN_CRYPTO_AES,
VPN_MAX_CRYPTO_ALG
} vpn_crypto_t;
//! IPSec authentication algorithms
typedef enum
{
VPN_MIN_HASH = 0,
//! HMAC-MD5
VPN_HASH_MD5,
//! HMAC-SHA
VPN_HASH_SHA,
VPN_MAX_HASH
} vpn_hash_t;
//! IP Compression algorithms
typedef enum
{
VPN_MIN_COMPRESS_ALG = 0,
//! No IP Compression
VPN_COMPRESS_NONE,
//! LZS
VPN_COMPRESS_LZS,
VPN_MAX_COMPRESS_ALG,
} vpn_compress_t;
//! NAT pass-through algorithms
typedef enum
{
VPN_MIN_NAT_MODE = 0,
//! Normal IPSec
VPN_NAT_NONE,
//! IPSec over UDP
VPN_NAT_IPSEC_OVER_UDP,
//! IPSec over cTCP
VPN_NAT_IPSEC_OVER_CTCP,
VPN_MAX_NAT_MODE
} vpn_nat_mode_t;
//! opaque representation of a communications channel with the VPN service
/*!
* This datatype is used to issue commands and receive data from the
* VPN service. It is intialized by calling vpn_channel_init() and
* destroyed by calling vpn_channel_destroy()
*/
typedef void *vpn_channel_t;
//! opaque representation VPN connection statistics
/*!
* This datastructure is accessed by the functions whose
* names begin with "vpn_stats"
*/
typedef void *vpn_stats_t;
//! opaque representation VPN authentication information
/*!
* This datastructure is accessed by the functions whose
* names begin with "vpn_auth"
*/
typedef void *vpn_auth_t;
//! datastructure represinting an IP address
/*! this datatype is set up so that ipv6 support can be added without
breaking binary compatibility. Also, the padding in struct ipv4 causes
an IPv4 address stored into this structure to be in a format understood
IPv6 address parsing routines.
*/
typedef union
{
struct
{
uint32_t pad[3];
//! IP address in network order
struct in_addr addr;
} ipv4;
#ifdef NOT_IMPLEMENTED
struct
{
struct in6_addr addr;
} ipv6;
#endif /* */
} vpn_ip_addr_t;
//! datastructure representing a route (secured or unsecured)
struct vpn_route
{
//! network portion of the address. (eg. 192.168.0.0)
vpn_ip_addr_t network;
//! netmask portion of the address. (eg. 255.255.255.0)
vpn_ip_addr_t mask;
//! bytes sent and received using this route.
uint32_t bytes;
//! is traffic secured?
uint16_t haskeys;
uint32_t reserved[2];
};
//! a set of routes.
struct vpn_routes
{
//! number of entries in the routes array
uint32_t num_routes;
uint32_t reserved[2];
//! contains num_routes vpn_route structures
struct vpn_route routes[];
};
//! IPSec traffic statistics
struct vpn_counters
{
//! number of seconds connected
uint32_t time_connected;
//! total bytes sent/received
uint32_t total_bytes;
//!
uint32_t bytes_sent;
//!
uint32_t bytes_recieved;
//! number of valid IPSec packets recieved
uint32_t packets_transformed;
//! number of packets successfully encrypted
uint32_t packets_encrypted;
//! number of packets successfully decrypted
uint32_t packets_decrypted;
//! number of packets sent without encryption
uint32_t packets_bypassed;
//! number of packets deleted by IPSec
uint32_t packets_discarded;
uint32_t reserved[2];
};
//! basic information about a VPN tunnel
struct vpn_tunnel_info
{
//! address of client on the internal network
vpn_ip_addr_t internal_addr;
//! address of currently connected headend
vpn_ip_addr_t peer_addr;
//! non-zero if the exclude local lan feature is enabled
uint8_t local_lan_enabled;
//! nat pass through mode
vpn_nat_mode_t nat_mode;
//! UDP or TCP port number used for nat passthrough
uint16_t nat_port;
//! encryption algorithm used for securing IPSec traffic
vpn_crypto_t crypto_algorithm;
//! encryption key length, in bytes
uint16_t crypto_key_length;
//! hash algorithm used for securing IPSec traffic
vpn_hash_t hash_algorithm;
//! IP compression algorithm
vpn_compress_t compress_algorithm;
uint32_t reserved[2];
};
//!
struct vpn_connect_error
{
vpn_error_t error;
uint32_t is_remote;
char * delete_reason;
uint32_t reserved[2];
};
/*@}*/
#ifndef VPN_API_DATATYPES_ONLY
/**
* \defgroup callbacks Callback Functions
*/
/*@{*/
//! callback for vpn_connect() results
/*!
* \param error error code from the vpn_connect() attempt.
* \param banner is a user displayable string that contains the login
* banner that the headend's administrator requires all users to
* acknowledge before connecting.
*/
typedef void (*vpn_connect_cb) (const struct vpn_connect_error *,
const char *banner);
//! callback for vpn_disconnect() result
/*!
* \param error error code from the vpn_disconnect() attempt
*/
typedef void (*vpn_disconnect_cb) (vpn_error_t error);
//! state transition callback
/*!
* \param state new state of the vpn connection.
* \param peer address of current headend. This may change during a
* connection attempt due to load balancing or backup servers.
* \param error when a state change happens because a connection
* attempt failed, this value will indicate the reason for the
* failure
*/
typedef void (*vpn_state_change_cb) (vpn_state_t state,
const vpn_ip_addr_t * peer,
const struct vpn_connect_error*);
//! callback for vpn_get_stats() results
/*!
* \param error error code from the vpn_get_stats() attempt.
* \param statgroups bitmask of VPN_STATGROUPS_ flags indicating which
* portions of the stats are available.
* \param stats handle used for accessing the various stats structures.
* This variable may be used only inside of this callback function.
*/
typedef void (*vpn_stats_cb) (vpn_error_t error, uint32_t stats_groups,
vpn_stats_t stats);
//! callback for authentication
/*!
* \param auth handle for accessing authentication attributes.
* This variable may be used until vpn_auth_respond() or
* vpn_auth_abort() is called, or vpn_auth_stop_cb() is
* recieved.
* \param auth_attrs bitmask of VPN_AUTH flags indicating which
* authentication attributes were requested by the headend
* \param allowed_save_attrs bitmask of VPN_AUTH flags indicating which
* authentication can be saved in the profile. See the save_attrs
* argument to vpn_auth_respond()
* \param profile_name
*/
typedef void (*vpn_auth_cb) (vpn_auth_t auth, uint32_t auth_attrs,
uint32_t allowed_save_attrs,
const char *profile_name);
//! callback to cancel authentication
/*!
* This callback is called to cancel any in-progress user authentication.
* All authentication user interfaces should be closed, and any state
* related to the authentication attempt should be destroyed.
*/
typedef void (*vpn_auth_stop_cb) (void);
//! structure for passing callback functions to the vpnapi
/*!
*/
struct vpn_callback_table
{
//! vpn_connect() callback
vpn_connect_cb fp_connect;
//! vpn_disconnect() callback
vpn_disconnect_cb fp_disconnect;
//! state change callback
vpn_state_change_cb fp_state_change;
//! vpn_get_stats() callback
vpn_stats_cb fp_stats;
//! authentication callback
vpn_auth_cb fp_auth;
//! authentication stop callback
vpn_auth_stop_cb fp_auth_stop;
};
/*@}*/
/*!
* \defgroup global Global Initialization Functions
*/
/*@{*/
//! must be called before any other api functions are called.
/*!
* \param version On input this should be set to VPNAPI_VERSION.
* On output it will be set to the version number supported in
* the shared library.
*/
DLL_EXPORT_NAME vpn_error_t vpn_api_init(uint32_t * version);
//! call when done issuing api calls
DLL_EXPORT_NAME vpn_error_t vpn_api_destroy(void);
/*@}*/
/*!
* \defgroup channel_functions Communications Channel Functions
* types of messages that client wants to send/recieve
*/
/*@{*/
//! initialize a communications channel to the VPN service component
/*!
\param channel will be set by this function
\param msgtypes should be set to some of flags above. On return, it will
be set to the VPN_MSGTYPEs that can actually be sent.
\param callbacks should be initialized with pointers to the callback
funcitons you want to use
*/
DLL_EXPORT_NAME vpn_error_t vpn_channel_init(vpn_chann
uint32_t * msgtypes,
const struct
vpn_callback_table *callbacks);
//! destroy the communictations channel
/*!
\param channel will be destroyed by this function.
*/
DLL_EXPORT_NAME vpn_error_t vpn_channel_destroy(vpn_ch
//! retreives a OS-level descriptor for the channel.
/*! This descriptor should only be used to initialize an event loop, either
* with select(), WaitForMultipleObjects() or similar functions
* \param channel
* \returns a socket descriptor
*/
DLL_EXPORT_NAME SOCKET vpn_channel_get_socket(vpn
//! event handling function
/*! call this function when the socket from vpn_channel_get_socket() becomes
* readable. All calls to callback functions will be made from within
* this function.
* \param channel
*/
DLL_EXPORT_NAME vpn_error_t vpn_channel_event(vpn_chan
//! simplified event handling function
/*! this function implements a simple event loop, which calls
* vpn_channel_event().
*
* this function.
* \param channel
* \param max_wait maximum time to wait for events.
*/
DLL_EXPORT_NAME vpn_error_t vpn_process_events(vpn_cha
//! retrieve msgtypes flags that were set in call to vpn_channel_init()
/*!
* \param channel
* \returns a bitmask of VPN_MSGTYPES
*/
DLL_EXPORT_NAME uint32_t vpn_channel_get_msgtypes(v
/*@}*/
/**
* \defgroup command_functions Command functions
* types of messages that client wants to send/recieve
*/
/*@{*/
//! try to connect using a given profile.
/*!
* \param channel the channel to use for sending the command
* \param profile the name of the profile
* \param group_name the name of the profile. May be NULL if the
* group name is saved in the profile
* \param password is the group password or the certificate password,
* depending on the setting of AuthType value in the profile.
* may be NULL if the group password is saved in the profile.
* \param option_flags bitmask of VPN_OPT_* flags.
*
* Calling this function will cause fp_connect to be called when the
* connection attempt suceeds. Additionally, fp_stats will be called
* for state changes during the connection attempt and fp_auth/fp_auth_stop
* will be called to handle authentication.
*/
DLL_EXPORT_NAME vpn_error_t vpn_connect(vpn_channel_t channel,
const char *profile,
const char *group_name,
const char *password,
uint32_t option_flags);
//! used to return users response to the banner given in vpn_connect_cb()
/*!
* \param channel
* \param banner_accepted TRUE if the user agrees to the banner,
* FALSE if the user disagrees.
*/
DLL_EXPORT_NAME vpn_error_t vpn_acknowledge_banner(vpn
int banner_accepted);
//! disconnect the vpn tunnel.
/*! causes fp_disconnect to be called with the result of the disconnect
* attempt. No VPN_MSGTYPE flag is needed to send.
*/
DLL_EXPORT_NAME vpn_error_t vpn_disconnect(vpn_channel
//! request statistics to be sent
/*! causes fp_statistics to be called. no mstype needed to send.
* \param channel
* \param stats_groups flags describing which statistics to send.
* use VPN_STATGROUP flags
*/
DLL_EXPORT_NAME vpn_error_t vpn_get_stats(vpn_channel_
uint32_t stats_groups);
//! Reset byte and packet counts in the statistics
/*! no mstype needed to send.
* \param channel
*/
DLL_EXPORT_NAME vpn_error_t vpn_reset_stats(vpn_channe
//! reply to a fp_auth callback.
/*!
* This function is called to pass back authentication attributes
* to the headend. msgtype VPN_MSGTYPE_AUTH is needed to send.
* \param channel
* \param auth
* \param save_attrs a bitmask of VPN_AUTH flags indicating which
* attributes should be saved in the profile. Attributes
* that were not set in the allowed_save_attrs argument
* to vpn_auth_cb will be ignored.
*/
DLL_EXPORT_NAME vpn_error_t vpn_auth_respond(vpn_chann
vpn_auth_t auth,
uint32_t save_attrs);
//! negative reply to a fp_auth callback.
/*!
* This function is called to cancel an authentication attempt.
* msgtype VPN_MSGTYPE_AUTH is needed to send.
* \param channel
* \param auth
*/
DLL_EXPORT_NAME vpn_error_t vpn_auth_abort(vpn_channel
vpn_auth_t auth);
/*@}*/
/**
* \defgroup stats_functions Statistics Functions
* Functions for accessing components of vpn_stats_t. These functions
* should only be used inside of your vpn_stats_cb. The memory
* returned by these functions is only valid in your vpn_stats_cb
* function. If need to use the data returned outside of this function,
* you should make a copy of the data.
*/
/*@{*/
//! returns list of local networks excluded from the VPN tunnel
DLL_EXPORT_NAME const struct vpn_routes
*vpn_stats_get_local_lan_r
//! returns list of networks included in the VPN tunnel
DLL_EXPORT_NAME const struct vpn_routes
*vpn_stats_get_secure_rout
//! returns basic information about the VPN tunnel
DLL_EXPORT_NAME const struct vpn_tunnel_info
*vpn_stats_get_tunnel_info
//! returns traffic information about the VPN tunnel
DLL_EXPORT_NAME const struct vpn_counters
*vpn_stats_get_counters(vp
//! returns the name of the profile used for the current VPN tunnel
DLL_EXPORT_NAME const char *vpn_stats_get_profile_nam
/*@}*/
/**
* \defgroup auth_functions Authentication Functions
* Functions for accessing components of vpn_auth_t. These functions
* should only be used inside of your vpn_stats_cb
*/
/*@{*/
/*!
\param auth authentication handle passed to vpn_auth_cb
\param auth_attr the authentication attribute to get
*/
DLL_EXPORT_NAME const char *vpn_auth_get_attribute(vp
uint32_t auth_attr);
/*!
\param auth authentication handle passed to vpn_auth_cb
\param auth_attr the authentication attribute to set
\param value new value for the attribute.
*/
DLL_EXPORT_NAME vpn_error_t vpn_auth_set_attribute(vpn
uint32_t auth_attr,
const char *value);
#ifdef _WIN32
DLL_EXPORT_NAME HANDLE vpn_get_service_start_even
#endif
#endif //VPN_API_DATATYPES_ONLY
/*@}*/
#ifdef _MSC_VER
/* re-enable warning:
nonstandard extension used: zero-sized array in struct/union
*/
#pragma warning( default: 4200 )
#endif
#ifdef __cplusplus
// *INDENT-OFF*
}
// *INDENT-ON*
#endif
#endif // VPNAPI_H
windows_stdint.h:
#ifndef WINDOWS_STDINT_H
#define WINDOWS_STDINT_H
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed long int32_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned long uint32_t;
#endif //WINDOWS_STDINT_H
I agree with robert :-)
you can download the C-to-Pascal Header Converter ftp://delphi-jedi.org//darth/headconv.zip from PROJECT JEDI
Best Regards
Cesario
you can download the C-to-Pascal Header Converter ftp://delphi-jedi.org//darth/headconv.zip from PROJECT JEDI
Best Regards
Cesario
ASKER
Cesario, I did include the original headers, my own attempt was partly bases on headconv. Do you want me to mail you the header files?
Hi RemkoEB,
I am sorry, but I too busy check you your original header.
Regards
Cesario
I am sorry, but I too busy check you your original header.
Regards
Cesario
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm currently testing, we seem to be close to getting it working.
ASKER
Headers are converted by and seem to be working. Callback functions are not working at this moment, but it's not likely that this is a problem with the conversion. So I will accept the answer here.
ASKER
In order to get the callbacks working you need to poll process_events
Hi RemkoEB and Robert ... I have the same problem with the same code. Is it possible to get a view of this solution?
The above headconv output is too ugly to work on.