VirtualBox

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

Last change on this file since 53544 was 48956, checked in by vboxsync, 11 years ago

NetworkServices: Whitespace (including tabs!) and svn:keywords cleanups by scm.

  • Property svn:eol-style set to native
File size: 2.0 KB
Line 
1/* -*- indent-tabs-mode: nil; -*- */
2#ifndef _PROXY_POLLMGR_H_
3#define _PROXY_POLLMGR_H_
4
5#ifndef RT_OS_WINDOWS
6# include <unistd.h> /* for ssize_t */
7#endif
8#include "lwip/sys.h"
9
10enum pollmgr_slot_t {
11 POLLMGR_CHAN_PXTCP_ADD, /* new proxy tcp connection from guest */
12 POLLMGR_CHAN_PXTCP_POLLIN, /* free space in ringbuf, may POLLIN */
13 POLLMGR_CHAN_PXTCP_POLLOUT, /* schedule one-shot POLLOUT callback */
14 POLLMGR_CHAN_PXTCP_DEL, /* delete pxtcp */
15 POLLMGR_CHAN_PXTCP_RESET, /* send RST and delete pxtcp */
16
17 POLLMGR_CHAN_PXUDP_ADD, /* new proxy udp conversation from guest */
18 POLLMGR_CHAN_PXUDP_DEL, /* delete pxudp from pollmgr */
19
20 POLLMGR_CHAN_PORTFWD, /* add/remove port forwarding rules */
21
22 POLLMGR_SLOT_STATIC_COUNT,
23 POLLMGR_SLOT_FIRST_DYNAMIC = POLLMGR_SLOT_STATIC_COUNT
24};
25
26
27struct pollmgr_handler; /* forward */
28typedef int (*pollmgr_callback)(struct pollmgr_handler *, SOCKET, int);
29
30struct pollmgr_handler {
31 pollmgr_callback callback;
32 void *data;
33 int slot;
34};
35
36struct pollmgr_refptr {
37 struct pollmgr_handler *ptr;
38 sys_mutex_t lock;
39 size_t strong;
40 size_t weak;
41};
42
43int pollmgr_init(void);
44
45/* static named slots (aka "channels") */
46SOCKET pollmgr_add_chan(int, struct pollmgr_handler *);
47ssize_t pollmgr_chan_send(int, void *buf, size_t nbytes);
48void *pollmgr_chan_recv_ptr(struct pollmgr_handler *, SOCKET, int);
49
50/* dynamic slots */
51int pollmgr_add(struct pollmgr_handler *, SOCKET, int);
52
53/* special-purpose strong/weak references */
54struct pollmgr_refptr *pollmgr_refptr_create(struct pollmgr_handler *);
55void pollmgr_refptr_weak_ref(struct pollmgr_refptr *);
56struct pollmgr_handler *pollmgr_refptr_get(struct pollmgr_refptr *);
57void pollmgr_refptr_unref(struct pollmgr_refptr *);
58
59void pollmgr_update_events(int, int);
60void pollmgr_del_slot(int);
61
62void pollmgr_thread(void *);
63
64/* buffer for callbacks to receive udp without worrying about truncation */
65extern u8_t pollmgr_udpbuf[64 * 1024];
66
67#endif /* _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