| AnyConnect Secure Mobility Client 5.1.10.233

CLIClientImpl.h
1/******************************************************************************\
2 * This sample is supplied as is with no implied warranty.
3 * It is designed to assist you in using the Cisco AnyConnect VPN API.
4 * It is assumed that you will build a production application and
5 * refer to this sample as a reference only.
6 \*****************************************************************************/
7
8#ifndef _CLICLIENTIMPL_
9#define _CLICLIENTIMPL_
10
11#include <mutex>
12#include <stdio.h>
13#include <stdlib.h>
14#include "ClientIfc.h"
15
16 enum RequestType
17{
18 REQ_CONNECT,
19 REQ_GROUPLIST,
20 REQ_STATE,
21 REQ_STATISTICS,
22 REQ_DISCONNECT,
23 REQ_END
24};
25
26/**
27 * This is an example application demonstrating the implementation of the
28 * AnyConnect API
29 */
30
31 class CLIClientImpl : public ClientIfc
32{
33 public:
34
35 CLIClientImpl();
36 virtual ~CLIClientImpl();
37
38 // The following methods are for support and not considered part of
39 // the main API interface.
40
41 void printHostList();
42
43 void printDefaultHost();
44
45 void connect(std::string host, std::string user,
46 std::string password, std::string group);
47
48 void disconnect();
49
50 void showGroups(std::string host);
51
52 /**
53 * This method demonstrates accessing the statistics data delivered
54 * via the ClientIfc::StatsCB method.
55 */
56 void getStats();
57
58 /**
59 * Method with example of parsing ConnectPromptInfo.
60 *
61 * This method is triggered by an API call on the method
62 * UserPromptCB(ConnectPromptInfo &).
63 */
64 void setUserData(ConnectPromptInfo &ConnectPrompt);
65
66 void printGroupList(ConnectPromptInfo &ConnectPrompt);
67
68 std::wstring convertMultiByteToWide(const std::string &sInputData);
69
70 void EventAvailable();
71 void ProcessEvents();
72
73 void SetRequestType(RequestType e_RequestType);
74
75 protected:
76
77 void StatsCB(VPNStats &stats);
78
79 void StateCB(const VPNState state,
80 const VPNSubState subState,
81 const tstring stateString);
82
83 void BannerCB(const tstring &banner);
84
85 void PreConnectReminderCB(const tstring &rtstrPreConnectReminder);
86
87 void NoticeCB(const tstring &notice,
88 const MessageType type,
89 const bool bSensitive = false);
90
91 void ExitNoticeCB(const tstring &notice,
92 const int returnCode);
93
94 void ServiceReadyCB();
95
96 void UserPromptCB(ConnectPromptInfo &ConnectPrompt);
97
98 void CertBlockedCB(const tstring &rtstrUntrustedServer);
99 void CertWarningCB(const tstring &rtstrUntrustedServer,
100 const std::list<tstring> &rltstrCertErrors,
101 bool bAllowImport);
102
103
104 private:
105
106 RequestType me_RequestType;
107
108 tstring ms_user,
109 ms_pswd,
110 ms_group;
111
112 std::mutex mtx;
113 volatile bool mb_exit;
114 volatile bool mb_eventAvailable;
115 bool mb_ConnectingStateReceived;
116};
117
118
119#endif // _CLICLIENTIMPL_
VPNSubState
VPNSubState
Definition api.h:169
MessageType
MessageType
Definition api.h:109
tstring
#define tstring
Definition api.h:35
VPNState
VPNState
Definition api.h:145
CLIClientImpl::ServiceReadyCB
void ServiceReadyCB()
Definition CLIClientImpl.cpp:237
CLIClientImpl::EventAvailable
void EventAvailable()
Definition CLIClientImpl.cpp:499
CLIClientImpl::setUserData
void setUserData(ConnectPromptInfo &ConnectPrompt)
Definition CLIClientImpl.cpp:266
CLIClientImpl::BannerCB
void BannerCB(const tstring &banner)
Definition CLIClientImpl.cpp:87
CLIClientImpl::ExitNoticeCB
void ExitNoticeCB(const tstring &notice, const int returnCode)
Definition CLIClientImpl.cpp:138
CLIClientImpl::StatsCB
void StatsCB(VPNStats &stats)
Definition CLIClientImpl.cpp:394
CLIClientImpl::PreConnectReminderCB
void PreConnectReminderCB(const tstring &rtstrPreConnectReminder)
Definition CLIClientImpl.cpp:94
CLIClientImpl::getStats
void getStats()
Definition CLIClientImpl.cpp:208
CLIClientImpl::StateCB
void StateCB(const VPNState state, const VPNSubState subState, const tstring stateString)
Definition CLIClientImpl.cpp:37
CLIClientImpl::CertWarningCB
void CertWarningCB(const tstring &rtstrUntrustedServer, const std::list< tstring > &rltstrCertErrors, bool bAllowImport)
Definition CLIClientImpl.cpp:447
CLIClientImpl::NoticeCB
void NoticeCB(const tstring &notice, const MessageType type, const bool bSensitive=false)
Definition CLIClientImpl.cpp:108
CLIClientImpl::CertBlockedCB
void CertBlockedCB(const tstring &rtstrUntrustedServer)
Definition CLIClientImpl.cpp:441
CLIClientImpl::UserPromptCB
void UserPromptCB(ConnectPromptInfo &ConnectPrompt)
Definition CLIClientImpl.cpp:240
ConnectPromptInfo
Definition ConnectPromptInfo.h:38
VPNStats
Definition VPNStats.h:36