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#ifdef HAVE_CONFIG_H
28#include "config.h"
29#endif
30
31#include <winsock2.h>
32#include <windows.h>
33#include <stdlib.h>
34#include <wchar.h>
35#include "../tapctl/basic.h"
36
37#define APPNAME _L(PACKAGE) L"serv"
38#define SERVICE_DEPENDENCIES _L(TAP_WIN_COMPONENT_ID) L"\0Dhcp\0\0"
39
40/*
41 * Message handling
42 */
43#define MSG_FLAGS_ERROR (1<<0)
44#define MSG_FLAGS_SYS_CODE (1<<1)
45#define M_INFO (0) /* informational */
46#define M_SYSERR (MSG_FLAGS_ERROR|MSG_FLAGS_SYS_CODE) /* error + system code */
47#define M_ERR (MSG_FLAGS_ERROR) /* error */
48
53
61
62#define MAX_NAME 256
63typedef struct {
64 WCHAR exe_path[MAX_PATH];
65 WCHAR config_dir[MAX_PATH];
66 WCHAR bin_dir[MAX_PATH];
67 WCHAR ext_string[16];
68 WCHAR log_dir[MAX_PATH];
69 WCHAR ovpn_admin_group[MAX_NAME];
70 WCHAR ovpn_service_user[MAX_NAME];
71 DWORD priority;
72 BOOL append;
74
76extern LPCWSTR service_instance;
77
78VOID WINAPI ServiceStartInteractiveOwn(DWORD argc, LPWSTR *argv);
79
80VOID WINAPI ServiceStartInteractive(DWORD argc, LPWSTR *argv);
81
83
84BOOL ReportStatusToSCMgr(SERVICE_STATUS_HANDLE service, SERVICE_STATUS *status);
85
86LPCWSTR GetLastErrorText(void);
87
88DWORD MsgToEventLog(DWORD flags, LPCWSTR lpszMsg, ...);
89
107wchar_t *utf8to16_size(const char *utf8, int size);
108
119static inline wchar_t *
120utf8to16(const char *utf8)
121{
122 return utf8to16_size(utf8, -1);
123}
124
125/* return windows system directory as a pointer to a static string */
126const wchar_t *get_win_sys_path(void);
127
128#endif /* ifndef _SERVICE_H */
static SERVICE_STATUS status
Definition interactive.c:53
static SERVICE_STATUS_HANDLE service
Definition interactive.c:52
const wchar_t * get_win_sys_path(void)
Definition win32.c:1113
VOID WINAPI ServiceStartInteractiveOwn(DWORD argc, LPWSTR *argv)
wchar_t * utf8to16_size(const char *utf8, int size)
Convert a UTF-8 string to UTF-16.
Definition common.c:267
DWORD MsgToEventLog(DWORD flags, LPCWSTR lpszMsg,...)
Definition common.c:231
BOOL ReportStatusToSCMgr(SERVICE_STATUS_HANDLE service, SERVICE_STATUS *status)
Definition service.c:22
LPCWSTR service_instance
Definition common.c:27
openvpn_service_t interactive_service
Definition interactive.c:61
DWORD GetOpenvpnSettings(settings_t *s)
Definition common.c:56
#define MAX_NAME
Definition service.h:62
VOID WINAPI ServiceStartInteractive(DWORD argc, LPWSTR *argv)
LPCWSTR GetLastErrorText(void)
Definition common.c:200
openvpn_service_type
Definition service.h:49
@ _service_max
Definition service.h:51
@ interactive
Definition service.h:50
static wchar_t * utf8to16(const char *utf8)
Convert a zero terminated UTF-8 string to UTF-16.
Definition service.h:120
Definition argv.h:35
WCHAR * dependencies
Definition service.h:58
openvpn_service_type type
Definition service.h:55
WCHAR * display_name
Definition service.h:57
BOOL append
Definition service.h:72
DWORD priority
Definition service.h:71