VirtualBox

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

Last change on this file since 94068 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 2.6 KB
Line 
1/* $Id: proxy_pollmgr.h 93115 2022-01-01 11:31:46Z vboxsync $ */
2/** @file
3 * NAT Network - poll manager, definitions and declarations.
4 */
5
6/*
7 * Copyright (C) 2013-2022 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef VBOX_INCLUDED_SRC_NAT_proxy_pollmgr_h
19#define VBOX_INCLUDED_SRC_NAT_proxy_pollmgr_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#ifndef RT_OS_WINDOWS
25# include <unistd.h> /* for ssize_t */
26#endif
27#include "lwip/sys.h"
28
29enum pollmgr_slot_t {
30 POLLMGR_CHAN_PXTCP_ADD, /* new proxy tcp connection from guest */
31 POLLMGR_CHAN_PXTCP_POLLIN, /* free space in ringbuf, may POLLIN */
32 POLLMGR_CHAN_PXTCP_POLLOUT, /* schedule one-shot POLLOUT callback */
33 POLLMGR_CHAN_PXTCP_DEL, /* delete pxtcp */
34 POLLMGR_CHAN_PXTCP_RESET, /* send RST and delete pxtcp */
35
36 POLLMGR_CHAN_PXUDP_ADD, /* new proxy udp conversation from guest */
37 POLLMGR_CHAN_PXUDP_DEL, /* delete pxudp from pollmgr */
38
39 POLLMGR_CHAN_PORTFWD, /* add/remove port forwarding rules */
40
41 POLLMGR_CHAN_COUNT
42};
43
44
45struct pollmgr_handler; /* forward */
46typedef int (*pollmgr_callback)(struct pollmgr_handler *, SOCKET, int);
47
48struct pollmgr_handler {
49 pollmgr_callback callback;
50 void *data;
51 int slot;
52};
53
54struct pollmgr_refptr {
55 struct pollmgr_handler *ptr;
56 sys_mutex_t lock;
57 size_t strong;
58 size_t weak;
59};
60
61int pollmgr_init(void);
62
63/* static named slots (aka "channels") */
64SOCKET pollmgr_add_chan(int, struct pollmgr_handler *);
65ssize_t pollmgr_chan_send(int, void *buf, size_t nbytes);
66void *pollmgr_chan_recv_ptr(struct pollmgr_handler *, SOCKET, int);
67
68/* dynamic slots */
69int pollmgr_add(struct pollmgr_handler *, SOCKET, int);
70
71/* special-purpose strong/weak references */
72struct pollmgr_refptr *pollmgr_refptr_create(struct pollmgr_handler *);
73void pollmgr_refptr_weak_ref(struct pollmgr_refptr *);
74struct pollmgr_handler *pollmgr_refptr_get(struct pollmgr_refptr *);
75void pollmgr_refptr_unref(struct pollmgr_refptr *);
76
77void pollmgr_update_events(int, int);
78void pollmgr_del_slot(int);
79
80void pollmgr_thread(void *);
81
82/* buffer for callbacks to receive udp without worrying about truncation */
83extern u8_t pollmgr_udpbuf[64 * 1024];
84
85#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