OpenVPN
Data Structures | Macros | Enumerations | Functions | Variables
service.h File Reference
#include <winsock2.h>
#include <windows.h>
#include <stdlib.h>
#include <tchar.h>
#include "../tapctl/basic.h"
Include dependency graph for service.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  openvpn_service_t
 
struct  settings_t
 

Macros

#define UNICODE
 
#define APPNAME   TEXT(PACKAGE) TEXT("serv")
 
#define SERVICE_DEPENDENCIES   TEXT(TAP_WIN_COMPONENT_ID) TEXT("\0Dhcp\0\0")
 
#define MSG_FLAGS_ERROR   (1<<0)
 
#define MSG_FLAGS_SYS_CODE   (1<<1)
 
#define M_INFO   (0) /* informational */
 
#define M_SYSERR   (MSG_FLAGS_ERROR|MSG_FLAGS_SYS_CODE) /* error + system code */
 
#define M_ERR   (MSG_FLAGS_ERROR) /* error */
 
#define MAX_NAME   256
 

Enumerations

enum  openvpn_service_type { interactive , _service_max }
 

Functions

VOID WINAPI ServiceStartInteractiveOwn (DWORD argc, LPTSTR *argv)
 
VOID WINAPI ServiceStartInteractive (DWORD argc, LPTSTR *argv)
 
DWORD GetOpenvpnSettings (settings_t *s)
 
BOOL ReportStatusToSCMgr (SERVICE_STATUS_HANDLE service, SERVICE_STATUS *status)
 
LPCTSTR GetLastErrorText (void)
 
DWORD MsgToEventLog (DWORD flags, LPCTSTR lpszMsg,...)
 
wchar_t * utf8to16_size (const char *utf8, int size)
 Convert a UTF-8 string to UTF-16.
 
static wchar_t * utf8to16 (const char *utf8)
 Convert a zero terminated UTF-8 string to UTF-16.
 
const wchar_t * get_win_sys_path (void)
 

Variables

openvpn_service_t interactive_service
 
LPCTSTR service_instance
 

Macro Definition Documentation

◆ APPNAME

#define APPNAME   TEXT(PACKAGE) TEXT("serv")

Definition at line 42 of file service.h.

◆ M_ERR

#define M_ERR   (MSG_FLAGS_ERROR) /* error */

Definition at line 52 of file service.h.

◆ M_INFO

#define M_INFO   (0) /* informational */

Definition at line 50 of file service.h.

◆ M_SYSERR

#define M_SYSERR   (MSG_FLAGS_ERROR|MSG_FLAGS_SYS_CODE) /* error + system code */

Definition at line 51 of file service.h.

◆ MAX_NAME

#define MAX_NAME   256

Definition at line 67 of file service.h.

◆ MSG_FLAGS_ERROR

#define MSG_FLAGS_ERROR   (1<<0)

Definition at line 48 of file service.h.

◆ MSG_FLAGS_SYS_CODE

#define MSG_FLAGS_SYS_CODE   (1<<1)

Definition at line 49 of file service.h.

◆ SERVICE_DEPENDENCIES

#define SERVICE_DEPENDENCIES   TEXT(TAP_WIN_COMPONENT_ID) TEXT("\0Dhcp\0\0")

Definition at line 43 of file service.h.

◆ UNICODE

#define UNICODE

Definition at line 29 of file service.h.

Enumeration Type Documentation

◆ openvpn_service_type

Enumerator
interactive 
_service_max 

Definition at line 54 of file service.h.

Function Documentation

◆ get_win_sys_path()

const wchar_t * get_win_sys_path ( void  )

◆ GetLastErrorText()

LPCTSTR GetLastErrorText ( void  )

Definition at line 184 of file common.c.

Referenced by CmdInstallServices(), CmdRemoveServices(), CmdStartService(), and MsgToEventLog().

◆ GetOpenvpnSettings()

DWORD GetOpenvpnSettings ( settings_t s)

◆ MsgToEventLog()

DWORD MsgToEventLog ( DWORD  flags,
LPCTSTR  lpszMsg,
  ... 
)

◆ ReportStatusToSCMgr()

BOOL ReportStatusToSCMgr ( SERVICE_STATUS_HANDLE  service,
SERVICE_STATUS *  status 
)

Definition at line 22 of file service.c.

References MSG_FLAGS_ERROR, MsgToEventLog(), service, and status.

Referenced by ServiceCtrlInteractive(), and ServiceStartInteractive().

◆ ServiceStartInteractive()

VOID WINAPI ServiceStartInteractive ( DWORD  argc,
LPTSTR *  argv 
)

◆ ServiceStartInteractiveOwn()

VOID WINAPI ServiceStartInteractiveOwn ( DWORD  argc,
LPTSTR *  argv 
)

Definition at line 2257 of file interactive.c.

References ServiceStartInteractive(), and status.

Referenced by _tmain().

◆ utf8to16()

static wchar_t * utf8to16 ( const char *  utf8)
inlinestatic

Convert a zero terminated UTF-8 string to UTF-16.

This is just a wrapper function that always passes -1 as string size to utf8to16_size.

Parameters
utf8const string to be converted
Returns
wchar_t* heap allocated result string

Definition at line 123 of file service.h.

References utf8to16_size().

Referenced by HandleDNSConfigMessage(), HandleWINSConfigMessage(), InterfaceLuid(), and SetDNSDomain().

◆ utf8to16_size()

wchar_t * utf8to16_size ( const char *  utf8,
int  size 
)

Convert a UTF-8 string to UTF-16.

The size parameter can be used to convert strings which contain inline NUL characters, like MULTI_SZ strings used as values in the registry do, or (sub)strings that are not zero terminated. If size is -1 the length of the string is determined automatically by the WIN32 API. Make sure you pass a terminated string or else bad things will happen. Note that the size you pass should always include the terminating zero as well.

If the returned string is not NULL it must be freed by the caller.

Parameters
utf8const string to be converted
sizethe size of the string
Returns
wchar_t* heap allocated result string

Definition at line 251 of file common.c.

Referenced by utf8to16().

Variable Documentation

◆ interactive_service

openvpn_service_t interactive_service
extern

Definition at line 61 of file interactive.c.

Referenced by _tmain(), and ServiceStartInteractive().

◆ service_instance

LPCTSTR service_instance
extern