Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

sbc/opt/cisco-vpnclient/include/vpnapi.h

Go to the documentation of this file.
00001 /* 
00002     note: the comments in this header file are used for automatic 
00003    documentation generation using doxygen (www.doxygen.org)
00004 */
00005 #ifndef VPNAPI_H
00006 #define VPNAPI_H
00007 
00008 #ifdef __cplusplus
00009 // *INDENT-OFF*
00010 extern "C"
00011 {
00012 // *INDENT-ON*
00013 #endif
00014 #ifdef _WIN32
00015 #include "windows_stdint.h"
00016 #include <winsock.h>
00017 #else
00018 #include <inttypes.h>
00019 #include <sys/types.h>
00020 #include <netinet/in.h>
00021 #endif
00022 
00023 #ifdef _MSC_VER
00024 /* disable warning: 
00025     nonstandard extension used: zero-sized array in struct/union
00026 */
00027 #pragma warning( disable : 4200 )
00028 #endif
00029 
00030 #ifdef _WIN32
00031 #define DLL_EXPORT_NAME __declspec(dllexport)
00032 #define CDECLAPI __cdecl
00033 #else
00034 typedef int SOCKET;
00035 
00036 #define CDECLAPI
00037 #define DLL_EXPORT_NAME
00038 #endif
00039 
00041 #define VPNAPI_VERSION 0x00010000
00042 
00046 
00062 
00063 
00066 #define VPN_MSGTYPE_AUTH   (1<<1)
00067 
00069 
00072 #define VPN_MSGTYPE_STATE_CHANGE (1<<2)
00073 
00075 #define VPN_MSGTYPE_MASK (VPN_MSGTYPE_AUTH | VPN_MSGTYPE_STATE_CHANGE)
00076 
00081 
00082 #define VPN_AUTH_MESSAGE      (1<<0)
00083 
00084 #define VPN_AUTH_USERNAME     (1<<1)
00085 
00086 #define VPN_AUTH_PASSWORD     (1<<2)
00087 
00088 #define VPN_AUTH_PASSCODE     (1<<3)
00089 
00090 #define VPN_AUTH_ANSWER       (1<<4)
00091 
00092 #define VPN_AUTH_NEXTPIN      (1<<5)
00093 
00094 #define VPN_AUTH_NEXTPASSWORD (1<<6)
00095 
00096 #define VPN_AUTH_DOMAIN       (1<<7)
00097 
00098 #define VPN_AUTH_PIN          (1<<8)
00099 
00100 #define VPN_AUTH_TOKENCODE    (1<<9)
00101 
00102 #define VPN_AUTH_MASK (VPN_AUTH_MESSAGE | VPN_AUTH_USERNAME | \
00103                        VPN_AUTH_PASSWORD | VPN_AUTH_PASSCODE | \
00104                        VPN_AUTH_ANSWER |  VPN_AUTH_NEXTPIN | \
00105                        VPN_AUTH_NEXT_PASSWORD | VPN_AUTH_DOMAIN \ \
00106                        VPN_AUTH_PIN | VPN_AUTH_TOKENCODE)
00107 
00112 
00113 #define VPN_STATGROUP_COUNTERS      (1L<<0)
00114 
00115 #define VPN_STATGROUP_TUNNEL_INFO   (1L<<1)
00116 
00117 #define VPN_STATGROUP_ROUTES        (1L<<2)
00118 
00119 #define VPN_STATGROUP_PROFILE       (1L<<3)
00120 
00121 #define VPN_STATGROUP_MASK (VPN_STATGROUP_COUNTERS | \
00122         VPN_STATGROUP_TUNNEL_INFO | \
00123         VPN_STATGROUP_ROUTES | \
00124         VPN_STATGROUP_PROFILE)
00125 
00130 
00131 #define VPN_OPT_SILENT_DISCONNECT   (1L<<0)
00132 #define VPN_OPT_MASK (VPN_OPT_SILENT_DISCONNECT)
00133 
00139 
00140 typedef int32_t vpn_error_t;
00141 
00143 typedef enum
00144 {
00145     VPN_MIN_STATE = -1,
00147     VPN_STATE_IDLE,
00149     VPN_STATE_WAIT_PPP,
00151     VPN_STATE_WAIT_CTCP,
00153     VPN_STATE_WAIT_PHASE1,
00155     VPN_STATE_WAIT_AUTH,
00157     VPN_STATE_WAIT_MODECFG,
00159     VPN_STATE_WAIT_PHASE2,
00161     VPN_STATE_CONNECTED, 
00162     VPN_MAX_STATE,
00163 } vpn_state_t;
00164 
00166 typedef enum
00167 {
00168     VPN_MIN_CRYPTO_ALG = 0,
00170     VPN_CRYPTO_DES,
00172     VPN_CRYPTO_3DES,
00174     VPN_CRYPTO_NULL,
00176     VPN_CRYPTO_AES,
00177     VPN_MAX_CRYPTO_ALG
00178 } vpn_crypto_t;
00179 
00181 typedef enum
00182 {
00183     VPN_MIN_HASH = 0,
00185     VPN_HASH_MD5,
00187     VPN_HASH_SHA,
00188     VPN_MAX_HASH
00189 } vpn_hash_t;
00190 
00192 typedef enum
00193 { 
00194     VPN_MIN_COMPRESS_ALG = 0,
00196     VPN_COMPRESS_NONE,
00198     VPN_COMPRESS_LZS, 
00199     VPN_MAX_COMPRESS_ALG,
00200 } vpn_compress_t;
00201 
00203 typedef enum
00204 { 
00205     VPN_MIN_NAT_MODE = 0,
00207     VPN_NAT_NONE,
00209     VPN_NAT_IPSEC_OVER_UDP,
00211     VPN_NAT_IPSEC_OVER_CTCP,
00212     VPN_MAX_NAT_MODE
00213 } vpn_nat_mode_t;
00214 
00216 
00221 typedef void *vpn_channel_t;
00222 
00224 
00228 typedef void *vpn_stats_t;
00229 
00231 
00235 typedef void *vpn_auth_t;
00236 
00238 
00243 typedef union
00244 {
00245     struct
00246     {
00247         uint32_t pad[3];
00248 
00250         struct in_addr addr;
00251     } ipv4;
00252 
00253 #ifdef NOT_IMPLEMENTED
00254     struct
00255     {
00256         struct in6_addr addr;
00257     } ipv6;
00258 
00259 #endif                          /*  */
00260 } vpn_ip_addr_t;
00261 
00263 struct vpn_route
00264 {
00265 
00267     vpn_ip_addr_t network;
00268 
00270     vpn_ip_addr_t mask;
00271 
00273     uint32_t bytes;
00274 
00276     uint16_t haskeys;
00277 
00278     uint32_t reserved[2];
00279 };
00280 
00282 struct vpn_routes
00283 {
00284 
00286     uint32_t num_routes;
00287 
00288     uint32_t reserved[2];
00289 
00291     struct vpn_route routes[];
00292 };
00293 
00295 struct vpn_counters
00296 {
00297 
00299     uint32_t time_connected;
00300 
00302     uint32_t total_bytes;
00303 
00305     uint32_t bytes_sent;
00306 
00308     uint32_t bytes_recieved;
00309 
00311     uint32_t packets_transformed;
00312 
00314     uint32_t packets_encrypted;
00315 
00317     uint32_t packets_decrypted;
00318 
00320     uint32_t packets_bypassed;
00321 
00323     uint32_t packets_discarded;
00324 
00325     uint32_t reserved[2];
00326 };
00327 
00329 struct vpn_tunnel_info
00330 {
00331 
00333     vpn_ip_addr_t internal_addr;
00334 
00336     vpn_ip_addr_t peer_addr;
00337 
00339     uint8_t local_lan_enabled;
00340 
00342     vpn_nat_mode_t nat_mode;
00343 
00345     uint16_t nat_port;
00346 
00348     vpn_crypto_t crypto_algorithm;
00349 
00351     uint16_t crypto_key_length;
00352 
00354     vpn_hash_t hash_algorithm;
00355 
00357     vpn_compress_t compress_algorithm;
00358 
00359     uint32_t reserved[2];
00360 };
00361 
00363 struct vpn_connect_error
00364 {
00365     vpn_error_t error;
00366     uint32_t is_remote;
00367     char * delete_reason;
00368 
00369     uint32_t reserved[2];
00370 };
00371 
00373 #ifndef VPN_API_DATATYPES_ONLY
00374 
00378 
00379 
00385 typedef void (*vpn_connect_cb) (const struct vpn_connect_error *,
00386                                 const char *banner);
00387 
00389 
00392 typedef void (*vpn_disconnect_cb) (vpn_error_t error);
00393 
00395 
00403 typedef void (*vpn_state_change_cb) (vpn_state_t state,
00404                                      const vpn_ip_addr_t * peer,
00405                                      const struct vpn_connect_error*);
00406 
00408 
00415 typedef void (*vpn_stats_cb) (vpn_error_t error, uint32_t stats_groups,
00416                               vpn_stats_t stats);
00417 
00419 
00431 typedef void (*vpn_auth_cb) (vpn_auth_t auth, uint32_t auth_attrs,
00432                              uint32_t allowed_save_attrs,
00433                              const char *profile_name);
00434 
00436 
00441 typedef void (*vpn_auth_stop_cb) (void);
00442 
00444 
00446 struct vpn_callback_table
00447 {
00448 
00450     vpn_connect_cb fp_connect;
00451 
00453     vpn_disconnect_cb fp_disconnect;
00454 
00456     vpn_state_change_cb fp_state_change;
00457 
00459     vpn_stats_cb fp_stats;
00460 
00462     vpn_auth_cb fp_auth;
00463 
00465     vpn_auth_stop_cb fp_auth_stop;
00466 };
00467 
00474 
00475 
00480 DLL_EXPORT_NAME vpn_error_t CDECLAPI vpn_api_init(uint32_t * version);
00481 
00483 DLL_EXPORT_NAME vpn_error_t CDECLAPI vpn_api_destroy(void);
00484 
00492 
00493 
00500 DLL_EXPORT_NAME vpn_error_t CDECLAPI
00501     vpn_channel_init(vpn_channel_t * channel,
00502                      uint32_t * msgtypes,
00503                      const struct vpn_callback_table *callbacks);
00504 
00506 
00509 DLL_EXPORT_NAME vpn_error_t CDECLAPI vpn_channel_destroy(vpn_channel_t channel);
00510 
00512 
00517 DLL_EXPORT_NAME SOCKET CDECLAPI vpn_channel_get_socket(vpn_channel_t channel);
00518 
00520 
00525 DLL_EXPORT_NAME vpn_error_t CDECLAPI vpn_channel_event(vpn_channel_t channel);
00527 
00534 DLL_EXPORT_NAME vpn_error_t CDECLAPI
00535     vpn_process_events(vpn_channel_t channel, unsigned int max_wait);
00536 
00538 
00542 DLL_EXPORT_NAME uint32_t CDECLAPI
00543     vpn_channel_get_msgtypes(vpn_channel_t channel);
00544 
00552 
00553 
00568 DLL_EXPORT_NAME vpn_error_t CDECLAPI
00569     vpn_connect(vpn_channel_t channel,
00570                 const char *profile,
00571                 const char *group_name,
00572                 const char *password,
00573                 uint32_t option_flags);
00574 
00576 
00581 DLL_EXPORT_NAME vpn_error_t CDECLAPI
00582     vpn_acknowledge_banner(vpn_channel_t channel,
00583                            int banner_accepted);
00584 
00586 
00589 DLL_EXPORT_NAME vpn_error_t CDECLAPI vpn_disconnect(vpn_channel_t channel);
00590 
00592 
00597 DLL_EXPORT_NAME vpn_error_t CDECLAPI
00598     vpn_get_stats(vpn_channel_t channel,
00599                   uint32_t stats_groups);
00600 
00602 
00605 DLL_EXPORT_NAME vpn_error_t CDECLAPI vpn_reset_stats(vpn_channel_t channel);
00606 
00608 
00618 DLL_EXPORT_NAME vpn_error_t CDECLAPI
00619     vpn_auth_respond(vpn_channel_t channel,
00620                      vpn_auth_t auth,
00621                      uint32_t save_attrs);
00622 
00624 
00630 DLL_EXPORT_NAME vpn_error_t CDECLAPI
00631     vpn_auth_abort(vpn_channel_t channel,
00632                    vpn_auth_t auth);
00633 
00645 
00646 DLL_EXPORT_NAME const struct vpn_routes * CDECLAPI
00647     vpn_stats_get_local_lan_routes(vpn_stats_t stats);
00648 
00650 DLL_EXPORT_NAME const struct vpn_routes * CDECLAPI
00651     vpn_stats_get_secure_routes(vpn_stats_t stats);
00652 
00654 DLL_EXPORT_NAME const struct vpn_tunnel_info * CDECLAPI
00655     vpn_stats_get_tunnel_info(vpn_stats_t stats);
00656 
00658 DLL_EXPORT_NAME const struct vpn_counters * CDECLAPI
00659     vpn_stats_get_counters(vpn_stats_t stats);
00660 
00662 DLL_EXPORT_NAME const char * CDECLAPI
00663     vpn_stats_get_profile_name(vpn_stats_t stats);
00664 
00677 DLL_EXPORT_NAME const char * CDECLAPI
00678     vpn_auth_get_attribute(vpn_auth_t auth,
00679                            uint32_t auth_attr);
00680 
00686 DLL_EXPORT_NAME vpn_error_t CDECLAPI
00687     vpn_auth_set_attribute(vpn_auth_t auth,
00688                            uint32_t auth_attr,
00689                            const char *value);
00690 
00691 #ifdef _WIN32
00692 DLL_EXPORT_NAME HANDLE CDECLAPI vpn_get_service_start_event(void);
00693 DLL_EXPORT_NAME HANDLE CDECLAPI vpn_get_gui_start_event(void);
00694 #endif
00695 
00696 #endif //VPN_API_DATATYPES_ONLY
00697 
00698 #ifdef _MSC_VER
00699 /* re-enable warning: 
00700     nonstandard extension used: zero-sized array in struct/union
00701 */
00702 #pragma warning( default: 4200 )
00703 #endif
00704 
00705 #ifdef __cplusplus
00706 // *INDENT-OFF*
00707 }
00708 // *INDENT-ON*
00709 #endif
00710 #endif // VPNAPI_H

Generated on Fri Sep 1 14:25:50 2006 for Raptor by  doxygen 1.4.4