Merge pull request #4 from richardg867/origin/port-forward-config
Configurable slirp port forwards
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
src/*.o
|
||||||
|
src/*.exe
|
||||||
|
src/*.res
|
20
src/ne2000.c
20
src/ne2000.c
@@ -1658,7 +1658,6 @@ void rtl8029as_init(ne2000_t *ne2000)
|
|||||||
|
|
||||||
void *ne2000_init()
|
void *ne2000_init()
|
||||||
{
|
{
|
||||||
struct in_addr myaddr;
|
|
||||||
int rc;
|
int rc;
|
||||||
int config_net_type;
|
int config_net_type;
|
||||||
int net_type;
|
int net_type;
|
||||||
@@ -1725,25 +1724,6 @@ void *ne2000_init()
|
|||||||
if ( rc == 0 )
|
if ( rc == 0 )
|
||||||
{
|
{
|
||||||
pclog("ne2000 slirp initalized!\n");
|
pclog("ne2000 slirp initalized!\n");
|
||||||
inet_aton("10.0.2.15",&myaddr);
|
|
||||||
//YES THIS NEEDS TO PULL FROM A CONFIG FILE... but for now.
|
|
||||||
rc=slirp_redir(0,42323,myaddr,23);
|
|
||||||
pclog("ne2000 slirp redir returned %d on port 42323 -> 23\n",rc);
|
|
||||||
rc=slirp_redir(0,42380,myaddr,80);
|
|
||||||
pclog("ne2000 slirp redir returned %d on port 42380 -> 80\n",rc);
|
|
||||||
rc=slirp_redir(0,42443,myaddr,443);
|
|
||||||
pclog("ne2000 slirp redir returned %d on port 42443 -> 443\n",rc);
|
|
||||||
rc=slirp_redir(0,42322,myaddr,22);
|
|
||||||
pclog("ne2000 slirp redir returned %d on port 42322 -> 22\n",rc);
|
|
||||||
|
|
||||||
//Kali
|
|
||||||
rc=slirp_redir(1,2213,myaddr,2213);
|
|
||||||
pclog("ne2000 slirp redir returned %d on port 2213 -> 2213\n",rc);
|
|
||||||
rc=slirp_redir(1,2231,myaddr,2231);
|
|
||||||
pclog("ne2000 slirp redir returned %d on port 2231 -> 2231\n",rc);
|
|
||||||
rc=slirp_redir(1,2271,myaddr,2271);
|
|
||||||
pclog("ne2000 slirp redir returned %d on port 2271 -> 2271\n",rc);
|
|
||||||
|
|
||||||
|
|
||||||
net_slirp_inited=1;
|
net_slirp_inited=1;
|
||||||
slirpq = QueueCreate();
|
slirpq = QueueCreate();
|
||||||
|
@@ -161,6 +161,33 @@ debug_init("slirplog.txt",DEBUG_DEFAULT);
|
|||||||
inet_aton(CTL_SPECIAL, &special_addr);
|
inet_aton(CTL_SPECIAL, &special_addr);
|
||||||
alias_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS);
|
alias_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS);
|
||||||
getouraddr();
|
getouraddr();
|
||||||
|
|
||||||
|
struct in_addr myaddr;
|
||||||
|
int rc;
|
||||||
|
inet_aton("10.0.2.15",&myaddr);
|
||||||
|
|
||||||
|
char* category = "SLiRP Port Forwarding";
|
||||||
|
char key[32];
|
||||||
|
int i = 0, udp, from, to;
|
||||||
|
while (1) {
|
||||||
|
sprintf(key, "%d_udp", i);
|
||||||
|
udp = config_get_int(category, key, 0);
|
||||||
|
sprintf(key, "%d_from", i);
|
||||||
|
from = config_get_int(category, key, 0);
|
||||||
|
if (from < 1)
|
||||||
|
break;
|
||||||
|
sprintf(key, "%d_to", i);
|
||||||
|
to = config_get_int(category, key, from);
|
||||||
|
|
||||||
|
rc = slirp_redir(udp, from, myaddr, to);
|
||||||
|
if (rc == 0)
|
||||||
|
pclog("slirp redir %d -> %d successful\n", from, to);
|
||||||
|
else
|
||||||
|
pclog("slirp redir %d -> %d failed (%d)\n", from, to, rc);
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user