OpenVPN
service.h
Go to the documentation of this file.
1/*
2 * OpenVPN -- An application to securely tunnel IP networks
3 * over a single TCP/UDP port, with support for SSL/TLS-based
4 * session authentication and key exchange,
5 * packet encryption, packet authentication, and
6 * packet compression.
7 *
8 * Copyright (C) 2013-2024 Heiko Hund <heiko.hund@sophos.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2
12 * as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 */
23
24#ifndef _SERVICE_H
25#define _SERVICE_H
26
27/* We do not support non-unicode builds */
28#ifndef UNICODE
29#define UNICODE
30#endif
31
32#ifdef HAVE_CONFIG_H
33#include "config.h"
34#endif
35
36#include <winsock2.h>
37#include <windows.h>
38#include <stdlib.h>
39#include <tchar.h>
40#include "../tapctl/basic.h"
41
42#define APPNAME TEXT(PACKAGE) TEXT("serv")
43#define SERVICE_DEPENDENCIES TEXT(TAP_WIN_COMPONENT_ID) TEXT("\0Dhcp\0\0")
44
45/*
46 * Message handling
47 */
48#define MSG_FLAGS_ERROR (1<<0)
49#define MSG_FLAGS_SYS_CODE (1<<1)
50#define M_INFO (0) /* informational */
51#define M_SYSERR (MSG_FLAGS_ERROR|MSG_FLAGS_SYS_CODE) /* error + system code */
52#define M_ERR (MSG_FLAGS_ERROR) /* error */
53
58
66
67#define MAX_NAME 256
68typedef struct {
69 TCHAR exe_path[MAX_PATH];
70 TCHAR config_dir[MAX_PATH];
71 TCHAR ext_string[16];
72 TCHAR log_dir[MAX_PATH];
73 TCHAR ovpn_admin_group[MAX_NAME];
74 DWORD priority;
75 BOOL append;
77
79extern LPCTSTR service_instance;
80
81VOID WINAPI ServiceStartInteractiveOwn(DWORD argc, LPTSTR *argv);
82
83VOID WINAPI ServiceStartInteractive(DWORD argc, LPTSTR *argv);
84
86
87BOOL ReportStatusToSCMgr(SERVICE_STATUS_HANDLE service, SERVICE_STATUS *status);
88
89LPCTSTR GetLastErrorText(void);
90
91DWORD MsgToEventLog(DWORD flags, LPCTSTR lpszMsg, ...);
92
110wchar_t *utf8to16_size(const char *utf8, int size);
111
122static inline wchar_t *
123utf8to16(const char *utf8)
124{
125 return utf8to16_size(utf8, -1);
126}
127
128/* return windows system directory as a pointer to a static string */
129const wchar_t *get_win_sys_path(void);
130
131#endif /* ifndef _SERVICE_H */
static SERVICE_STATUS status
Definition interactive.c:53
static SERVICE_STATUS_HANDLE service
Definition interactive.c:52
LPCTSTR GetLastErrorText(void)
Definition common.c:184
const wchar_t * get_win_sys_path(void)
Definition win32.c:1113
DWORD MsgToEventLog(DWORD flags, LPCTSTR lpszMsg,...)
Definition common.c:215
wchar_t * utf8to16_size(const char *utf8, int size)
Convert a UTF-8 string to UTF-16.
Definition common.c:251
VOID WINAPI ServiceStartInteractive(DWORD argc, LPTSTR *argv)
BOOL ReportStatusToSCMgr(SERVICE_STATUS_HANDLE service, SERVICE_STATUS *status)
Definition service.c:22
openvpn_service_t interactive_service
Definition interactive.c:61
DWORD GetOpenvpnSettings(settings_t *s)
Definition common.c:56
LPCTSTR service_instance
Definition common.c:27
#define MAX_NAME
Definition service.h:67
openvpn_service_type
Definition service.h:54
@ _service_max
Definition service.h:56
@ interactive
Definition service.h:55
static wchar_t * utf8to16(const char *utf8)
Convert a zero terminated UTF-8 string to UTF-16.
Definition service.h:123
VOID WINAPI ServiceStartInteractiveOwn(DWORD argc, LPTSTR *argv)
Definition argv.h:35
TCHAR * display_name
Definition service.h:62
openvpn_service_type type
Definition service.h:60
TCHAR * dependencies
Definition service.h:63
BOOL append
Definition service.h:75
DWORD priority
Definition service.h:74