portfwd.c revision 23bcfa32fddbe29a8c4c40d3bcfa4693a555c177
/* $Id$ */
/** @file
* NAT Network - port-forwarding rules.
*/
/*
* Copyright (C) 2013-2014 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#define LOG_GROUP LOG_GROUP_NAT_SERVICE
#include "winutils.h"
#include "portfwd.h"
#ifndef RT_OS_WINDOWS
#include <netdb.h>
#include <poll.h>
#else
# include "winpoll.h"
#endif
#include <stdio.h>
#include <string.h>
#include "proxy.h"
#include "proxy_pollmgr.h"
#include "pxremap.h"
struct portfwd_msg {
int add;
};
static int portfwd_chan_send(struct portfwd_msg *);
static int portfwd_rule_add_del(struct fwspec *, int);
static struct pollmgr_handler portfwd_pmgr_chan_hdl;
void
portfwd_init(void)
{
/* add preconfigured forwarders */
fwtcp_init();
fwudp_init();
}
static int
{
if (nsent < 0) {
return -1;
}
return 0;
}
static int
{
struct portfwd_msg *msg;
return -1;
}
return portfwd_chan_send(msg);
}
int
{
}
int
{
return portfwd_rule_add_del(fwspec, 0);
}
/**
* POLLMGR_CHAN_PORTFWD handler.
*/
static int
{
}
else {
}
}
else { /* SOCK_DGRAM */
}
else {
}
}
return POLLIN;
}
int
{
int status;
if (status != 0) {
return -1;
}
if (status != 0) {
return -1;
}
}
else { /* PF_INET6 */
}
return 0;
}
int
{
LWIP_ASSERT1(a != NULL);
LWIP_ASSERT1(b != NULL);
return 0;
}
}
else { /* PF_INET6 */
}
}
/**
* Set fwdsrc to the IP address of the peer.
*
* For port-forwarded connections originating from hosts loopback the
* source address is set to the address of one of lwIP interfaces.
*
* Currently we only have one interface so there's not much logic
* here. In the future we might need to additionally consult fwspec
* and routing table to determine which netif is used for connections
* to the specified guest.
*/
int
{
int mapping;
}
}
else {
}
return mapping;
}