VirtualBox

source: vbox/trunk/src/VBox/NetworkServices/NAT/proxy_pollmgr.h@ 104620

Last change on this file since 104620 was 98103, checked in by vboxsync, 22 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 2.9 KB
Line 
1/* $Id: proxy_pollmgr.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * NAT Network - poll manager, definitions and declarations.
4 */
5
6/*
7 * Copyright (C) 2013-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef VBOX_INCLUDED_SRC_NAT_proxy_pollmgr_h
29#define VBOX_INCLUDED_SRC_NAT_proxy_pollmgr_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#ifndef RT_OS_WINDOWS
35# include <unistd.h> /* for ssize_t */
36#endif
37#include "lwip/sys.h"
38
39enum pollmgr_slot_t {
40 POLLMGR_CHAN_PXTCP_ADD, /* new proxy tcp connection from guest */
41 POLLMGR_CHAN_PXTCP_POLLIN, /* free space in ringbuf, may POLLIN */
42 POLLMGR_CHAN_PXTCP_POLLOUT, /* schedule one-shot POLLOUT callback */
43 POLLMGR_CHAN_PXTCP_DEL, /* delete pxtcp */
44 POLLMGR_CHAN_PXTCP_RESET, /* send RST and delete pxtcp */
45
46 POLLMGR_CHAN_PXUDP_ADD, /* new proxy udp conversation from guest */
47 POLLMGR_CHAN_PXUDP_DEL, /* delete pxudp from pollmgr */
48
49 POLLMGR_CHAN_PORTFWD, /* add/remove port forwarding rules */
50
51 POLLMGR_CHAN_COUNT
52};
53
54
55struct pollmgr_handler; /* forward */
56typedef int (*pollmgr_callback)(struct pollmgr_handler *, SOCKET, int);
57
58struct pollmgr_handler {
59 pollmgr_callback callback;
60 void *data;
61 int slot;
62};
63
64struct pollmgr_refptr {
65 struct pollmgr_handler *ptr;
66 sys_mutex_t lock;
67 size_t strong;
68 size_t weak;
69};
70
71int pollmgr_init(void);
72
73/* static named slots (aka "channels") */
74SOCKET pollmgr_add_chan(int, struct pollmgr_handler *);
75ssize_t pollmgr_chan_send(int, void *buf, size_t nbytes);
76void *pollmgr_chan_recv_ptr(struct pollmgr_handler *, SOCKET, int);
77
78/* dynamic slots */
79int pollmgr_add(struct pollmgr_handler *, SOCKET, int);
80
81/* special-purpose strong/weak references */
82struct pollmgr_refptr *pollmgr_refptr_create(struct pollmgr_handler *);
83void pollmgr_refptr_weak_ref(struct pollmgr_refptr *);
84struct pollmgr_handler *pollmgr_refptr_get(struct pollmgr_refptr *);
85void pollmgr_refptr_unref(struct pollmgr_refptr *);
86
87void pollmgr_update_events(int, int);
88void pollmgr_del_slot(int);
89
90void pollmgr_thread(void *);
91
92/* buffer for callbacks to receive udp without worrying about truncation */
93extern u8_t pollmgr_udpbuf[64 * 1024];
94
95#endif /* !VBOX_INCLUDED_SRC_NAT_proxy_pollmgr_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette